1 | /*!\file GroundinglineMigrationx
|
---|
2 | * \brief: migration grounding line position.
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "./GroundinglineMigrationx.h"
|
---|
6 | #include "./GroundinglineMigrationxLocal.h"
|
---|
7 | #include "../../shared/shared.h"
|
---|
8 | #include "../../io/io.h"
|
---|
9 | #include "../../include/include.h"
|
---|
10 | #include "../../toolkits/toolkits.h"
|
---|
11 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
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 floating
|
---|
24 |
|
---|
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,Vertices* vertices,Parameters* parameters,double* vertices_potentially_ungrounding){
|
---|
45 |
|
---|
46 | int i,analysis_type;
|
---|
47 | int numberofvertices;
|
---|
48 | int nflipped,local_nflipped;
|
---|
49 | double* nodes_on_iceshelf = NULL;
|
---|
50 | double* elements_touching_iceshelf = NULL;
|
---|
51 | Vec vec_element_touching_iceshelf = NULL;
|
---|
52 | Vec vec_nodes_on_iceshelf = NULL;
|
---|
53 | Node* node = NULL;
|
---|
54 | Element* element = NULL;
|
---|
55 |
|
---|
56 |
|
---|
57 | /*recover parameters: */
|
---|
58 | parameters->FindParam(&analysis_type,AnalysisTypeEnum);
|
---|
59 | numberofvertices=vertices->NumberOfVertices();
|
---|
60 |
|
---|
61 | /*recover vec_nodes_on_iceshelf*/
|
---|
62 | vec_nodes_on_iceshelf=NewVec(numberofvertices);
|
---|
63 |
|
---|
64 | /*Loop through nodes, and fill nodes_on_iceshelf: */
|
---|
65 | for(i=0;i<nodes->Size();i++){
|
---|
66 | node=(Node*)nodes->GetObjectByOffset(i);
|
---|
67 | if(node->InAnalysis(analysis_type)){
|
---|
68 | if(node->IsFloating()){
|
---|
69 | VecSetValue(vec_nodes_on_iceshelf,node->Sid(),1.0,INSERT_VALUES);
|
---|
70 | }
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | /*Assemble vector and serialize: */
|
---|
75 | VecAssemblyBegin(vec_nodes_on_iceshelf);
|
---|
76 | VecAssemblyEnd(vec_nodes_on_iceshelf);
|
---|
77 | VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
|
---|
78 |
|
---|
79 | nflipped=1; //bootstrap
|
---|
80 | while(nflipped){
|
---|
81 |
|
---|
82 | /*Vector of size number of elements*/
|
---|
83 | vec_element_touching_iceshelf=NewVec(elements->NumberOfElements(),true);
|
---|
84 |
|
---|
85 | /*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/
|
---|
86 | for(i=0;i<elements->Size();i++){
|
---|
87 | element=(Element*)elements->GetObjectByOffset(i);
|
---|
88 | VecSetValue(vec_element_touching_iceshelf,element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_iceshelf)?1.0:0.0,INSERT_VALUES);
|
---|
89 | }
|
---|
90 |
|
---|
91 | /*Assemble vector and serialize: */
|
---|
92 | VecAssemblyBegin(vec_element_touching_iceshelf);
|
---|
93 | VecAssemblyEnd(vec_element_touching_iceshelf);
|
---|
94 | VecToMPISerial(&elements_touching_iceshelf,vec_element_touching_iceshelf);
|
---|
95 |
|
---|
96 | /*Go through elements_touching_iceshelf, and flag their nodes that can unground inside potential_sheet_ungrounding*/
|
---|
97 | local_nflipped=0;
|
---|
98 | for(i=0;i<elements->Size();i++){
|
---|
99 | element=(Element*)elements->GetObjectByOffset(i);
|
---|
100 | if(elements_touching_iceshelf[element->Sid()]){
|
---|
101 | local_nflipped+=element->UpdatePotentialSheetUngrounding(vertices_potentially_ungrounding,vec_nodes_on_iceshelf,nodes_on_iceshelf);
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 | MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
|
---|
106 | _printf_(VerboseConvergence()," number of grounded vertices connected to grounding line: %i\n",nflipped);
|
---|
107 |
|
---|
108 | /*Avoid leaks: */
|
---|
109 | xfree((void**)&elements_touching_iceshelf);
|
---|
110 | xfree((void**)&nodes_on_iceshelf);
|
---|
111 |
|
---|
112 | /*Assemble and serialize:*/
|
---|
113 | VecFree(&vec_element_touching_iceshelf);
|
---|
114 | VecAssemblyBegin(vec_nodes_on_iceshelf);
|
---|
115 | VecAssemblyEnd(vec_nodes_on_iceshelf);
|
---|
116 | VecToMPISerial(&nodes_on_iceshelf,vec_nodes_on_iceshelf);
|
---|
117 | }
|
---|
118 |
|
---|
119 | /*Free ressources:*/
|
---|
120 | VecFree(&vec_nodes_on_iceshelf);
|
---|
121 | xfree((void**)&elements_touching_iceshelf);
|
---|
122 |
|
---|
123 | return nodes_on_iceshelf;
|
---|
124 | }
|
---|
125 | /*}}}*/
|
---|