forked from mrkearden/abaqus_umat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElasticSolve.F90
5689 lines (4865 loc) · 231 KB
/
ElasticSolve.F90
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
!/*****************************************************************************/
! *
! * Elmer, A Finite Element Software for Multiphysical Problems
! *
! * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
! *
! * This program is free software; you can redistribute it and/or
! * modify it under the terms of the GNU General Public License
! * as published by the Free Software Foundation; either version 2
! * of the License, or (at your option) any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU General Public License
! * along with this program (in file fem/GPL-2); if not, write to the
! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
! * Boston, MA 02110-1301, USA.
! *
! *****************************************************************************/
!
!/******************************************************************************
! *
! * Authors: Juha Ruokolainen, Mikko Lyly, Mika Malinen
! * Email: [email protected], [email protected]
! * Web: http://www.csc.fi/elmer
! * Address: CSC - IT Center for Science Ltd.
! * Keilaranta 14
! * 02101 Espoo, Finland
! *
! * Original Date: 08 Jun 1997
! *
! *****************************************************************************/
!------------------------------------------------------------------------------
!> Initializations for the primary solver: ElasticSolver
!------------------------------------------------------------------------------
SUBROUTINE ElasticSolver_Init0( Model,Solver,dt,Transient )
!------------------------------------------------------------------------------
USE DefUtils
IMPLICIT NONE
TYPE(Model_t) :: Model
TYPE(Solver_t) :: Solver
REAL(KIND=dp) :: dt
LOGICAL :: Transient
!------------------------------------------------------------------------------
TYPE(ValueList_t), POINTER :: SolverParams
LOGICAL :: MixedFormulation, Found
!------------------------------------------------------------------------------
SolverParams => GetSolverParams()
MixedFormulation = GetLogical(SolverParams, 'Mixed Formulation', Found) .AND. &
GetLogical(SolverParams, 'Neo-Hookean Material', Found)
IF( MixedFormulation ) THEN
CALL ListAddNewString( SolverParams, "Element", "p:2" )
END IF
!------------------------------------------------------------------------------
END SUBROUTINE ElasticSolver_Init0
!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
SUBROUTINE ElasticSolver_Init( Model,Solver,dt,Transient )
!------------------------------------------------------------------------------
USE DefUtils
IMPLICIT NONE
TYPE(Model_t) :: Model
TYPE(Solver_t) :: Solver
REAL(KIND=dp) :: dt
LOGICAL :: Transient
!------------------------------------------------------------------------------
TYPE(ValueList_t), POINTER :: SolverParams
INTEGER :: dim, i, DOFs
LOGICAL :: Found, AxialSymmetry, MixedFormulation
LOGICAL :: CalculateStrains, CalculateStresses
LOGICAL :: CalcPrincipalAngle, CalcPrincipal
LOGICAL :: CalcPrincipalStress, CalcPrincipalStrain
LOGICAL :: UseUMAT, OutputStateVars
!------------------------------------------------------------------------------
SolverParams => GetSolverParams()
AxialSymmetry = CurrentCoordinateSystem() == AxisSymmetric
MixedFormulation = GetLogical(SolverParams, 'Mixed Formulation', Found) .AND. &
GetLogical(SolverParams, 'Neo-Hookean Material', Found)
IF ( .NOT. ListCheckPresent( SolverParams, 'Variable') ) THEN
dim = CoordinateSystemDimension()
IF (MixedFormulation) THEN
DOFs = dim + 1
SELECT CASE(dim)
CASE(2)
CALL ListAddString( SolverParams, 'Variable', 'MixedSol[Disp:2 Pres:1]' )
CASE(3)
CALL ListAddString( SolverParams, 'Variable', 'MixedSol[Disp:3 Pres:1]' )
END SELECT
ELSE
DOFs = dim
CALL ListAddString( SolverParams, 'Variable', 'Displacement' )
END IF
CALL ListAddInteger( SolverParams, 'Variable DOFs', DOFs )
END IF
CALL ListAddInteger( SolverParams,'Time derivative order', 2 )
CALL ListAddNewLogical( SolverParams,'Bubbles in Global System',.TRUE.)
CALL ListAddNewLogical( SolverParams,'Displace Mesh At Init',.TRUE.)
CalculateStrains = GetLogical(SolverParams, 'Calculate Strains', Found)
CalculateStresses = GetLogical(SolverParams, 'Calculate Stresses', Found)
!-------------------------------------------------------------------------------
! If stress computation is requested somewhere, then enforce it:
!--------------------------------------------------------------------------------
IF( .NOT. CalculateStresses ) THEN
CalculateStresses = ListGetLogicalAnyEquation( Model,'Calculate Stresses')
IF ( CalculateStresses ) CALL ListAddLogical( SolverParams,'Calculate Stresses',.TRUE.)
END IF
CalcPrincipal = GetLogical(SolverParams, 'Calculate Principal', Found)
CalcPrincipalAngle = GetLogical(SolverParams, 'Calculate PAngle', Found)
IF (CalcPrincipalAngle) CalcPrincipal = .TRUE. ! Principal angle computation enforces component calculation
!----------------------------------------------------------------------------------------------------
CalcPrincipalStress = CalculateStresses .AND. CalcPrincipal
CalcPrincipalStrain = CalculateStrains .AND. CalcPrincipal
IF ( CalculateStresses ) THEN
IF (AxialSymmetry) THEN
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Stress[Stress_xx:1 Stress_zz:1 Stress_yy:1 Stress_xy:1]' )
ELSE
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Stress[Stress_xx:1 Stress_yy:1 Stress_zz:1 Stress_xy:1 Stress_yz:1 Stress_xz:1]' )
END IF
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), 'vonMises' )
IF (CalcPrincipalStress) THEN
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Principal Stress[Principal Stress:3]' )
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Tresca' )
IF (CalcPrincipalAngle) THEN
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'-dofs 9 Principal Angle' )
END IF
END IF
END IF
IF (CalculateStrains) THEN
IF (AxialSymmetry) THEN
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Strain[Strain_xx:1 Strain_zz:1 Strain_yy:1 Strain_xy:1]' )
ELSE
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Strain[Strain_xx:1 Strain_yy:1 Strain_zz:1 Strain_xy:1 Strain_yz:1 Strain_xz:1]' )
END IF
IF (CalcPrincipalStrain) THEN
CALL ListAddString( SolverParams,&
NextFreeKeyword('Exported Variable ',SolverParams), &
'Principal Strain[Principal Strain:3]' )
END IF
END IF
UseUMAT = ListGetLogical(SolverParams, 'Use UMAT', Found)
IF (UseUMAT) THEN
OutputStateVars = GetLogical(SolverParams, 'Output State Variables', Found)
IF (OutputStateVars) THEN
CALL ListAddString(SolverParams, NextFreeKeyword('Exported Variable ', SolverParams), &
'-dofs 3 -ip StateVar[D1:1 D2:1 D3:1]' )
CALL ListAddString(SolverParams, NextFreeKeyword('Exported Variable ', SolverParams), &
'-dofs 9 -ip StateDir[PDir1_x:1 PDir1_y:1 PDir1_z:1 PDir2_x:1 PDir2_y:1 PDir2_z:1 PDir3_x:1 PDir3_y:1 PDir3_z:1]')
END IF
END IF
!------------------------------------------------------------------------------
END SUBROUTINE ElasticSolver_Init
!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
!> Solver for the general non-linear elasticity equations.
!> \ingroup Solvers
!------------------------------------------------------------------------------
SUBROUTINE ElasticSolver( Model, Solver, dt, TransientSimulation )
!------------------------------------------------------------------------------
USE Adaptive
USE DefUtils
USE MaterialModels
USE StressLocal
IMPLICIT NONE
!------------------------------------------------------------------------------
TYPE(Model_t) :: Model
TYPE(Solver_t), TARGET :: Solver
LOGICAL :: TransientSimulation
REAL(KIND=dp) :: dt
!------------------------------------------------------------------------------
! Local variables
!------------------------------------------------------------------------------
TYPE(Mesh_t), POINTER :: Mesh
TYPE(Matrix_t), POINTER :: StiffMatrix, PMatrix
TYPE(Solver_t), POINTER :: PSolver
TYPE(Variable_t), POINTER :: StressSol, TempSol, FlowSol, Var, StateSol, StateDir
TYPE(ValueList_t), POINTER :: SolverParams, Material, BC, Equation, BodyForce
TYPE(Nodes_t) :: ElementNodes, ParentNodes, FlowNodes
TYPE(Element_t), POINTER :: CurrentElement, ParentElement, FlowElement
TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff
LOGICAL :: GotForceBC, GotFSIBC, GotIt, NewtonLinearization = .FALSE., Isotropic = .TRUE., &
RotateModuli, LinearModel = .FALSE., MeshDisplacementActive, NeoHookeanMaterial = .FALSE., &
AxialSymmetry
LOGICAL :: UseUMAT, InitializeStateVars, OutputStateVars, HenckyStrain
LOGICAL :: LargeDeflection
LOGICAL :: MixedFormulation
LOGICAL :: PseudoTraction, GlobalPseudoTraction
LOGICAL :: PlaneStress, CalculateStrains, CalculateStresses
LOGICAL :: CalcPrincipalAngle, CalcPrincipal
LOGICAL :: CalcPrincipalStress, CalcPrincipalStrain
LOGICAL :: AllocationsDone = .FALSE.
LOGICAL :: CompressibilityDefined = .FALSE.
LOGICAL :: NormalSpring, NormalTangential
LOGICAL :: Converged, NoExternalLoads
LOGICAL :: Parallel, Scanning
INTEGER, POINTER :: TempPerm(:),StressPerm(:),PressPerm(:),NodeIndexes(:), &
Indices(:), FlowPerm(:), AdjacentNodes(:)
INTEGER :: dim,i,j,k,l,m,n,nd,nb,ntot,t,iter,NDeg,k1,k2,STDOFs,LocalNodes,istat
INTEGER :: NewtonIter, NonlinearIter, MinNonlinearIter, FlowNOFNodes
INTEGER :: CoordinateSystem
INTEGER :: NPROPS, NSTATEV, MaxIntegrationPoints = 1, N_Gauss
REAL(KIND=dp), POINTER :: Temperature(:),Pressure(:),Displacement(:), UWrk(:,:), &
Work(:,:), ForceVector(:), Velocity(:,:), FlowSolution(:), SaveValues(:), &
NodalStrain(:), NodalStress(:), VonMises(:), &
PrincipalStress(:), PrincipalStrain(:), Tresca(:), PrincipalAngle(:)
REAL(KIND=dp), POINTER :: PointwiseStateV(:,:), PointwiseStateV0(:,:), MaterialConstants(:,:)
REAL(KIND=dp), POINTER :: TotalSol(:) => NULL()
REAL(KIND=dp), POINTER CONTIG :: ValuesSaved(:) => NULL()
REAL(KIND=dp), POINTER :: Pb(:)
REAL(KIND=dp), ALLOCATABLE :: LocalMassMatrix(:,:),LocalStiffMatrix(:,:),&
LocalDampMatrix(:,:),LoadVector(:,:),InertialLoad(:,:), Viscosity(:), LocalForce(:), &
LocalTemperature(:),ElasticModulus(:,:,:),PoissonRatio(:), Density(:), &
Damping(:), HeatExpansionCoeff(:,:,:),Alpha(:,:),Beta(:), &
ReferenceTemperature(:),BoundaryDispl(:),LocalDisplacement(:,:), PrevSOL(:), &
PrevLocalDisplacement(:,:), SpringCoeff(:,:,:), LocalExternalForce(:)
REAL(KIND=dp) :: UNorm, TransformMatrix(3,3), Tdiff, Normal(3), s, UnitNorm, DragCoeff
REAL(KIND=dp) :: Norm, NonlinTol, NonlinRes0, NonlinRes
#ifdef USE_ISO_C_BINDINGS
REAL(KIND=dp) :: at,at0
#else
REAL(KIND=dp) :: at,at0,CPUTime,RealTime
#endif
CHARACTER(LEN=MAX_NAME_LEN) :: str, CompressibilityFlag
CHARACTER(LEN=MAX_NAME_LEN) :: EquationName
!------------------------------------------------------------------------------
SAVE LocalMassMatrix,LocalStiffMatrix,LocalDampMatrix,LoadVector,InertialLoad, Viscosity, &
LocalForce,ElementNodes,ParentNodes,FlowNodes,Alpha,Beta, &
LocalTemperature,AllocationsDone,ReferenceTemperature,BoundaryDispl, &
ElasticModulus, PoissonRatio,Density,Damping,HeatExpansionCoeff, &
LocalDisplacement, Velocity, Pressure, PrevSOL, CalculateStrains, CalculateStresses, &
OutputStateVars, NodalStrain, NodalStress, VonMises, PrincipalStress, PrincipalStrain, &
Tresca, PrincipalAngle, CalcPrincipalAngle, CalcPrincipal, &
PrevLocalDisplacement, SpringCoeff, Indices
SAVE NPROPS, NSTATEV, MaxIntegrationPoints, PointwiseStateV, PointwiseStateV0, &
InitializeStateVars, TotalSol, LocalExternalForce
!-----------------------------------------------------------------------------------------------------
INTERFACE
FUNCTION ElastBoundaryResidual( Model,Edge,Mesh,Quant,Perm, Gnorm ) RESULT(Indicator)
USE Types
TYPE(Element_t), POINTER :: Edge
TYPE(Model_t) :: Model
TYPE(Mesh_t), POINTER :: Mesh
REAL(KIND=dp) :: Quant(:), Indicator(2), Gnorm
INTEGER :: Perm(:)
END FUNCTION ElastBoundaryResidual
FUNCTION ElastEdgeResidual( Model,Edge,Mesh,Quant,Perm ) RESULT(Indicator)
USE Types
TYPE(Element_t), POINTER :: Edge
TYPE(Model_t) :: Model
TYPE(Mesh_t), POINTER :: Mesh
REAL(KIND=dp) :: Quant(:), Indicator(2)
INTEGER :: Perm(:)
END FUNCTION ElastEdgeResidual
FUNCTION ElastInsideResidual( Model,Element,Mesh,Quant,Perm, Fnorm ) RESULT(Indicator)
USE Types
TYPE(Element_t), POINTER :: Element
TYPE(Model_t) :: Model
TYPE(Mesh_t), POINTER :: Mesh
REAL(KIND=dp) :: Quant(:), Indicator(2), Fnorm
INTEGER :: Perm(:)
END FUNCTION ElastInsideResidual
END INTERFACE
!------------------------------------------------------------------------------
! Get variables needed for solution
!------------------------------------------------------------------------------
CALL Info( 'ElasticSolve', 'Starting Solver', Level=10 )
IF ( .NOT. ASSOCIATED( Solver % Matrix ) ) RETURN
SolverParams => GetSolverParams()
Mesh => GetMesh()
dim = CoordinateSystemDimension()
CoordinateSystem = CurrentCoordinateSystem()
AxialSymmetry = CoordinateSystem == AxisSymmetric
Parallel = ParEnv % PEs > 1
Scanning = ListGetString(Model % Simulation, 'Simulation Type', GotIt) == 'scanning'
StressSol => Solver % Variable
StressPerm => StressSol % Perm
STDOFs = StressSol % DOFs
Displacement => StressSol % Values
StiffMatrix => Solver % Matrix
ForceVector => StiffMatrix % RHS
LocalNodes = COUNT( StressPerm > 0 )
IF ( LocalNodes <= 0 ) RETURN
TempSol => VariableGet( Mesh % Variables, 'Temperature' )
IF ( ASSOCIATED( TempSol) ) THEN
TempPerm => TempSol % Perm
Temperature => TempSol % Values
END IF
FlowSol => VariableGet( Mesh % Variables, 'Flow Solution' )
IF ( ASSOCIATED( FlowSol) ) THEN
FlowPerm => FlowSol % Perm
k = SIZE( FlowSol % Values )
FlowSolution => FlowSol % Values
END IF
MeshDisplacementActive = ListGetLogical( SolverParams, &
'Displace Mesh', GotIt )
IF ( .NOT. GotIt ) MeshDisplacementActive = .TRUE.
IF ( AllocationsDone .AND. MeshDisplacementActive ) THEN
CALL DisplaceMesh( Mesh, Displacement, -1, StressPerm, STDOFs, UpdateDirs=dim )
END IF
!-------------------------------------------------------------------------
! Check how material behaviour is defined:
!-------------------------------------------------------------------------
UseUMAT = ListGetLogical( SolverParams, 'Use UMAT', GotIt )
! IF (UseUMAT .AND. TransientSimulation) CALL Fatal('ElasticSolve', &
! 'UMAT version does not yet support transient simulation')
NeoHookeanMaterial = ListGetLogical( SolverParams, 'Neo-Hookean Material', GotIt )
IF (NeoHookeanMaterial) Isotropic = .TRUE.
MixedFormulation = NeoHookeanMaterial .AND. &
ListGetLogical( SolverParams, 'Mixed Formulation', GotIt )
IF (MixedFormulation .AND. (STDOFs /= (dim + 1))) CALL Fatal('ElasticSolve', &
'With mixed formulation variable DOFs should equal to space dimensions + 1')
!------------------------------------------------------------------------------
! Allocate some permanent storage, this is done first time only
!------------------------------------------------------------------------------
IF ( .NOT. AllocationsDone .OR. Mesh % Changed ) THEN
N = Mesh % MaxElementDOFs
IF ( AllocationsDone ) THEN
DEALLOCATE( &
BoundaryDispl, &
ReferenceTemperature, &
HeatExpansionCoeff, &
LocalTemperature, &
Pressure, Velocity, &
ElasticModulus, PoissonRatio, &
Density, Damping, &
LocalForce, LocalExternalForce, Viscosity, &
LocalMassMatrix, &
LocalStiffMatrix, &
LocalDampMatrix, &
LoadVector, InertialLoad, Alpha, Beta, &
LocalDisplacement, &
PrevLocalDisplacement, &
SpringCoeff, &
Indices)
END IF
ALLOCATE( &
BoundaryDispl( N ), &
ReferenceTemperature( N ), &
HeatExpansionCoeff( 3,3,N ), &
LocalTemperature( N ), &
Pressure( N ), Velocity( 3,N ), &
ElasticModulus( 6,6,N ), PoissonRatio( N ), &
Density( N ), Damping( N ), &
LocalForce( STDOFs*N ), LocalExternalForce( STDOFs*N ), Viscosity( N ), &
LocalMassMatrix( STDOFs*N,STDOFs*N ), &
LocalStiffMatrix( STDOFs*N,STDOFs*N ), &
LocalDampMatrix( STDOFs*N,STDOFs*N ), &
LoadVector( 4,N ), InertialLoad(3,N), Alpha( 3,N ), Beta( N ), &
LocalDisplacement( 4,N ), &
PrevLocalDisplacement( 4,N ), &
SpringCoeff( N,3,3 ), &
Indices(N), &
STAT=istat )
IF ( istat /= 0 ) THEN
CALL Fatal( 'ElasticSolve', 'Memory allocation error.' )
END IF
IF (UseUMAT .AND. (.NOT. AllocationsDone) ) THEN
!------------------------------------------------------------------------------
! The UMAT description of the material behavior may depend on a list of state
! variables that depend on the material point. This description is produced
! at each integration point. The following is used for finding the right size
! of an array holding this information and allocating the array.
! TO DO: Take into account the possibility Mesh % Changed = .TRUE.
!------------------------------------------------------------------------------
M = GetNOFActive()
DO t=1,M
CurrentElement => GetActiveElement(t)
Material => GetMaterial()
NPROPS = GetInteger( Material, 'Number of Material Constants', GotIt)
IF (.NOT. GotIt) CALL Fatal('ElasticSolve', &
'Number of Material Constants for UMAT must be specified')
NSTATEV = GetInteger( Material, 'Number of State Variables', GotIt)
IF (.NOT. GotIt) CALL Fatal('ElasticSolve', &
'Number of Material Constants for UMAT must be specified')
IntegStuff = GaussPoints( CurrentElement )
MaxIntegrationPoints = MAX( IntegStuff % n, MaxIntegrationPoints )
END DO
! ---------------------------------------------------------------------
! PointwiseStateV is now allocated for keeping the state variables as
! they evolve during the nonlinear iteration to obtain the solution
! at the new time level m+1. Allocation is done for the given number
! of state variables + 9 additional variables which are three energy
! variables and six stress components:
! ---------------------------------------------------------------------
CALL AllocateArray(PointwiseStateV, M * MaxIntegrationPoints, NSTATEV+9)
PointwiseStateV = 0.0d0
! ----------------------------------------------------------------------
! We also create a similar variable PointwiseStateV0 which keeps the
! the state variables that describe the material state corresponding to
! the converged solution at the previous time level m. The right values
! of the state variables corresponding to the initial state can be found
! by making an extra UMAT call. Whether this call is needed is indicated
! by the last extra entry: a value < 0 means that the state variables have
! not yet been initiated by the extra call.
! ----------------------------------------------------------------------
CALL AllocateArray(PointwiseStateV0, M * MaxIntegrationPoints, NSTATEV+10)
PointwiseStateV0 = 0.0d0
PointwiseStateV0(:,NSTATEV+10) = -1.0d0
InitializeStateVars = GetLogical(SolverParams, 'Initialize State Variables', &
GotIt)
END IF
!----------------------------------------------------------------
! Check whether strains and stresses are computed...
!----------------------------------------------------------------
CalculateStrains = GetLogical(SolverParams, 'Calculate Strains', GotIt )
CalculateStresses = GetLogical(SolverParams, 'Calculate Stresses', GotIt )
IF (UseUMAT) THEN
OutputStateVars = GetLogical(SolverParams, 'Output State Variables', GotIt)
! Principal tensors are not yet available:
CalcPrincipal = .FALSE.
CalcPrincipalAngle = .FALSE.
ELSE
OutputStateVars = .FALSE.
CalcPrincipal = GetLogical(SolverParams, 'Calculate Principal', GotIt )
CalcPrincipalAngle = GetLogical(SolverParams, 'Calculate PAngle', GotIt )
! Principal angle computation enforces component calculation:
IF (CalcPrincipalAngle) CalcPrincipal = .TRUE.
END IF
AllocationsDone = .TRUE.
END IF
!---------------------------------------------------------------------------------------------------
! Set pointers to the variables containing the stress and strain fields:
!--------------------------------------------------------------------------------------------------
CalcPrincipalStress = CalculateStresses .AND. CalcPrincipal
CalcPrincipalStrain = CalculateStrains .AND. CalcPrincipal
IF ( CalculateStresses ) THEN
Var => VariableGet( Mesh % Variables, 'Stress', .TRUE. )
IF ( ASSOCIATED( Var ) ) THEN
StressPerm => Var % Perm
NodalStress => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > Stress < does not exits!')
END IF
Var => VariableGet( Mesh % Variables, 'VonMises',.TRUE. )
IF ( ASSOCIATED( Var ) ) THEN
VonMises => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > vonMises < does not exits!')
END IF
IF (CalcPrincipalStress) THEN
Var => VariableGet( Mesh % Variables, 'Principal Stress',.TRUE. )
IF ( ASSOCIATED( Var ) ) THEN
PrincipalStress => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > Principal Stress < does not exits!')
END IF
Var => VariableGet( Mesh % Variables, 'Tresca',.TRUE. )
IF ( ASSOCIATED( Var ) ) THEN
Tresca => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > Tresca < does not exits!')
END IF
IF (CalcPrincipalAngle) THEN
Var => VariableGet( Mesh % Variables, 'Principal Angle' )
IF ( ASSOCIATED( Var ) ) THEN
PrincipalAngle => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > Principal Angle < does not exits!')
END IF
END IF
END IF
END IF
IF (CalculateStrains) THEN
Var => VariableGet( Mesh % Variables, 'Strain' )
IF ( ASSOCIATED( Var ) ) THEN
NodalStrain => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > Strain < does not exits!')
END IF
IF (CalcPrincipalStrain) THEN
Var => VariableGet( Mesh % Variables, 'Principal Strain' )
IF ( ASSOCIATED( Var ) ) THEN
PrincipalStrain => Var % Values
ELSE
CALL Fatal('ElasticSolver','Variable > Principal Strain < does not exits!')
END IF
END IF
END IF
IF (UseUMAT .AND. OutputStateVars) THEN
StateSol => VariableGet(Mesh % Variables, 'StateVar')
IF ( .NOT. ASSOCIATED(StateSol) ) THEN
CALL Fatal('ElasticSolver','Variable > StateVar < does not exits!')
END IF
StateDir => VariableGet(Mesh % Variables, 'StateDir')
IF ( .NOT. ASSOCIATED(StateDir) ) THEN
CALL Fatal('ElasticSolver','Variable > StateDir < does not exits!')
END IF
END IF
ALLOCATE( PrevSOL(SIZE(Displacement)) )
PrevSOL = Displacement
IF (UseUMAT) THEN
IF (.NOT. ASSOCIATED(StiffMatrix % BulkRHS)) &
ALLOCATE(StiffMatrix % BulkRHS(SIZE(StiffMatrix % RHS)))
StiffMatrix % BulkRHS = 0.0d0
IF (.NOT. ASSOCIATED(TotalSol)) ALLOCATE( TotalSol(SIZE(Displacement)) )
IF (Scanning .AND. .NOT. ASSOCIATED( StressSol % PrevValues )) THEN
ALLOCATE(StressSol % PrevValues(SIZE(Displacement), 1))
StressSol % PrevValues = 0.0d0
END IF
CALL ListAddLogical(SolverParams, 'Skip Compute Nonlinear Change', .TRUE.)
HenckyStrain = ListGetLogical(SolverParams, 'Use Hencky strain', GotIt)
END IF
!------------------------------------------------------------------------------
! Do some additional initialization, and go for it
!------------------------------------------------------------------------------
NonlinearIter = ListGetInteger( SolverParams, &
'Nonlinear System Max Iterations', GotIt )
IF ( .NOT. GotIt ) NonlinearIter = 1
NonlinTol = GetConstReal(SolverParams, 'Nonlinear System Convergence Tolerance')
MinNonlinearIter = ListGetInteger( SolverParams, &
'Nonlinear System Min Iterations', GotIt )
LinearModel = ListGetLogical( SolverParams, &
'Elasticity Solver Linear', GotIt )
LargeDeflection = ListGetLogical(SolverParams, 'Large Deflection', GotIt)
IF (.NOT. GotIt) LargeDeflection = .TRUE.
IF (.NOT. LargeDeflection) HenckyStrain = .FALSE.
GlobalPseudoTraction = GetLogical( SolverParams, 'Pseudo-Traction', GotIt)
CALL DefaultStart()
DO iter=1,NonlinearIter
at = CPUTime()
at0 = RealTime()
CALL Info( 'ElasticSolve', ' ', Level=4 )
CALL Info( 'ElasticSolve', ' ', Level=4 )
CALL Info( 'ElasticSolve', &
'-------------------------------------', Level=4 )
WRITE( Message, * ) 'ELASTICITY ITERATION ', iter
CALL Info( 'ElasticSolve', Message, Level=4 )
CALL Info( 'ElasticSolve', &
'-------------------------------------', Level=4 )
CALL Info( 'ElasticSolve', ' ', Level=4 )
CALL Info( 'ElasticSolve', 'Starting assembly...', Level=4 )
IF (UseUMAT) TotalSol(:) = Displacement(:)
!------------------------------------------------------------------------------
100 CALL DefaultInitialize()
!------------------------------------------------------------------------------
DO t=1,GetNOFActive()
IF ( RealTime() - at0 > 1.0 ) THEN
WRITE(Message,'(a,i3,a)' ) ' Assembly: ', INT(100.0 - 100.0 * &
(Solver % NumberOfActiveElements-t) / &
(1.0*Solver % NumberOfActiveElements)), ' % done'
CALL Info( 'ElasticSolve', Message, Level=5 )
at0 = RealTime()
END IF
CurrentElement => GetActiveElement(t)
CALL GetElementNodes(ElementNodes, CurrentElement)
NodeIndexes => CurrentElement % NodeIndexes
n = GetElementNOFNodes()
nd = GetElementDOFs( Indices )
nb = GetElementNOFBDOFs()
ntot = nd + nb
!-----------------------------------------------------------------------------------
! Get the material parameters relating to the constitutive law:
!------------------------------------------------------------------------------------
Equation => GetEquation()
Material => GetMaterial()
PlaneStress = GetLogical( Equation, 'Plane Stress', GotIt )
PoissonRatio = 0.0d0
IF (UseUMAT) THEN
CALL GetConstRealArray( Material, MaterialConstants, 'Material Constants', GotIt)
IF ( SIZE(MaterialConstants,1) /= NPROPS) &
CALL Fatal('ElasticSolve','Check the size of Material Constants array')
ELSE
IF (NeoHookeanMaterial) THEN
ElasticModulus(1,1,1:n) = ListGetReal( Material, &
'Youngs Modulus', n, NodeIndexes, GotIt )
ELSE
CALL InputTensor( ElasticModulus, Isotropic, &
'Youngs Modulus', Material, n, NodeIndexes )
!------------------------------------------------------------------------------
! Check whether the rotation transformation of elastic modulus is necessary...
!------------------------------------------------------------------------------
RotateModuli = GetLogical( Material, 'Rotate Elasticity Tensor', GotIt )
IF ( RotateModuli ) THEN
DO i=1,3
RotateModuli = .FALSE.
IF( i == 1 ) THEN
CALL GetConstRealArray( Material, UWrk, &
'Material Coordinates Unit Vector 1', GotIt, CurrentElement )
ELSE IF( i == 2 ) THEN
CALL GetConstRealArray( Material, UWrk, &
'Material Coordinates Unit Vector 2', GotIt, CurrentElement )
ELSE
CALL GetConstRealArray( Material, UWrk, &
'Material Coordinates Unit Vector 3', GotIt, CurrentElement )
END IF
IF( GotIt ) THEN
UnitNorm = SQRT( SUM( Uwrk(1:3,1)**2 ) )
IF( UnitNorm < EPSILON( UnitNorm ) ) THEN
CALL Fatal('ElasticSolve','Given > Material Coordinate Unit Vector < too short!')
END IF
TransformMatrix(i,1:3) = Uwrk(1:3,1) / UnitNorm
RotateModuli = .TRUE.
END IF
IF( .NOT. RotateModuli ) CALL Fatal( 'ElasticSolve', &
'No unit vectors found but > Rotate Elasticity Tensor < set True?' )
END DO
END IF
END IF
IF (Isotropic) PoissonRatio(1:n) = GetReal( Material, 'Poisson Ratio' )
END IF
HeatExpansionCoeff = 0.0D0
DO i=1,3
HeatExpansionCoeff(i,i,1:n) = GetReal( Material,'Heat Expansion Coefficient', GotIt )
END DO
ReferenceTemperature(1:n) = GetReal( Material, 'Reference Temperature', GotIt )
Density(1:n) = GetReal( Material, 'Density', GotIt )
Damping(1:n) = GetReal( Material, 'Damping' ,GotIt )
!------------------------------------------------------------------------------
! Set body forces
!------------------------------------------------------------------------------
BodyForce => GetBodyForce()
LoadVector = 0.0D0
InertialLoad = 0.0D0
IF ( ASSOCIATED(BodyForce) ) THEN
LoadVector(1,1:n) = GetReal( BodyForce, 'Stress Bodyforce 1', GotIt )
LoadVector(2,1:n) = GetReal( BodyForce, 'Stress Bodyforce 2', GotIt )
IF ( dim > 2 ) THEN
LoadVector(3,1:n) = GetReal( BodyForce, 'Stress Bodyforce 3', GotIt )
END IF
InertialLoad(1,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 1', GotIt )
InertialLoad(2,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 2', GotIt )
IF ( dim > 2 ) THEN
InertialLoad(3,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 3', GotIt )
END IF
END IF
!------------------------------------------------------------------------------
! Get values of field variables:
!------------------------------------------------------------------------------
LocalTemperature = 0.0D0
IF (UseUMAT) THEN
IF ( ASSOCIATED(TempSol) ) THEN
DO i=1,n
k = TempPerm(NodeIndexes(i))
LocalTemperature(i) = Temperature(k)
END DO
ELSE
DO i=1,n
LocalTemperature(i) = ReferenceTemperature(i)
END DO
END IF
ELSE
IF ( ASSOCIATED(TempSol) ) THEN
DO i=1,n
k = TempPerm(NodeIndexes(i))
LocalTemperature(i) = Temperature(k) - ReferenceTemperature(i)
END DO
END IF
END IF
LocalDisplacement = 0.0D0
DO i=1,nd
k = StressPerm(Indices(i))
DO j=1,STDOFs
LocalDisplacement(j,i) = Displacement(STDOFs*(k-1)+j)
END DO
END DO
! ----------------------------------------------------------------
! Some material models may need the displacement field at the
! previous time/load step
! ----------------------------------------------------------------
PrevLocalDisplacement = 0.0D0
IF (UseUMAT) THEN
IF (TransientSimulation) THEN
DO i=1,nd
k = StressPerm(Indices(i))
DO j=1,STDOFs
PrevLocalDisplacement(j,i) = Solver % Variable % PrevValues(STDOFs*(k-1)+j,3)
END DO
END DO
ELSE
IF (Scanning) THEN
DO i=1,nd
k = StressPerm(Indices(i))
DO j=1,STDOFs
PrevLocalDisplacement(j,i) = Solver % Variable % PrevValues(STDOFs*(k-1)+j,1)
END DO
END DO
END IF
END IF
END IF
IF ( LinearModel ) LocalDisplacement = 0.0d0
!-------------------------------------------------------------------------------------------
! Select subroutine to integrate the element matrix and vector
!-------------------------------------------------------------------------------------------
IF ( CoordinateSystem == Cartesian .OR. AxialSymmetry) THEN
IF (UseUMAT) THEN
! ------------------------------------------------------------------------------
! This branch assumes that the material behavior is defined
! via an umat subroutine. The umat routine should specify
! a material response function which gives the Cauchy stress
! as a function of the strain tensor and state variables.
!-------------------------------------------------------------------------------
CALL LocalMatrixWithUMAT(LocalMassMatrix, LocalDampMatrix, &
LocalStiffMatrix, LocalForce, LocalExternalForce, dt, LoadVector, InertialLoad, &
MaterialConstants, NPROPS, PointwiseStateV, PointwiseStateV0, NSTATEV, &
MaxIntegrationPoints, InitializeStateVars, Density, Damping, AxialSymmetry, &
PlaneStress, LargeDeflection, HenckyStrain, CurrentElement, n, nd, ntot, STDOFs, &
ElementNodes, LocalDisplacement, PrevLocalDisplacement, LocalTemperature, &
t, Iter)
!CALL Fatal( 'ElasticSolve', 'This version does not offer an umat interface' )
! ---------------------------------------------------------------------------
! Create a RHS vector which contains just the contribution of external loads
! for the purpose of nonlinear error estimation:
! ---------------------------------------------------------------------------
IF (Iter == 1) THEN
ValuesSaved => StiffMatrix % RHS
StiffMatrix % RHS => StiffMatrix % BulkRHS
CALL DefaultUpdateForce(LocalExternalForce)
Solver % Matrix % RHS => ValuesSaved
END IF
ELSE
!-------------------------------------------------------
! The following are used for handling cases where
! the material response function gives the second
! Piola-Kirchhoff stress
!--------------------------------------------------------
IF (NeoHookeanMaterial) THEN
CALL NeoHookeanLocalMatrix( LocalMassMatrix, LocalDampMatrix, &
LocalStiffMatrix, LocalForce, LoadVector, InertialLoad, ElasticModulus, &
PoissonRatio,Density,Damping,AxialSymmetry,PlaneStress,HeatExpansionCoeff, &
LocalTemperature,CurrentElement,n,ntot,ElementNodes,LocalDisplacement, &
MixedFormulation)
ELSE
CALL LocalMatrix( LocalMassMatrix, LocalDampMatrix, &
LocalStiffMatrix,LocalForce, LoadVector, InertialLoad, ElasticModulus, &
PoissonRatio,Density,Damping,AxialSymmetry,PlaneStress,HeatExpansionCoeff, &
LocalTemperature,CurrentElement,n,ntot,ElementNodes,LocalDisplacement, &
Isotropic, RotateModuli, TransformMatrix)
END IF
END IF
ELSE
CALL Fatal('ElasticSolve', 'Unsupported coordinate system')
END IF
!------------------------------------------------------------------------------
! If time dependent simulation, add mass matrix to global
! matrix and global RHS vector
!------------------------------------------------------------------------------
IF ( TransientSimulation ) THEN
CALL Default2ndOrderTime( LocalMassMatrix, LocalDampMatrix, &
LocalStiffMatrix, LocalForce )
END IF
!------------------------------------------------------------------------------
! Update global matrices from local matrices
!------------------------------------------------------------------------------
CALL DefaultUpdateEquations( LocalStiffMatrix, LocalForce )
!------------------------------------------------------------------------------
END DO
CALL DefaultFinishBulkAssembly()
!------------------------------------------------------------------------------
! Neumann & Newton boundary conditions
!------------------------------------------------------------------------------
DO t = 1,GetNOFBoundaryElements()
CurrentElement => GetBoundaryElement(t)
IF ( CurrentElement % TYPE % ElementCode == 101 ) CYCLE
IF (.NOT. ActiveBoundaryElement()) CYCLE
n = GetElementNOFNodes()
ntot = GetElementNOFDOFs()
BC => GetBC()
IF ( ASSOCIATED( BC ) ) THEN
LoadVector = 0.0D0
Alpha = 0.0D0
Beta = 0.0D0
SpringCoeff = 0.0d0
!------------------------------------------------------------------------------
! The components of surface forces
!------------------------------------------------------------------------------
GotForceBC = .FALSE.
LoadVector(1,1:n) = GetReal( BC, 'Surface Traction 1', GotIt )
IF (.NOT. GotIt) LoadVector(1,1:n) = GetReal( BC, 'Force 1', GotIt )
GotForceBC = GotForceBC .OR. GotIt
LoadVector(2,1:n) = GetReal( BC, 'Surface Traction 2', GotIt )
IF (.NOT. GotIt) LoadVector(2,1:n) = GetReal( BC, 'Force 2', GotIt )
GotForceBC = GotForceBC .OR. GotIt
LoadVector(3,1:n) = GetReal( BC, 'Surface Traction 3', GotIt )
IF (.NOT. GotIt) LoadVector(3,1:n) = GetReal( BC, 'Force 3', GotIt )
GotForceBC = GotForceBC .OR. GotIt
Beta(1:n) = GetReal( BC, 'Normal Surface Traction', GotIt )
IF (.NOT. GotIt) Beta(1:n) = GetReal( BC, 'Normal Force', gotIt )
GotForceBC = GotForceBC .OR. GotIt
GotForceBC = GotForceBC .OR. GetLogical( BC, 'Force BC', GotIt )
SpringCoeff(1:n,1,1) = GetReal( BC, 'Spring', NormalSpring )
IF ( .NOT. NormalSpring ) THEN
DO i=1,dim
SpringCoeff(1:n,i,i) = GetReal( BC, ComponentName('Spring',i), GotIt)
END DO
DO i=1,dim
DO j=1,dim
IF (ListCheckPresent(BC,'Spring '//TRIM(i2s(i))//i2s(j) )) &
SpringCoeff(1:n,i,j)=GetReal( BC, 'Spring '//TRIM(i2s(i))//i2s(j), GotIt)
END DO
END DO
END IF
GotFSIBC = GetLogical( BC, 'FSI BC', GotIt )
IF(.NOT. GotIt ) GotFSIBc = ASSOCIATED( FlowSol )
IF ( .NOT. GotForceBC .AND. .NOT. GotFSIBC .AND. ALL( SpringCoeff==0.0d0 ) ) CYCLE
PseudoTraction = GetLogical( BC, 'Pseudo-Traction', GotIt)
IF(.NOT. GotIt ) PseudoTraction = GlobalPseudoTraction
!------------------------------------------------------------------------------
ParentElement => CurrentElement % BoundaryInfo % Left
IF ( .NOT. ASSOCIATED( ParentElement ) ) THEN
ParentElement => CurrentElement % BoundaryInfo % Right
ELSE
IF ( ANY(StressPerm(ParentElement % NodeIndexes)==0 )) &
ParentElement => CurrentElement % BoundaryInfo % Right
END IF
nd = GetElementDOFs(Indices, ParentElement)
CALL GetElementNodes( ParentNodes, ParentElement )
LocalDisplacement = 0.0D0
IF( .NOT. LinearModel ) THEN
DO l=1,nd
k = StressPerm(Indices(l))
DO j=1,STDOFs
LocalDisplacement(j,l) = Displacement(STDOFs*(k-1)+j)
END DO
END DO
END IF
NULLIFY( FlowElement )
FlowNOFNodes = 1
! Note: Here the flow solution is not interpolated using the full p-basis
IF ( GotFSIBC ) THEN
FlowElement => CurrentElement % BoundaryInfo % Left
IF ( .NOT. ASSOCIATED(FlowElement) ) THEN
FlowElement => CurrentElement % BoundaryInfo % Right
ELSE
IF ( ANY(FlowPerm(FlowElement % NodeIndexes)==0 )) THEN
FlowElement => CurrentElement % BoundaryInfo % Right
END IF
END IF
IF ( ASSOCIATED(FlowElement) ) THEN
FlowNOFNodes = 0
FlowNOFNodes = FlowElement % TYPE % NumberOfNodes
AdjacentNodes => FlowElement % NodeIndexes
CALL GetElementNodes( FlowNodes, FlowElement )
DO j=1,FlowNOFNodes
k = StressPerm(AdjacentNodes(j))
IF ( k /= 0 ) THEN
k = STDOFs*(k-1)
FlowNodes % x(j) = FlowNodes % x(j) + PrevSOL( k+1 )
IF ( STDOFs > 1 ) &
FlowNodes % y(j) = FlowNodes % y(j) + PrevSOL( k+2 )
IF ( STDOFs > 2 ) &
FlowNodes % z(j) = FlowNodes % z(j) + PrevSOL( k+3 )
END IF
END DO
Velocity = 0.0D0
DO l=1,FlowNOFNodes
k = FlowPerm(AdjacentNodes(l))
DO j=1,FlowSol % DOFs-1
Velocity(j,l) = FlowSolution(FlowSol % DOFs*(k-1)+j)
END DO
Pressure(l) = FlowSolution(FlowSol % DOFs*k)
END DO