1 | /*
|
---|
2 | * CreateElementsNodesAndMaterialsDiagnosticHutter.c:
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "../../../DataSet/DataSet.h"
|
---|
6 | #include "../../../toolkits/toolkits.h"
|
---|
7 | #include "../../../io/io.h"
|
---|
8 | #include "../../../EnumDefinitions/EnumDefinitions.h"
|
---|
9 | #include "../../../objects/objects.h"
|
---|
10 | #include "../../../shared/shared.h"
|
---|
11 | #include "../../MeshPartitionx/MeshPartitionx.h"
|
---|
12 | #include "../../../include/include.h"
|
---|
13 | #include "../ModelProcessorx.h"
|
---|
14 |
|
---|
15 | void CreateElementsNodesAndMaterialsDiagnosticHutter(DataSet** pelements,DataSet** pnodes, DataSet** pvertices,DataSet** pmaterials, IoModel* iomodel,ConstDataHandle iomodel_handle){
|
---|
16 |
|
---|
17 | /*Intermediary*/
|
---|
18 | int i,j,k,n;
|
---|
19 |
|
---|
20 | /*DataSets: */
|
---|
21 | DataSet* elements = NULL;
|
---|
22 | DataSet* nodes = NULL;
|
---|
23 | DataSet* vertices = NULL;
|
---|
24 | DataSet* materials = NULL;
|
---|
25 |
|
---|
26 | /*First create the elements, nodes and material properties: */
|
---|
27 | elements = new DataSet(ElementsEnum);
|
---|
28 | nodes = new DataSet(NodesEnum);
|
---|
29 | vertices = new DataSet(VerticesEnum);
|
---|
30 | materials = new DataSet(MaterialsEnum);
|
---|
31 |
|
---|
32 | /*Now, is the flag ishutter on? otherwise, do nothing: */
|
---|
33 | if (!iomodel->ishutter)goto cleanup_and_return;
|
---|
34 |
|
---|
35 | /*Partition elements and vertices and nodes: */
|
---|
36 | Partitioning(&iomodel->my_elements, &iomodel->my_vertices, &iomodel->my_nodes, &iomodel->my_bordervertices, iomodel, iomodel_handle);
|
---|
37 |
|
---|
38 | /*Hutter elements can be partitioned using epart, even if
|
---|
39 | * each hutter elements either lies on a node (in 2d), or a pair of vertically juxtaposed nodes (in 3d): */
|
---|
40 |
|
---|
41 | /*Fetch data temporarily needed: */
|
---|
42 | IoModelFetchData(&iomodel->gridonhutter,NULL,NULL,iomodel_handle,"gridonhutter");
|
---|
43 | IoModelFetchData(&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness");
|
---|
44 | IoModelFetchData(&iomodel->surface,NULL,NULL,iomodel_handle,"surface");
|
---|
45 | IoModelFetchData(&iomodel->bed,NULL,NULL,iomodel_handle,"bed");
|
---|
46 | IoModelFetchData(&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface");
|
---|
47 | IoModelFetchData(&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed");
|
---|
48 | IoModelFetchData(&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids");
|
---|
49 | IoModelFetchData(&iomodel->drag_coefficient,NULL,NULL,iomodel_handle,"drag_coefficient");
|
---|
50 | IoModelFetchData(&iomodel->rheology_B,NULL,NULL,iomodel_handle,"rheology_B");
|
---|
51 | IoModelFetchData(&iomodel->rheology_n,NULL,NULL,iomodel_handle,"rheology_n");
|
---|
52 | IoModelFetchData(&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type");
|
---|
53 | IoModelFetchData(&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed");
|
---|
54 | IoModelFetchData(&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface");
|
---|
55 | IoModelFetchData(&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater");
|
---|
56 | IoModelFetchData(&iomodel->elements,NULL,NULL,iomodel_handle,"elements");
|
---|
57 | IoModelFetchData(&iomodel->upperelements,NULL,NULL,iomodel_handle,"upperelements");
|
---|
58 | IoModelFetchData(&iomodel->lowerelements,NULL,NULL,iomodel_handle,"lowerelements");
|
---|
59 |
|
---|
60 | /*2d mesh: */
|
---|
61 | if (iomodel->dim==2){
|
---|
62 |
|
---|
63 | for (i=0;i<iomodel->numberofelements;i++){
|
---|
64 |
|
---|
65 | if(iomodel->my_elements[i]){
|
---|
66 |
|
---|
67 | if (*(iomodel->elements_type+2*i+0)==HutterFormulationEnum){ //create only Hutter elements
|
---|
68 |
|
---|
69 | /*Create and add penta element to elements dataset: */
|
---|
70 | elements->AddObject(new Tria(i+1,i,iomodel));
|
---|
71 |
|
---|
72 | /*Create and add material property to materials dataset: */
|
---|
73 | materials->AddObject(new Matice(i+1,i,iomodel,3));
|
---|
74 | }
|
---|
75 | }
|
---|
76 | } //for (i=0;i<iomodel->numberofvertices;i++)
|
---|
77 | } //if (iomodel->dim==2)
|
---|
78 | else{
|
---|
79 |
|
---|
80 | for (i=0;i<iomodel->numberofelements;i++){
|
---|
81 |
|
---|
82 | if(iomodel->my_elements[i]){
|
---|
83 |
|
---|
84 | if (*(iomodel->elements_type+2*i+0)==HutterFormulationEnum){ //create only Hutter elements
|
---|
85 |
|
---|
86 | /*Create and add penta element to elements dataset: */
|
---|
87 | elements->AddObject(new Penta(i+1,i,iomodel));
|
---|
88 |
|
---|
89 |
|
---|
90 | /*Create and add material property to materials dataset: */
|
---|
91 | materials->AddObject(new Matice(i+1,i,iomodel,6));
|
---|
92 |
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | } //for (i=0;i<iomodel->numberofelements;i++)
|
---|
97 |
|
---|
98 | } //if (iomodel->dim==2)
|
---|
99 |
|
---|
100 | /*Free data: */
|
---|
101 | xfree((void**)&iomodel->elements);
|
---|
102 | xfree((void**)&iomodel->elementonbed);
|
---|
103 | xfree((void**)&iomodel->elementonsurface);
|
---|
104 | xfree((void**)&iomodel->elements_type);
|
---|
105 | xfree((void**)&iomodel->gridonhutter);
|
---|
106 | xfree((void**)&iomodel->thickness);
|
---|
107 | xfree((void**)&iomodel->surface);
|
---|
108 | xfree((void**)&iomodel->bed);
|
---|
109 | xfree((void**)&iomodel->gridonbed);
|
---|
110 | xfree((void**)&iomodel->elementonwater);
|
---|
111 | xfree((void**)&iomodel->uppernodes);
|
---|
112 | xfree((void**)&iomodel->drag_coefficient);
|
---|
113 | xfree((void**)&iomodel->rheology_B);
|
---|
114 | xfree((void**)&iomodel->rheology_n);
|
---|
115 | xfree((void**)&iomodel->upperelements);
|
---|
116 | xfree((void**)&iomodel->lowerelements);
|
---|
117 |
|
---|
118 | /*Add new constrant material property to materials, at the end: */
|
---|
119 | if (iomodel->dim==2){
|
---|
120 | materials->AddObject(new Matpar(iomodel->numberofelements+1,iomodel)); //put it at the end of the materials
|
---|
121 | }
|
---|
122 | else{
|
---|
123 | materials->AddObject(new Matpar(iomodel->numberofelements+1,iomodel)); //put it at the end of the materials
|
---|
124 | }
|
---|
125 |
|
---|
126 | /*First fetch data: */
|
---|
127 | if (iomodel->dim==3){
|
---|
128 | IoModelFetchData(&iomodel->deadgrids,NULL,NULL,iomodel_handle,"deadgrids");
|
---|
129 | IoModelFetchData(&iomodel->uppernodes,NULL,NULL,iomodel_handle,"uppergrids");
|
---|
130 | }
|
---|
131 | IoModelFetchData(&iomodel->x,NULL,NULL,iomodel_handle,"x");
|
---|
132 | IoModelFetchData(&iomodel->y,NULL,NULL,iomodel_handle,"y");
|
---|
133 | IoModelFetchData(&iomodel->z,NULL,NULL,iomodel_handle,"z");
|
---|
134 | IoModelFetchData(&iomodel->thickness,NULL,NULL,iomodel_handle,"thickness");
|
---|
135 | IoModelFetchData(&iomodel->bed,NULL,NULL,iomodel_handle,"bed");
|
---|
136 | IoModelFetchData(&iomodel->gridonbed,NULL,NULL,iomodel_handle,"gridonbed");
|
---|
137 | IoModelFetchData(&iomodel->gridonsurface,NULL,NULL,iomodel_handle,"gridonsurface");
|
---|
138 | IoModelFetchData(&iomodel->gridonhutter,NULL,NULL,iomodel_handle,"gridonhutter");
|
---|
139 | IoModelFetchData(&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet");
|
---|
140 | IoModelFetchData(&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf");
|
---|
141 | IoModelFetchData(&iomodel->elements,NULL,NULL,iomodel_handle,"elements");
|
---|
142 | CreateNumberNodeToElementConnectivity(iomodel);
|
---|
143 |
|
---|
144 | for (i=0;i<iomodel->numberofvertices;i++){
|
---|
145 |
|
---|
146 | /*vertices and nodes (same number, as we are running continuous galerkin formulation: */
|
---|
147 | if(iomodel->my_vertices[i]){
|
---|
148 |
|
---|
149 | /*Add vertex to vertices dataset: */
|
---|
150 | vertices->AddObject(new Vertex(i+1,i,iomodel));
|
---|
151 |
|
---|
152 | /*Add node to nodes dataset: */
|
---|
153 | nodes->AddObject(new Node(i+1,i,iomodel));
|
---|
154 |
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | /*Clean fetched data: */
|
---|
159 | xfree((void**)&iomodel->deadgrids);
|
---|
160 | xfree((void**)&iomodel->x);
|
---|
161 | xfree((void**)&iomodel->y);
|
---|
162 | xfree((void**)&iomodel->z);
|
---|
163 | xfree((void**)&iomodel->thickness);
|
---|
164 | xfree((void**)&iomodel->bed);
|
---|
165 | xfree((void**)&iomodel->gridonbed);
|
---|
166 | xfree((void**)&iomodel->gridonsurface);
|
---|
167 | xfree((void**)&iomodel->gridonhutter);
|
---|
168 | xfree((void**)&iomodel->uppernodes);
|
---|
169 | xfree((void**)&iomodel->gridonicesheet);
|
---|
170 | xfree((void**)&iomodel->gridoniceshelf);
|
---|
171 | xfree((void**)&iomodel->elements);
|
---|
172 | xfree((void**)&iomodel->numbernodetoelementconnectivity);
|
---|
173 |
|
---|
174 | /*All our datasets are already order by ids. Set presort flag so that later on, when sorting is requested on these
|
---|
175 | * datasets, it will not be redone: */
|
---|
176 | elements->Presort();
|
---|
177 | nodes->Presort();
|
---|
178 | vertices->Presort();
|
---|
179 | materials->Presort();
|
---|
180 |
|
---|
181 | cleanup_and_return:
|
---|
182 |
|
---|
183 | /*Assign output pointer: */
|
---|
184 | *pelements=elements;
|
---|
185 | *pnodes=nodes;
|
---|
186 | *pvertices=vertices;
|
---|
187 | *pmaterials=materials;
|
---|
188 | }
|
---|