-
Notifications
You must be signed in to change notification settings - Fork 62
/
equations_mapping_routines.f90
3889 lines (3348 loc) · 205 KB
/
equations_mapping_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 Chris Bradley
!> \brief This module handles all equations mapping 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):
!>
!> 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 equations mapping routines.
MODULE EquationsMappingRoutines
USE BaseRoutines
USE DOMAIN_MAPPINGS
USE EquationsAccessRoutines
USE EquationsMappingAccessRoutines
USE EquationsSetConstants
USE EquationsSetAccessRoutines
USE FIELD_ROUTINES
USE FieldAccessRoutines
USE INPUT_OUTPUT
USE ISO_VARYING_STRING
USE Kinds
USE Strings
USE Types
#include "macros.h"
IMPLICIT NONE
PRIVATE
!Module parameters
!Module types
!Module variables
!Interfaces
INTERFACE EquationsMapping_DynamicMatricesSet
MODULE PROCEDURE EquationsMapping_DynamicMatricesSet1
MODULE PROCEDURE EquationsMapping_DynamicMatricesSet2
END INTERFACE EquationsMapping_DynamicMatricesSet
INTERFACE EquationsMapping_DynamicMatricesCoeffsSet
MODULE PROCEDURE EquationsMapping_DynamicMatricesCoeffsSet1
MODULE PROCEDURE EquationsMapping_DynamicMatricesCoeffsSet2
END INTERFACE EquationsMapping_DynamicMatricesCoeffsSet
PUBLIC EquationsMapping_DynamicMatricesSet
PUBLIC EquationsMapping_DynamicMatricesCoeffsSet
PUBLIC EquationsMapping_DynamicVariableTypeSet
PUBLIC EquationsMapping_LinearMatricesCoeffsSet
PUBLIC EquationsMapping_LinearMatricesNumberSet
PUBLIC EquationsMapping_LinearMatricesVariableTypesSet
PUBLIC EquationsMapping_ResidualCoeffSet
PUBLIC EquationsMapping_ResidualVariableTypesSet
PUBLIC EquationsMapping_ResidualVariablesNumberSet
PUBLIC EquationsMapping_RHSCoeffSet
PUBLIC EquationsMapping_RHSVariableTypeSet
PUBLIC EquationsMapping_ScalarDestroy
PUBLIC EquationsMapping_SourceCoeffSet
PUBLIC EquationsMapping_SourceVariableTypeSet
PUBLIC EquationsMapping_VectorCreateFinish,EquationsMapping_VectorCreateStart
PUBLIC EquationsMapping_VectorDestroy
CONTAINS
!
!================================================================================================================================
!
!>Calculates the equations vector mapping.
SUBROUTINE EquationsMapping_VectorCalculate(vectorMapping,err,error,*)
!Argument variables
TYPE(EquationsMappingVectorType), POINTER :: vectorMapping !<A pointer to the equations vector mapping to calculate
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: columnIdx,dofIdx,linearMatrixStart,matrixIdx,numberOfRows,numberOfGlobalRows,rowIdx, &
& totalNumberOfRows,variableIdx,variableType,variableTypeIdx
TYPE(EquationsType), POINTER :: equations
TYPE(EquationsVectorType), POINTER :: vectorEquations
TYPE(EquationsMappingVectorCreateValuesCacheType), POINTER :: createValuesCache
TYPE(EquationsMappingDynamicType), POINTER :: dynamicMapping
TYPE(EquationsMappingLinearType), POINTER :: linearMapping
TYPE(EquationsMappingNonlinearType), POINTER :: nonlinearMapping
TYPE(EquationsMappingRHSType), POINTER :: rhsMapping
TYPE(EquationsMappingSourceType), POINTER :: sourceMapping
TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet
TYPE(FIELD_TYPE), POINTER :: dependentField,sourceField
TYPE(FIELD_VARIABLE_TYPE), POINTER :: dependentVariable,sourceVariable,rowVariable
TYPE(VARYING_STRING) :: localError
ENTERS("EquationsMapping_VectorCalculate",err,error,*999)
IF(.NOT.ASSOCIATED(vectorMapping)) CALL FlagError("Equations mapping is not associated.",err,error,*999)
NULLIFY(vectorEquations)
CALL EquationsMappingVector_VectorEquationsGet(vectorMapping,vectorEquations,err,error,*999)
NULLIFY(equations)
CALL EquationsVector_EquationsGet(vectorEquations,equations,err,error,*999)
NULLIFY(equationsSet)
CALL Equations_EquationsSetGet(equations,equationsSet,err,error,*999)
NULLIFY(createValuesCache)
CALL EquationsMappingVector_CreateValuesCacheGet(vectorMapping,createValuesCache,err,error,*999)
NULLIFY(dependentField)
CALL EquationsSet_DependentFieldGet(equationsSet,dependentField,err,error,*999)
NULLIFY(sourceField)
IF(createValuesCache%sourceVariableType/=0) CALL EquationsSet_SourceFieldGet(equationsSet,sourceField,err,error,*999)
!Calculate the number of rows in the equations set
linearMatrixStart=1
SELECT CASE(equations%timeDependence)
CASE(EQUATIONS_STATIC,EQUATIONS_QUASISTATIC)
SELECT CASE(equations%linearity)
CASE(EQUATIONS_LINEAR,EQUATIONS_NONLINEAR_BCS)
!Static linear equations set
IF(createValuesCache%numberOfLinearMatrices>=1) THEN
linearMatrixStart=2
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%linearMatrixVariableTypes(1))%ptr
ELSE
localError="The create values cache number of linear matrices of "// &
& TRIM(NumberToVString(createValuesCache%numberOfLinearMatrices,"*",err,error))// &
& " is invalid. The number of linear equations matrices must be >= 1 for a linear equations set."
CALL FlagError(localError,err,error,*999)
ENDIF
CASE(EQUATIONS_NONLINEAR)
!Static nonlinear equations set
!Use first listed nonlinear variable
IF(createValuesCache%numberOfResidualVariables>=1) THEN
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%residualVariableTypes(1))%ptr
ELSE
localError="The create values cache number of residual vectors of "// &
& TRIM(NumberToVString(createValuesCache%numberOfResidualVariables,"*",err,error))// &
& " is invalid. The number of Jacobian matrices must be >= 1 for a nonlinear equations set."
CALL FlagError(localError,err,error,*999)
ENDIF
CASE DEFAULT
localError="The equations linearity type of "//TRIM(NumberToVString(equations%linearity,"*",err,error))//" is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
CASE(EQUATIONS_FIRST_ORDER_DYNAMIC,EQUATIONS_SECOND_ORDER_DYNAMIC)
SELECT CASE(equations%linearity)
CASE(EQUATIONS_LINEAR,EQUATIONS_NONLINEAR_BCS)
!Dynamic linear equations set
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%dynamicVariableType)%ptr
CASE(EQUATIONS_NONLINEAR)
!Dynamic nonlinear equations set
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%residualVariableTypes(1))%ptr
CASE DEFAULT
localError="The equations linearity type of "//TRIM(NumberToVString(equations%linearity,"*",err,error))//" is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
CASE(EQUATIONS_TIME_STEPPING)
!Time stepping DAE equations set
!!NOTE: The time stepping variable type doesn't have to come from the dependent field, it could come from, say, the source field.
!dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%TIME_STEPPING_VARIABLE_TYPE)%ptr
CALL FlagError("Not implemented.",err,error,*999)
CASE DEFAULT
localError="The equations time dependence type of "//TRIM(NumberToVString(equations%timeDependence,"*",err,error))// &
& " is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
IF(.NOT.ASSOCIATED(dependentVariable)) CALL FlagError("The dependent variable is not associated.",err,error,*999)
numberOfRows=dependentVariable%NUMBER_OF_DOFS
totalNumberOfRows=dependentVariable%TOTAL_NUMBER_OF_DOFS
vectorMapping%rowDofsMapping=>dependentVariable%DOMAIN_MAPPING
IF(.NOT.ASSOCIATED(vectorMapping%rowDofsMapping)) &
& CALL FlagError("Dependent variable domain mapping is not associated.",err,error,*999)
numberOfGlobalRows=vectorMapping%rowDofsMapping%NUMBER_OF_GLOBAL
!Check that the number of rows is consistent across the remaining linear matrices
DO matrixIdx=linearMatrixStart,createValuesCache%numberOfLinearMatrices
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%linearMatrixVariableTypes(matrixIdx))%ptr
IF(ASSOCIATED(dependentVariable)) THEN
IF(dependentVariable%NUMBER_OF_DOFS/=numberOfRows) THEN
localError="Invalid equations set up. The number of rows in the equations set ("// &
& TRIM(NumberToVString(numberOfRows,"*",err,error))// &
& ") does not match the number of rows in equations linear matrix number "// &
& TRIM(NumberToVString(matrixIdx,"*",err,error))//" ("// &
& TRIM(NumberToVString(dependentVariable%NUMBER_OF_DOFS,"*",err,error))//")."
CALL FlagError(localError,err,error,*999)
ENDIF
IF(dependentVariable%TOTAL_NUMBER_OF_DOFS/=totalNumberOfRows) THEN
localError="Invalid equations set up. The total number of rows in the equations set ("// &
& TRIM(NumberToVString(totalNumberOfRows,"*",err,error))// &
& ") does not match the total number of rows in equations matrix number "// &
& TRIM(NumberToVString(matrixIdx,"*",err,error))//" ("// &
& TRIM(NumberToVString(dependentVariable%TOTAL_NUMBER_OF_DOFS,"*",err,error))//")."
CALL FlagError(localError,err,error,*999)
ENDIF
ELSE
localError="The dependent variable mapped to linear matrix number "// &
& TRIM(NumberToVString(matrixIdx,"*",err,error))//" is not associated."
CALL FlagError(localError,err,error,*999)
ENDIF
ENDDO !matrixIdx
!Check the Jacobian matrices
!Can't check the number of rows now as Jacobian's might not be square so just check variables are associated
DO matrixIdx=1,createValuesCache%numberOfResidualVariables
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%residualVariableTypes(matrixIdx))%ptr
IF(.NOT.ASSOCIATED(dependentVariable)) THEN
localError="The dependent variable mapped to Jacobian matrix number "// &
& TRIM(NumberToVString(matrixIdx,"*",err,error))//" is not associated."
CALL FlagError(localError,err,error,*999)
ENDIF
ENDDO !matrixIdx
!Check that the number of rows are consistent with the RHS vector if it exists
IF(createValuesCache%rhsVariableType/=0) THEN
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%rhsVariableType)%ptr
IF(ASSOCIATED(dependentVariable)) THEN
IF(dependentVariable%NUMBER_OF_DOFS/=numberOfRows) THEN
localError="Invalid equations set up. The number of rows in the equations set ("// &
& TRIM(NumberToVString(numberOfRows,"*",err,error))// &
& ") does not match the number of rows in the RHS vector ("// &
& TRIM(NumberToVString(dependentVariable%NUMBER_OF_DOFS,"*",err,error))//")."
CALL FlagError(localError,err,error,*999)
ENDIF
IF(dependentVariable%TOTAL_NUMBER_OF_DOFS/=totalNumberOfRows) THEN
localError="Invalid equations set up. The total number of rows in the equations set ("// &
& TRIM(NumberToVString(totalNumberOfRows,"*",err,error))// &
& ") does not match the total number of rows in the RHS vector ("// &
& TRIM(NumberToVString(dependentVariable%TOTAL_NUMBER_OF_DOFS,"*",err,error))//")."
CALL FlagError(localError,err,error,*999)
ENDIF
ELSE
CALL FlagError("The dependent variable mapped to the RHS vector is not associated.",err,error,*999)
ENDIF
ENDIF
!Check that the number of rows are consistent with the source vector if it exists
!IF(createValuesCache%sourceVariableType/=0) THEN
! sourceVariable=>sourceField%VARIABLE_TYPE_MAP(createValuesCache%sourceVariableType)%ptr
! IF(ASSOCIATED(sourceVariable)) THEN
! IF(sourceVariable%NUMBER_OF_DOFS/=numberOfRows) THEN
! localError="Invalid equations set up. The number of rows in the equations set ("// &
! & TRIM(NumberToVString(numberOfRows,"*",err,error))// &
! & ") does not match the number of rows in the source vector ("// &
! & TRIM(NumberToVString(sourceVariable%NUMBER_OF_DOFS,"*",err,error))//")."
! CALL FlagError(localError,err,error,*999)
! ENDIF
! IF(sourceVariable%TOTAL_NUMBER_OF_DOFS/=totalNumberOfRows) THEN
! localError="Invalid equations set up. The total number of rows in the equations set ("// &
! & TRIM(NumberToVString(totalNumberOfRows,"*",err,error))// &
! & ") does not match the total number of rows in the source vector ("// &
! & TRIM(NumberToVString(sourceVariable%TOTAL_NUMBER_OF_DOFS,"*",err,error))//")."
! CALL FlagError(localError,err,error,*999)
! ENDIF
! ELSE
! CALL FlagError("The source variable mapped to the source vector is not associated.",err,error,*999)
! ENDIF
!ENDIF
vectorMapping%numberOfRows=numberOfRows
vectorMapping%totalNumberOfRows=totalNumberOfRows
vectorMapping%numberOfGlobalRows=numberOfGlobalRows
!Calculate dynamic mappings
IF(createValuesCache%dynamicVariableType/=0) THEN
CALL EquationsMapping_DynamicMappingInitialise(vectorMapping,err,error,*999)
NULLIFY(dynamicMapping)
CALL EquationsMappingVector_DynamicMappingGet(vectorMapping,dynamicMapping,err,error,*999)
dynamicMapping%numberOfDynamicMatrices=createValuesCache%numberOfDynamicMatrices
dynamicMapping%stiffnessMatrixNumber=createValuesCache%dynamicStiffnessMatrixNumber
dynamicMapping%dampingMatrixNumber=createValuesCache%dynamicDampingMatrixNumber
dynamicMapping%massMatrixNumber=createValuesCache%dynamicMassMatrixNumber
!Initialise the variable type maps
ALLOCATE(dynamicMapping%varToEquationsMatricesMaps(FIELD_NUMBER_OF_VARIABLE_TYPES),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations mapping variable to equations map.",err,error,*999)
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
CALL EquationsMapping_VarToEquatsMatricesMapInitialise(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx), &
& err,error,*999)
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%variableIndex=variableTypeIdx
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%variableType=variableTypeIdx
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%variable=>dependentField%VARIABLE_TYPE_MAP(variableTypeIdx)%ptr
ENDDO !variableTypeIdx
dynamicMapping%varToEquationsMatricesMaps(createValuesCache%dynamicVariableType)% &
& numberOfEquationsMatrices=createValuesCache%numberOfDynamicMatrices
IF(createValuesCache%rhsVariableType/=0) &
& dynamicMapping%varToEquationsMatricesMaps(createValuesCache%rhsVariableType)%numberOfEquationsMatrices=-1
!Allocate and initialise the variable to equations matrices maps
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(variableTypeIdx)%ptr
IF(ASSOCIATED(dependentVariable)) THEN
IF(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices==-1) THEN
!!TODO: check if this can be removed and just allocate those variables that are actually used
ALLOCATE(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap( &
& dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps dof to rows map.",err,error,*999)
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap=0
ELSE IF(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices>0) THEN
ALLOCATE(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers( &
& dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps equations matrix numbers.", &
& err,error,*999)
ALLOCATE(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToColumnsMaps( &
& dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps dof to columns map.",err,error,*999)
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers=0
IF(createValuesCache%dynamicVariableType==variableTypeIdx) THEN
IF(createValuesCache%dynamicStiffnessMatrixNumber/=0) &
& dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers( &
& createValuesCache%dynamicStiffnessMatrixNumber)=createValuesCache%dynamicStiffnessMatrixNumber
IF(createValuesCache%dynamicDampingMatrixNumber/=0) &
& dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers( &
& createValuesCache%dynamicDampingMatrixNumber)=createValuesCache%dynamicDampingMatrixNumber
IF(createValuesCache%dynamicMassMatrixNumber/=0) &
& dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers( &
& createValuesCache%dynamicMassMatrixNumber)=createValuesCache%dynamicMassMatrixNumber
DO matrixIdx=1,dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices
ALLOCATE(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToColumnsMaps( &
& matrixIdx)%columnDOF(dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable dof to columns map column dof.",err,error,*999)
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
columnIdx=dependentVariable%DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(dofIdx)
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToColumnsMaps(matrixIdx)%columnDOF(dofIdx)=columnIdx
ENDDO !dofIdx
ENDDO !matrixIdx
ALLOCATE(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap( &
& dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps dof to rows map.",err,error,*999)
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mappings for now.
rowIdx=dofIdx
dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap(dofIdx)=rowIdx
ENDDO !dofIdx
ENDIF
ENDIF
ENDIF
ENDDO !variableTypeIdx
!Allocate and initialise the equations matrix to variable maps types
ALLOCATE(dynamicMapping%equationsMatrixToVarMaps(dynamicMapping%numberOfDynamicMatrices),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations mapping equations matrix to variable maps.",err,error,*999)
!Create the individual matrix maps and column maps
variableType=createValuesCache%dynamicVariableType
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(variableType)%ptr
dynamicMapping%dynamicVariableType=variableType
dynamicMapping%dynamicVariable=>dependentVariable
DO matrixIdx=1,dynamicMapping%numberOfDynamicMatrices
CALL EquationsMapping_EquatsMatrixToVarMapInitialise(dynamicMapping%equationsMatrixToVarMaps(matrixIdx),err,error,*999)
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%matrixNumber=matrixIdx
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%variableType=variableType
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%variable=>dependentVariable
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%numberOfColumns=dependentVariable%DOMAIN_MAPPING%NUMBER_OF_GLOBAL
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%matrixCoefficient=createValuesCache%dynamicMatrixCoefficients(matrixIdx)
ALLOCATE(dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap(dependentVariable%DOMAIN_MAPPING% &
& NUMBER_OF_GLOBAL),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equation matrix to variable map column to dof map.",err,error,*999)
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap=0
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
columnIdx=dependentVariable%DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(dofIdx)
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap(columnIdx)=dofIdx
ENDDO !dofIdx
dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%columnDOFSMapping=>dependentVariable%DOMAIN_MAPPING
ENDDO !matrixIdx
!Allocate the row mappings
ALLOCATE(dynamicMapping%equationsRowToVariableDOFMaps(vectorMapping%totalNumberOfRows),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations row to variable dof maps.",err,error,*999)
!Set up the row mappings
DO rowIdx=1,vectorMapping%totalNumberOfRows
!1-1 mapping for now
dynamicMapping%equationsRowToVariableDOFMaps(rowIdx)=rowIdx
ENDDO !rowIdx
ENDIF
!Calculate linear mappings
IF(createValuesCache%numberOfLinearMatrices>0) THEN
CALL EquationsMapping_LinearMappingInitialise(vectorMapping,err,error,*999)
NULLIFY(linearMapping)
CALL EquationsMappingVector_LinearMappingGet(vectorMapping,linearMapping,err,error,*999)
linearMapping%numberOfLinearMatrices=createValuesCache%numberOfLinearMatrices
!Allocate and initialise the variable type maps
ALLOCATE(linearMapping%varToEquationsMatricesMaps(FIELD_NUMBER_OF_VARIABLE_TYPES),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations mapping variable to equations map.",err,error,*999)
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
CALL EquationsMapping_VarToEquatsMatricesMapInitialise(linearMapping%varToEquationsMatricesMaps(variableTypeIdx), &
& err,error,*999)
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%variableIndex=variableTypeIdx
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%variableType=variableTypeIdx
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%variable=>dependentField%VARIABLE_TYPE_MAP(variableTypeIdx)%ptr
ENDDO !variableTypeIdx
!Calculate the number of variable type maps and initialise
DO matrixIdx=1,linearMapping%numberOfLinearMatrices
variableType=createValuesCache%linearMatrixVariableTypes(matrixIdx)
linearMapping%varToEquationsMatricesMaps(variableType)%numberOfEquationsMatrices= &
& linearMapping%varToEquationsMatricesMaps(variableType)%numberOfEquationsMatrices+1
ENDDO !matrixIdx
IF(createValuesCache%rhsVariableType/=0) &
& linearMapping%varToEquationsMatricesMaps(createValuesCache%rhsVariableType)%numberOfEquationsMatrices=-1
linearMapping%numberOfLinearMatrixVariables=0
!Allocate and initialise the variable to equations matrices maps
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(variableTypeIdx)%ptr
IF(ASSOCIATED(dependentVariable)) THEN
IF(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices==-1) THEN
!!TODO: check if this can be removed and just allocate those variables that are actually used
ALLOCATE(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap( &
& dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps dof to rows map.",err,error,*999)
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap=0
linearMapping%numberOfLinearMatrixVariables=linearMapping%numberOfLinearMatrixVariables+1
ELSE IF(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices>0) THEN
ALLOCATE(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers( &
& linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices),STAT=err)
IF(err/=0) &
& CALL FlagError("Could not allocate variable to equations matrices maps equations matrix numbers.",err,error,*999)
ALLOCATE(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToColumnsMaps( &
& linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps dof to columns map.",err,error,*999)
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers=0
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices=0
DO matrixIdx=1,linearMapping%numberOfLinearMatrices
IF(createValuesCache%linearMatrixVariableTypes(matrixIdx)==variableTypeIdx) THEN
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices= &
& linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices+1
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%equationsMatrixNumbers( &
& linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices)=matrixIdx
ALLOCATE(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToColumnsMaps( &
& linearMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& numberOfEquationsMatrices)%columnDOF(dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable dof to columns map column dof.",err,error,*999)
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
columnIdx=dependentVariable%DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(dofIdx)
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToColumnsMaps( &
& linearMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& numberOfEquationsMatrices)%columnDOF(dofIdx)=columnIdx
ENDDO !dofIdx
ENDIF
ENDDO !matrixIdx
ALLOCATE(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap( &
& dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to equations matrices maps dof to rows map.",err,error,*999)
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mappings for now.
rowIdx=dofIdx
linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%dofToRowsMap(dofIdx)=rowIdx
ENDDO !dofIdx
linearMapping%numberOfLinearMatrixVariables=linearMapping%numberOfLinearMatrixVariables+1
ENDIF
ENDIF
ENDDO !variableTypeIdx
!Allocate and initialise the variable types
ALLOCATE(linearMapping%linearMatrixVariableTypes(linearMapping%numberOfLinearMatrixVariables),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations mapping matrix variable types.",err,error,*999)
linearMapping%numberOfLinearMatrixVariables=0
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
IF(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices>0) THEN
linearMapping%numberOfLinearMatrixVariables=linearMapping%numberOfLinearMatrixVariables+1
linearMapping%linearMatrixVariableTypes(linearMapping%numberOfLinearMatrixVariables)=variableTypeIdx
ENDIF
ENDDO !variableTypeIdx
!Allocate and initialise the equations matrix to variable maps types
ALLOCATE(linearMapping%equationsMatrixToVarMaps(linearMapping%numberOfLinearMatrices),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations mapping equations matrix to variable maps.",err,error,*999)
!Create the individual matrix maps and column maps
DO matrixIdx=1,linearMapping%numberOfLinearMatrices
variableType=createValuesCache%linearMatrixVariableTypes(matrixIdx)
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(variableType)%ptr
CALL EquationsMapping_EquatsMatrixToVarMapInitialise(linearMapping%equationsMatrixToVarMaps(matrixIdx),err,error,*999)
linearMapping%equationsMatrixToVarMaps(matrixIdx)%matrixNumber=matrixIdx
linearMapping%equationsMatrixToVarMaps(matrixIdx)%variableType=variableType
linearMapping%equationsMatrixToVarMaps(matrixIdx)%variable=>dependentVariable
linearMapping%equationsMatrixToVarMaps(matrixIdx)%numberOfColumns=dependentVariable%DOMAIN_MAPPING%NUMBER_OF_GLOBAL
linearMapping%equationsMatrixToVarMaps(matrixIdx)%matrixCoefficient=vectorMapping% &
createValuesCache%linearMatrixCoefficients(matrixIdx)
ALLOCATE(linearMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap( &
& dependentVariable%DOMAIN_MAPPING%NUMBER_OF_GLOBAL),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equation matrix to variable map column to dof map.",err,error,*999)
linearMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap=0
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
columnIdx=dependentVariable%DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(dofIdx)
linearMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap(columnIdx)=dofIdx
ENDDO !dofIdx
linearMapping%equationsMatrixToVarMaps(matrixIdx)%columnDOFSMapping=>dependentVariable%DOMAIN_MAPPING
ENDDO !matrixIdx
!Allocate the row mappings
ALLOCATE(linearMapping%equationsRowToVariableDOFMaps(vectorMapping%totalNumberOfRows, &
& linearMapping%numberOfLinearMatrixVariables),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations row to variable dof maps.",err,error,*999)
!Set up the row mappings
DO variableIdx=1,linearMapping%numberOfLinearMatrixVariables
DO rowIdx=1,vectorMapping%totalNumberOfRows
!1-1 mapping for now
linearMapping%equationsRowToVariableDOFMaps(rowIdx,variableIdx)=rowIdx
ENDDO !rowIdx
ENDDO !variableIdx
ENDIF
!Calculate non-linear mappings
IF(createValuesCache%numberOfResidualVariables/=0) THEN
CALL EquationsMapping_NonlinearMappingInitialise(vectorMapping,err,error,*999)
NULLIFY(nonlinearMapping)
CALL EquationsMappingVector_NonlinearMappingGet(vectorMapping,nonlinearMapping,err,error,*999)
nonlinearMapping%numberOfResidualVariables=createValuesCache%numberOfResidualVariables
ALLOCATE(nonlinearMapping%varToJacobianMap(nonlinearMapping%numberOfResidualVariables),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to Jacobian maps.",err,error,*999)
ALLOCATE(nonlinearMapping%jacobianToVarMap(nonlinearMapping%numberOfResidualVariables),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate Jacobian to variable maps.",err,error,*999)
ALLOCATE(nonlinearMapping%residualVariables(nonlinearMapping%numberOfResidualVariables),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate nonlinear mapping residual variables.",err,error,*999)
DO matrixIdx=1,nonlinearMapping%numberOfResidualVariables
CALL EquationsMapping_VarToEquatsJacobianMapInitialise(nonlinearMapping%varToJacobianMap(matrixIdx),err,error,*999)
nonlinearMapping%varToJacobianMap(matrixIdx)%jacobianNumber=matrixIdx
nonlinearMapping%varToJacobianMap(matrixIdx)%variableType=createValuesCache%residualVariableTypes(matrixIdx)
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%residualVariableTypes(matrixIdx))%ptr
nonlinearMapping%varToJacobianMap(matrixIdx)%variable=>dependentVariable
nonlinearMapping%residualVariables(matrixIdx)%ptr=>dependentVariable
!Row variable is RHS if set, otherwise first nonlinear variable
IF(createValuesCache%rhsVariableType/=0) THEN
rowVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%rhsVariableType)%ptr
ELSE
rowVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%residualVariableTypes(1))%ptr
ENDIF
!Allocate and set dof to Jacobian columns map
ALLOCATE(nonlinearMapping%varToJacobianMap(matrixIdx)%dofToColumnsMap(dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to Jacobian map dof to columns map.",err,error,*999)
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
columnIdx=dependentVariable%DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(dofIdx)
nonlinearMapping%varToJacobianMap(matrixIdx)%dofToColumnsMap(dofIdx)=columnIdx
ENDDO !dofIdx
!Allocate and set dof to Jacobian rows map
ALLOCATE(nonlinearMapping%varToJacobianMap(matrixIdx)%dofToRowsMap(rowVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate variable to Jacobian map dof to columns map.",err,error,*999)
DO dofIdx=1,rowVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
rowIdx=dofIdx
nonlinearMapping%varToJacobianMap(matrixIdx)%dofToRowsMap(dofIdx)=rowIdx
ENDDO !dofIdx
CALL EquationsMapping_EquatsJacobianToVarMapInitialise(nonlinearMapping%jacobianToVarMap(matrixIdx),err,error,*999)
nonlinearMapping%jacobianToVarMap(matrixIdx)%jacobianNumber=matrixIdx
nonlinearMapping%jacobianToVarMap(matrixIdx)%variableType=createValuesCache%residualVariableTypes(matrixIdx)
nonlinearMapping%jacobianToVarMap(matrixIdx)%variable=>dependentVariable
nonlinearMapping%jacobianToVarMap(matrixIdx)%numberOfColumns=dependentVariable%DOMAIN_MAPPING%NUMBER_OF_GLOBAL
nonlinearMapping%jacobianToVarMap(matrixIdx)%jacobianCoefficient=createValuesCache%residualCoefficient
ALLOCATE(nonlinearMapping%jacobianToVarMap(matrixIdx)%equationsColumnToDOFVariableMap( &
& dependentVariable%DOMAIN_MAPPING%NUMBER_OF_GLOBAL),STAT=err)
nonlinearMapping%jacobianToVarMap(matrixIdx)%equationsColumnToDOFVariableMap=0
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
columnIdx=dependentVariable%DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(dofIdx)
nonlinearMapping%jacobianToVarMap(matrixIdx)%equationsColumnToDOFVariableMap(columnIdx)=dofIdx
ENDDO !dofIdx
nonlinearMapping%jacobianToVarMap(matrixIdx)%columnDOFSMapping=>dependentVariable%DOMAIN_MAPPING
ENDDO !matrixIdx
!Set up the row mappings
ALLOCATE(nonlinearMapping%equationsRowToResidualDOFMap(totalNumberOfRows),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations row to residual dof map.",err,error,*999)
DO rowIdx=1,totalNumberOfRows
!1-1 mapping for now
dofIdx=rowIdx
nonlinearMapping%equationsRowToResidualDOFMap(rowIdx)=dofIdx
ENDDO !rowIdx
ENDIF
!Calculate RHS mappings
IF(createValuesCache%rhsVariableType/=0) THEN
CALL EquationsMapping_RHSMappingInitialise(vectorMapping,err,error,*999)
NULLIFY(rhsMapping)
CALL EquationsMappingVector_RHSMappingGet(vectorMapping,rhsMapping,err,error,*999)
rhsMapping%rhsVariableType=createValuesCache%rhsVariableType
dependentVariable=>dependentField%VARIABLE_TYPE_MAP(createValuesCache%rhsVariableType)%ptr
rhsMapping%rhsVariable=>dependentVariable
rhsMapping%rhsVariableMapping=>dependentVariable%DOMAIN_MAPPING
rhsMapping%rhsCoefficient=createValuesCache%rhsCoefficient
!Allocate and set up the row mappings
ALLOCATE(rhsMapping%rhsDOFToEquationsRowMap(dependentVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate rhs dof to equations row map.",err,error,*999)
ALLOCATE(rhsMapping%equationsRowToRHSDOFMap(totalNumberOfRows),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate equations row to dof map.",err,error,*999)
DO dofIdx=1,dependentVariable%TOTAL_NUMBER_OF_DOFS
!1-1 mapping for now
rowIdx=dofIdx
rhsMapping%rhsDOFToEquationsRowMap(dofIdx)=rowIdx
ENDDO !dofIdx
DO rowIdx=1,totalNumberOfRows
!1-1 mapping for now
dofIdx=rowIdx
rhsMapping%equationsRowToRHSDOFMap(rowIdx)=dofIdx
ENDDO !rowIdx
ENDIF
!Calcuate the source mappings
IF(createValuesCache%sourceVariableType/=0) THEN
CALL EquationsMapping_SourceMappingInitialise(vectorMapping,err,error,*999)
NULLIFY(sourceMapping)
CALL EquationsMappingVector_SourceMappingGet(vectorMapping,sourceMapping,err,error,*999)
sourceMapping%sourceVariableType=createValuesCache%sourceVariableType
sourceVariable=>sourceField%VARIABLE_TYPE_MAP(createValuesCache%sourceVariableType)%ptr
sourceMapping%sourceVariable=>sourceVariable
! sourceMapping%sourceVariableMapping=>sourceVariable%DOMAIN_MAPPING
! sourceMapping%sourceCoefficient=createValuesCache%sourceCoefficient
! !Allocate and set up the row mappings
! ALLOCATE(sourceMapping%sourceDOFToEquationsRowMap(sourceVariable%TOTAL_NUMBER_OF_DOFS),STAT=err)
! IF(err/=0) CALL FlagError("Could not allocate source dof to equations row map.",err,error,*999)
! ALLOCATE(sourceMapping%equationsRowToSourceDOFMap(totalNumberOfRows),STAT=err)
! IF(err/=0) CALL FlagError("Could not allocate equations row to source map.",err,error,*999)
! DO dofIdx=1,sourceVariable%TOTAL_NUMBER_OF_DOFS
! !1-1 mapping for now
! rowIdx=dofIdx
! sourceMapping%sourceDOFToEquationsRowMap(dofIdx)=rowIdx
! ENDDO !dofIdx
! DO rowIdx=1,totalNumberOfRows
! !1-1 mapping for now
! dofIdx=rowIdx
! sourceMapping%equationsRowToSourceDOFMap(rowIdx)=dofIdx
! ENDDO !rowIdx
ENDIF
IF(diagnostics1) THEN
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE,"Equations vector mappings:",err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of rows = ",vectorMapping%numberOfRows,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total umber of rows = ",vectorMapping%totalNumberOfRows,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of global rows = ",vectorMapping%numberOfGlobalRows,err,error,*999)
dynamicMapping=>vectorMapping%dynamicMapping
IF(ASSOCIATED(dynamicMapping)) THEN
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Dynamic mappings:",err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of dynamic equations matrices = ",dynamicMapping% &
& numberOfDynamicMatrices,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Dynamic stiffness matrix number = ",dynamicMapping% &
& stiffnessMatrixNumber,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Dynamic damping matrix number = ",dynamicMapping% &
& dampingMatrixNumber,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Dynamic mass matrix number = ",dynamicMapping% &
& massMatrixNumber,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Dynamic variable type = ",dynamicMapping%dynamicVariableType, &
& err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Variable to matrices mappings:",err,error,*999)
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Variable type : ",variableTypeIdx,err,error,*999)
IF(ASSOCIATED(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%variable)) THEN
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total number of DOFs = ",dynamicMapping% &
& varToEquationsMatricesMaps(variableTypeIdx)%variable%TOTAL_NUMBER_OF_DOFS,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of equations matrices = ",dynamicMapping% &
& varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices,err,error,*999)
IF(dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices>0) THEN
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& numberOfEquationsMatrices,4,4,dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& equationsMatrixNumbers,'(" Matrix numbers :",4(X,I12))','(22X,4(X,I12))',err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," DOF to column maps :",err,error,*999)
DO matrixIdx=1,dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix number : ",matrixIdx,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,dynamicMapping%varToEquationsMatricesMaps( &
& variableTypeIdx)%variable%TOTAL_NUMBER_OF_DOFS,5,5,dynamicMapping%varToEquationsMatricesMaps( &
& variableTypeIdx)%dofToColumnsMaps(matrixIdx)%columnDOF, &
& '(" Column numbers :",5(X,I13))','(24X,5(X,I13))',err,error,*999)
ENDDO !matrixIdx
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& VARIABLE%TOTAL_NUMBER_OF_DOFS,5,5,dynamicMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& dofToRowsMap,'(" DOF to row maps :",5(X,I13))','(24X,5(X,I13))',err,error,*999)
ENDIF
ENDIF
ENDDO !variableTypeIdx
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Matrix to variable mappings:",err,error,*999)
DO matrixIdx=1,dynamicMapping%numberOfDynamicMatrices
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix number : ",matrixIdx,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Variable type = ",dynamicMapping% &
& equationsMatrixToVarMaps(matrixIdx)%variableType,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of columns = ",dynamicMapping% &
& equationsMatrixToVarMaps(matrixIdx)%numberOfColumns,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix coefficient = ",dynamicMapping% &
& equationsMatrixToVarMaps(matrixIdx)%matrixCoefficient,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,dynamicMapping%equationsMatrixToVarMaps(matrixIdx)% &
& numberOfColumns,5,5,dynamicMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap, &
& '(" Column to DOF maps :",5(X,I13))','(28X,5(X,I13))',err,error,*999)
ENDDO !matrixIdx
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Row mappings:",err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,vectorMapping%totalNumberOfRows,5,5, &
& dynamicMapping%equationsRowToVariableDOFMaps,'(" Row to DOF maps :",5(X,I13))','(21X,5(X,I13))', &
& err,error,*999)
ENDIF
linearMapping=>vectorMapping%linearMapping
IF(ASSOCIATED(linearMapping)) THEN
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Linear mappings:",err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of linear equations matrices = ",linearMapping% &
& numberOfLinearMatrices,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of linear matrix variables = ",linearMapping% &
& numberOfLinearMatrixVariables,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,linearMapping%numberOfLinearMatrixVariables,4,4, &
& linearMapping%linearMatrixVariableTypes,'(" Linear matrix variable types :",4(X,I12))','(27X,4(X,I12))', &
& err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Variable to matrices mappings:",err,error,*999)
DO variableTypeIdx=1,FIELD_NUMBER_OF_VARIABLE_TYPES
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Variable type : ",variableTypeIdx,err,error,*999)
IF(ASSOCIATED(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%variable)) THEN
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total number of DOFs = ",linearMapping% &
& varToEquationsMatricesMaps(variableTypeIdx)%variable%TOTAL_NUMBER_OF_DOFS,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of equations matrices = ",linearMapping% &
& varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices,err,error,*999)
IF(linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices>0) THEN
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,linearMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& numberOfEquationsMatrices,4,4,linearMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& equationsMatrixNumbers,'(" Matrix numbers :",4(X,I12))','(22X,4(X,I12))',err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," DOF to column maps :",err,error,*999)
DO matrixIdx=1,linearMapping%varToEquationsMatricesMaps(variableTypeIdx)%numberOfEquationsMatrices
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix number : ",matrixIdx,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,linearMapping%varToEquationsMatricesMaps( &
& variableTypeIdx)%variable%TOTAL_NUMBER_OF_DOFS,5,5,linearMapping%varToEquationsMatricesMaps( &
& variableTypeIdx)%dofToColumnsMaps(matrixIdx)%columnDOF, &
& '(" Column numbers :",5(X,I13))','(24X,5(X,I13))',err,error,*999)
ENDDO !matrixIdx
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,linearMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& VARIABLE%TOTAL_NUMBER_OF_DOFS,5,5,linearMapping%varToEquationsMatricesMaps(variableTypeIdx)% &
& dofToRowsMap,'(" DOF to row maps :",5(X,I13))','(24X,5(X,I13))',err,error,*999)
ENDIF
ENDIF
ENDDO !variableTypeIdx
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Matrix to variable mappings:",err,error,*999)
DO matrixIdx=1,linearMapping%numberOfLinearMatrices
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix number : ",matrixIdx,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Variable type = ",linearMapping% &
& equationsMatrixToVarMaps(matrixIdx)%variableType,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of columns = ",linearMapping% &
& equationsMatrixToVarMaps(matrixIdx)%numberOfColumns,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix coefficient = ",linearMapping% &
& equationsMatrixToVarMaps(matrixIdx)%matrixCoefficient,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,linearMapping%equationsMatrixToVarMaps(matrixIdx)% &
& numberOfColumns,5,5,linearMapping%equationsMatrixToVarMaps(matrixIdx)%columnToDOFMap, &
& '(" Column to DOF maps :",5(X,I13))','(28X,5(X,I13))',err,error,*999)
ENDDO !matrixIdx
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Row mappings:",err,error,*999)
DO variableIdx=1,linearMapping%numberOfLinearMatrixVariables
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Variable number : ",variableIdx,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,vectorMapping%totalNumberOfRows,5,5, &
& linearMapping%equationsRowToVariableDOFMaps(:,variableIdx), &
& '(" Row to DOF maps :",5(X,I13))','(21X,5(X,I13))',err,error,*999)
ENDDO !variableIdx
ENDIF
nonlinearMapping=>vectorMapping%nonlinearMapping
IF(ASSOCIATED(nonlinearMapping)) THEN
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Nonlinear mappings:",err,error,*999)
DO matrixIdx=1,nonlinearMapping%numberOfResidualVariables
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix number : ",matrixIdx,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Residual variable type = ",nonlinearMapping% &
& jacobianToVarMap(matrixIdx)%variableType,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total number of residual DOFs = ",nonlinearMapping% &
& jacobianToVarMap(matrixIdx)%variable%TOTAL_NUMBER_OF_DOFS,err,error,*999)
ENDDO
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Residual coefficient = ",nonlinearMapping%residualCoefficient, &
& err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Residual row mappings:",err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,vectorMapping%totalNumberOfRows,5,5, &
& nonlinearMapping%equationsRowToResidualDOFMap,'(" Row to DOF mappings :",5(X,I13))','(25X,5(X,I13))', &
& err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Jacobian mappings:",err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Variable to Jacobian mappings:",err,error,*999)
DO matrixIdx=1,nonlinearMapping%numberOfResidualVariables
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Matrix number : ",matrixIdx,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Jacobian variable type = ",nonlinearMapping% &
& varToJacobianMap(matrixIdx)%variableType,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total number of Jacobain DOFs = ",nonlinearMapping% &
& varToJacobianMap(matrixIdx)%variable%TOTAL_NUMBER_OF_DOFS,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,nonlinearMapping%varToJacobianMap(matrixIdx)%variable% &
& TOTAL_NUMBER_OF_DOFS,5,5,nonlinearMapping%varToJacobianMap(matrixIdx)%dofToColumnsMap, &
& '(" DOF to column map :",5(X,I13))','(26X,5(X,I13))',err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,nonlinearMapping%varToJacobianMap(matrixIdx)%variable% &
& TOTAL_NUMBER_OF_DOFS,5,5,nonlinearMapping%varToJacobianMap(matrixIdx)%dofToRowsMap, &
& '(" DOF to row map :",5(X,I13))','(26X,5(X,I13))',err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Jacobian to variable mappings:",err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Jacobian variable type = ",nonlinearMapping% &
& jacobianToVarMap(matrixIdx)%variableType,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Number of columns = ",nonlinearMapping% &
& jacobianToVarMap(matrixIdx)%numberOfColumns,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Jacobian coefficient = ",nonlinearMapping% &
& jacobianToVarMap(matrixIdx)%jacobianCoefficient,err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,nonlinearMapping%jacobianToVarMap(matrixIdx)%numberOfColumns, &
& 5,5,nonlinearMapping%jacobianToVarMap(matrixIdx)%equationsColumnToDOFVariableMap, &
& '(" Column to DOF map :",5(X,I13))','(26X,5(X,I13))',err,error,*999)
ENDDO
ENDIF
rhsMapping=>vectorMapping%rhsMapping
IF(ASSOCIATED(rhsMapping)) THEN
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," RHS mappings:",err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," RHS variable type = ",rhsMapping%rhsVariableType,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total number of RHS DOFs = ",rhsMapping%rhsVariable% &
& TOTAL_NUMBER_OF_DOFS,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," RHS coefficient = ",rhsMapping%rhsCoefficient,err,error,*999)
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Row mappings:",err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,rhsMapping%rhsVariable%TOTAL_NUMBER_OF_DOFS,5,5, &
& rhsMapping%rhsDOFToEquationsRowMap,'(" DOF to row mappings :",5(X,I13))','(25X,5(X,I13))',err,error,*999)
CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,vectorMapping%totalNumberOfRows,5,5, &
& rhsMapping%equationsRowToRHSDOFMap,'(" Row to DOF mappings :",5(X,I13))','(25X,5(X,I13))',err,error,*999)
ENDIF
sourceMapping=>vectorMapping%sourceMapping
IF(ASSOCIATED(sourceMapping)) THEN
CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Source mappings:",err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Source variable type = ",sourceMapping%sourceVariableType, &
& err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Total number of source DOFs = ",sourceMapping%sourceVariable% &
& TOTAL_NUMBER_OF_DOFS,err,error,*999)
CALL WriteStringValue(DIAGNOSTIC_OUTPUT_TYPE," Source coefficient = ",sourceMapping%sourceCoefficient,err,error,*999)
!CALL WriteString(DIAGNOSTIC_OUTPUT_TYPE," Row mappings:",err,error,*999)
!CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,sourceMapping%sourceVariable%TOTAL_NUMBER_OF_DOFS,5,5, &
! & sourceMapping%sourceDOFToEquationsRowMap,'(" DOF to row mappings :",5(X,I13))','(25X,5(X,I13))', &
! & err,error,*999)
!CALL WriteStringVector(DIAGNOSTIC_OUTPUT_TYPE,1,1,vectorMapping%totalNumberOfRows,5,5, &
! & sourceMapping%equationsRowToSourceDOFMap,'(" Row to DOF mappings :",5(X,I13))','(25X,5(X,I13))', &
! & err,error,*999)
ENDIF
ENDIF
EXITS("EquationsMapping_VectorCalculate")
RETURN
999 ERRORSEXITS("EquationsMapping_VectorCalculate",err,error)
RETURN 1
END SUBROUTINE EquationsMapping_VectorCalculate
!
!================================================================================================================================
!
!>Finishes the process of creating an equations vector mapping
SUBROUTINE EquationsMapping_VectorCreateFinish(vectorMapping,err,error,*)
!Argument variables
TYPE(EquationsMappingVectorType), POINTER :: vectorMapping !<A pointer to the equations vector mapping
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: matrixIdx
LOGICAL :: isResidualType
TYPE(EquationsType), POINTER :: equations
TYPE(EquationsMappingVectorCreateValuesCacheType), POINTER :: createValuesCache
TYPE(EquationsVectorType), POINTER :: vectorEquations
TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet
TYPE(VARYING_STRING) :: localError
ENTERS("EquationsMapping_VectorCreateFinish",err,error,*999)
IF(.NOT.ASSOCIATED(vectorMapping)) CALL FlagError("Vector equations mapping is not associated.",err,error,*999)
IF(vectorMapping%vectorMappingFinished) CALL FlagError("Equations mapping has already been finished.",err,error,*999)
NULLIFY(createValuesCache)
CALL EquationsMappingVector_CreateValuesCacheGet(vectorMapping,createValuesCache,err,error,*999)
NULLIFY(vectorEquations)
CALL EquationsMappingVector_VectorEquationsGet(vectorMapping,vectorEquations,err,error,*999)
NULLIFY(equations)
CALL EquationsVector_EquationsGet(vectorEquations,equations,err,error,*999)
NULLIFY(equationsSet)
CALL Equations_EquationsSetGet(equations,equationsSet,err,error,*999)
!Check that all the variables have been mapped properly
SELECT CASE(equations%timeDependence)
CASE(EQUATIONS_STATIC,EQUATIONS_QUASISTATIC)
SELECT CASE(equations%linearity)
CASE(EQUATIONS_LINEAR,EQUATIONS_NONLINEAR_BCS)
IF(createValuesCache%rhsVariableType==0.AND.createValuesCache%numberOfLinearMatrices==0) &
& CALL FlagError("Invalid equations mapping. The RHS variable type must be set if there are no "// &
& "linear matrices.",err,error,*999)
CASE(EQUATIONS_NONLINEAR)
DO matrixIdx=1,createValuesCache%numberOfResidualVariables
IF(createValuesCache%residualVariableTypes(matrixIdx)==0) THEN
localError="Invalid equations mapping. The residual variable type is not set for Jacobian number "// &
& TRIM(NumberToVString(matrixIdx,"*",err,error))//"."
CALL FlagError(localError,err,error,*999)
ENDIF
ENDDO !matrixIdx
IF(createValuesCache%rhsVariableType==0.AND.createValuesCache%numberOfLinearMatrices==0) &
& CALL FlagError("Invalid equations mapping. The RHS variable type must be set if there are no "// &
& "linear matrices.",err,error,*999)
CASE DEFAULT
localError="The equations linearity type of "//TRIM(NumberToVString(equations%linearity,"*",err,error))//" is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
CASE(EQUATIONS_FIRST_ORDER_DYNAMIC,EQUATIONS_SECOND_ORDER_DYNAMIC)
SELECT CASE(equations%linearity)
CASE(EQUATIONS_LINEAR,EQUATIONS_NONLINEAR_BCS)
IF(createValuesCache%dynamicVariableType==0) CALL FlagError("Invalid equations mapping. "// &
& "The dynamic variable type must be set for dynamic equations.", err,error,*999)
IF(createValuesCache%rhsVariableType==0.AND.createValuesCache%numberOfLinearMatrices==0) &
& CALL FlagError("Invalid equations mapping. The RHS variable type must be set if there are no "// &
& "linear matrices.",err,error,*999)
CASE(EQUATIONS_NONLINEAR)
! SEBK 19/08/2009 not sure about mapping here
!|
IF(createValuesCache%dynamicVariableType==0) CALL FlagError("Invalid equations mapping. "// &
& "The dynamic variable type must be set for dynamic equations.", err,error,*999)
IF(createValuesCache%rhsVariableType==0.AND.createValuesCache%numberOfLinearMatrices==0) &
& CALL FlagError("Invalid equations mapping. The RHS variable type must be set if there are no "// &
& "linear matrices.",err,error,*999)
isResidualType=.FALSE.
DO matrixIdx=1,createValuesCache%numberOfResidualVariables
IF(createValuesCache%residualVariableTypes(matrixIdx)==0) THEN
localError="Invalid equations mapping. The residual variable type is not set for Jacobian number "// &
& TRIM(NumberToVString(matrixIdx,"*",err,error))//"."
CALL FlagError(localError,err,error,*999)
ENDIF
IF(createValuesCache%residualVariableTypes(matrixIdx)==createValuesCache%dynamicVariableType) THEN
isResidualType=.TRUE.
ENDIF
ENDDO !matrixIdx
IF(.NOT.isResidualType) THEN
CALL FlagError("Invalid equations mapping. The residual variable type must correspond to the "// &
& "dynamic variable type for nonlinear dynamic equations.", err,error,*999)
ENDIF
CASE DEFAULT
localError="The equations linearity type of "//TRIM(NumberToVString(equations%linearity,"*",err,error))//" is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
CASE DEFAULT
localError="The equations time dependence type of "//TRIM(NumberToVString(equations%timeDependence,"*",err,error))// &
& " is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
!Check the linear matrices variable types
DO matrixIdx=1,createValuesCache%numberOfLinearMatrices
IF(createValuesCache%linearMatrixVariableTypes(matrixIdx)==0) THEN
localError="Invalid equations mapping. The linear matrix variable type is not set for linear matrix number "//&
& TRIM(NumberToVString(matrixIdx,"*",err,error))//"."
CALL FlagError(localError,err,error,*999)
ENDIF
ENDDO !matrixIdx
!Now calculate the equations mapping and clean up
CALL EquationsMapping_VectorCalculate(vectorMapping,err,error,*999)
CALL EquationsMapping_VectorCreateValuesCacheFinalise(vectorMapping%createValuesCache,err,error,*999)
vectorMapping%vectorMappingFinished=.TRUE.
EXITS("EquationsMapping_VectorCreateFinish")
RETURN
999 ERRORSEXITS("EquationsMapping_VectorCreateFinish",err,error)
RETURN 1
END SUBROUTINE EquationsMapping_VectorCreateFinish
!
!================================================================================================================================
!
!>Finishes the process of creating an equations vector mapping for an equations
SUBROUTINE EquationsMapping_VectorCreateStart(vectorEquations,lhsVariableType,vectorMapping,err,error,*)
!Argument variables
TYPE(EquationsVectorType), POINTER :: vectorEquations !<A pointer to the equations to create the equations vector mapping from.
INTEGER(INTG), INTENT(IN) :: lhsVariableType !<The variable type associated with the equations left hand side (LHS). The LHS variable controls the row mappings for vector equations sets.
TYPE(EquationsMappingVectorType), POINTER :: vectorMapping !<On return, a pointer to the equations vector mapping. This must not be associated on entry
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
TYPE(EquationsType), POINTER :: equations
TYPE(EquationsMappingLHSType), POINTER :: lhsMapping
TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet
TYPE(FIELD_TYPE), POINTER :: dependentField
TYPE(FIELD_VARIABLE_TYPE), POINTER :: lhsVariable
ENTERS("EquationsMapping_VectorCreateStart",err,error,*998)
IF(ASSOCIATED(vectorMapping)) CALL FlagError("Vector equations mapping is already associated.",err,error,*998)
IF(.NOT.ASSOCIATED(vectorEquations)) CALL FlagError("Vector equations is not associated.",err,error,*999)
NULLIFY(equations)
CALL EquationsVector_EquationsGet(vectorEquations,equations,err,error,*999)