Changeset 10356
- Timestamp:
- 10/28/11 17:11:38 (14 years ago)
- Location:
- issm/trunk/src/c/modules/GroundinglineMigrationx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
r10355 r10356 16 16 int i, migration_style; 17 17 double* vertices_potentially_ungrounding = NULL; 18 double* sheet_ungrounding= NULL;18 double* vertices_ungrounding = NULL; 19 19 Element* element = NULL; 20 20 … … 31 31 32 32 /*propagate ice shelf into connex areas of the ice sheet that potentially want to unground: */ 33 sheet_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding);33 vertices_ungrounding=PropagateShelfIntoConnexIceSheet(elements,nodes,parameters,vertices_potentially_ungrounding); 34 34 } 35 35 … … 37 37 for(i=0;i<elements->Size();i++){ 38 38 element=(Element*)elements->GetObjectByOffset(i); 39 element->Migration( sheet_ungrounding);39 element->Migration(vertices_ungrounding); 40 40 } 41 41 … … 48 48 /*free ressouces: */ 49 49 xfree((void**)&vertices_potentially_ungrounding); 50 xfree((void**)& sheet_ungrounding);50 xfree((void**)&vertices_ungrounding); 51 51 } -
issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxLocal.h
r10354 r10356 17 17 double* CreateElementOnIceShelf(Elements* elements); 18 18 double* CreateElementTouchingIceShelf(Elements* elements,Vec vec_nodes_on_iceshelf); 19 Vec CreateNodesOnIceShelf(Nodes* nodes,int analysis_type); 20 19 21 int UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf); 20 Vec CreateNodesOnIceShelf(Nodes* nodes,int analysis_type);21 22 #endif /* _GROUNDINGLINEMIGRATIONXLOCAL_H */ -
issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationxUtils.cpp
r10355 r10356 11 11 #include "../../EnumDefinitions/EnumDefinitions.h" 12 12 13 /*FUNCTION PotentialSheetUngrounding {{{1*/14 double* PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){15 16 int i,numberofvertices;17 double* vertices_potentially_ungrounding = NULL;18 Vec vec_vertices_potentially_ungrounding = NULL;19 Element* element = NULL;20 21 /*Initialize vector with number of vertices*/22 numberofvertices=vertices->NumberOfVertices();23 vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating24 25 /*Fill vector vertices_potentially_floating: */26 for(i=0;i<elements->Size();i++){27 element=(Element*)elements->GetObjectByOffset(i);28 element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);29 }30 31 /*Assemble vector: */32 VecAssemblyBegin(vec_vertices_potentially_ungrounding);33 VecAssemblyEnd(vec_vertices_potentially_ungrounding);34 35 /*Serialize vector: */36 VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding);37 38 /*free ressouces and return: */39 VecFree(&vec_vertices_potentially_ungrounding);40 return vertices_potentially_ungrounding;41 }42 /*}}}*/43 /*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/44 double* PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Parameters* parameters,double* potential_sheet_ungrounding){45 46 int i;47 Element* element=NULL;48 int numnods;49 int analysis_type;50 Vec vec_nodes_on_iceshelf=NULL;51 double* nodes_on_iceshelf=NULL;52 int nflipped,local_nflipped;53 double* elements_touching_iceshelf=NULL;54 55 /*recover parameters: */56 parameters->FindParam(&analysis_type,AnalysisTypeEnum);57 58 /*recover vec_nodes_on_iceshelf: */59 vec_nodes_on_iceshelf=CreateNodesOnIceShelf(nodes,analysis_type);60 61 nflipped=1; //bootstrap62 while(nflipped){63 64 /*get a list of potential elements that have nodes on ice shelf: */65 elements_touching_iceshelf=CreateElementTouchingIceShelf(elements,vec_nodes_on_iceshelf);66 67 /*now, go through elements_touching_iceshelf, and if they have nodes inside potential_sheet_ungrounding,68 * flag it: */69 local_nflipped=0;70 71 /*serialize vec_nodes_on_iceshelf, needed by element's UpdatePotentialSheetUngrounding routine, to figure out if72 * nodes have flipped from grounded to ungrounded: */73 VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);74 75 for(i=0;i<elements->Size();i++){76 element=(Element*)elements->GetObjectByOffset(i);77 if(elements_touching_iceshelf[element->Sid()]){78 local_nflipped+=element->UpdatePotentialSheetUngrounding(potential_sheet_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);79 }80 }81 82 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);83 _printf_(VerboseConvergence()," number of grounded vertices connected to grounding line: %i\n",nflipped);84 85 /*Avoid leaks: */86 xfree((void**)&nodes_on_iceshelf);87 xfree((void**)&elements_touching_iceshelf);88 89 /*Assemble:*/90 VecAssemblyBegin(vec_nodes_on_iceshelf);91 VecAssemblyEnd(vec_nodes_on_iceshelf);92 }93 94 /*Serialize: */95 VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);96 97 /*Free ressources:*/98 VecFree(&vec_nodes_on_iceshelf);99 xfree((void**)&elements_touching_iceshelf);100 101 return nodes_on_iceshelf;102 }103 /*}}}*/104 13 /*FUNCTION CreateElementOnGroundingline {{{1*/ 105 14 bool* CreateElementOnGroundingline(Elements* elements,double* element_on_iceshelf){ 106 15 107 int i,j;108 Element *element = NULL;109 16 bool *element_on_gl = NULL; 110 17 bool ongl=false; 18 int i,j,sid,shelf; 111 19 int *neighboorsids = NULL; 112 int sid; 113 int shelf; 20 Element *element = NULL; 114 21 115 22 /*Go through elements, and look for elements that can possibly have a grounding line migration. These … … 140 47 double* CreateElementOnIceShelf(Elements* elements){ 141 48 142 int i;143 Element* element=NULL;144 Vec vec_element_on_iceshelf=NULL;145 double* element_on_iceshelf=NULL;49 int i; 50 double *element_on_iceshelf = NULL; 51 Element *element = NULL; 52 Vec vec_element_on_iceshelf = NULL; 146 53 147 54 /*Create vector holding all the elements IsFloating flags: */ … … 170 77 double* CreateElementTouchingIceShelf(Elements* elements,Vec vec_nodes_on_iceshelf){ 171 78 172 int i; 173 Element* element=NULL; 174 Vec vec_element_touching_iceshelf=NULL; 175 double* nodes_on_iceshelf=NULL; 176 177 /*output: */ 178 double* element_touching_iceshelf=NULL; 79 int i; 80 double *nodes_on_iceshelf = NULL; 81 double *element_touching_iceshelf = NULL; 82 Element *element = NULL; 83 Vec vec_element_touching_iceshelf = NULL; 179 84 180 85 /*serialize: */ … … 204 109 } 205 110 /*}}}*/ 206 /*FUNCTION UpdateShelfStatus {{{1*/207 int UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf){208 209 int i;210 Element* element=NULL;211 int configuration_type;212 int numnods;213 Vec vec_new_shelf_nodes=NULL;214 double* new_shelf_nodes=NULL;215 216 /*output: */217 int local_nflipped=0;218 int nflipped=0;219 220 /*recover parameters: */221 parameters->FindParam(&configuration_type,ConfigurationTypeEnum);222 223 /*First, initialize vec_new_shelf_nodes, which will track which nodes have changed status: */224 numnods=nodes->NumberOfNodes(configuration_type);225 vec_new_shelf_nodes=NewVec(numnods);226 227 /*Ok, now go through the elements that have gone through grounding line migration,228 * and update their flags: */229 for(i=0;i<elements->Size();i++){230 element=(Element*)elements->GetObjectByOffset(i);231 if(element_touching_iceshelf[element->Sid()]){232 local_nflipped+=element->UpdateShelfStatus(vec_new_shelf_nodes);233 }234 }235 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);236 237 /*Serialize vec_new_shelf_nodes: */238 VecToMPISerial(&new_shelf_nodes,vec_new_shelf_nodes);239 240 /*Now, go through ALL elements, and update the status of the nodes, to propagate what happened at the grounding line: */241 /*Carry out grounding line migration for those elements: */242 for(i=0;i<elements->Size();i++){243 element=(Element*)elements->GetObjectByOffset(i);244 element->UpdateShelfFlags(new_shelf_nodes);245 }246 247 /*Free ressources: */248 VecFree(&vec_new_shelf_nodes);249 xfree((void**)&new_shelf_nodes);250 251 return nflipped;252 }253 /*}}}*/254 111 /*FUNCTION CreateNodesOnIceShelf {{{1*/ 255 112 Vec CreateNodesOnIceShelf(Nodes* nodes,int configuration_type){ 256 113 257 /*output: */ 258 Vec nodes_on_iceshelf=NULL; 259 260 /*intermediary: */ 261 int numnods; 262 int i; 263 Node* node=NULL; 114 int i,numnods; 115 Vec nodes_on_iceshelf = NULL; 116 Node* node = NULL; 264 117 265 118 /*First, initialize nodes_on_iceshelf, which will track which nodes have changed status: */ … … 284 137 } 285 138 /*}}}*/ 139 /*FUNCTION PotentialSheetUngrounding {{{1*/ 140 double* PotentialSheetUngrounding(Elements* elements,Vertices* vertices,Parameters* parameters){ 141 142 int i,numberofvertices; 143 double* vertices_potentially_ungrounding = NULL; 144 Vec vec_vertices_potentially_ungrounding = NULL; 145 Element* element = NULL; 146 147 /*Initialize vector with number of vertices*/ 148 numberofvertices=vertices->NumberOfVertices(); 149 vec_vertices_potentially_ungrounding=NewVec(numberofvertices); //grounded vertex that could start floating 150 151 /*Fill vector vertices_potentially_floating: */ 152 for(i=0;i<elements->Size();i++){ 153 element=(Element*)elements->GetObjectByOffset(i); 154 element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding); 155 } 156 157 /*Assemble vector: */ 158 VecAssemblyBegin(vec_vertices_potentially_ungrounding); 159 VecAssemblyEnd(vec_vertices_potentially_ungrounding); 160 161 /*Serialize vector: */ 162 VecToMPISerial(&vertices_potentially_ungrounding,vec_vertices_potentially_ungrounding); 163 164 /*free ressouces and return: */ 165 VecFree(&vec_vertices_potentially_ungrounding); 166 return vertices_potentially_ungrounding; 167 } 168 /*}}}*/ 169 /*FUNCTION PropagateShelfIntoConnexIceSheet {{{1*/ 170 double* PropagateShelfIntoConnexIceSheet(Elements* elements,Nodes* nodes,Parameters* parameters,double* vertices_potentially_ungrounding){ 171 172 int i,numnods,analysis_type; 173 int nflipped,local_nflipped; 174 double* nodes_on_iceshelf = NULL; 175 double* elements_touching_iceshelf = NULL; 176 Vec vec_nodes_on_iceshelf = NULL; 177 Element* element = NULL; 178 179 /*recover parameters: */ 180 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 181 182 /*recover vec_nodes_on_iceshelf: */ 183 vec_nodes_on_iceshelf=CreateNodesOnIceShelf(nodes,analysis_type); 184 185 nflipped=1; //bootstrap 186 while(nflipped){ 187 188 /*get a list of potential elements that have nodes on ice shelf: */ 189 elements_touching_iceshelf=CreateElementTouchingIceShelf(elements,vec_nodes_on_iceshelf); 190 191 /*now, go through elements_touching_iceshelf, and if they have nodes inside potential_sheet_ungrounding, 192 * flag it: */ 193 local_nflipped=0; 194 195 /*serialize vec_nodes_on_iceshelf, needed by element's UpdatePotentialSheetUngrounding routine, to figure out if 196 * nodes have flipped from grounded to ungrounded: */ 197 VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf); 198 199 for(i=0;i<elements->Size();i++){ 200 element=(Element*)elements->GetObjectByOffset(i); 201 if(elements_touching_iceshelf[element->Sid()]){ 202 local_nflipped+=element->UpdatePotentialSheetUngrounding(potential_sheet_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf); 203 } 204 } 205 206 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 207 _printf_(VerboseConvergence()," number of grounded vertices connected to grounding line: %i\n",nflipped); 208 209 /*Avoid leaks: */ 210 xfree((void**)&nodes_on_iceshelf); 211 xfree((void**)&elements_touching_iceshelf); 212 213 /*Assemble:*/ 214 VecAssemblyBegin(vec_nodes_on_iceshelf); 215 VecAssemblyEnd(vec_nodes_on_iceshelf); 216 } 217 218 /*Serialize: */ 219 VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf); 220 221 /*Free ressources:*/ 222 VecFree(&vec_nodes_on_iceshelf); 223 xfree((void**)&elements_touching_iceshelf); 224 225 return nodes_on_iceshelf; 226 } 227 /*}}}*/ 228 229 /*FUNCTION UpdateShelfStatus {{{1*/ 230 int UpdateShelfStatus(Elements* elements,Nodes* nodes,Parameters* parameters,double* element_touching_iceshelf){ 231 232 int i,numnods,configuration_type; 233 int nflipped=0; 234 int local_nflipped=0; 235 Vec vec_new_shelf_nodes = NULL; 236 double* new_shelf_nodes = NULL; 237 Element* element = NULL; 238 239 /*recover parameters: */ 240 parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 241 242 /*First, initialize vec_new_shelf_nodes, which will track which nodes have changed status: */ 243 numnods=nodes->NumberOfNodes(configuration_type); 244 vec_new_shelf_nodes=NewVec(numnods); 245 246 /*Ok, now go through the elements that have gone through grounding line migration, 247 * and update their flags: */ 248 for(i=0;i<elements->Size();i++){ 249 element=(Element*)elements->GetObjectByOffset(i); 250 if(element_touching_iceshelf[element->Sid()]){ 251 local_nflipped+=element->UpdateShelfStatus(vec_new_shelf_nodes); 252 } 253 } 254 MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD); 255 256 /*Serialize vec_new_shelf_nodes: */ 257 VecToMPISerial(&new_shelf_nodes,vec_new_shelf_nodes); 258 259 /*Now, go through ALL elements, and update the status of the nodes, to propagate what happened at the grounding line: */ 260 /*Carry out grounding line migration for those elements: */ 261 for(i=0;i<elements->Size();i++){ 262 element=(Element*)elements->GetObjectByOffset(i); 263 element->UpdateShelfFlags(new_shelf_nodes); 264 } 265 266 /*Free ressources: */ 267 VecFree(&vec_new_shelf_nodes); 268 xfree((void**)&new_shelf_nodes); 269 270 return nflipped; 271 } 272 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.