1 | /*
|
---|
2 | * UpdateElementsStressbalance:
|
---|
3 | */
|
---|
4 | #ifdef HAVE_CONFIG_H
|
---|
5 | #include <config.h>
|
---|
6 | #else
|
---|
7 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
8 | #endif
|
---|
9 |
|
---|
10 | #include "../../../toolkits/toolkits.h"
|
---|
11 | #include "../../../classes/classes.h"
|
---|
12 | #include "../../../shared/shared.h"
|
---|
13 | #include "../../MeshPartitionx/MeshPartitionx.h"
|
---|
14 | #include "../ModelProcessorx.h"
|
---|
15 |
|
---|
16 | void UpdateElementsStressbalance(Elements* elements, IoModel* iomodel,int analysis_counter,int analysis_type){
|
---|
17 |
|
---|
18 | int materials_type,finiteelement;
|
---|
19 | int approximation;
|
---|
20 | int* finiteelement_list=NULL;
|
---|
21 | bool isSSA,isL1L2,isHO,isFS,iscoupling;
|
---|
22 | bool control_analysis;
|
---|
23 | bool dakota_analysis;
|
---|
24 |
|
---|
25 | /*Fetch constants needed: */
|
---|
26 | iomodel->Constant(&isSSA,FlowequationIsSSAEnum);
|
---|
27 | iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum);
|
---|
28 | iomodel->Constant(&isHO,FlowequationIsHOEnum);
|
---|
29 | iomodel->Constant(&isFS,FlowequationIsFSEnum);
|
---|
30 | iomodel->Constant(&control_analysis,InversionIscontrolEnum);
|
---|
31 | iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum);
|
---|
32 | iomodel->Constant(&materials_type,MaterialsEnum);
|
---|
33 |
|
---|
34 | /*Now, is the flag macayaealHO on? otherwise, do nothing: */
|
---|
35 | if(!isSSA & !isL1L2 & !isHO & !isFS) return;
|
---|
36 |
|
---|
37 | /*Fetch data needed and allocate vectors: */
|
---|
38 | iomodel->FetchData(1,FlowequationElementEquationEnum);
|
---|
39 | finiteelement_list=xNewZeroInit<int>(iomodel->numberofelements);
|
---|
40 |
|
---|
41 |
|
---|
42 | /*Do we have coupling*/
|
---|
43 | if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)
|
---|
44 | iscoupling = true;
|
---|
45 | else
|
---|
46 | iscoupling = false;
|
---|
47 |
|
---|
48 | /*Get finite element type*/
|
---|
49 | if(!iscoupling){
|
---|
50 | if(isSSA) iomodel->Constant(&finiteelement,FlowequationFeSSAEnum);
|
---|
51 | else if(isL1L2) finiteelement = P1Enum;
|
---|
52 | else if(isHO) iomodel->Constant(&finiteelement,FlowequationFeHOEnum);
|
---|
53 | else if(isFS) iomodel->Constant(&finiteelement,FlowequationFeFSEnum);
|
---|
54 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
55 | finiteelement_list[i]=finiteelement;
|
---|
56 | }
|
---|
57 | }
|
---|
58 | else{
|
---|
59 | if(isFS){
|
---|
60 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
61 | approximation=reCast<int>(iomodel->Data(FlowequationElementEquationEnum)[i]);
|
---|
62 | if(approximation==FSApproximationEnum || approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){
|
---|
63 | finiteelement_list[i]=MINIcondensedEnum;
|
---|
64 | }
|
---|
65 | else{
|
---|
66 | finiteelement_list[i]=P1Enum;
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 | else{
|
---|
71 | finiteelement = P1Enum;
|
---|
72 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
73 | finiteelement_list[i]=finiteelement;
|
---|
74 | }
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | /*Update elements: */
|
---|
79 | int counter=0;
|
---|
80 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
81 | if(iomodel->my_elements[i]){
|
---|
82 | Element* element=(Element*)elements->GetObjectByOffset(counter);
|
---|
83 | element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement_list[i]);
|
---|
84 | counter++;
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | /*Create inputs: */
|
---|
89 | iomodel->FetchDataToInput(elements,ThicknessEnum);
|
---|
90 | iomodel->FetchDataToInput(elements,GeometryHydrostaticRatioEnum);
|
---|
91 | iomodel->FetchDataToInput(elements,SurfaceEnum);
|
---|
92 | iomodel->FetchDataToInput(elements,BedEnum);
|
---|
93 | iomodel->FetchDataToInput(elements,FrictionCoefficientEnum);
|
---|
94 | iomodel->FetchDataToInput(elements,FrictionPEnum);
|
---|
95 | iomodel->FetchDataToInput(elements,FrictionQEnum);
|
---|
96 | iomodel->FetchDataToInput(elements,MaskElementonfloatingiceEnum);
|
---|
97 | iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum);
|
---|
98 | iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum);
|
---|
99 | iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum);
|
---|
100 | iomodel->FetchDataToInput(elements,VxEnum);
|
---|
101 | iomodel->FetchDataToInput(elements,VyEnum);
|
---|
102 | iomodel->FetchDataToInput(elements,LoadingforceXEnum);
|
---|
103 | iomodel->FetchDataToInput(elements,LoadingforceYEnum);
|
---|
104 | if(materials_type==MatdamageiceEnum){
|
---|
105 | iomodel->FetchDataToInput(elements,MaterialsRheologyZEnum);
|
---|
106 | }
|
---|
107 | if(iomodel->dim==3){
|
---|
108 | iomodel->FetchDataToInput(elements,MeshElementonbedEnum);
|
---|
109 | iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
|
---|
110 | iomodel->FetchDataToInput(elements,VzEnum);
|
---|
111 | iomodel->FetchDataToInput(elements,SurfaceforcingsMassBalanceEnum);
|
---|
112 | iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
|
---|
113 | iomodel->FetchDataToInput(elements,FlowequationBorderFSEnum);
|
---|
114 | iomodel->FetchDataToInput(elements,LoadingforceZEnum);
|
---|
115 | }
|
---|
116 |
|
---|
117 | if(control_analysis){
|
---|
118 | iomodel->FetchDataToInput(elements,InversionVxObsEnum);
|
---|
119 | iomodel->FetchDataToInput(elements,InversionVyObsEnum);
|
---|
120 | }
|
---|
121 |
|
---|
122 | /*Post-process: */
|
---|
123 | elements->InputDuplicate(VxEnum,VxPicardEnum);
|
---|
124 | elements->InputDuplicate(VxEnum,InversionVxObsEnum);
|
---|
125 | if(dakota_analysis)elements->InputDuplicate(VxEnum,QmuVxEnum);
|
---|
126 |
|
---|
127 | #ifdef _HAVE_ANDROID_
|
---|
128 | elements->InputDuplicate(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum);
|
---|
129 | #endif
|
---|
130 |
|
---|
131 | elements->InputDuplicate(VyEnum,VyPicardEnum);
|
---|
132 | elements->InputDuplicate(VyEnum,InversionVyObsEnum);
|
---|
133 | if(dakota_analysis)elements->InputDuplicate(VyEnum,QmuVyEnum);
|
---|
134 |
|
---|
135 | if(iomodel->dim==3){
|
---|
136 | elements->InputDuplicate(VzEnum,VzPicardEnum);
|
---|
137 | elements->InputDuplicate(VzEnum,InversionVzObsEnum);
|
---|
138 | if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum);
|
---|
139 | }
|
---|
140 |
|
---|
141 | /*Free data: */
|
---|
142 | iomodel->DeleteData(1,FlowequationElementEquationEnum);
|
---|
143 | xDelete<int>(finiteelement_list);
|
---|
144 | }
|
---|