Ice Sheet System Model  4.18
Code documentation
Functions
GroundinglineMigrationx.cpp File Reference
#include "../../shared/shared.h"
#include "../../toolkits/toolkits.h"
#include "../../classes/classes.h"
#include "./GroundinglineMigrationx.h"

Go to the source code of this file.

Functions

void GroundinglineMigrationx (Elements *elements, Nodes *nodes, Vertices *vertices, Loads *loads, Materials *materials, Parameters *parameters)
 
IssmDoubleContactFSLevelset (Elements *elements, Vertices *vertices)
 
IssmDoublePotentialUngrounding (Elements *elements, Vertices *vertices, Parameters *parameters)
 
IssmDoublePropagateFloatingiceToGroundedNeighbors (Elements *elements, Nodes *nodes, Vertices *vertices, Parameters *parameters, IssmDouble *vertices_potentially_ungrounding)
 

Function Documentation

◆ GroundinglineMigrationx()

void GroundinglineMigrationx ( Elements elements,
Nodes nodes,
Vertices vertices,
Loads loads,
Materials materials,
Parameters parameters 
)

Definition at line 10 of file GroundinglineMigrationx.cpp.

10  {
11 
12  int migration_style,analysis_type;
13  IssmDouble *vertices_potentially_ungrounding = NULL;
14  IssmDouble *phi_ungrounding = NULL;
15  Element *element = NULL;
16 
17  /*retrieve parameters: */
18  parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
19  parameters->FindParam(&analysis_type,AnalysisTypeEnum);
20 
21  if(migration_style==NoneEnum) return;
22 
23  if(VerboseModule()) _printf0_(" Migrating grounding line\n");
24 
25  /*Set toolkit to default*/
27 
28  switch(migration_style){
29  case SoftMigrationEnum:
30  /*Create flag for grounded vertices above the hydrostatic equilibrium: */
31  vertices_potentially_ungrounding=PotentialUngrounding(elements,vertices,parameters);
32  /*propagate ice shelf into connex areas of the ice sheet that potentially want to unground: */
33  phi_ungrounding=PropagateFloatingiceToGroundedNeighbors(elements,nodes,vertices,parameters,vertices_potentially_ungrounding);
34  break;
35  case ContactEnum:
36  phi_ungrounding=ContactFSLevelset(elements,vertices);
37  break;
40  case GroundingOnlyEnum:
41  /*Nothing additional to do here, MigrateGroundingLine takes care of everything*/
42  break;
43  default:
44  _error_("Grounding line migration "<<EnumToStringx(migration_style) << " not supported yet!");
45  }
46 
47  /*Migrate grounding line : */
48  for(int i=0;i<elements->Size();i++){
49  element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
50  element->MigrateGroundingLine(phi_ungrounding);
51  }
52 
53  /*free ressouces: */
54  xDelete<IssmDouble>(vertices_potentially_ungrounding);
55  xDelete<IssmDouble>(phi_ungrounding);
56 }

◆ ContactFSLevelset()

IssmDouble* ContactFSLevelset ( Elements elements,
Vertices vertices 
)

Definition at line 58 of file GroundinglineMigrationx.cpp.

58  { /*{{{*/
59 
60  Vector<IssmDouble>* vertex_sigmann = NULL;
61  Vector<IssmDouble>* vertex_waterpressure = NULL;
62  IssmDouble* serial_vertex_sigmann = NULL;
63  IssmDouble* serial_vertex_waterpressure = NULL;
64  IssmDouble* phi = NULL;
65 
66  /*Initialize vector with number of vertices*/
67  int numberofvertices = vertices->NumberOfVertices();
68  vertex_sigmann = new Vector<IssmDouble>(numberofvertices);
69  vertex_waterpressure = new Vector<IssmDouble>(numberofvertices);
70  phi = xNew<IssmDouble>(numberofvertices);
71 
72  /*Fill vector vertices_potentially_floating: */
73  for(int i=0;i<elements->Size();i++){
74  Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
75  element->FSContactMigration(vertex_sigmann,vertex_waterpressure);
76  }
77  /*Assemble vector and serialize */
78  vertex_sigmann->Assemble();
79  vertex_waterpressure->Assemble();
80  serial_vertex_sigmann=vertex_sigmann->ToMPISerial();
81  serial_vertex_waterpressure=vertex_waterpressure->ToMPISerial();
82 
83  for(int i=0;i<numberofvertices;i++){
84  if (serial_vertex_waterpressure[i] > serial_vertex_sigmann[i]) phi[i]=-1;
85  else phi[i]=1;
86  }
87 
88  /*free ressouces and return: */
89  delete vertex_sigmann;
90  delete vertex_waterpressure;
91  xDelete<IssmDouble>(serial_vertex_sigmann);
92  xDelete<IssmDouble>(serial_vertex_waterpressure);
93 
94  return phi;
95 }

◆ PotentialUngrounding()

IssmDouble* PotentialUngrounding ( Elements elements,
Vertices vertices,
Parameters parameters 
)

Definition at line 97 of file GroundinglineMigrationx.cpp.

97  { /*{{{*/
98 
99  int i,numberofvertices;
100  IssmDouble* vertices_potentially_ungrounding = NULL;
101  Vector<IssmDouble>* vec_vertices_potentially_ungrounding = NULL;
102  Element* element = NULL;
103 
104  /*Initialize vector with number of vertices*/
105  numberofvertices=vertices->NumberOfVertices();
106  vec_vertices_potentially_ungrounding=new Vector<IssmDouble>(numberofvertices); //grounded vertex that could start floating
107 
108  /*Fill vector vertices_potentially_floating: */
109  for(i=0;i<elements->Size();i++){
110  element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
111  element->PotentialUngrounding(vec_vertices_potentially_ungrounding);
112  }
113 
114  /*Assemble vector and serialize */
115  vec_vertices_potentially_ungrounding->Assemble();
116  vertices_potentially_ungrounding=vec_vertices_potentially_ungrounding->ToMPISerial();
117 
118  /*free ressouces and return: */
119  delete vec_vertices_potentially_ungrounding;
120  return vertices_potentially_ungrounding;
121 }

◆ PropagateFloatingiceToGroundedNeighbors()

IssmDouble* PropagateFloatingiceToGroundedNeighbors ( Elements elements,
Nodes nodes,
Vertices vertices,
Parameters parameters,
IssmDouble vertices_potentially_ungrounding 
)

Definition at line 123 of file GroundinglineMigrationx.cpp.

123  { /*{{{*/
124  int i,analysis_type;
125  int nflipped,local_nflipped;
126  IssmDouble* phi = NULL;
127  IssmDouble* elements_neighboring_floatingce = NULL;
128  Vector<IssmDouble>* vec_elements_neighboring_floatingice = NULL;
129  Vector<IssmDouble>* vec_phi = NULL;
130  Element* element = NULL;
131 
132  /*recover parameters: */
133  parameters->FindParam(&analysis_type,AnalysisTypeEnum);
134 
135  /*recover vec_phi*/
136  vec_phi=new Vector<IssmDouble>(vertices->NumberOfVertices());
137  for(i=0;i<elements->Size();i++){
138  Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
140  }
141  vec_phi->Assemble();
142  phi=vec_phi->ToMPISerial();
143 
144  nflipped=1; //bootstrap
145  while(nflipped){
146 
147  /*Vector of size number of elements*/
148  vec_elements_neighboring_floatingice=new Vector<IssmDouble>(elements->NumberOfElements(),true);
149 
150  /*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/
151  for(i=0;i<elements->Size();i++){
152  element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
153  vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(phi)?1.0:0.0,INS_VAL);
154  }
155 
156  /*Assemble vector and serialize: */
157  vec_elements_neighboring_floatingice->Assemble();
158  elements_neighboring_floatingce=vec_elements_neighboring_floatingice->ToMPISerial();
159 
160  /*Go through elements_neighboring_floatingce, and update vector of the nodes that will start floating*/
161  local_nflipped=0;
162  for(i=0;i<elements->Size();i++){
163  element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
164  if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){
165  local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_phi,phi);
166  }
167  }
168  vec_phi->Assemble();
169 
170  ISSM_MPI_Allreduce(&local_nflipped,&nflipped,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
171  if(VerboseConvergence()) _printf0_(" Additional number of vertices allowed to unground: " << nflipped << "\n");
172 
173  /*Avoid leaks: */
174  xDelete<IssmDouble>(elements_neighboring_floatingce);
175  xDelete<IssmDouble>(phi);
176 
177  /*Assemble and serialize:*/
178  delete vec_elements_neighboring_floatingice;
179  phi=vec_phi->ToMPISerial();
180  }
181 
182  /*Free ressources:*/
183  delete vec_phi;
184  xDelete<IssmDouble>(elements_neighboring_floatingce);
185 
186  return phi;
187 }
DataSet::Size
int Size()
Definition: DataSet.cpp:399
GroundingOnlyEnum
@ GroundingOnlyEnum
Definition: EnumDefinitions.h:1091
ContactFSLevelset
IssmDouble * ContactFSLevelset(Elements *elements, Vertices *vertices)
Definition: GroundinglineMigrationx.cpp:58
IssmDouble
double IssmDouble
Definition: types.h:37
GroundinglineMigrationEnum
@ GroundinglineMigrationEnum
Definition: EnumDefinitions.h:161
ContactEnum
@ ContactEnum
Definition: EnumDefinitions.h:1014
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
ISSM_MPI_Allreduce
int ISSM_MPI_Allreduce(void *sendbuf, void *recvbuf, int count, ISSM_MPI_Datatype datatype, ISSM_MPI_Op op, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:116
VerboseConvergence
bool VerboseConvergence(void)
Definition: Verbosity.cpp:26
SoftMigrationEnum
@ SoftMigrationEnum
Definition: EnumDefinitions.h:1277
MaskOceanLevelsetEnum
@ MaskOceanLevelsetEnum
Definition: EnumDefinitions.h:640
ISSM_MPI_SUM
#define ISSM_MPI_SUM
Definition: issmmpi.h:134
IssmComm::GetComm
static ISSM_MPI_Comm GetComm(void)
Definition: IssmComm.cpp:30
Element::PotentialUngrounding
virtual void PotentialUngrounding(Vector< IssmDouble > *potential_sheet_ungrounding)=0
ToolkitsOptionsFromAnalysis
void ToolkitsOptionsFromAnalysis(Parameters *parameters, int analysis_type)
Vertices::NumberOfVertices
int NumberOfVertices(void)
Definition: Vertices.cpp:255
Element::Sid
int Sid()
Definition: Element.cpp:3578
VerboseModule
bool VerboseModule(void)
Definition: Verbosity.cpp:23
Element::IsNodeOnShelfFromFlags
virtual bool IsNodeOnShelfFromFlags(IssmDouble *flags)=0
DefaultAnalysisEnum
@ DefaultAnalysisEnum
Definition: EnumDefinitions.h:1032
Element
Definition: Element.h:41
ISSM_MPI_INT
#define ISSM_MPI_INT
Definition: issmmpi.h:127
PotentialUngrounding
IssmDouble * PotentialUngrounding(Elements *elements, Vertices *vertices, Parameters *parameters)
Definition: GroundinglineMigrationx.cpp:97
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
Element::GetVectorFromInputs
void GetVectorFromInputs(Vector< IssmDouble > *vector, int name_enum, int type)
Definition: Element.cpp:1331
INS_VAL
@ INS_VAL
Definition: toolkitsenums.h:14
Vector::Assemble
void Assemble(void)
Definition: Vector.h:142
PropagateFloatingiceToGroundedNeighbors
IssmDouble * PropagateFloatingiceToGroundedNeighbors(Elements *elements, Nodes *nodes, Vertices *vertices, Parameters *parameters, IssmDouble *vertices_potentially_ungrounding)
Definition: GroundinglineMigrationx.cpp:123
VertexPIdEnum
@ VertexPIdEnum
Definition: EnumDefinitions.h:1324
Element::MigrateGroundingLine
void MigrateGroundingLine(IssmDouble *sheet_ungrounding)
Definition: Element.cpp:2238
NoneEnum
@ NoneEnum
Definition: EnumDefinitions.h:1202
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
Parameters::FindParam
void FindParam(bool *pinteger, int enum_type)
Definition: Parameters.cpp:262
AnalysisTypeEnum
@ AnalysisTypeEnum
Definition: EnumDefinitions.h:36
Elements::NumberOfElements
int NumberOfElements(void)
Definition: Elements.cpp:67
SubelementMigrationEnum
@ SubelementMigrationEnum
Definition: EnumDefinitions.h:1297
Vector::ToMPISerial
doubletype * ToMPISerial(void)
Definition: Vector.h:277
Vector< IssmDouble >
AggressiveMigrationEnum
@ AggressiveMigrationEnum
Definition: EnumDefinitions.h:973
Vector::SetValue
void SetValue(int dof, doubletype value, InsMode mode)
Definition: Vector.h:163
Element::FSContactMigration
virtual void FSContactMigration(Vector< IssmDouble > *vertex_sigmann, Vector< IssmDouble > *vertex_waterpressure)=0
Element::UpdatePotentialUngrounding
virtual int UpdatePotentialUngrounding(IssmDouble *potential_sheet_ungrounding, Vector< IssmDouble > *vec_nodes_on_iceshelf, IssmDouble *nodes_on_iceshelf)=0