-
Notifications
You must be signed in to change notification settings - Fork 62
/
fitting_routines.f90
6606 lines (6320 loc) · 411 KB
/
fitting_routines.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
!> \file
!> \author Sebastian Krittian
!> \brief This module handles all fitting routines.
!>
!> \section LICENSE
!>
!> Version: MPL 1.1/GPL 2.0/LGPL 2.1
!>
!> The contents of this file are subject to the Mozilla Public License
!> Version 1.1 (the "License"); you may not use this file except in
!> compliance with the License. You may obtain a copy of the License at
!> http://www.mozilla.org/MPL/
!>
!> Software distributed under the License is distributed on an "AS IS"
!> basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
!> License for the specific language governing rights and limitations
!> under the License.
!>
!> The Original Code is OpenCMISS
!>
!> The Initial Developer of the Original Code is University of Auckland,
!> Auckland, New Zealand, the University of Oxford, Oxford, United
!> Kingdom and King's College, London, United Kingdom. Portions created
!> by the University of Auckland, the University of Oxford and King's
!> College, London are Copyright (C) 2007-2010 by the University of
!> Auckland, the University of Oxford and King's College, London.
!> All Rights Reserved.
!>
!> Contributor(s): Chris Bradley
!>
!> Alternatively, the contents of this file may be used under the terms of
!> either the GNU General Public License Version 2 or later (the "GPL"), or
!> the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
!> in which case the provisions of the GPL or the LGPL are applicable instead
!> of those above. If you wish to allow use of your version of this file only
!> under the terms of either the GPL or the LGPL, and not to allow others to
!> use your version of this file under the terms of the MPL, indicate your
!> decision by deleting the provisions above and replace them with the notice
!> and other provisions required by the GPL or the LGPL. If you do not delete
!> the provisions above, a recipient may use your version of this file under
!> the terms of any one of the MPL, the GPL or the LGPL.
!>
!>This module handles all fitting routines.
MODULE FittingRoutines
USE BaseRoutines
USE BasisRoutines
USE BasisAccessRoutines
USE BOUNDARY_CONDITIONS_ROUTINES
USE Constants
USE CONTROL_LOOP_ROUTINES
USE ControlLoopAccessRoutines
USE DARCY_EQUATIONS_ROUTINES, ONLY: idebug1
USE DistributedMatrixVector
USE DOMAIN_MAPPINGS
USE EquationsRoutines
USE EquationsAccessRoutines
USE EquationsMappingRoutines
USE EquationsMatricesRoutines
USE EquationsSetConstants
USE EquationsSetAccessRoutines
USE FIELD_ROUTINES
USE FieldAccessRoutines
USE FLUID_MECHANICS_IO_ROUTINES
USE INPUT_OUTPUT
USE ISO_VARYING_STRING
USE Kinds
USE MatrixVector
USE Maths
USE NODE_ROUTINES
USE PROBLEM_CONSTANTS
USE Strings
USE SOLVER_ROUTINES
USE SolverAccessRoutines
USE Timer
USE Types
#include "macros.h"
IMPLICIT NONE
PRIVATE
!Module parameters
!Module types
!Module variables
!Interfaces
PUBLIC Fitting_EquationsSetSetup
PUBLIC Fitting_EquationsSetSpecificationSet
PUBLIC Fitting_EquationsSetSolutionMethodSet
PUBLIC Fitting_ProblemSetup
PUBLIC Fitting_ProblemSpecificationSet
PUBLIC Fitting_FiniteElementCalculate
PUBLIC Fitting_FiniteElementResidualEvaluate
PUBLIC Fitting_PreSolve
PUBLIC Fitting_PostSolve
CONTAINS
!
!================================================================================================================================
!
!>Calculates the element stiffness matrices and RHS for a Galerkin projection finite element equations set.
SUBROUTINE Fitting_FiniteElementCalculate(equationsSet,elementNumber,err,error,*)
!Argument variables
TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet !<A pointer to the equations set to perform the finite element calculations on
INTEGER(INTG), INTENT(IN) :: elementNumber !<The element number to calculate
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
INTEGER(INTG) :: ng,mh,mhs,ms,nh,nhs,ns,mi,ni
INTEGER(INTG) :: dependentComponentColumnIdx,dependentComponentRowIdx,dependentElementParameterColumnIdx, &
& dependentElementParameterRowIdx,dependentParameterColumnIdx,dependentParameterRowIdx,gaussPointIdx, &
& meshComponentRow,meshComponentColumn,numberOfDataComponents
REAL(DP) :: rwg,sum,jacobianGaussWeight
REAL(DP) :: basisFunctionRow,basisFunctionColumn,PGM,PGN,PGMSI(3),PGNSI(3)
REAL(DP) :: uValue(3)
REAL(DP) :: phiM,phiN
TYPE(DataProjectionType), POINTER :: dataProjection
TYPE(DECOMPOSITION_TOPOLOGY_TYPE), POINTER :: decompositionTopology
TYPE(DecompositionDataPointsType), POINTER :: dataPoints
TYPE(BASIS_TYPE), POINTER :: dependentBasis,geometricBasis,sourceBasis,dependentBasisRow,dependentBasisColumn
TYPE(EquationsType), POINTER :: equations
TYPE(EquationsMappingVectorType), POINTER :: vectorMapping
TYPE(EquationsMappingLinearType), POINTER :: linearMapping
TYPE(EquationsMatricesVectorType), POINTER :: vectorMatrices
TYPE(EquationsMatricesLinearType), POINTER :: linearMatrices
TYPE(EquationsMatricesRHSType), POINTER :: rhsVector
TYPE(EquationsMatricesSourceType), POINTER :: sourceVector
TYPE(EquationsMatrixType), POINTER :: equationsMatrix
TYPE(EquationsVectorType), POINTER :: vectorEquations
TYPE(FIELD_TYPE), POINTER :: dependentField,geometricField,independentField,materialsField,sourceField
TYPE(FIELD_VARIABLE_TYPE), POINTER :: dataVariable,dataWeightVariable,dependentVariable,fieldVariable
TYPE(FIELD_INTERPOLATED_POINT_TYPE), POINTER :: materialsInterpolatedPoint
TYPE(FIELD_INTERPOLATED_POINT_TYPE), POINTER :: geometricInterpolatedPoint
TYPE(FIELD_INTERPOLATED_POINT_TYPE), POINTER :: referenceGeometricInterpolatedPoint
TYPE(QUADRATURE_SCHEME_TYPE), POINTER :: quadratureScheme,quadratureSchemeColumn,quadratureSchemeRow
TYPE(VARYING_STRING) :: localError
REAL(DP), POINTER :: independentVectorParameters(:),independentWeightParameters(:)
REAL(DP) :: projectionXi(3)
REAL(DP) :: porosity0, porosity, permOverVisParam0, permOverVisParam,tauParam,kappaParam
REAL(DP) :: tension,curvature
REAL(DP) :: materialFact
REAL(DP) :: dXdY(3,3), dXdXi(3,3), dYdXi(3,3), dXidY(3,3), dXidX(3,3)
REAL(DP) :: Jxy, Jyxi
REAL(DP) :: dataPointWeight(99),dataPointVector(99)
INTEGER(INTG) :: derivative_idx, component_idx, xi_idx, numberOfDimensions,smoothingType
INTEGER(INTG) :: dataPointIdx,dataPointUserNumber,dataPointLocalNumber,dataPointGlobalNumber
INTEGER(INTG) :: numberOfXi
INTEGER(INTG) :: componentIdx
INTEGER(INTG) :: dependentVariableType,variableType,localDof
INTEGER(INTG) numberDofs
INTEGER(INTG) meshComponent1,meshComponent2
ENTERS("Fitting_FiniteElementCalculate",err,error,*999)
NULLIFY(dependentBasis,geometricBasis)
NULLIFY(equations)
NULLIFY(vectorMapping)
NULLIFY(linearMapping)
NULLIFY(vectorMatrices)
NULLIFY(linearMatrices)
NULLIFY(rhsVector)
NULLIFY(equationsMatrix)
NULLIFY(dependentField,geometricField,materialsField)
NULLIFY(dataPoints)
NULLIFY(dataProjection)
NULLIFY(decompositionTopology)
NULLIFY(independentField)
NULLIFY(independentVectorParameters)
NULLIFY(independentWeightParameters)
NULLIFY(fieldVariable)
NULLIFY(dependentVariable)
NULLIFY(quadratureScheme)
NULLIFY(geometricInterpolatedPoint,materialsInterpolatedPoint)
dataPointVector = 0.0_DP
dataPointWeight = 0.0_DP
IF(ASSOCIATED(equationsSet)) THEN
equations=>equationsSet%equations
IF(ASSOCIATED(equations)) THEN
NULLIFY(vectorEquations)
CALL Equations_VectorEquationsGet(equations,vectorEquations,err,error,*999)
IF(.NOT.ALLOCATED(equationsSet%specification)) &
& CALL FlagError("Equations set specification is not allocated.",err,error,*999)
IF(SIZE(equationsSet%specification,1)/=4) &
& CALL FlagError("Equations set specification must have four entries for a fitting type equations set.",err,error,*999)
smoothingType=equationsSet%specification(4)
SELECT CASE(equationsSet%specification(2))
CASE(EQUATIONS_SET_DATA_FITTING_EQUATION_TYPE)
SELECT CASE(equationsSet%specification(3))
CASE(EQUATIONS_SET_DATA_POINT_FITTING_SUBTYPE)
geometricField=>equations%interpolation%geometricField
dependentField=>equations%interpolation%dependentField
independentField=>equations%interpolation%independentField
vectorMatrices=>vectorEquations%vectorMatrices
linearMatrices=>vectorMatrices%linearMatrices
equationsMatrix=>linearMatrices%matrices(1)%ptr
rhsVector=>vectorMatrices%rhsVector
vectorMapping=>vectorEquations%vectorMapping
linearMapping=>vectorMapping%linearMapping
dependentVariable=>linearMapping%equationsMatrixToVarMaps(1)%VARIABLE
dependentVariableType=dependentVariable%VARIABLE_TYPE
dataVariable=>independentField%VARIABLE_TYPE_MAP(FIELD_U_VARIABLE_TYPE)%ptr
dataWeightVariable=>independentField%VARIABLE_TYPE_MAP(FIELD_V_VARIABLE_TYPE)%ptr
dependentBasis=>dependentField%decomposition%domain(dependentField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
geometricBasis=>geometricField%decomposition%domain(geometricField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureScheme=>dependentBasis%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& geometricInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& dependentInterpParameters(dependentVariableType)%ptr,err,error,*999)
CALL Field_NumberOfComponentsGet(geometricField,FIELD_U_VARIABLE_TYPE,numberOfDimensions,err,error,*999)
CALL Field_NumberOfComponentsGet(independentField,FIELD_U_VARIABLE_TYPE,numberOfDataComponents,err,error,*999)
IF(numberOfDataComponents>99) CALL FlagError("Increase the size of the data point vectors.",err,error,*999)
numberOfXi = dependentBasis%NUMBER_OF_XI
!Get data point vector parameters
CALL Field_ParameterSetDataGet(independentField,FIELD_U_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentVectorParameters,err,error,*999)
!Get data point weight parameters
CALL Field_ParameterSetDataGet(independentField,FIELD_V_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentWeightParameters,err,error,*999)
!===============================
! D a t a P o i n t F i t
!===============================
dataProjection=>independentField%dataProjection
IF(.NOT.ASSOCIATED(dataProjection)) &
& CALL FlagError("Data projection is not associated on independent field.",err,error,*999)
decompositionTopology=>independentField%decomposition%topology
IF(ASSOCIATED(decompositionTopology)) THEN
dataPoints=>decompositionTopology%dataPoints
IF(.NOT.ASSOCIATED(dataPoints)) &
& CALL FlagError("Data points are not associated on the decomposition topology of the independent field.", &
& err,error,*999)
ELSE
CALL FlagError("Decomposition topology is not associated on the independent field.",err,error,*999)
ENDIF
!Loop over data points
DO dataPointIdx=1,dataPoints%elementDataPoint(elementNumber)%numberOfProjectedData
dataPointUserNumber = dataPoints%elementDataPoint(elementNumber)%dataIndices(dataPointIdx)%userNumber
dataPointLocalNumber = dataPoints%elementDataPoint(elementNumber)%dataIndices(dataPointIdx)%localNumber
dataPointGlobalNumber = dataPoints%elementDataPoint(elementNumber)%dataIndices(dataPointIdx)%globalNumber
! Need to use global number to get the correct projection results
projectionXi(1:numberOfXi) = dataProjection%dataProjectionResults(dataPointGlobalNumber)%elementXi(1:numberOfXi)
CALL Field_InterpolateXi(FIRST_PART_DERIV,projectionXi,equations%interpolation% &
& geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolateXi(FIRST_PART_DERIV,projectionXi,equations%interpolation% &
& dependentInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolatedPointMetricsCalculate(geometricBasis%NUMBER_OF_XI,equations%interpolation% &
& geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
!Get data point vector value and weight
DO componentIdx=1,numberOfDataComponents
localDof=dataVariable%components(componentIdx)%PARAM_TO_DOF_MAP% &
& DATA_POINT_PARAM2DOF_MAP%DATA_POINTS(dataPointLocalNumber)
dataPointVector(componentIdx)=independentVectorParameters(localDof)
localDof=dataWeightVariable%components(componentIdx)%PARAM_TO_DOF_MAP% &
& DATA_POINT_PARAM2DOF_MAP%DATA_POINTS(dataPointLocalNumber)
dataPointWeight(componentIdx)=independentWeightParameters(localDof)
ENDDO !componentIdx
dependentParameterRowIdx=0
!Loop over element rows
DO dependentComponentRowIdx=1,dependentVariable%NUMBER_OF_COMPONENTS
meshComponentRow=dependentVariable%components(dependentComponentRowIdx)%MESH_COMPONENT_NUMBER
dependentBasisRow=>dependentField%decomposition%domain(meshComponentRow)%ptr%topology%elements% &
& elements(elementNumber)%basis
DO dependentElementParameterRowIdx=1,dependentBasisRow%NUMBER_OF_ELEMENT_PARAMETERS
dependentParameterRowIdx=dependentParameterRowIdx+1
dependentParameterColumnIdx=0
basisFunctionRow=Basis_EvaluateXi(dependentBasisRow,dependentElementParameterRowIdx,NO_PART_DERIV, &
& projectionXi,err,error)
IF(equationsMatrix%updateMatrix) THEN
!Loop over element columns
DO dependentComponentColumnIdx=1,dependentVariable%NUMBER_OF_COMPONENTS
meshComponentColumn=dependentVariable%components(dependentComponentColumnIdx)%MESH_COMPONENT_NUMBER
dependentBasisColumn=>dependentField%decomposition%domain(meshComponentColumn)%ptr% &
& topology%elements%elements(elementNumber)%basis
DO dependentElementParameterColumnIdx=1,dependentBasisColumn%NUMBER_OF_ELEMENT_PARAMETERS
dependentParameterColumnIdx=dependentParameterColumnIdx+1
!Treat each component as separate and independent so only calculate the diagonal blocks
IF(dependentComponentColumnIdx==dependentComponentRowIdx) THEN
basisFunctionColumn=Basis_EvaluateXi(dependentBasisColumn,dependentElementParameterColumnIdx, &
& NO_PART_DERIV,projectionXi,err,error)
sum = basisFunctionRow*basisFunctionColumn*dataPointWeight(dependentComponentRowIdx)
equationsMatrix%elementMatrix%matrix(dependentParameterRowIdx,dependentParameterColumnIdx)= &
& equationsMatrix%elementMatrix%matrix(dependentParameterRowIdx,dependentParameterColumnIdx)+sum
ENDIF
ENDDO !dependentElementParameterColumnIdx
ENDDO !dependentComponentColumnIdx
ENDIF
IF(rhsVector%updateVector) THEN
sum = basisFunctionRow*dataPointVector(dependentComponentRowIdx)*dataPointWeight(dependentComponentRowIdx)
rhsVector%elementVector%vector(dependentParameterRowIdx)= &
& rhsVector%elementVector%vector(dependentParameterRowIdx)+sum
ENDIF
ENDDO !dependentElementParameterRowIdx
ENDDO !dependentComponentRowIdx
ENDDO !dataPointIdx
!Restore data point vector parameters
CALL Field_ParameterSetDataRestore(independentField,FIELD_U_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentVectorParameters,err,error,*999)
!Restore data point weight parameters
CALL Field_ParameterSetDataRestore(independentField,FIELD_V_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentWeightParameters,err,error,*999)
SELECT CASE(smoothingType)
CASE(EQUATIONS_SET_FITTING_NO_SMOOTHING)
!Do nothing
CASE(EQUATIONS_SET_FITTING_SOBOLEV_VALUE_SMOOTHING)
IF(equationsMatrix%updateMatrix) THEN
materialsField=>equations%interpolation%materialsField
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& materialsInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
!Loop over Gauss points
DO gaussPointIdx=1,quadratureScheme%NUMBER_OF_GAUSS
!Interpolate fields
CALL Field_InterpolateGauss(FIRST_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,gaussPointIdx, &
& equations%interpolation%geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolateGauss(SECOND_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,gaussPointIdx, &
& equations%interpolation%dependentInterpPoint(dependentVariableType)%ptr,err,error,*999)
CALL Field_InterpolatedPointMetricsCalculate(geometricBasis%NUMBER_OF_XI,equations%interpolation% &
& geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
!Get Sobolev smoothing parameters from interpolated material field
CALL Field_InterpolateGauss(NO_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,gaussPointIdx, &
& equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
tauParam=equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(1,NO_PART_DERIV)
kappaParam=equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(2,NO_PART_DERIV)
jacobianGaussWeight=equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr%jacobian* &
& quadratureScheme%GAUSS_WEIGHTS(gaussPointIdx)
!Loop over field components
dependentParameterRowIdx=0
DO dependentComponentRowIdx=1,dependentVariable%NUMBER_OF_COMPONENTS
!Loop over element rows
meshComponentRow=dependentVariable%components(dependentComponentRowIdx)%MESH_COMPONENT_NUMBER
dependentBasisRow=>dependentField%decomposition%domain(meshComponentRow)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureSchemeRow=>dependentBasisRow%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
DO dependentElementParameterRowIdx=1,dependentBasisRow%NUMBER_OF_ELEMENT_PARAMETERS
dependentParameterRowIdx=dependentParameterRowIdx+1
dependentParameterColumnIdx=0
!Loop over element columns
DO dependentComponentColumnIdx=1,dependentVariable%NUMBER_OF_COMPONENTS
meshComponentColumn=dependentVariable%components(dependentComponentColumnIdx)%MESH_COMPONENT_NUMBER
dependentBasisColumn=>dependentField%decomposition%domain(meshComponentColumn)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureSchemeColumn=>dependentBasisColumn%quadrature%QUADRATURE_SCHEME_MAP( &
& BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
DO dependentElementParameterColumnIdx=1,dependentBasisColumn%NUMBER_OF_ELEMENT_PARAMETERS
dependentParameterColumnIdx=dependentParameterColumnIdx+1
!Calculate Sobolev surface tension and curvature smoothing terms
tension = tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S1, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S1, &
& gaussPointIdx))
curvature = kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S1_S1, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S1_S1, &
& gaussPointIdx))
IF(numberOfXi > 1) THEN
tension = tension + tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S2, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S2, &
& gaussPointIdx))
curvature = curvature + kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S2_S2, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S2_S2, &
& gaussPointIdx) + &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S1_S2, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S1_S2, &
& gaussPointIdx))
IF(numberOfXi > 2) THEN
tension = tension + tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S3, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S3, &
& gaussPointIdx))
curvature = curvature + kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S3_S3, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S3_S3, &
& gaussPointIdx)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S1_S3, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S1_S3, &
& gaussPointIdx)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(dependentElementParameterRowIdx,PART_DERIV_S2_S3, &
& gaussPointIdx)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(dependentElementParameterColumnIdx,PART_DERIV_S2_S3, &
& gaussPointIdx))
ENDIF ! 3D
ENDIF ! 2 or 3D
sum = (tension + curvature) * jacobianGaussWeight
equationsMatrix%elementMatrix%matrix(dependentParameterRowIdx,dependentParameterColumnIdx)= &
equationsMatrix%elementMatrix%matrix(dependentParameterRowIdx,dependentParameterColumnIdx)+sum
ENDDO !dependentElementParameterColumnIdx
ENDDO !dependentComponentColumnIdx
ENDDO !dependentElementParameterRowIdx
ENDDO !dependentComponentRowIdx
ENDDO !gaussPointIdx
ENDIF
CASE(EQUATIONS_SET_FITTING_SOBOLEV_DIFFERENCE_SMOOTHING)
CALL FlagError("Not implemented.",err,error,*999)
CASE(EQUATIONS_SET_FITTING_STRAIN_ENERGY_SMOOTHING)
CALL FlagError("Not implemented.",err,error,*999)
CASE DEFAULT
localError="The fitting smoothing type of "//TRIM(NumberToVString(smoothingType,"*",err,error))// &
& " is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
CASE(EQUATIONS_SET_DATA_POINT_VECTOR_STATIC_FITTING_SUBTYPE, &
& EQUATIONS_SET_DATA_POINT_VECTOR_QUASISTATIC_FITTING_SUBTYPE)
dependentField=>equations%interpolation%dependentField
independentField=>equations%interpolation%independentField
dataProjection=>independentField%dataProjection
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated on independent field.", &
& err,error,*999)
decompositionTopology=>independentField%decomposition%topology
IF(.NOT.ASSOCIATED(decompositionTopology)) &
& CALL FlagError("Decomposition topology is not associated on the independent field.",err,error,*999)
dataPoints=>decompositionTopology%dataPoints
IF(.NOT.ASSOCIATED(dataPoints)) &
& CALL FlagError("Data points are not associated on the decomposition topology of the independent field.", &
& err,error,*999)
geometricField=>equations%interpolation%geometricField
materialsField=>equations%interpolation%materialsField
vectorMatrices=>vectorEquations%vectorMatrices
linearMatrices=>vectorMatrices%linearMatrices
equationsMatrix=>linearMatrices%matrices(1)%ptr
rhsVector=>vectorMatrices%rhsVector
vectorMapping=>vectorEquations%vectorMapping
linearMapping=>vectorMapping%linearMapping
dependentVariable=>linearMapping%equationsMatrixToVarMaps(1)%variable
dependentVariableType=dependentVariable%VARIABLE_TYPE
dependentBasis=>dependentField%decomposition%domain(dependentField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
geometricBasis=>geometricField%decomposition%domain(geometricField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureScheme=>dependentBasis%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& geometricInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& dependentInterpParameters(dependentVariableType)%ptr,err,error,*999)
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& materialsInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_NumberOfComponentsGet(geometricField,FIELD_U_VARIABLE_TYPE,numberOfDimensions,err,error,*999)
numberOfXi = dependentBasis%NUMBER_OF_XI
projectionXi=0.0_DP
! Get data point vector parameters
CALL Field_ParameterSetDataGet(independentField,FIELD_U_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentVectorParameters,err,error,*999)
! Get data point weight parameters
CALL Field_ParameterSetDataGet(independentField,FIELD_V_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentWeightParameters,err,error,*999)
!===========================================
! D a t a P o i n t V e c t o r F i t
!===========================================
!Loop over data points
DO dataPointIdx=1,dataPoints%elementDataPoint(elementNumber)%numberOfProjectedData
dataPointUserNumber = dataPoints%elementDataPoint(elementNumber)%dataIndices(dataPointIdx)%userNumber
dataPointLocalNumber = dataPoints%elementDataPoint(elementNumber)%dataIndices(dataPointIdx)%localNumber
dataPointGlobalNumber = dataPoints%elementDataPoint(elementNumber)%dataIndices(dataPointIdx)%globalNumber
! Need to use global number to get the correct projection results
projectionXi(1:numberOfXi) = dataProjection%dataProjectionResults(dataPointGlobalNumber)%elementXi(1:numberOfXi)
CALL Field_InterpolateXi(FIRST_PART_DERIV,projectionXi,equations%interpolation% &
& geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolateXi(FIRST_PART_DERIV,projectionXi,equations%interpolation% &
& dependentInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolatedPointMetricsCalculate(geometricBasis%NUMBER_OF_XI,equations%interpolation% &
& geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
! Get data point vector value
variableType=independentField%variables(1)%VARIABLE_TYPE
fieldVariable=>independentField%VARIABLE_TYPE_MAP(variableType)%ptr
!!TODO: Shouldn't this be over the number of dimensions???
DO componentIdx=1,numberOfXi
localDof=fieldVariable%components(componentIdx)%PARAM_TO_DOF_MAP% &
& DATA_POINT_PARAM2DOF_MAP%DATA_POINTS(dataPointLocalNumber)
dataPointVector(componentIdx)=independentVectorParameters(localDof)
ENDDO
variableType=independentField%variables(2)%VARIABLE_TYPE
fieldVariable=>independentField%VARIABLE_TYPE_MAP(variableType)%ptr
localDof=fieldVariable%components(1)%PARAM_TO_DOF_MAP%DATA_POINT_PARAM2DOF_MAP%DATA_POINTS(dataPointLocalNumber)
dataPointWeight(1)=independentWeightParameters(localDof)
mhs=0
!Loop over element rows
DO mh=1,dependentVariable%NUMBER_OF_COMPONENTS
meshComponent1=dependentVariable%components(mh)%MESH_COMPONENT_NUMBER
dependentBasisRow=>dependentField%decomposition%domain(meshComponent1)%ptr%topology%elements% &
& elements(elementNumber)%basis
DO ms=1,dependentBasisRow%NUMBER_OF_ELEMENT_PARAMETERS
mhs=mhs+1
nhs=0
PGM=Basis_EvaluateXi(dependentBasisRow,ms,NO_PART_DERIV,projectionXi,err,error)
IF(equationsMatrix%updateMatrix) THEN
!Loop over element columns
DO nh=1,dependentVariable%NUMBER_OF_COMPONENTS
meshComponent2=dependentVariable%components(nh)%MESH_COMPONENT_NUMBER
dependentBasisColumn=>dependentField%decomposition%domain(meshComponent2)%ptr% &
& topology%elements%elements(elementNumber)%basis
DO ns=1,dependentBasisColumn%NUMBER_OF_ELEMENT_PARAMETERS
nhs=nhs+1
PGN=Basis_EvaluateXi(dependentBasisColumn,ns,NO_PART_DERIV,projectionXi,err,error)
sum=0.0_DP
IF(mh==nh) THEN
sum = sum + PGM * PGN * dataPointWeight(1)
ENDIF
equationsMatrix%elementMatrix%matrix(mhs,nhs)=equationsMatrix%elementMatrix%matrix(mhs,nhs)+sum
ENDDO !ns
ENDDO !nh
ENDIF
sum=0.0_DP
IF(rhsVector%updateVector) THEN
sum = sum + PGM*dataPointVector(mh)*dataPointWeight(1)
rhsVector%elementVector%vector(mhs)=rhsVector%elementVector%vector(mhs) + sum
ENDIF
ENDDO !ms
ENDDO !mh
ENDDO !dataPointIdx
!Restore data point vector parameters
CALL Field_ParameterSetDataRestore(independentField,FIELD_U_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentVectorParameters,err,error,*999)
!Restore data point weight parameters
CALL Field_ParameterSetDataRestore(independentField,FIELD_V_VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, &
& independentWeightParameters,err,error,*999)
SELECT CASE(smoothingType)
CASE(EQUATIONS_SET_FITTING_NO_SMOOTHING)
!Do nothing
CASE(EQUATIONS_SET_FITTING_SOBOLEV_VALUE_SMOOTHING)
!===========================================
! S o b o l e v S m o o t h i n g
!===========================================
!Loop over gauss points
DO ng=1,quadratureScheme%NUMBER_OF_GAUSS
CALL Field_InterpolateGauss(SECOND_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolateGauss(SECOND_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& dependentInterpPoint(dependentVariableType)%ptr,err,error,*999)
CALL Field_InterpolateGauss(NO_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolatedPointMetricsCalculate(geometricBasis%NUMBER_OF_XI,equations%interpolation% &
& geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
tauParam=equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(1,NO_PART_DERIV)
kappaParam=equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(2,NO_PART_DERIV)
!Loop over field components
jacobianGaussWeight=equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr%jacobian* &
& quadratureScheme%GAUSS_WEIGHTS(ng)
mhs=0
DO mh=1,dependentVariable%NUMBER_OF_COMPONENTS
!Loop over element rows
meshComponent1=dependentVariable%components(mh)%MESH_COMPONENT_NUMBER
dependentBasisRow=>dependentField%decomposition%domain(meshComponent1)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureSchemeRow=>dependentBasisRow%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
DO ms=1,dependentBasisRow%NUMBER_OF_ELEMENT_PARAMETERS
mhs=mhs+1
nhs=0
IF(equationsMatrix%updateMatrix) THEN
!Loop over element columns
DO nh=1,dependentVariable%NUMBER_OF_COMPONENTS
meshComponent2=dependentVariable%components(nh)%MESH_COMPONENT_NUMBER
dependentBasisColumn=>dependentField%decomposition%domain(meshComponent2)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureSchemeColumn=>dependentBasisColumn%quadrature%QUADRATURE_SCHEME_MAP( &
& BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
DO ns=1,dependentBasisColumn%NUMBER_OF_ELEMENT_PARAMETERS
nhs=nhs+1
sum = 0.0_DP
!Calculate sobolev surface tension and curvature smoothing terms
tension = tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1,ng))
curvature = kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S1,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S1,ng))
IF(dependentVariable%NUMBER_OF_COMPONENTS > 1) THEN
tension = tension + tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2,ng))
curvature = curvature + kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2_S2,ng) + &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S2,ng))
IF(dependentVariable%NUMBER_OF_COMPONENTS > 2) THEN
tension = tension + tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S3,ng))
curvature = curvature + kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S3_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S3_S3,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S3,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2_S3,ng))
ENDIF ! 3D
ENDIF ! 2 or 3D
! Add in smoothing terms to the element matrix
equationsMatrix%elementMatrix%matrix(mhs,nhs) = &
& equationsMatrix%elementMatrix%matrix(mhs,nhs) + (tension + curvature) * jacobianGaussWeight
ENDDO !ns
ENDDO !nh
ENDIF ! update matrix
ENDDO !ms
ENDDO !mh
ENDDO !ng
CASE(EQUATIONS_SET_FITTING_SOBOLEV_DIFFERENCE_SMOOTHING)
CALL FlagError("Not implemented.",err,error,*999)
CASE(EQUATIONS_SET_FITTING_STRAIN_ENERGY_SMOOTHING)
CALL FlagError("Not implemented.",err,error,*999)
CASE DEFAULT
localError="The fitting smoothing type of "//TRIM(NumberToVString(smoothingType,"*",err,error))// &
& " is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
CASE(EQUATIONS_SET_MAT_PROPERTIES_DATA_FITTING_SUBTYPE, &
& EQUATIONS_SET_MAT_PROPERTIES_INRIA_MODEL_DATA_FITTING_SUBTYPE)
!!TODO: move these and scale factor adjustment out once generalised Galerkin projection is put in.
!Store all these in equations matrices/somewhere else?????
dependentField=>equations%interpolation%dependentField
geometricField=>equations%interpolation%geometricField
materialsField=>equations%interpolation%materialsField
vectorMatrices=>vectorEquations%vectorMatrices
linearMatrices=>vectorMatrices%linearMatrices
equationsMatrix=>linearMatrices%matrices(1)%ptr
rhsVector=>vectorMatrices%rhsVector
vectorMapping=>vectorEquations%vectorMapping
linearMapping=>vectorMapping%linearMapping
fieldVariable=>linearMapping%equationsMatrixToVarMaps(1)%VARIABLE
dependentVariableType=fieldVariable%VARIABLE_TYPE
dependentBasis=>dependentField%decomposition%domain(dependentField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
geometricBasis=>geometricField%decomposition%domain(geometricField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber, &
& equations%interpolation%geometricInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber, &
& equations%interpolation%materialsInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
quadratureScheme=>dependentBasis%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
!--- Loop over gauss points
DO ng=1,quadratureScheme%NUMBER_OF_GAUSS
!--- Interpolation of Reference Geometry
CALL Field_InterpolationParametersElementGet(FIELD_INITIAL_VALUES_SET_TYPE,elementNumber, &
& equations%interpolation%geometricInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
referenceGeometricInterpolatedPoint=>equations%interpolation%geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr
CALL Field_InterpolateGauss(FIRST_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng, &
& referenceGeometricInterpolatedPoint,err,error,*999)
!--- Retrieve local map dYdXi
DO component_idx=1,dependentBasis%NUMBER_OF_XI
DO xi_idx=1,dependentBasis%NUMBER_OF_XI
derivative_idx=PARTIAL_DERIVATIVE_FIRST_DERIVATIVE_MAP(xi_idx) !2,4,7
dYdXi(component_idx,xi_idx)=referenceGeometricInterpolatedPoint%values(component_idx,derivative_idx) !dy/dxi (y = referential)
ENDDO
ENDDO
!--- Interpolation of (actual) Geometry and Metrics
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber, &
& equations%interpolation%geometricInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
geometricInterpolatedPoint=>equations%interpolation%geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr
CALL Field_InterpolateGauss(FIRST_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng, &
& geometricInterpolatedPoint,err,error,*999)
CALL Field_InterpolatedPointMetricsCalculate(geometricBasis%NUMBER_OF_XI, &
& equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
!--- Retrieve local map dXdXi
DO component_idx=1,dependentBasis%NUMBER_OF_XI
DO xi_idx=1,dependentBasis%NUMBER_OF_XI
derivative_idx=PARTIAL_DERIVATIVE_FIRST_DERIVATIVE_MAP(xi_idx) !2,4,7
dXdXi(component_idx,xi_idx)=geometricInterpolatedPoint%values(component_idx,derivative_idx) !dx/dxi
ENDDO
ENDDO
!--- Compute deformation gradient tensor dXdY and its Jacobian Jxy
CALL Invert(dYdXi,dXidY,Jyxi,err,error,*999) !dy/dxi -> dxi/dy
CALL MatrixProduct(dXdXi,dXidY,dXdY,err,error,*999) !dx/dxi * dxi/dy = dx/dy (deformation gradient tensor, F)
CALL Determinant(dXdY,Jxy,err,error,*999)
!--- Interpolation of Materials Field
materialsInterpolatedPoint => equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr
CALL Field_InterpolateGauss(NO_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng, &
& materialsInterpolatedPoint,err,error,*999)
!--- Retrieve reference material parameters:
porosity0 = materialsInterpolatedPoint%values(1,NO_PART_DERIV)
permOverVisParam0 = materialsInterpolatedPoint%values(2,NO_PART_DERIV)
!--- Material dependence on structural deformation
IF( ABS(Jxy) > ZERO_TOLERANCE ) THEN
porosity = 1.0_DP - ( 1.0_DP - porosity0 ) / Jxy
ELSE
CALL FlagError("Jacobian Jxy is zero.",err,error,*999)
END IF
IF(equationsSet%specification(3)==EQUATIONS_SET_MAT_PROPERTIES_INRIA_MODEL_DATA_FITTING_SUBTYPE) THEN
permOverVisParam = permOverVisParam0
ELSE
materialFact = ( Jxy * porosity / porosity0 )**2.0_DP
permOverVisParam = materialFact * permOverVisParam0
!material modeling could use gradient information, or solve some PDE
END IF
IF(DIAGNOSTICS2) THEN
IF(idebug1) THEN
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE,"geometricInterpPointMetrics%jacobian = ", &
& equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr%jacobian,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE,"Jxy = ",Jxy,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE,"porosity = ",porosity,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE,"permOverVisParam = ",permOverVisParam,err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," ",err,error,*999)
idebug1 = .FALSE.
ENDIF
ENDIF
!!TODO: Think about symmetric problems.
rwg=equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr%jacobian* &
& quadratureScheme%GAUSS_WEIGHTS(ng)
!Loop over field components
mhs=0
DO mh=1,fieldVariable%NUMBER_OF_COMPONENTS
!Loop over element rows
!!TODO: CHANGE ELEMENT CALCULATE TO WORK OF ns ???
DO ms=1,dependentBasis%NUMBER_OF_ELEMENT_PARAMETERS
mhs=mhs+1
nhs=0
IF(equationsMatrix%updateMatrix) THEN
!Loop over element columns
DO nh=1,fieldVariable%NUMBER_OF_COMPONENTS
DO ns=1,dependentBasis%NUMBER_OF_ELEMENT_PARAMETERS
nhs=nhs+1
PGM=quadratureScheme%GAUSS_BASIS_FNS(ms,NO_PART_DERIV,ng)
PGN=quadratureScheme%GAUSS_BASIS_FNS(ns,NO_PART_DERIV,ng)
sum = 0.0_DP
IF(mh==nh) THEN
sum = sum + PGM * PGN
ENDIF
equationsMatrix%elementMatrix%matrix(mhs,nhs) = &
& equationsMatrix%elementMatrix%matrix(mhs,nhs) + sum * rwg
ENDDO !ns
ENDDO !nh
ENDIF
IF(rhsVector%updateVector) THEN
PGM=quadratureScheme%GAUSS_BASIS_FNS(ms,NO_PART_DERIV,ng)
sum = 0.0_DP
IF(mh==1) THEN
sum = sum + PGM * porosity
ELSE IF(mh==2) THEN
sum = sum + PGM * permOverVisParam
END IF
rhsVector%elementVector%vector(mhs) = rhsVector%elementVector%vector(mhs) + sum * rwg
ENDIF
ENDDO !ms
ENDDO !mh
ENDDO !ng
!-----------------------------------------------------------------------------------------------------------------------------------
! CHECK STIFFNESS MATRIX AND RHS VECTOR WITH CMHEART
IF(DIAGNOSTICS5) THEN
IF( elementNumber == 1 ) THEN
numberDofs = 0
DO mh=1,fieldVariable%NUMBER_OF_COMPONENTS
meshComponent1 = fieldVariable%components(mh)%MESH_COMPONENT_NUMBER
dependentBasisRow => dependentField%decomposition%domain(meshComponent1)%ptr% &
& topology%elements%elements(elementNumber)%basis
numberDofs = numberDofs + dependentBasisRow%NUMBER_OF_ELEMENT_PARAMETERS
END DO
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE,"Element Matrix for element number 1 (Galerkin Projection):",err,error,*999)
DO mhs=1,numberDofs
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE,"row number = ",mhs,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,numberDofs,numberDofs,numberDofs,&
& equationsMatrix%elementMatrix%matrix(mhs,:), &
& '("",4(X,E13.6))','4(4(X,E13.6))',err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," ",err,error,*999)
END DO
END IF
END IF
CASE(EQUATIONS_SET_VECTOR_DATA_FITTING_SUBTYPE,EQUATIONS_SET_DIVFREE_VECTOR_DATA_FITTING_SUBTYPE, &
& EQUATIONS_SET_VECTOR_DATA_PRE_FITTING_SUBTYPE,EQUATIONS_SET_DIVFREE_VECTOR_DATA_PRE_FITTING_SUBTYPE)
dependentField=>equations%interpolation%dependentField
geometricField=>equations%interpolation%geometricField
materialsField=>equations%interpolation%materialsField
sourceField=>equations%interpolation%sourceField
vectorMatrices=>vectorEquations%vectorMatrices
linearMatrices=>vectorMatrices%linearMatrices
equationsMatrix=>linearMatrices%matrices(1)%ptr
rhsVector=>vectorMatrices%rhsVector
sourceVector=>vectorMatrices%sourceVector
vectorMapping=>vectorEquations%vectorMapping
linearMapping=>vectorMapping%linearMapping
fieldVariable=>linearMapping%equationsMatrixToVarMaps(1)%VARIABLE
dependentVariableType=fieldVariable%VARIABLE_TYPE
dependentBasis=>dependentField%decomposition%domain(dependentField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
geometricBasis=>geometricField%decomposition%domain(geometricField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
sourceBasis=>sourceField%decomposition%domain(sourceField%decomposition%MESH_COMPONENT_NUMBER)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureScheme=>dependentBasis%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& geometricInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& dependentInterpParameters(dependentVariableType)%ptr,err,error,*999)
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber,equations%interpolation% &
& materialsInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_NumberOfComponentsGet(geometricField,FIELD_U_VARIABLE_TYPE,numberOfDimensions,err,error,*999)
!Loop over gauss points
DO ng=1,quadratureScheme%NUMBER_OF_GAUSS
! CALL Field_InterpolateGauss(FIRST_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
CALL Field_InterpolateGauss(SECOND_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& geometricInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolateGauss(SECOND_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& dependentInterpPoint(dependentVariableType)%ptr,err,error,*999)
CALL Field_InterpolateGauss(NO_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolatedPointMetricsCalculate(geometricBasis%NUMBER_OF_XI,equations%interpolation% &
& geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
tauParam=equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(1,NO_PART_DERIV)
kappaParam=equations%interpolation%materialsInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(2,NO_PART_DERIV)
! WRITE(*,*)'tauParam ',tauParam
uValue=0.0_DP
IF(sourceVector%updateVector) THEN
CALL Field_InterpolationParametersElementGet(FIELD_VALUES_SET_TYPE,elementNumber, &
& equations%interpolation%sourceInterpParameters(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
CALL Field_InterpolateGauss(SECOND_PART_DERIV,BASIS_DEFAULT_QUADRATURE_SCHEME,ng,equations%interpolation% &
& sourceInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr,err,error,*999)
uValue(1)=equations%interpolation%sourceInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(1,NO_PART_DERIV)
uValue(2)=equations%interpolation%sourceInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(2,NO_PART_DERIV)
IF(dependentBasis%NUMBER_OF_XI==3) THEN
uValue(3)=equations%interpolation%sourceInterpPoint(FIELD_U_VARIABLE_TYPE)%ptr%values(3,NO_PART_DERIV)
ENDIF
ENDIF
!Calculate rwg.
rwg=equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr%jacobian* &
& quadratureScheme%GAUSS_WEIGHTS(ng)
!Loop over field components
mhs=0
DO mh=1,fieldVariable%NUMBER_OF_COMPONENTS
!Loop over element rows
meshComponent1=fieldVariable%components(mh)%MESH_COMPONENT_NUMBER
dependentBasisRow=>dependentField%decomposition%domain(meshComponent1)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureSchemeRow=>dependentBasisRow%quadrature%QUADRATURE_SCHEME_MAP(BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
DO ms=1,dependentBasisRow%NUMBER_OF_ELEMENT_PARAMETERS
mhs=mhs+1
nhs=0
IF(equationsMatrix%updateMatrix) THEN
!Loop over element columns
DO nh=1,fieldVariable%NUMBER_OF_COMPONENTS
meshComponent2=fieldVariable%components(nh)%MESH_COMPONENT_NUMBER
dependentBasisColumn=>dependentField%decomposition%domain(meshComponent2)%ptr% &
& topology%elements%elements(elementNumber)%basis
quadratureSchemeColumn=>dependentBasisColumn%quadrature%QUADRATURE_SCHEME_MAP &
& (BASIS_DEFAULT_QUADRATURE_SCHEME)%ptr
DO ns=1,dependentBasisColumn%NUMBER_OF_ELEMENT_PARAMETERS
nhs=nhs+1
PGM=quadratureSchemeRow%GAUSS_BASIS_FNS(ms,NO_PART_DERIV,ng)
PGN=quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,NO_PART_DERIV,ng)
DO ni=1,dependentBasisColumn%NUMBER_OF_XI
DO mi=1,dependentBasisRow%NUMBER_OF_XI
dXidX(mi,ni)=equations%interpolation%geometricInterpPointMetrics(FIELD_U_VARIABLE_TYPE)%ptr% &
& dXi_dX(mi,ni)
END DO
PGMSI(ni)=quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PARTIAL_DERIVATIVE_FIRST_DERIVATIVE_MAP(ni),ng)
PGNSI(ni)=quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PARTIAL_DERIVATIVE_FIRST_DERIVATIVE_MAP(ni),ng)
END DO !ni
sum = 0.0_DP
!Calculate sum
IF(equationsSet%specification(3)==equations_SET_VECTOR_DATA_FITTING_SUBTYPE.OR. &
& equationsSet%specification(3)==EQUATIONS_SET_VECTOR_DATA_PRE_FITTING_SUBTYPE) THEN
IF(mh==nh) THEN
!This stiffness matrix contribution is without "integration" means ng=nd in fact = least square!
sum = sum + PGM * PGN
ENDIF
!
! IF(mh==nh) THEN
! !This stiffness matrix happens with "integration" so the integral error is reduced!
! sum = sum + PGM * PGN * rwg
! ENDIF
!REDUCED SOBOLEV SMOOTHING
!This stiffness matrix contribution is with "integration" means ng=ng in fact!
SELECT CASE(smoothingType)
CASE(EQUATIONS_SET_FITTING_NO_SMOOTHING)
!Do nothing
CASE(EQUATIONS_SET_FITTING_SOBOLEV_VALUE_SMOOTHING)
sum = sum + ( &
& tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S3,ng)) +&
& kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S1,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S1,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2_S2,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S3_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S3_S3,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S2,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S3,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2_S3,ng))) !&
! no weighting either?
! & * rwg
CASE(EQUATIONS_SET_FITTING_SOBOLEV_DIFFERENCE_SMOOTHING)
CALL FlagError("Not implemented.",err,error,*999)
CASE(EQUATIONS_SET_FITTING_STRAIN_ENERGY_SMOOTHING)
CALL FlagError("Not implemented.",err,error,*999)
CASE DEFAULT
localError="The fitting smoothing type of "//TRIM(NumberToVString(smoothingType,"*",err,error))// &
& " is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
equationsMatrix%elementMatrix%matrix(mhs,nhs) = &
& equationsMatrix%elementMatrix%matrix(mhs,nhs) + sum
ELSE IF(equationsSet%specification(3)==EQUATIONS_SET_DIVFREE_VECTOR_DATA_FITTING_SUBTYPE.OR. &
& equationsSet%specification(3)==EQUATIONS_SET_DIVFREE_VECTOR_DATA_PRE_FITTING_SUBTYPE) THEN
IF(mh==nh.AND.mh<=numberOfDimensions) sum = sum + PGM * PGN
SELECT CASE(smoothingType)
CASE(EQUATIONS_SET_FITTING_NO_SMOOTHING)
!Do nothing
CASE(EQUATIONS_SET_FITTING_SOBOLEV_VALUE_SMOOTHING)
!REDUCED SOBOLEV SMOOTHING
!This stiffness matrix contribution is with "integration" means ng=ng in fact!
sum = sum + ( &
& tauParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S3,ng)) +&
& kappaParam*2.0_DP* ( &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S1_S1,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S1_S1,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S2_S2,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S2_S2,ng)+ &
& quadratureSchemeRow%GAUSS_BASIS_FNS(ms,PART_DERIV_S3_S3,ng)* &
& quadratureSchemeColumn%GAUSS_BASIS_FNS(ns,PART_DERIV_S3_S3,ng)+ &