-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathSolidMechanicsAugmentedLagrangianContact.cpp
More file actions
2350 lines (1894 loc) · 110 KB
/
Copy pathSolidMechanicsAugmentedLagrangianContact.cpp
File metadata and controls
2350 lines (1894 loc) · 110 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2024 TotalEnergies
* Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2023-2024 Chevron
* Copyright (c) 2019- GEOS/GEOSX Contributors
* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/
/*
* SolidMechanicsAugmentedLagrangianContact.cpp
*/
#include "SolidMechanicsAugmentedLagrangianContact.hpp"
#include "physicsSolvers/fluidFlow/FlowSolverBase.hpp"
#include "physicsSolvers/fluidFlow/FlowSolverBaseFields.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsConformingContactKernelsBase.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsALMKernels.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsALMKernelsBase.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsALMSimultaneousKernels.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsDisplacementJumpUpdateKernels.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsConformingPressureContributionKernels.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsContactFaceBubbleKernels.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsPressureFaceBubbleKernels.hpp"
#include "physicsSolvers/solidMechanics/contact/LogLevelsInfo.hpp"
#include "physicsSolvers/solidMechanics/contact/ContactFields.hpp"
#include "physicsSolvers/solidMechanics/SolidMechanicsFields.hpp"
#include "physicsSolvers/LogLevelsInfo.hpp"
#include "constitutive/contact/FrictionSelector.hpp"
#include "constitutive/solid/PorousSolid.hpp"
#include "constitutive/solid/SolidFields.hpp"
#include "physicsSolvers/solidMechanics/contact/kernels/SolidMechanicsALMContactPorousKernelsDispatchTypeList.hpp"
#include "finiteElement/FiniteElementDiscretization.hpp"
#include "mesh/DomainPartition.hpp"
#include <cmath>
#include <stdio.h>
#if defined( GEOS_USE_CUDA )
#include <cuda_runtime.h>
#endif
namespace geos
{
using namespace constitutive;
using namespace dataRepository;
using namespace fields;
// Workaround for nvcc bug: forDiscretizationOnMeshTargets lambdas receive
// string_array const & (= stdVector<std::string>) as a parameter. When the
// lambda body also contains device kernel launches, nvcc erroneously tries to
// generate a device-compatible destructor for stdVector<std::string> even
// though it is a reference parameter whose lifetime is not managed by the lambda.
GEOS_NV_HOST_DEVICE_DIAG_SUPPRESS
SolidMechanicsAugmentedLagrangianContact::SolidMechanicsAugmentedLagrangianContact( const string & name,
Group * const parent ):
ContactSolverBase( name, parent )
{
registerWrapper( viewKeyStruct::simultaneousString(), &m_simultaneous ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 1 ).
setDescription( "Flag to update the Lagrange multiplier at each Newton iteration (true), or only after the Newton loop has converged (false)" );
registerWrapper( viewKeyStruct::symmetricString(), &m_symmetric ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 1 ).
setDescription( "Flag to neglect the non-symmetric contribution in the tangential matrix" );
registerWrapper( viewKeyStruct::iterativePenaltyNFacString(), &m_iterPenaltyNFac ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 10.0 ).
setDescription( "Factor for tuning the iterative penalty coefficient for normal traction" );
registerWrapper( viewKeyStruct::iterativePenaltyTFacString(), &m_iterPenaltyTFac ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 0.1 ).
setDescription( "Factor for tuning the iterative penalty coefficient for tangential traction" );
registerWrapper( viewKeyStruct::tolJumpDispNFacString(), &m_tolJumpDispNFac ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 1.e-07 ).
setDescription( "Factor to adjust the tolerance for normal jump" );
registerWrapper( viewKeyStruct::tolJumpDispTFacString(), &m_tolJumpDispTFac ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 1.e-05 ).
setDescription( "Factor to adjust the tolerance for tangential jump" );
registerWrapper( viewKeyStruct::tolNormalTracFacString(), &m_tolNormalTracFac ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 0.5 ).
setDescription( "Factor to adjust the tolerance for normal traction" );
registerWrapper( viewKeyStruct::tolTauLimitString(), &m_slidingCheckTolerance ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 5.e-02 ).
setDescription( "Tolerance for the sliding check" );
registerWrapper( viewKeyStruct::symmetricString(), &m_isAnisotropic ).
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( 1 ).
setDescription( "Flag to use anisotropic scaling in tolerances and penalties computations" );
// Set the default linear solver parameters
LinearSolverParameters & linSolParams = m_linearSolverParameters.get();
// Strategy: AMG with separate displacement components
linSolParams.dofsPerNode = 3;
linSolParams.isSymmetric = true;
linSolParams.amg.separateComponents = true;
// Strategy: static condensation of bubble dofs using MGR
linSolParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::augmentedLagrangianContactMechanics;
linSolParams.mgr.separateComponents = true;
}
SolidMechanicsAugmentedLagrangianContact::~SolidMechanicsAugmentedLagrangianContact()
{}
void SolidMechanicsAugmentedLagrangianContact::registerDataOnMesh( dataRepository::Group & meshBodies )
{
ContactSolverBase::registerDataOnMesh( meshBodies );
forDiscretizationOnMeshTargets( meshBodies, [&] ( string const &,
MeshLevel & meshLevel,
string_array const & )
{
FaceManager & faceManager = meshLevel.getFaceManager();
// Register the total bubble displacement
faceManager.registerField< contact::totalBubbleDisplacement >( getName() ).
reference().resizeDimension< 1 >( 3 );
// Register the incremental bubble displacement
faceManager.registerField< contact::incrementalBubbleDisplacement >( getName() ).
reference().resizeDimension< 1 >( 3 );
} );
forFractureRegionOnMeshTargets( meshBodies, [&] ( SurfaceElementRegion & fractureRegion )
{
fractureRegion.forElementSubRegions< SurfaceElementSubRegion >( [&]( SurfaceElementSubRegion & subRegion )
{
subRegion.registerField< contact::deltaTraction >( getName() ).
reference().resizeDimension< 1 >( 3 );
// Register the rotation matrix
subRegion.registerField< contact::rotationMatrix >( getName() ).
reference().resizeDimension< 1, 2 >( 3, 3 );
// Register the penalty coefficients for the iterative procedure
subRegion.registerField< contact::iterativePenalty >( getName() ).
reference().resizeDimension< 1 >( 5 );
subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::normalTractionToleranceString() ).
setPlotLevel( PlotLevel::NOPLOT ).
setRegisteringObjects( getName()).
setDescription( "An array that holds the normal traction tolerance." );
subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::normalDisplacementToleranceString() ).
setPlotLevel( PlotLevel::NOPLOT ).
setRegisteringObjects( getName()).
setDescription( "An array that holds the normal displacement tolerance." );
subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::slidingToleranceString() ).
setPlotLevel( PlotLevel::NOPLOT ).
setRegisteringObjects( getName()).
setDescription( "An array that holds the sliding tolerance." );
subRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dispJumpUpdPenaltyString() ).
setPlotLevel( PlotLevel::NOPLOT ).
setRegisteringObjects( getName()).
setDescription( "An array that stores the displacement jumps used to update the penalty coefficients." ).
reference().resizeDimension< 1 >( 3 );
// Register pressure fields for sequential poromechanics coupling and stress initialization
// In coupled poromechanics, the flow solver will overwrite these with actual values
subRegion.registerField< flow::pressure >( getName() ).
setApplyDefaultValue( 0.0 ).
setPlotLevel( PlotLevel::NOPLOT );
subRegion.registerField< flow::pressure_n >( getName() ).
setApplyDefaultValue( 0.0 ).
setPlotLevel( PlotLevel::NOPLOT );
} );
} );
}
void SolidMechanicsAugmentedLagrangianContact::initializePostInitialConditionsPreSubGroups()
{
ContactSolverBase::initializePostInitialConditionsPreSubGroups();
DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );
validateTetrahedralQuadrature( domain.getMeshBodies() );
}
void SolidMechanicsAugmentedLagrangianContact::validateTetrahedralQuadrature( Group & meshBodies )
{
string const discretizationName = getDiscretizationName();
NumericalMethodsManager const & numericalMethodManager =
this->getGroupByPath< DomainPartition >( "/Problem/domain" ).getNumericalMethodManager();
FiniteElementDiscretizationManager const & feDiscretizationManager =
numericalMethodManager.getFiniteElementDiscretizationManager();
FiniteElementDiscretization const & feDiscretization =
feDiscretizationManager.getGroup< FiniteElementDiscretization >( discretizationName );
integer const useHighOrderQuadrature =
feDiscretization.getReference< integer >( "useHighOrderQuadratureRule" );
bool hasTetrahedra = false;
forDiscretizationOnMeshTargets( meshBodies, [&]( string const &,
MeshLevel const & mesh,
string_array const & regionNames )
{
ElementRegionManager const & elemManager = mesh.getElemManager();
elemManager.forElementRegions< CellElementRegion >( regionNames, [&]( localIndex const,
CellElementRegion const & region )
{
region.forElementSubRegions< CellElementSubRegion >( [&]( CellElementSubRegion const & subRegion )
{
if( subRegion.getElementType() == ElementType::Tetrahedron )
{
hasTetrahedra = true;
}
} );
} );
} );
GEOS_ERROR_IF( hasTetrahedra && useHighOrderQuadrature != 1,
GEOS_FMT( "{}: Tetrahedral meshes require useHighOrderQuadratureRule=\"1\" for correct integration of bubble contributions. "
"Please add this attribute to your FiniteElements/{} XML block.",
getName(), discretizationName ) );
}
void SolidMechanicsAugmentedLagrangianContact::setupDofs( DomainPartition const & domain,
DofManager & dofManager ) const
{
GEOS_MARK_FUNCTION;
SolidMechanicsLagrangianFEM::setupDofs( domain, dofManager );
map< std::pair< string, string >, string_array > meshTargets;
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshBodyName,
MeshLevel const & meshLevel,
string_array const & )
{
string_array regions;
regions.emplace_back( getUniqueFractureRegionName() );
meshTargets[std::make_pair( meshBodyName, meshLevel.getName())] = std::move( regions );
} );
dofManager.addField( contact::totalBubbleDisplacement::key(),
FieldLocation::Face,
3,
meshTargets );
// Add coupling between bubble
// Useful to create connection between bubble dofs for Augmented Lagrangian formulation
dofManager.addCoupling( contact::totalBubbleDisplacement::key(),
contact::totalBubbleDisplacement::key(),
DofManager::Connector::Elem );
}
void SolidMechanicsAugmentedLagrangianContact::setupSystem( DomainPartition & domain,
DofManager & dofManager,
CRSMatrix< real64, globalIndex > & localMatrix,
ParallelVector & rhs,
ParallelVector & solution,
bool const setSparsity )
{
GEOS_MARK_FUNCTION;
// Recompute geometric quantities (face normals, areas) after mesh topology changes.
// This is critical for distorted/non-axis-aligned meshes and after fracture events.
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & )
{
NodeManager const & nodeManager = mesh.getNodeManager();
FaceManager & faceManager = mesh.getFaceManager();
ElementRegionManager & elemManager = mesh.getElemManager();
// Recompute face geometry (normals and areas)
faceManager.computeGeometry( nodeManager );
// Recompute element geometry for volume elements (centers and volumes)
elemManager.forElementSubRegions< CellElementSubRegion >( [&]( CellElementSubRegion & subRegion )
{
subRegion.calculateElementGeometricQuantities( nodeManager, faceManager );
} );
// Recompute element geometry for face elements (uses updated face areas)
elemManager.forElementSubRegions< FaceElementSubRegion >( [&]( FaceElementSubRegion & subRegion )
{
subRegion.calculateElementGeometricQuantities( nodeManager, faceManager );
// Reorder kf1 nodes to match kf0 for conforming contact kernels.
// flipFaceMap and fixNeighboringFacesNormals are already called by
// ProblemManager::applyNumericalMethods after ghosting is complete.
if( subRegion.size() > 0 )
{
subRegion.fixNeighboringFacesNormals( faceManager, elemManager );
subRegion.orderKf1NodesConsistentlyWithKf0( faceManager, nodeManager );
}
} );
} );
// Create the lists of interface elements that have same type.
createFaceTypeList( domain );
// Create the lists of interface elements that have same type and same fracture state.
updateStickSlipList( domain );
// Create the list of cell elements that they are enriched with bubble functions.
createBubbleCellList( domain );
PhysicsSolverBase::setupSystem( domain, dofManager, localMatrix, rhs, solution, setSparsity );
}
void SolidMechanicsAugmentedLagrangianContact::postInputInitialization()
{
ContactSolverBase::postInputInitialization();
DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );
NumericalMethodsManager const & numericalMethodManager = domain.getNumericalMethodManager();
FiniteElementDiscretizationManager const & feDiscretizationManager =
numericalMethodManager.getFiniteElementDiscretizationManager();
FiniteElementDiscretization const & feDiscretization =
feDiscretizationManager.getGroup< FiniteElementDiscretization >( getDiscretizationName() );
m_faceTypeToFiniteElements.insert( {"Quadrilateral", feDiscretization.factory( ElementType::Quadrilateral )} );
m_faceTypeToFiniteElements.insert( {"Triangle", feDiscretization.factory( ElementType::Triangle )} );
GEOS_LOG_RANK_0( GEOS_FMT( "{} using finite element discretization {}:",
getName(), getDiscretizationName() ) );
for( auto const & [name, fePtr] : m_faceTypeToFiniteElements )
{
GEOS_LOG_RANK_0( GEOS_FMT( " {} face elements: {} quadrature points",
name, fePtr->getNumQuadraturePoints() ) );
}
}
void SolidMechanicsAugmentedLagrangianContact::setSparsityPattern( DomainPartition & domain,
DofManager & dofManager,
CRSMatrix< real64, globalIndex > & GEOS_UNUSED_PARAM( localMatrix ),
SparsityPattern< globalIndex > & pattern )
{
// Set the sparsity pattern without the Abu and Aub blocks.
SparsityPattern< globalIndex > patternDiag;
dofManager.setSparsityPattern( patternDiag );
// Get the original row lengths (diagonal blocks only)
array1d< localIndex > rowLengths( patternDiag.numRows());
for( localIndex localRow = 0; localRow < patternDiag.numRows(); ++localRow )
{
rowLengths[localRow] = patternDiag.numNonZeros( localRow );
}
// Add the number of nonzeros induced by coupling
addCouplingNumNonzeros( domain, dofManager, rowLengths.toView());
// Create a new pattern with enough capacity for coupled matrix
pattern.resizeFromRowCapacities< parallelHostPolicy >( patternDiag.numRows(), patternDiag.numColumns(), rowLengths.data());
// Copy the original nonzeros
for( localIndex localRow = 0; localRow < patternDiag.numRows(); ++localRow )
{
globalIndex const * cols = patternDiag.getColumns( localRow ).dataIfContiguous();
pattern.insertNonZeros( localRow, cols, cols + patternDiag.numNonZeros( localRow ));
}
// Add the nonzeros from coupling
addCouplingSparsityPattern( domain, dofManager, pattern.toView());
}
void SolidMechanicsAugmentedLagrangianContact::implicitStepSetup( real64 const & time_n,
real64 const & dt,
DomainPartition & domain )
{
SolidMechanicsLagrangianFEM::implicitStepSetup( time_n, dt, domain );
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & )
{
FaceManager & faceManager = mesh.getFaceManager();
ElementRegionManager & elemManager = mesh.getElemManager();
SurfaceElementRegion & region = elemManager.getRegion< SurfaceElementRegion >( getUniqueFractureRegionName() );
FaceElementSubRegion & subRegion = region.getUniqueSubRegion< FaceElementSubRegion >();
arrayView2d< real64 const > const faceNormal = faceManager.faceNormal();
arrayView2d< localIndex const > const elemsToFaces = subRegion.faceList().toViewConst();
arrayView2d< real64 > const incrBubbleDisp =
faceManager.getField< contact::incrementalBubbleDisplacement >();
arrayView3d< real64 > const
rotationMatrix = subRegion.getField< contact::rotationMatrix >().toView();
arrayView2d< real64 > const unitNormal = subRegion.getNormalVector();
arrayView2d< real64 > const unitTangent1 = subRegion.getTangentVector1();
arrayView2d< real64 > const unitTangent2 = subRegion.getTangentVector2();
if( subRegion.size() > 0 )
{
solidMechanicsConformingContactKernels::ComputeRotationMatricesKernel::
launch< parallelDevicePolicy<> >( subRegion.size(),
faceNormal,
elemsToFaces,
rotationMatrix,
unitNormal,
unitTangent1,
unitTangent2 );
}
// Set the tollerances
computeTolerances( domain );
// Initialize the traction from the stress in adjacent volume elements.
// This is only done during stress initialization step to ensure the ALM solver
// starts with a physically consistent traction rather than zero.
// On subsequent time steps, the traction from the previous step is preserved.
if( m_performStressInitialization )
{
initializeTractionFromAdjacentCellStress( domain );
}
// Set array to update penalty coefficients
arrayView2d< real64 > const dispJumpUpdPenalty =
subRegion.getReference< array2d< real64 > >( viewKeyStruct::dispJumpUpdPenaltyString() );
arrayView2d< real64 > const
iterativePenalty = subRegion.getField< contact::iterativePenalty >().toView();
arrayView1d< integer const > const fractureState = subRegion.getField< contact::fractureState >();
if( subRegion.size() > 0 )
{
if( m_simultaneous )
{
forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOS_DEVICE ( localIndex const k )
{
if( fractureState[k] == contact::FractureState::Stick )
{
iterativePenalty[k][2] = iterativePenalty[k][1];
iterativePenalty[k][3] = iterativePenalty[k][1];
iterativePenalty[k][4] = 0.0;
}
else
{
iterativePenalty[k][2] = 0.0;
iterativePenalty[k][3] = 0.0;
iterativePenalty[k][4] = 0.0;
}
} );
}
forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOS_DEVICE ( localIndex const k )
{
LvArray::tensorOps::fill< 3 >( dispJumpUpdPenalty[k], 0.0 );
localIndex const kf0 = elemsToFaces[k][0];
localIndex const kf1 = elemsToFaces[k][1];
LvArray::tensorOps::fill< 3 >( incrBubbleDisp[kf0], 0.0 );
LvArray::tensorOps::fill< 3 >( incrBubbleDisp[kf1], 0.0 );
} );
}
} );
// Sync iterativePenalty
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & )
{
FieldIdentifiers fieldsToBeSync;
fieldsToBeSync.addElementFields( { contact::iterativePenalty::key() },
{ getUniqueFractureRegionName() } );
// Synchronize bubble displacement fields to ensure ghost values are initialized
// This prevents race conditions when computing residuals in parallel
fieldsToBeSync.addFields( FieldLocation::Face,
{ contact::incrementalBubbleDisplacement::key(),
contact::totalBubbleDisplacement::key() } );
CommunicationTools::getInstance().synchronizeFields( fieldsToBeSync,
mesh,
domain.getNeighbors(),
true );
} );
}
void SolidMechanicsAugmentedLagrangianContact::assembleSystem( real64 const time,
real64 const dt,
DomainPartition & domain,
DofManager const & dofManager,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs )
{
GEOS_MARK_FUNCTION;
synchronizeFractureState( domain );
SolidMechanicsLagrangianFEM::assembleSystem( time,
dt,
domain,
dofManager,
localMatrix,
localRhs );
assembleContact( time, dt, domain, dofManager, localMatrix, localRhs );
// for sequential: add (fixed) pressure force contribution into residual (no derivatives)
if( m_isFixedStressPoromechanicsUpdate || m_performStressInitialization )
{
assembleForceResidualPressureContribution( domain, dt, dofManager, localMatrix, localRhs );
}
}
void SolidMechanicsAugmentedLagrangianContact::assembleContact( real64 const time,
real64 const dt,
DomainPartition & domain,
DofManager const & dofManager,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs )
{
GEOS_MARK_FUNCTION;
GEOS_UNUSED_VAR( time );
// Loop for assembling contributes from interface elements (Aut*eps^-1*Atu and Aub*eps^-1*Abu)
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshName,
MeshLevel & mesh,
string_array const & )
{
NodeManager const & nodeManager = mesh.getNodeManager();
FaceManager const & faceManager = mesh.getFaceManager();
string const & dispDofKey = dofManager.getKey( solidMechanics::totalDisplacement::key() );
string const & bubbleDofKey = dofManager.getKey( contact::totalBubbleDisplacement::key() );
arrayView1d< globalIndex const > const dispDofNumber = nodeManager.getReference< globalIndex_array >( dispDofKey );
arrayView1d< globalIndex const > const bubbleDofNumber = faceManager.getReference< globalIndex_array >( bubbleDofKey );
string const & fractureRegionName = getUniqueFractureRegionName();
forFiniteElementOnStickFractureSubRegions( meshName, [&] ( string const &,
finiteElement::FiniteElementBase const & subRegionFE,
arrayView1d< localIndex const > const & faceElementList,
bool const )
{
if( m_simultaneous )
{
solidMechanicsALMKernels::ALMSimultaneousFactory kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
faceElementList );
real64 maxTraction = finiteElement::interfaceBasedKernelApplication< parallelDevicePolicy< >, CoulombFriction >( mesh,
fractureRegionName,
faceElementList,
subRegionFE,
viewKeyStruct::frictionLawNameString(),
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
}
else
{
solidMechanicsALMKernels::ALMFactory kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
faceElementList,
m_symmetric );
real64 maxTraction = finiteElement::
interfaceBasedKernelApplication
< parallelDevicePolicy< >,
CoulombFriction >( mesh,
fractureRegionName,
faceElementList,
subRegionFE,
viewKeyStruct::frictionLawNameString(),
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
}
} );
forFiniteElementOnSlipFractureSubRegions( meshName, [&] ( string const &,
finiteElement::FiniteElementBase const & subRegionFE,
arrayView1d< localIndex const > const & faceElementList,
bool const )
{
if( m_simultaneous )
{
solidMechanicsALMKernels::ALMSimultaneousFactory kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
faceElementList );
real64 maxTraction = finiteElement::
interfaceBasedKernelApplication
< parallelDevicePolicy< >,
CoulombFriction >( mesh,
fractureRegionName,
faceElementList,
subRegionFE,
viewKeyStruct::frictionLawNameString(),
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
}
else
{
solidMechanicsALMKernels::ALMFactory kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
faceElementList,
m_symmetric );
real64 maxTraction = finiteElement::interfaceBasedKernelApplication< parallelDevicePolicy< >, CoulombFriction >( mesh,
fractureRegionName,
faceElementList,
subRegionFE,
viewKeyStruct::frictionLawNameString(),
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
}
} );
} );
// Loop for assembling contributes of bubble elements (Abb, Abu, Aub)
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & regionNames )
{
NodeManager const & nodeManager = mesh.getNodeManager();
FaceManager const & faceManager = mesh.getFaceManager();
string const & dispDofKey = dofManager.getKey( solidMechanics::totalDisplacement::key() );
string const & bubbleDofKey = dofManager.getKey( contact::totalBubbleDisplacement::key() );
arrayView1d< globalIndex const > const dispDofNumber = nodeManager.getReference< globalIndex_array >( dispDofKey );
arrayView1d< globalIndex const > const bubbleDofNumber = faceManager.getReference< globalIndex_array >( bubbleDofKey );
real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( gravityVector() );
solidMechanicsConformingContactKernels::FaceBubbleFactory kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
gravityVectorData );
real64 maxTraction = finiteElement::regionBasedKernelApplication< parallelDevicePolicy< >, ElasticIsotropic, CellElementSubRegion >( mesh,
regionNames,
getDiscretizationName(),
SolidMechanicsLagrangianFEM::viewKeyStruct::
solidMaterialNamesString(),
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
} );
}
void SolidMechanicsAugmentedLagrangianContact::assembleForceResidualPressureContribution( DomainPartition & domain,
real64 const & dt,
DofManager const & dofManager,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs )
{
GEOS_MARK_FUNCTION;
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshName,
MeshLevel & mesh,
string_array const & regionNames )
{
NodeManager const & nodeManager = mesh.getNodeManager();
FaceManager const & faceManager = mesh.getFaceManager();
string const & dispDofKey = dofManager.getKey( solidMechanics::totalDisplacement::key() );
string const & bubbleDofKey = dofManager.getKey( contact::totalBubbleDisplacement::key() );
arrayView1d< globalIndex const > const dispDofNumber = nodeManager.getReference< globalIndex_array >( dispDofKey );
arrayView1d< globalIndex const > const bubbleDofNumber = faceManager.getReference< globalIndex_array >( bubbleDofKey );
string const & fractureRegionName = this->getUniqueFractureRegionName();
forFiniteElementOnFractureSubRegions( meshName, [&] ( string const &,
finiteElement::FiniteElementBase const & subRegionFE,
arrayView1d< localIndex const > const & faceElementList )
{
solidMechanicsConformingContactKernels::AssemblePressureContributionFactory
kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
faceElementList );
real64 maxTraction = finiteElement::
interfaceBasedKernelApplication
< parallelDevicePolicy< >,
constitutive::NullModel >( mesh,
fractureRegionName,
faceElementList,
subRegionFE,
"",
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
} );
set< string > poromechanicsRegions;
ElementRegionManager const & elementRegionManager = mesh.getElemManager();
elementRegionManager.forElementSubRegions< CellElementSubRegion >( regionNames,
[&]
( localIndex const regionIndex, auto & elementSubRegion )
{
if( elementSubRegion.template hasWrapper< string >( FlowSolverBase::viewKeyStruct::solidNamesString() ) )
{
poromechanicsRegions.insert( regionNames[regionIndex] );
}
} );
string_array poromechanicsRegionNames;
poromechanicsRegionNames.reserve( poromechanicsRegions.size());
for( auto const & region : poromechanicsRegions )
{
poromechanicsRegionNames.emplace_back( region );
}
solidMechanicsConformingContactKernels::PressureFaceBubbleFactory kernelFactory( dispDofNumber,
bubbleDofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt );
real64 maxTraction = finiteElement::regionBasedKernelApplication
< parallelDevicePolicy< >,
SolidMechanicsALMContactPorousKernelsDispatchTypeList >( mesh,
poromechanicsRegionNames,
getDiscretizationName(),
FlowSolverBase::viewKeyStruct::solidNamesString(),
kernelFactory );
GEOS_UNUSED_VAR( maxTraction );
} );
}
void SolidMechanicsAugmentedLagrangianContact::implicitStepComplete( real64 const & time_n,
real64 const & dt,
DomainPartition & domain )
{
SolidMechanicsLagrangianFEM::implicitStepComplete( time_n, dt, domain );
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & )
{
//fractureRegion.forElementSubRegions< FaceElementSubRegion >( [&]( FaceElementSubRegion & subRegion )
//{
ElementRegionManager & elemManager = mesh.getElemManager();
SurfaceElementRegion & region = elemManager.getRegion< SurfaceElementRegion >( getUniqueFractureRegionName() );
FaceElementSubRegion & subRegion = region.getUniqueSubRegion< FaceElementSubRegion >();
arrayView2d< real64 const > const dispJump = subRegion.getField< contact::dispJump >();
arrayView2d< real64 > const oldDispJump = subRegion.getField< contact::oldDispJump >();
arrayView2d< real64 > const deltaDispJump = subRegion.getField< contact::deltaDispJump >();
arrayView2d< real64 > const traction = subRegion.getField< contact::traction >();
arrayView1d< integer const > const fractureState = subRegion.getField< contact::fractureState >();
arrayView1d< integer > const oldFractureState = subRegion.getField< contact::oldFractureState >();
arrayView1d< real64 > const slip = subRegion.getField< contact::slip >();
arrayView1d< real64 > const tangentialTraction = subRegion.getField< contact::tangentialTraction >();
forAll< parallelDevicePolicy<> >( subRegion.size(),
[ = ]
GEOS_DEVICE ( localIndex const kfe )
{
// Compute the slip
real64 const shearDisp[2] = { dispJump[kfe][1],
dispJump[kfe][2] };
slip[kfe] = LvArray::tensorOps::l2Norm< 2 >( shearDisp );
// Compute current Tau and limit Tau
real64 const tau[2] = { traction[kfe][1],
traction[kfe][2] };
tangentialTraction[kfe] = LvArray::tensorOps::l2Norm< 2 >( tau );
LvArray::tensorOps::fill< 3 >( deltaDispJump[kfe], 0.0 );
LvArray::tensorOps::copy< 3 >( oldDispJump[kfe], dispJump[kfe] );
oldFractureState[kfe] = fractureState[kfe];
} );
} );
// } );
}
real64 SolidMechanicsAugmentedLagrangianContact::calculateResidualNorm( real64 const & time,
real64 const & dt,
DomainPartition const & domain,
DofManager const & dofManager,
arrayView1d< real64 const > const & localRhs )
{
GEOS_MARK_FUNCTION;
real64 const solidResidualNorm = SolidMechanicsLagrangianFEM::calculateResidualNorm( time, dt, domain, dofManager, localRhs );
string const bubbleDofKey = dofManager.getKey( contact::totalBubbleDisplacement::key() );
globalIndex const rankOffset = dofManager.rankOffset();
RAJA::ReduceSum< parallelDeviceReduce, real64 > localSum( 0.0 );
// globalResidualNorm[0]: the sum of all the local sum(rhs^2).
// globalResidualNorm[1]: max of max force of each rank. Basically max force globally
real64 globalResidualNorm[2] = {0, 0};
// Bubble residual
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel const & mesh,
string_array const & )
{
FaceManager const & faceManager = mesh.getFaceManager();
auto const & fGhost = faceManager.ghostRank();
ElementRegionManager const & elemManager = mesh.getElemManager();
SurfaceElementRegion const & region = elemManager.getRegion< SurfaceElementRegion >( getUniqueFractureRegionName() );
FaceElementSubRegion const & subRegion = region.getUniqueSubRegion< FaceElementSubRegion >();
arrayView1d< integer const > const ghostRank = subRegion.ghostRank();
arrayView2d< localIndex const > const elemsToFaces = subRegion.faceList().toViewConst();
arrayView1d< globalIndex const > const bubbleDofNumber = faceManager.getReference< globalIndex_array >( bubbleDofKey );
forAll< parallelDevicePolicy<> >( subRegion.size(),
[ = ]
GEOS_HOST_DEVICE ( localIndex const kfe )
{
if( ghostRank[kfe] < 0 )
{
for( int kk=0; kk<2; ++kk )
{
localIndex const k = elemsToFaces[kfe][kk];
localIndex const localRow = LvArray::integerConversion< localIndex >( bubbleDofNumber[k] - rankOffset );
if( fGhost[k] < 0 )
{
for( localIndex i = 0; i < 3; ++i )
{
localSum += localRhs[localRow + i] * localRhs[localRow + i];
}
}
}
}
} );
real64 const localResidualNorm[2] = { localSum.get(), SolidMechanicsLagrangianFEM::getMaxForce() };
int const rank = MpiWrapper::commRank( MPI_COMM_GEOS );
int const numRanks = MpiWrapper::commSize( MPI_COMM_GEOS );
array1d< real64 > globalValues( numRanks * 2 );
// Everything is done on rank 0
MpiWrapper::gather( localResidualNorm,
2,
globalValues.data(),
2,
0,
MPI_COMM_GEOS );
if( rank==0 )
{
for( int r=0; r<numRanks; ++r )
{
// sum/max across all ranks
globalResidualNorm[0] += globalValues[r*2];
globalResidualNorm[1] = std::max( globalResidualNorm[1], globalValues[r*2+1] );
}
}
MpiWrapper::bcast( globalResidualNorm, 2, 0, MPI_COMM_GEOS );
} );
real64 const bubbleResidualNorm = sqrt( globalResidualNorm[0] )/(globalResidualNorm[1]+1); // the + 1 is for the first
// time-step when maxForce = 0;
GEOS_LOG_LEVEL_RANK_0_NLR( logInfo::ResidualNorm,
GEOS_FMT( " ( RBubbleDisp ) = ( {:4.2e} )", bubbleResidualNorm ));
real64 totalResidualNorm = sqrt( solidResidualNorm * solidResidualNorm + bubbleResidualNorm * bubbleResidualNorm );
getConvergenceStats().setResidualValue( "RBubbleDisp", bubbleResidualNorm );
return totalResidualNorm;
}
void SolidMechanicsAugmentedLagrangianContact::applySystemSolution( DofManager const & dofManager,
arrayView1d< real64 const > const & localSolution,
real64 const scalingFactor,
real64 const dt,
DomainPartition & domain )
{
GEOS_MARK_FUNCTION;
SolidMechanicsLagrangianFEM::applySystemSolution( dofManager,
localSolution,
scalingFactor,
dt,
domain );
dofManager.addVectorToField( localSolution,
contact::totalBubbleDisplacement::key(),
contact::totalBubbleDisplacement::key(),
scalingFactor );
dofManager.addVectorToField( localSolution,
contact::totalBubbleDisplacement::key(),
contact::incrementalBubbleDisplacement::key(),
scalingFactor );
// Synchronize bubble displacements before computing displacement jump
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & )
{
FieldIdentifiers fieldsToBeSync;
fieldsToBeSync.addFields( FieldLocation::Face,
{ contact::incrementalBubbleDisplacement::key(),
contact::totalBubbleDisplacement::key() } );
CommunicationTools::getInstance().synchronizeFields( fieldsToBeSync,