| 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 | /*Do we have coupling*/
|
|---|
| 42 | if( (isSSA?1.:0.) + (isL1L2?1.:0.) + (isHO?1.:0.) + (isFS?1.:0.) >1.)
|
|---|
| 43 | iscoupling = true;
|
|---|
| 44 | else
|
|---|
| 45 | iscoupling = false;
|
|---|
| 46 |
|
|---|
| 47 | /*Get finite element type*/
|
|---|
| 48 | if(!iscoupling){
|
|---|
| 49 | if(isSSA) iomodel->Constant(&finiteelement,FlowequationFeSSAEnum);
|
|---|
| 50 | else if(isL1L2) finiteelement = P1Enum;
|
|---|
| 51 | else if(isHO) iomodel->Constant(&finiteelement,FlowequationFeHOEnum);
|
|---|
| 52 | else if(isFS) iomodel->Constant(&finiteelement,FlowequationFeFSEnum);
|
|---|
| 53 | for(int i=0;i<iomodel->numberofelements;i++){
|
|---|
| 54 | finiteelement_list[i]=finiteelement;
|
|---|
| 55 | }
|
|---|
| 56 | }
|
|---|
| 57 | else{
|
|---|
| 58 | if(isFS){
|
|---|
| 59 | for(int i=0;i<iomodel->numberofelements;i++){
|
|---|
| 60 | approximation=reCast<int>(iomodel->Data(FlowequationElementEquationEnum)[i]);
|
|---|
| 61 | if(approximation==FSApproximationEnum || approximation==HOFSApproximationEnum || approximation==SSAFSApproximationEnum){
|
|---|
| 62 | finiteelement_list[i]=MINIcondensedEnum;
|
|---|
| 63 | }
|
|---|
| 64 | else{
|
|---|
| 65 | finiteelement_list[i]=P1Enum;
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | else{
|
|---|
| 70 | finiteelement = P1Enum;
|
|---|
| 71 | for(int i=0;i<iomodel->numberofelements;i++){
|
|---|
| 72 | finiteelement_list[i]=finiteelement;
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | /*Update elements: */
|
|---|
| 78 | int counter=0;
|
|---|
| 79 | for(int i=0;i<iomodel->numberofelements;i++){
|
|---|
| 80 | if(iomodel->my_elements[i]){
|
|---|
| 81 | Element* element=(Element*)elements->GetObjectByOffset(counter);
|
|---|
| 82 | element->Update(i,iomodel,analysis_counter,analysis_type,finiteelement_list[i]);
|
|---|
| 83 | counter++;
|
|---|
| 84 | }
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /*Create inputs: */
|
|---|
| 88 | iomodel->FetchDataToInput(elements,ThicknessEnum);
|
|---|
| 89 | iomodel->FetchDataToInput(elements,SurfaceEnum);
|
|---|
| 90 | iomodel->FetchDataToInput(elements,BedEnum);
|
|---|
| 91 | iomodel->FetchDataToInput(elements,FrictionCoefficientEnum);
|
|---|
| 92 | iomodel->FetchDataToInput(elements,FrictionPEnum);
|
|---|
| 93 | iomodel->FetchDataToInput(elements,FrictionQEnum);
|
|---|
| 94 | iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum);
|
|---|
| 95 | iomodel->FetchDataToInput(elements,MaskGroundediceLevelsetEnum);
|
|---|
| 96 | iomodel->FetchDataToInput(elements,MaterialsRheologyBEnum);
|
|---|
| 97 | iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum);
|
|---|
| 98 | iomodel->FetchDataToInput(elements,VxEnum,0.);
|
|---|
| 99 | if(dakota_analysis)elements->InputDuplicate(VxEnum,QmuVxEnum);
|
|---|
| 100 | iomodel->FetchDataToInput(elements,VyEnum,0.);
|
|---|
| 101 | if(dakota_analysis)elements->InputDuplicate(VyEnum,QmuVyEnum);
|
|---|
| 102 | iomodel->FetchDataToInput(elements,LoadingforceXEnum);
|
|---|
| 103 | iomodel->FetchDataToInput(elements,LoadingforceYEnum);
|
|---|
| 104 | iomodel->FetchDataToInput(elements,DamageDEnum);
|
|---|
| 105 |
|
|---|
| 106 | if(iomodel->meshtype==Mesh3DEnum){
|
|---|
| 107 | iomodel->FetchDataToInput(elements,MeshElementonbedEnum);
|
|---|
| 108 | iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
|
|---|
| 109 | iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
|
|---|
| 110 | iomodel->FetchDataToInput(elements,FlowequationBorderFSEnum);
|
|---|
| 111 | iomodel->FetchDataToInput(elements,LoadingforceZEnum);
|
|---|
| 112 | iomodel->FetchDataToInput(elements,VzEnum,0.);
|
|---|
| 113 | if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum);
|
|---|
| 114 | }
|
|---|
| 115 | if(isFS){
|
|---|
| 116 | iomodel->FetchDataToInput(elements,MeshVertexonbedEnum);
|
|---|
| 117 | iomodel->FetchDataToInput(elements,PressureEnum,0.);
|
|---|
| 118 | if(dakota_analysis)elements->InputDuplicate(PressureEnum,QmuPressureEnum);
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | #ifdef _HAVE_ANDROID_
|
|---|
| 122 | elements->InputDuplicate(FrictionCoefficientEnum,AndroidFrictionCoefficientEnum);
|
|---|
| 123 | #endif
|
|---|
| 124 |
|
|---|
| 125 | /*Free data: */
|
|---|
| 126 | iomodel->DeleteData(1,FlowequationElementEquationEnum);
|
|---|
| 127 | xDelete<int>(finiteelement_list);
|
|---|
| 128 | }
|
|---|