| 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*/
|
|---|
| 8 | int HydrologyShreveAnalysis::DofsPerNode(int** doflist,int meshtype,int approximation){/*{{{*/
|
|---|
| 9 | return 1;
|
|---|
| 10 | }/*}}}*/
|
|---|
| 11 | void HydrologyShreveAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
|
|---|
| 12 |
|
|---|
| 13 | /*retrieve some parameters: */
|
|---|
| 14 | int hydrology_model;
|
|---|
| 15 | iomodel->Constant(&hydrology_model,HydrologyModelEnum);
|
|---|
| 16 |
|
|---|
| 17 | /*Now, do we really want Shreve?*/
|
|---|
| 18 | if(hydrology_model!=HydrologyshreveEnum) return;
|
|---|
| 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 | }/*}}}*/
|
|---|
| 55 | void HydrologyShreveAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/
|
|---|
| 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);
|
|---|
| 65 | ::CreateNodes(nodes,iomodel,HydrologyShreveAnalysisEnum,P1Enum);
|
|---|
| 66 | iomodel->DeleteData(2,MeshVertexonbedEnum,MeshVertexonsurfaceEnum);
|
|---|
| 67 | }/*}}}*/
|
|---|
| 68 | void HydrologyShreveAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/
|
|---|
| 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 | }/*}}}*/
|
|---|
| 79 | void HydrologyShreveAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
|
|---|
| 80 | /*No loads*/
|
|---|
| 81 | }/*}}}*/
|
|---|
| 82 |
|
|---|
| 83 | /*Numerics*/
|
|---|
| 84 | void HydrologyShreveAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
|
|---|
| 85 | element->GetSolutionFromInputsOneDof(solution,WatercolumnEnum);
|
|---|
| 86 | }/*}}}*/
|
|---|
| 87 | void HydrologyShreveAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
|
|---|
| 88 |
|
|---|
| 89 | /*Intermediary*/
|
|---|
| 90 | int* doflist = NULL;
|
|---|
| 91 |
|
|---|
| 92 | /*Fetch number of nodes for this finite element*/
|
|---|
| 93 | int numnodes = element->GetNumberOfNodes();
|
|---|
| 94 |
|
|---|
| 95 | /*Fetch dof list and allocate solution vector*/
|
|---|
| 96 | element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
|
|---|
| 97 | IssmDouble* values = xNew<IssmDouble>(numnodes);
|
|---|
| 98 |
|
|---|
| 99 | /*Use the dof list to index into the solution vector: */
|
|---|
| 100 | for(int i=0;i<numnodes;i++){
|
|---|
| 101 | values[i]=solution[doflist[i]];
|
|---|
| 102 | if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector");
|
|---|
| 103 | if (values[i]<10e-10) values[i]=10e-10; //correcting the water column to positive values
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | /*Add input to the element: */
|
|---|
| 107 | element->AddInput(WatercolumnEnum,values,P1Enum);
|
|---|
| 108 |
|
|---|
| 109 | /*Free ressources:*/
|
|---|
| 110 | xDelete<IssmDouble>(values);
|
|---|
| 111 | xDelete<int>(doflist);
|
|---|
| 112 | }/*}}}*/
|
|---|