[16534] | 1 | #include "./HydrologyShreveAnalysis.h"
|
---|
| 2 | #include "../toolkits/toolkits.h"
|
---|
| 3 | #include "../classes/classes.h"
|
---|
| 4 | #include "../shared/shared.h"
|
---|
| 5 | #include "../modules/modules.h"
|
---|
| 6 |
|
---|
| 7 | /*Model processing*/
|
---|
[16539] | 8 | int HydrologyShreveAnalysis::DofsPerNode(int** doflist,int meshtype,int approximation){/*{{{*/
|
---|
[16534] | 9 | return 1;
|
---|
| 10 | }/*}}}*/
|
---|
[16542] | 11 | void HydrologyShreveAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
|
---|
[16539] | 12 |
|
---|
| 13 | /*retrieve some parameters: */
|
---|
[16542] | 14 | int hydrology_model;
|
---|
[16539] | 15 | iomodel->Constant(&hydrology_model,HydrologyModelEnum);
|
---|
| 16 |
|
---|
| 17 | /*Now, do we really want Shreve?*/
|
---|
[16542] | 18 | if(hydrology_model!=HydrologyshreveEnum) return;
|
---|
[16539] | 19 |
|
---|
| 20 | parameters->AddObject(new IntParam(HydrologyModelEnum,hydrology_model));
|
---|
| 21 | parameters->AddObject(iomodel->CopyConstantObject(HydrologyshreveStabilizationEnum));
|
---|
| 22 |
|
---|
| 23 | }/*}}}*/
|
---|
| 24 | void HydrologyShreveAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
|
---|
| 25 |
|
---|
| 26 | /*Fetch data needed: */
|
---|
| 27 | int hydrology_model;
|
---|
| 28 | iomodel->Constant(&hydrology_model,HydrologyModelEnum);
|
---|
| 29 |
|
---|
| 30 | /*Now, do we really want Shreve?*/
|
---|
| 31 | if(hydrology_model!=HydrologyshreveEnum) return;
|
---|
| 32 |
|
---|
| 33 | /*Update elements: */
|
---|
| 34 | int counter=0;
|
---|
| 35 | for(int i=0;i<iomodel->numberofelements;i++){
|
---|
| 36 | if(iomodel->my_elements[i]){
|
---|
| 37 | Element* element=(Element*)elements->GetObjectByOffset(counter);
|
---|
| 38 | element->Update(i,iomodel,analysis_counter,analysis_type,P1Enum);
|
---|
| 39 | counter++;
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | iomodel->FetchDataToInput(elements,ThicknessEnum);
|
---|
| 44 | iomodel->FetchDataToInput(elements,SurfaceEnum);
|
---|
| 45 | iomodel->FetchDataToInput(elements,BedEnum);
|
---|
| 46 | iomodel->FetchDataToInput(elements,MeshElementonbedEnum);
|
---|
| 47 | iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
|
---|
| 48 | iomodel->FetchDataToInput(elements,MaskIceLevelsetEnum);
|
---|
| 49 | iomodel->FetchDataToInput(elements,MaskGroundediceLevelsetEnum);
|
---|
| 50 | iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
|
---|
| 51 | iomodel->FetchDataToInput(elements,WatercolumnEnum);
|
---|
| 52 |
|
---|
| 53 | elements->InputDuplicate(WatercolumnEnum,WaterColumnOldEnum);
|
---|
| 54 | }/*}}}*/
|
---|
[16542] | 55 | void HydrologyShreveAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/
|
---|
[16539] | 56 |
|
---|
| 57 | /*Fetch parameters: */
|
---|
| 58 | int hydrology_model;
|
---|
| 59 | iomodel->Constant(&hydrology_model,HydrologyModelEnum);
|
---|
| 60 |
|
---|
| 61 | /*Now, do we really want Shreve?*/
|
---|
| 62 | if(hydrology_model!=HydrologyshreveEnum) return;
|
---|
| 63 |
|
---|
| 64 | if(iomodel->meshtype==Mesh3DEnum) iomodel->FetchData(2,MeshVertexonbedEnum,MeshVertexonsurfaceEnum);
|
---|
[16542] | 65 | ::CreateNodes(nodes,iomodel,HydrologyShreveAnalysisEnum,P1Enum);
|
---|
[16539] | 66 | iomodel->DeleteData(2,MeshVertexonbedEnum,MeshVertexonsurfaceEnum);
|
---|
| 67 | }/*}}}*/
|
---|
[16542] | 68 | void HydrologyShreveAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/
|
---|
[16539] | 69 |
|
---|
| 70 | /*retrieve some parameters: */
|
---|
| 71 | int hydrology_model;
|
---|
| 72 | iomodel->Constant(&hydrology_model,HydrologyModelEnum);
|
---|
| 73 |
|
---|
| 74 | if(hydrology_model!=HydrologyshreveEnum) return;
|
---|
| 75 |
|
---|
| 76 | IoModelToConstraintsx(constraints,iomodel,HydrologyshreveSpcwatercolumnEnum,HydrologyShreveAnalysisEnum,P1Enum);
|
---|
| 77 |
|
---|
| 78 | }/*}}}*/
|
---|
[16542] | 79 | void HydrologyShreveAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
|
---|
[16539] | 80 | /*No loads*/
|
---|
| 81 | }/*}}}*/
|
---|
[16675] | 82 |
|
---|
[16782] | 83 | /*Finite Element Analysis*/
|
---|
| 84 | ElementMatrix* HydrologyShreveAnalysis::CreateKMatrix(Element* element){/*{{{*/
|
---|
| 85 | _error_("not implemented yet");
|
---|
| 86 | }/*}}}*/
|
---|
| 87 | ElementVector* HydrologyShreveAnalysis::CreatePVector(Element* element){/*{{{*/
|
---|
| 88 | _error_("not implemented yet");
|
---|
| 89 | }/*}}}*/
|
---|
[16675] | 90 | void HydrologyShreveAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
|
---|
| 91 | element->GetSolutionFromInputsOneDof(solution,WatercolumnEnum);
|
---|
| 92 | }/*}}}*/
|
---|
[16684] | 93 | void HydrologyShreveAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
|
---|
[16761] | 94 |
|
---|
| 95 | /*Intermediary*/
|
---|
| 96 | int* doflist = NULL;
|
---|
| 97 |
|
---|
| 98 | /*Fetch number of nodes for this finite element*/
|
---|
| 99 | int numnodes = element->GetNumberOfNodes();
|
---|
| 100 |
|
---|
| 101 | /*Fetch dof list and allocate solution vector*/
|
---|
| 102 | element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
|
---|
| 103 | IssmDouble* values = xNew<IssmDouble>(numnodes);
|
---|
| 104 |
|
---|
| 105 | /*Use the dof list to index into the solution vector: */
|
---|
| 106 | for(int i=0;i<numnodes;i++){
|
---|
| 107 | values[i]=solution[doflist[i]];
|
---|
| 108 | if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector");
|
---|
| 109 | if (values[i]<10e-10) values[i]=10e-10; //correcting the water column to positive values
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | /*Add input to the element: */
|
---|
| 113 | element->AddInput(WatercolumnEnum,values,P1Enum);
|
---|
| 114 |
|
---|
| 115 | /*Free ressources:*/
|
---|
| 116 | xDelete<IssmDouble>(values);
|
---|
| 117 | xDelete<int>(doflist);
|
---|
[16684] | 118 | }/*}}}*/
|
---|