Ice Sheet System Model  4.18
Code documentation
L2ProjectionEPLAnalysis.cpp
Go to the documentation of this file.
2 #include "../toolkits/toolkits.h"
3 #include "../classes/classes.h"
4 #include "../shared/shared.h"
5 #include "../modules/modules.h"
6 
7 /*Model processing*/
9 
10  /*No constraints*/
11 }/*}}}*/
12 void L2ProjectionEPLAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/
13 
14  /*No loads*/
15 }/*}}}*/
16 void L2ProjectionEPLAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel,bool isamr){/*{{{*/
17  /*Now, do we really want DC?*/
18  int hydrology_model;
19  iomodel->FindConstant(&hydrology_model,"md.hydrology.model");
20  if(hydrology_model!=HydrologydcEnum) return;
21 
22  /*Do we want an efficient layer*/
23  bool isefficientlayer;
24  iomodel->FindConstant(&isefficientlayer,"md.hydrology.isefficientlayer");
25  if(!isefficientlayer) return;
26 
27  if(iomodel->domaintype==Domain3DEnum){
28  iomodel->FetchData(1,"md.mesh.vertexonbase");
29  }
30  else if(iomodel->domaintype==Domain2DverticalEnum){
31  iomodel->FetchData(1,"md.mesh.vertexonbase");
32  }
34  iomodel->DeleteData(1,"md.mesh.vertexonbase");
35 }/*}}}*/
36 int L2ProjectionEPLAnalysis::DofsPerNode(int** doflist,int domaintype,int approximation){/*{{{*/
37  return 1;
38 }/*}}}*/
39 void L2ProjectionEPLAnalysis::UpdateElements(Elements* elements,Inputs2* inputs2,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/
40 
41  bool isefficientlayer;
42  int hydrology_model;
43 
44  /*Now, do we really want DC?*/
45  iomodel->FindConstant(&hydrology_model,"md.hydrology.model");
46  if(hydrology_model!=HydrologydcEnum) return;
47 
48  /*Do we want an efficient layer*/
49  iomodel->FindConstant(&isefficientlayer,"md.hydrology.isefficientlayer");
50  if(!isefficientlayer) return;
51 
52  /*Update elements: */
53  int counter=0;
54  for(int i=0;i<iomodel->numberofelements;i++){
55  if(iomodel->my_elements[i]){
56  Element* element=(Element*)elements->GetObjectByOffset(counter);
57  element->Update(inputs2,i,iomodel,analysis_counter,analysis_type,P1Enum);
58  counter++;
59  }
60  }
61 
62  iomodel->FetchDataToInput(inputs2,elements,"md.initialization.epl_head",EplHeadSubstepEnum);
63  iomodel->FetchDataToInput(inputs2,elements,"md.mask.ice_levelset",MaskIceLevelsetEnum);
64  if(iomodel->domaintype!=Domain2DhorizontalEnum){
65  iomodel->FetchDataToInput(inputs2,elements,"md.mesh.vertexonbase",MeshVertexonbaseEnum);
66  iomodel->FetchDataToInput(inputs2,elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum);
67  }
68 }/*}}}*/
69 void L2ProjectionEPLAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/
70 }/*}}}*/
71 
72 /*Finite Element Analysis*/
74  _error_("not implemented");
75 }/*}}}*/
77  /*Default, return NULL*/
78  return NULL;
79 }/*}}}*/
81 _error_("Not implemented");
82 }/*}}}*/
84 
85  /*Intermediaries*/
86  int domaintype;
87  bool active_element;
88  Element* basalelement;
89 
90  /*Get basal element*/
91  element->FindParam(&domaintype,DomainTypeEnum);
92  switch(domaintype){
94  basalelement = element;
95  break;
97  if(!element->IsOnBase()) return NULL;
98  basalelement = element->SpawnBasalElement();
99  break;
100  case Domain3DEnum:
101  if(!element->IsOnBase()) return NULL;
102  basalelement = element->SpawnBasalElement();
103  break;
104  default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet");
105  }
106 
107  basalelement->GetInput2Value(&active_element,HydrologydcMaskEplactiveEltEnum);
108 
109  /* Check that all nodes are active, else return empty matrix */
110  if(!active_element){
111  if(domaintype!=Domain2DhorizontalEnum){
112  basalelement->DeleteMaterials();
113  delete basalelement;
114  }
115  return NULL;
116  }
117 
118  /*Intermediaries */
119  IssmDouble D,Jdet;
120  IssmDouble *xyz_list = NULL;
121 
122  /*Fetch number of nodes and dof for this finite element*/
123  int numnodes = basalelement->GetNumberOfNodes();
124 
125  /*Initialize Element vector*/
127  IssmDouble* basis = xNew<IssmDouble>(numnodes);
128 
129  /*Retrieve all inputs and parameters*/
130  basalelement->GetVerticesCoordinates(&xyz_list);
131 
132  /* Start looping on the number of gaussian points: */
133  Gauss* gauss=basalelement->NewGauss(2);
134  for(int ig=gauss->begin();ig<gauss->end();ig++){
135  gauss->GaussPoint(ig);
136 
137  basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss);
138  basalelement->NodalFunctions(basis,gauss);
139  D=gauss->weight*Jdet;
140 
141  TripleMultiply(basis,1,numnodes,1,
142  &D,1,1,0,
143  basis,1,numnodes,0,
144  &Ke->values[0],1);
145  }
146 
147  /*Clean up and return*/
148  xDelete<IssmDouble>(xyz_list);
149  xDelete<IssmDouble>(basis);
150  delete gauss;
151  if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;};
152  return Ke;
153 }/*}}}*/
155 
156  /*Intermediaries*/
157  int domaintype;
158  bool active_element;
159  Element* basalelement;
160 
161  /*Get basal element*/
162  element->FindParam(&domaintype,DomainTypeEnum);
163  switch(domaintype){
165  basalelement = element;
166  break;
167  case Domain3DEnum:
168  if(!element->IsOnBase()) return NULL;
169  basalelement = element->SpawnBasalElement();
170  break;
171  default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet");
172  }
173 
174  basalelement->GetInput2Value(&active_element,HydrologydcMaskEplactiveEltEnum);
175 
176  /*Check that all nodes are active, else return empty matrix*/
177  if(!active_element) {
178  if(domaintype!=Domain2DhorizontalEnum){
179  basalelement->DeleteMaterials();
180  delete basalelement;
181  }
182  return NULL;
183  }
184 
185  /*Intermediaries */
186  int input_enum,index;
187  IssmDouble Jdet,slopes[2];
188  Input2 *input = NULL;
189  IssmDouble *xyz_list = NULL;
190 
191  /*Fetch number of nodes and dof for this finite element*/
192  int numnodes = basalelement->GetNumberOfNodes();
193 
194  /*Initialize Element vector*/
195  ElementVector* pe = basalelement->NewElementVector();
196  IssmDouble* basis = xNew<IssmDouble>(numnodes);
197 
198  /*Retrieve all inputs and parameters*/
199  basalelement->GetVerticesCoordinates(&xyz_list);
200  basalelement->FindParam(&input_enum,InputToL2ProjectEnum);
201  switch(input_enum){
202  case EplHeadSlopeXEnum: input = basalelement->GetInput2(EplHeadSubstepEnum); index = 0; _assert_(input); break;
203  case EplHeadSlopeYEnum: input = basalelement->GetInput2(EplHeadSubstepEnum); index = 1; _assert_(input); break;
204  default: _error_("not implemented");
205  }
206 
207  /* Start looping on the number of gaussian points: */
208  Gauss* gauss=basalelement->NewGauss(2);
209  for(int ig=gauss->begin();ig<gauss->end();ig++){
210  gauss->GaussPoint(ig);
211 
212  basalelement->JacobianDeterminant(&Jdet,xyz_list,gauss);
213  basalelement->NodalFunctions(basis,gauss);
214 
215  input->GetInputDerivativeValue(&slopes[0],xyz_list,gauss);
216  for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*slopes[index]*basis[i];
217  }
218 
219  /*Clean up and return*/
220  xDelete<IssmDouble>(xyz_list);
221  xDelete<IssmDouble>(basis);
222  delete gauss;
223  if(domaintype!=Domain2DhorizontalEnum){basalelement->DeleteMaterials(); delete basalelement;};
224  return pe;
225 }/*}}}*/
227  _error_("not implemented yet");
228 }/*}}}*/
229 void L2ProjectionEPLAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/
230  _error_("Not implemented yet");
231 }/*}}}*/
233  int inputenum,domaintype;
234 
235  element->FindParam(&inputenum,InputToL2ProjectEnum);
236  element->FindParam(&domaintype,DomainTypeEnum);
237  switch(domaintype){
239  element->InputUpdateFromSolutionOneDof(solution,inputenum);
240  break;
242  element->InputUpdateFromSolutionOneDof(solution,inputenum);
243  break;
244  case Domain3DEnum:
245  element->InputUpdateFromSolutionOneDofCollapsed(solution,inputenum);
246  break;
247  default: _error_("mesh "<<EnumToStringx(domaintype)<<" not supported yet");
248  }
249 }/*}}}*/
251  /*Default, do nothing*/
252  return;
253 }/*}}}*/
EplHeadSlopeXEnum
@ EplHeadSlopeXEnum
Definition: EnumDefinitions.h:555
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
IssmDouble
double IssmDouble
Definition: types.h:37
Element::IsOnBase
bool IsOnBase()
Definition: Element.cpp:1984
Nodes
Declaration of Nodes class.
Definition: Nodes.h:19
Element::GetNumberOfNodes
virtual int GetNumberOfNodes(void)=0
Element::FindParam
void FindParam(bool *pvalue, int paramenum)
Definition: Element.cpp:933
HydrologydcEnum
@ HydrologydcEnum
Definition: EnumDefinitions.h:1106
L2ProjectionEPLAnalysis::InputUpdateFromSolution
void InputUpdateFromSolution(IssmDouble *solution, Element *element)
Definition: L2ProjectionEPLAnalysis.cpp:232
Parameters
Declaration of Parameters class.
Definition: Parameters.h:18
MaskIceLevelsetEnum
@ MaskIceLevelsetEnum
Definition: EnumDefinitions.h:641
L2ProjectionEPLAnalysis::UpdateConstraints
void UpdateConstraints(FemModel *femmodel)
Definition: L2ProjectionEPLAnalysis.cpp:250
L2ProjectionEPLAnalysis.h
: header file for generic external result object
Constraints
Declaration of Constraints class.
Definition: Constraints.h:13
Element::SpawnBasalElement
virtual Element * SpawnBasalElement(void)=0
MeshVertexonbaseEnum
@ MeshVertexonbaseEnum
Definition: EnumDefinitions.h:653
Elements
Declaration of Elements class.
Definition: Elements.h:17
TripleMultiply
int TripleMultiply(IssmDouble *a, int nrowa, int ncola, int itrna, IssmDouble *b, int nrowb, int ncolb, int itrnb, IssmDouble *c, int nrowc, int ncolc, int itrnc, IssmDouble *d, int iaddd)
Definition: MatrixUtils.cpp:20
ElementVector::values
IssmDouble * values
Definition: ElementVector.h:24
IoModel::my_elements
bool * my_elements
Definition: IoModel.h:66
Input2::GetInputDerivativeValue
virtual void GetInputDerivativeValue(IssmDouble *derivativevalues, IssmDouble *xyz_list, Gauss *gauss)
Definition: Input2.h:37
Element::GetInput2
virtual Input2 * GetInput2(int inputenum)=0
Element::DeleteMaterials
void DeleteMaterials(void)
Definition: Element.cpp:429
L2ProjectionEPLAnalysis::CreateDVector
ElementVector * CreateDVector(Element *element)
Definition: L2ProjectionEPLAnalysis.cpp:76
Element
Definition: Element.h:41
Element::NodalFunctions
virtual void NodalFunctions(IssmDouble *basis, Gauss *gauss)=0
L2ProjectionEPLAnalysis::UpdateElements
void UpdateElements(Elements *elements, Inputs2 *inputs2, IoModel *iomodel, int analysis_counter, int analysis_type)
Definition: L2ProjectionEPLAnalysis.cpp:39
P1Enum
@ P1Enum
Definition: EnumDefinitions.h:662
Domain2DhorizontalEnum
@ Domain2DhorizontalEnum
Definition: EnumDefinitions.h:534
Element::NewElementVector
ElementVector * NewElementVector(int approximation_enum=NoneApproximationEnum)
Definition: Element.cpp:2505
IoModel::DeleteData
void DeleteData(int num,...)
Definition: IoModel.cpp:500
IoModel::numberofelements
int numberofelements
Definition: IoModel.h:96
NoneApproximationEnum
@ NoneApproximationEnum
Definition: EnumDefinitions.h:1201
L2ProjectionEPLAnalysis::DofsPerNode
int DofsPerNode(int **doflist, int domaintype, int approximation)
Definition: L2ProjectionEPLAnalysis.cpp:36
DomainTypeEnum
@ DomainTypeEnum
Definition: EnumDefinitions.h:124
Element::NewGauss
virtual Gauss * NewGauss(void)=0
Element::InputUpdateFromSolutionOneDof
virtual void InputUpdateFromSolutionOneDof(IssmDouble *solution, int inputenum)=0
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
L2ProjectionEPLAnalysis::GetSolutionFromInputs
void GetSolutionFromInputs(Vector< IssmDouble > *solution, Element *element)
Definition: L2ProjectionEPLAnalysis.cpp:226
IoModel::FindConstant
void FindConstant(bool *pvalue, const char *constant_name)
Definition: IoModel.cpp:2362
Element::GetInput2Value
void GetInput2Value(bool *pvalue, int enum_type)
Definition: Element.cpp:1185
Element::GetVerticesCoordinates
void GetVerticesCoordinates(IssmDouble **xyz_list)
Definition: Element.cpp:1446
IoModel::FetchData
void FetchData(bool *pboolean, const char *data_name)
Definition: IoModel.cpp:933
Inputs2
Declaration of Inputs class.
Definition: Inputs2.h:23
Domain3DEnum
@ Domain3DEnum
Definition: EnumDefinitions.h:536
Input2
Definition: Input2.h:18
FemModel
Definition: FemModel.h:31
Loads
Declaration of Loads class.
Definition: Loads.h:16
L2ProjectionEPLAnalysisEnum
@ L2ProjectionEPLAnalysisEnum
Definition: EnumDefinitions.h:1137
L2ProjectionEPLAnalysis::CreateLoads
void CreateLoads(Loads *loads, IoModel *iomodel)
Definition: L2ProjectionEPLAnalysis.cpp:12
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
L2ProjectionEPLAnalysis::CreateJacobianMatrix
ElementMatrix * CreateJacobianMatrix(Element *element)
Definition: L2ProjectionEPLAnalysis.cpp:80
Gauss::begin
virtual int begin(void)=0
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
MeshVertexonsurfaceEnum
@ MeshVertexonsurfaceEnum
Definition: EnumDefinitions.h:655
L2ProjectionEPLAnalysis::Core
void Core(FemModel *femmodel)
Definition: L2ProjectionEPLAnalysis.cpp:73
Element::JacobianDeterminant
virtual void JacobianDeterminant(IssmDouble *Jdet, IssmDouble *xyz_list, Gauss *gauss)=0
Gauss::GaussPoint
virtual void GaussPoint(int ig)=0
Element::Update
virtual void Update(Inputs2 *inputs2, int index, IoModel *iomodel, int analysis_counter, int analysis_type, int finite_element)=0
L2ProjectionEPLAnalysis::CreateNodes
void CreateNodes(Nodes *nodes, IoModel *iomodel, bool isamr=false)
Definition: L2ProjectionEPLAnalysis.cpp:16
IoModel::FetchDataToInput
void FetchDataToInput(Inputs2 *inputs2, Elements *elements, const char *vector_name, int input_enum)
Definition: IoModel.cpp:1651
InputToL2ProjectEnum
@ InputToL2ProjectEnum
Definition: EnumDefinitions.h:206
L2ProjectionEPLAnalysis::CreatePVector
ElementVector * CreatePVector(Element *element)
Definition: L2ProjectionEPLAnalysis.cpp:154
L2ProjectionEPLAnalysis::CreateKMatrix
ElementMatrix * CreateKMatrix(Element *element)
Definition: L2ProjectionEPLAnalysis.cpp:83
L2ProjectionEPLAnalysis::GradientJ
void GradientJ(Vector< IssmDouble > *gradient, Element *element, int control_type, int control_index)
Definition: L2ProjectionEPLAnalysis.cpp:229
ElementVector
Definition: ElementVector.h:20
Gauss::weight
IssmDouble weight
Definition: Gauss.h:11
IoModel
Definition: IoModel.h:48
EplHeadSubstepEnum
@ EplHeadSubstepEnum
Definition: EnumDefinitions.h:557
IoModel::domaintype
int domaintype
Definition: IoModel.h:78
EplHeadSlopeYEnum
@ EplHeadSlopeYEnum
Definition: EnumDefinitions.h:556
L2ProjectionEPLAnalysis::CreateConstraints
void CreateConstraints(Constraints *constraints, IoModel *iomodel)
Definition: L2ProjectionEPLAnalysis.cpp:8
Domain2DverticalEnum
@ Domain2DverticalEnum
Definition: EnumDefinitions.h:535
ElementMatrix
Definition: ElementMatrix.h:19
L2ProjectionEPLAnalysis::UpdateParameters
void UpdateParameters(Parameters *parameters, IoModel *iomodel, int solution_enum, int analysis_enum)
Definition: L2ProjectionEPLAnalysis.cpp:69
Vector< IssmDouble >
Element::InputUpdateFromSolutionOneDofCollapsed
virtual void InputUpdateFromSolutionOneDofCollapsed(IssmDouble *solution, int inputenum)=0
HydrologydcMaskEplactiveEltEnum
@ HydrologydcMaskEplactiveEltEnum
Definition: EnumDefinitions.h:607
Gauss
Definition: Gauss.h:8
ElementMatrix::values
IssmDouble * values
Definition: ElementMatrix.h:26
Element::NewElementMatrix
ElementMatrix * NewElementMatrix(int approximation_enum=NoneApproximationEnum)
Definition: Element.cpp:2497
femmodel
FemModel * femmodel
Definition: esmfbinders.cpp:16