Debian Codegraph @

packages/pamgen/mesh_spec_lt/pamgen_mesh_specification.h

raw
1 // @HEADER
2 // *****************************************************************************
3 // Pamgen Package
4 //
5 // Copyright 2004 NTESS and the Pamgen contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef pamgen_mesh_specification_LT_H
11 #define pamgen_mesh_specification_LT_H
12
13 #include "pamgen_element_dictionary.h"
14 #include <string>
15 #include <sstream>
16 #include <ios>
17 using namespace PAMGEN_NEVADA;
18 namespace ms_lt{
19
20
21 /*****************************************************************************/
22 class Mesh_Specification
23 /*****************************************************************************/
24 // This abstract class represents a mesh specification.
25 //
26 // A note on numbering. Most file formats for specifying meshes were
27 // developed in the FORTRAN world, where the default convention is for array
28 // indices to begin at 1 rather than 0. In addition, when a mesh is
29 // decomposed for parallel computations, its topological entities are
30 // assigned a global number. As a result, there is considerable potential
31 // for confusion about numbering. Unless otherwise specified, local indexing
32 // starts at 0. When indices returned by a function are based on the
33 // FORTRAN convention (indices starting at 1), this will be noted. Global
34 // numbering will always be explicitly noted when not obvious.
35 {
36 public:
37
38 enum MSPPA {
39 ELMT_NODE_LINKAGE,
40 NODE_SET_NODES,
41 SIDE_SET_ELEMENTS,
42 SIDE_SET_FACES,
43 SIDE_SET_NODES,
44 SIDE_SET_NODE_COUNTER,
45 COMM_NODE_IDS,
46 COMM_NODE_PROC_IDS,
47 COMM_ELEM_IDS,
48 COMM_ELEM_PROC_IDS,
49 COMM_SIDE_IDS,
50 NUM_MSPPA
51 };
52
53 enum MSPPDA{
54 ATTRIBUTES,
55 NODE_SET_DF,
56 SIDE_SET_DF,
57 NUM_MSPPDA
58 };
59
60 enum MSPSA{
61 INFO_STRINGS,
62 COORDINATE_NAMES,
63 ELEMENT_TYPES,
64 NUM_MSPSA
65 };
66
67 enum MSPA {
68 ELEM_ORDER_MAP=0,
69 BLOCK_ID,
70 ELEMENTS_IN_BLOCK,
71 NODES_PER_ELEMENT,
72 ELEMENT_ATTRIBUTES,
73 NODE_SET_ID,
74 NUM_NODES_IN_NODE_SET,
75 NUM_DF_IN_NODE_SET,
76 SIDE_SET_ID,
77 NUM_ELEMENTS_IN_SIDE_SET,
78 NUM_NODES_IN_SIDE_SET,
79 NUM_DF_IN_SIDE_SET,
80 GLOBAL_ELEMENT_NUMBERS,
81 GLOBAL_NODE_NUMBERS,
82 NBR_PROC_LIST,
83 ELEM_BLK_IDS_GLOBAL,
84 ELEM_BLK_CNTS_GLOBAL,
85 NS_IDS_GLOBAL,
86 NS_CNTS_GLOBAL,
87 NS_DF_CNTS_GLOBAL,
88 SS_IDS_GLOBAL,
89 SS_CNTS_GLOBAL,
90 SS_DF_CNTS_GLOBAL,
91 INTERNAL_ELEMENTS,
92 BORDER_ELEMENTS,
93 INTERNAL_NODES,
94 BORDER_NODES,
95 EXTERNAL_NODES,
96 NODE_CMAP_NODE_CNTS,
97 NODE_CMAP_IDS,
98 ELEM_CMAP_ELEM_CNTS,
99 ELEM_CMAP_IDS,
100 BLOCK_PARENT_MESHES,
101 SIDESET_PARENT_MESHES,
102 NODESET_PARENT_MESHES,
103 NUM_MSPA};
104
105 enum MSIA {
106 DIM=0,
107 PROC_ID,
108 NUM_QA_RECORDS,
109 NUM_INFO_RECORDS,
110 NUM_TOTAL_PROC,
111 NUM_PROC_IN_FILE,
112 NUM_NODES,
113 NUM_ELEMENTS,
114 NUM_EDGES,
115 NUM_FACES,
116 NUM_BLOCKS,
117 NUM_NODE_SETS,
118 NUM_SIDE_SET_NODES,
119 NUM_SIDE_SETS,
120 NUM_NODES_GLOBAL,
121 NUM_ELEMS_GLOBAL,
122 NUM_ELM_BLKS_GLOBAL,
123 NUM_NODE_SETS_GLOBAL,
124 NUM_SIDE_SETS_GLOBAL,
125 NUM_INTERNAL_NODES,
126 NUM_BORDER_NODES,
127 NUM_EXTERNAL_NODES,
128 NUM_INTERNAL_ELEMS,
129 NUM_BORDER_ELEMS,
130 NUM_NODE_COMM_MAPS,
131 NUM_ELEM_COMM_MAPS,
132 NUM_NBR_PROCS,
133 NUM_PARENT_MESHES,
134 NUM_MSIA};
135
136 long long getMSI(MSIA ind){return msia[ind];}
137 void setMSI(MSIA ind,long long the_int){msia[ind] = the_int;}
138
139 long long * getMSP(MSPA ind) {return mspa[ind];}
140 const long long * getMSP(MSPA ind) const {return mspa[ind];}
141
142 std::string * getMSPSA(MSPSA ind) {return mspsa[ind];}
143 const std::string * getMSPSA(MSPSA ind) const {return mspsa[ind];}
144
145 long long * const * getMSPP(MSPPA ind) {return msppa[ind];}
146 const long long * const * getMSPP(MSPPA ind) const {return msppa[ind];}
147
148 double * const * getMSPPD(MSPPDA ind) {return msppda[ind];}
149 const double * const * getMSPPD(MSPPDA ind) const {return msppda[ind];}
150
151 static Mesh_Specification * first_ms_static_storage;
152
153 static void Add_MS(Mesh_Specification * ms){
154 /*set the first pointer if unset*/
155 /*add the new entry to next if there is an im_static_storage*/
156 /*set im_static_storage*/
157 if(!first_ms_static_storage){
158 first_ms_static_storage = ms;
159 }
160 else{
161 Mesh_Specification * ams = first_ms_static_storage;
162 while(ams->next){
163 ams=ams->next;
164 }
165 ams->next = ms;
166 }
167 }
168
169 static void Replace_MS(Mesh_Specification * ms){
170 /*set the first pointer if unset*/
171 /*add the new entry to next if there is an im_static_storage*/
172 /*set im_static_storage*/
173 if(ms == first_ms_static_storage)return;
174 else if(first_ms_static_storage){
175 delete first_ms_static_storage;
176 }
177 first_ms_static_storage = ms;
178 }
179
180 Mesh_Specification * consolidateMS();
181
182 Mesh_Specification * Next(){return next;}
183
184 Mesh_Specification();
185
186 virtual ~Mesh_Specification();
187
188 std::string getErrorString() {return error_stream.str();}
189 std::string getWarningString(){return warning_stream.str();}
190
191
192 // Access functions for local data
193
194 const std::string& Title() const {return title;}
195
196 // Nodal coordinates
197
198 const double* Coord() const {return coord;}
199 double* Coord() {return coord;}
200 // Stored by node, then by coordinate component. Thus, Coord()[n] returns
201 // the X coordinate of the nth node, while Coord()[n+Number_Of_Nodes()]
202 // returns the Y coordinate of the nth node if Dimensionality()>1.
203
204 virtual const std::string& File_Type() {return file_type;}
205
206 // Information records
207
208 typedef std::string QA_Record[4];
209 const QA_Record *QA_Records() const {return qa_strings;}
210 QA_Record *QA_Records() {return qa_strings;}
211 // The QA records give information on every code that has "touched"
212 // the data in the mesh specification. Each QA record consists
213 // of four parts enumerated below:
214 enum {
215 QA_CODE_NAME = 0,
216 QA_CODE_DESCRIPTOR = 1,
217 QA_ANALYSIS_DATE = 2,
218 QA_ANALYSIS_TIME = 3
219 };
220
221
222 bool Are_Warnings_Suppressed() const;
223
224 void Parallel_Data_Size(long long,long long,long long,long long,long long,long long,long long);
225 void Allocate_Locational_Data();
226 void Allocate_LoadBal_Data();
227 void Allocate_Global_Data();
228 void Global_Data_Size( long long, long long, long long, long long, long long, long long, long long);
229 void Allocate_Parallel_Data();
230 void Free_Parallel_Data();
231 void Free_Locational_Data();
232 void Free_Global_Data();
233
234 // Definition functions
235
236 void Specify_Global_Information(const std::string &title,
237 long long dimensionality,
238 long long number_of_nodes,
239 long long number_of_elements,
240 long long number_of_element_blocks,
241 long long number_of_node_sets,
242 long long number_of_side_sets,
243 long long number_of_qa_records,
244 long long number_of_info_records);
245 // Specifies the overall dimensions of the mesh, and allocates
246 // storage for next level of information.
247
248 void Specify_Block_Information(long long index,
249 long long block_id,
250 long long number_of_block_elements,
251 long long number_of_nodes_per_element,
252 long long number_of_element_attributes,
253 Element_Type block_element_type);
254 // Specifies the dimensions of a particular element block, and
255 // allocates storage for the next level of information for the block.
256
257
258
259 void Specify_Node_Set_Information(long long index,
260 long long node_set_id,
261 long long number_of_nodes_in_node_set,
262 long long number_of_df_in_node_set);
263 // Specifies the dimensions of a particular node set, and allocates
264 // storage for the next level of information for the node set.
265
266 void Specify_Side_Set_Information(long long index,
267 long long side_set_id,
268 long long number_of_faces_in_side_set,
269 long long number_of_nodes_in_side_set,
270 long long number_of_df_in_side_set);
271 // Specifies the dimensions of a particular side set, and allocates
272 // storage for the next level of information for the side set.
273
274 void Resize_Info_Store(long long number_of_info_records);
275 // Increase the number of information records.
276
277 void Suppress_Warnings(long long);
278
279
280 void Free_NonTransient_Storage();
281 // Free all storage except that which contains data required for
282 // time step dumps. After a call to Free_NonTransient_Storage(),
283 // Block_ID() and Number_Of_Block_Elements() will return pointers
284 // to meaningful data, but all other functions returning a pointer
285 // will return a null pointer.
286
287 // Set IJK
288 void Set_Total_Num_IJK(long long nnx,
289 long long nny,
290 long long nnz)
291 {
292 total_num_ijk[0] = nnx;
293 total_num_ijk[1] = nny;
294 total_num_ijk[2] = nnz;
295 return;
296 }
297 void Set_Local_Num_IJK(long long nnx,
298 long long nny,
299 long long nnz)
300 {
301 local_num_ijk[0] = nnx;
302 local_num_ijk[1] = nny;
303 local_num_ijk[2] = nnz;
304 return;
305 }
306 void Set_Global_IJK(long long ilow, long long ihi,
307 long long jlow, long long jhi,
308 long long klow, long long khi)
309 {
310 global_ijk[0] = ilow;
311 global_ijk[1] = ihi;
312 global_ijk[2] = jlow;
313 global_ijk[3] = jhi;
314 global_ijk[4] = klow;
315 global_ijk[5] = khi;
316 return;
317 }
318
319 // Get IJK
320 void Get_Total_Num_IJK(long long * num_ijk)
321 {
322 num_ijk[0] = total_num_ijk[0];
323 num_ijk[1] = total_num_ijk[1];
324 num_ijk[2] = total_num_ijk[2];
325 return;
326 }
327 void Get_Local_Num_IJK(long long * num_ijk)
328 {
329 num_ijk[0] = local_num_ijk[0];
330 num_ijk[1] = local_num_ijk[1];
331 num_ijk[2] = local_num_ijk[2];
332 return;
333 }
334 void Get_Global_IJK(long long* global_ranges)
335 {
336 global_ranges[0] = global_ijk[0];
337 global_ranges[1] = global_ijk[1];
338 global_ranges[2] = global_ijk[2];
339 global_ranges[3] = global_ijk[3];
340 global_ranges[4] = global_ijk[4];
341 global_ranges[5] = global_ijk[5];
342 return;
343 }
344
345 protected:
346
347 // Store IJK
348 long long global_ijk[6];
349 long long local_num_ijk[3];
350 long long total_num_ijk[3];
351
352 std::string title;
353 std::stringstream error_stream;
354 std::stringstream warning_stream;
355
356 double* coord;
357
358 Element_Type* block_element_type;
359
360 QA_Record* qa_strings;
361
362 bool suppress_warnings;
363
364 Mesh_Specification * next;
365
366 //nem data
367 std::string file_type;
368
369 //Arrays for storing ints pointers,
370 // automatically sized by the enums
371 long long msia[NUM_MSIA];
372 long long * mspa[NUM_MSPA];
373 long long * * msppa[NUM_MSPPA];
374 double * * msppda[NUM_MSPPDA];
375 std::string * mspsa[NUM_MSPSA];
376 private:
377
378 Mesh_Specification(const Mesh_Specification &);
379 Mesh_Specification &operator=(const Mesh_Specification &);
380
381 void Zero_Set();
382 void Free();
383 };
384
385 }
386 #endif