Debian Codegraph @

packages/seacas/applications/nem_spread/globals.h

raw
1 /*
2 * Copyright(C) 1999-2023 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8 #pragma once
9
10 #include <cstdlib>
11 #include <exodusII.h>
12 #include <rf_allo.h>
13 #include <vector>
14
15 /*---------------------------------------------------------------------------*/
16 /* STRUCTURES FOR COMMUNICATION MAPS */
17 /*---------------------------------------------------------------------------*/
18 template <typename INT> struct ELEM_COMM_MAP
19 {
20 size_t map_id{0};
21 size_t elem_cnt{0};
22 std::vector<INT> elem_ids{};
23 std::vector<INT> side_ids{};
24 std::vector<INT> proc_ids{};
25 };
26
27 template <typename INT> struct NODE_COMM_MAP
28 {
29 size_t map_id{0};
30 size_t node_cnt{0};
31 std::vector<INT> node_ids{};
32 std::vector<INT> proc_ids{};
33 };
34
35 /*---------------------------------------------------------------------------*/
36 /* GLOBAL QUANTITIES THAT ARE THE SAME ON ALL PROCESSORS */
37 /*---------------------------------------------------------------------------*/
38 template <typename T, typename INT> class Globals
39 {
40 public:
41 int Num_Dim{0}; /* Number of physical dimensions in the problem*/
42 size_t Num_Node{0}; /* Total number of nodes in the entire mesh *
43 * - this is a global quantity */
44 size_t Num_Elem{0}; /* Total number of elements in the entire mesh *
45 * - this is a global quantity */
46 int Num_Elem_Blk{0}; /* Total number of element blocks */
47 int Num_Node_Set{0}; /* Total number of node sets defined in the *
48 * mesh exoII file */
49 int Num_Side_Set{0}; /* Total number of side sets defined in the *
50 * mesh exoII file */
51 int Max_NP_Elem{0}; /* Maximum number of nodes in any element *
52 * - this is a global quantity */
53 int Num_QA_Recs{0}; /* Number of QA records in original file */
54 int Num_Info_Recs{0}; /* Number of Info records in original file */
55
56 int Num_Coordinate_Frames{0};
57 int Num_Assemblies{0};
58
59 /*---------------------------------------------------------------------------*/
60 /* VARIABLES THAT DEAL WITH SPECIFICATION OF LOAD BALANCE PROPERTIES */
61 /* THAT ARE THE DIFFERENT ON EACH PROCESSOR */
62 /*---------------------------------------------------------------------------*/
63
64 std::vector<INT> Num_Internal_Nodes{}; /* Number of internal nodes on the current proc*/
65 std::vector<INT> Num_Border_Nodes{}; /* Number of border nodes on the current proc */
66 std::vector<INT> Num_External_Nodes{}; /* Number of external nodes on the current proc*/
67 std::vector<INT> Num_Internal_Elems{}; /* Number of Elements on the local processor. */
68
69 std::vector<INT> Num_Border_Elems{}; /* Number of Elements on the local processor *
70 * and shared by other processors. */
71
72 std::vector<INT> Num_N_Comm_Maps{}; /* Number of nodal communication maps */
73 std::vector<INT> Num_E_Comm_Maps{}; /* Number of elemental communication maps */
74
75 std::vector<ELEM_COMM_MAP<INT>> E_Comm_Map{}; /* Elemental communication map structure */
76 std::vector<NODE_COMM_MAP<INT>> N_Comm_Map{}; /* Nodal communication map structure */
77
78 std::vector<std::vector<INT>> GNodes{}; /* Data structure which contains the internal, *
79 * border, and external nodes on each processor*
80 * They are structured in that order, and *
81 * monotonically within each category *
82 * Type: int vector of length *
83 * (Num_Internal_Nodes + Num_Border_Nodes*
84 Num_External_Nodes) */
85
86 std::vector<std::vector<INT>> GElems{}; /* Data structure which contains the internal *
87 * elements on each processor. It is a map *
88 * from the local element number to the global *
89 * element number. *
90 * Type: int vector of length *
91 * Num_Internal_Elems */
92
93 std::vector<std::vector<INT>> Elem_Map{}; /* Map for Nemesis output */
94
95 std::vector<std::vector<INT>>
96 Proc_Global_Node_Id_Map{}; /* Data structure which contains the internal *
97 * nodes on each processor. It is a map *
98 * from the local node number to the global *
99 * node id (as found in node_num_map) *
100 * Type: int vector of length *
101 * (Num_Internal_Nodes + Num_Border_Nodes*
102 * Num_External_Nodes) */
103
104 std::vector<std::vector<INT>>
105 Proc_Global_Elem_Id_Map{}; /* Data structure which contains the internal *
106 * elements on each processor. It is a map *
107 * from the local element number to the global *
108 * element id (as found in elem_num_map) *
109 * Type: int vector of length *
110 * Num_Internal_Elems */
111
112 INT **GElem_Blks{nullptr}; /* Data structure which contains the mapping *
113 * from the local element block number to the *
114 * global element block number *
115 * Type: int vector of length *
116 * Proc_Num_Elem_Blk */
117
118 INT **GNode_Sets{nullptr}; /* Data structure which contains the mapping *
119 * from the local node set number to the *
120 * global node set number *
121 * Type: int vector of length *
122 * Proc_Num_Node_Sets */
123
124 INT **GSide_Sets{nullptr}; /* Data structure which contains the mapping *
125 * from the local side set number to the *
126 * global side set number *
127 * Type: int vector of length *
128 * Proc_Num_Side_Sets */
129
130 /*---------------------------------------------------------------------------*/
131 /* VARIABLES THAT DEAL WITH SPECIFICATION OF NODAL PROPERTIES */
132 /* THAT ARE THE DIFFERENT ON EACH PROCESSOR */
133 /*---------------------------------------------------------------------------*/
134
135 T ***Coor{nullptr}; /* 2d dynamically allocated array containing *
136 * the physical space coordinates for each *
137 * node, defined on the local processor. *
138 * Type: double/float vector of length *
139 * Num_Dim by *
140 * (Num_Internal_Nodes + Num_Border_Nodes*
141 * Num_External_Nodes) */
142
143 /*---------------------------------------------------------------------------*/
144 /* VARIABLES THAT DEAL WITH SPECIFICATION OF ELEMENT PROPERTIES */
145 /* THAT ARE THE DIFFERENT ON EACH PROCESSOR */
146 /*---------------------------------------------------------------------------*/
147
148 INT **Proc_Connect_Ptr{nullptr}; /* Vector of pointers to the start of each *
149 * element in Proc_Elem_Connect *
150 * Type: int vector of length *
151 * Num_Internal_Elems */
152
153 int **Elem_Type{nullptr}; /* Vector which contains the element code for *
154 * each defined on the current processor *
155 * Type: int vector of length *
156 * Num_Internal_Elems */
157
158 INT **Proc_Elem_Connect{nullptr}; /* Connectivity lists for the elements *
159 * required by the current processor *
160 * Type: int vector of variable length */
161
162 std::vector<std::vector<T>> Proc_Elem_Attr{}; /* Attribute list for the elements *
163 * required by the current processor *
164 * Type: float vector of variable length */
165
166 /*---------------------------------------------------------------------------*/
167 /* VARIABLES THAT DEAL WITH SPECIFICATION OF ELEMENT BLOCK PROPERTIES */
168 /* THAT ARE THE DIFFERENT ON EACH PROCESSOR */
169 /*---------------------------------------------------------------------------*/
170
171 int *Proc_Num_Elem_Blk{nullptr}; /* Number of element blocks on this processor */
172
173 INT **Proc_Num_Elem_In_Blk{nullptr};
174 /* Number of elements in the processor's *
175 * element blocks *
176 * Type: int vector of length *
177 * Proc_Num_Elem_Blk */
178
179 INT **Proc_Elem_Blk_Ids{nullptr};
180 /* Element block id's for the processor's *
181 * element blocks *
182 * Type: int vector of length *
183 * Proc_Num_Elem_Blk */
184
185 INT **Proc_Elem_Blk_Types{nullptr};
186 /* Element block types for the processor's *
187 * element blocks *
188 * Type: int vector of length *
189 * Proc_Num_Elem_Blk */
190
191 INT **Proc_Nodes_Per_Elem{nullptr};
192 /* Number of nodes per element for each *
193 * block on the current processor *
194 * Type: int vector of length *
195 * Proc_Num_Elem_Blk */
196
197 INT **Proc_Num_Attr{nullptr}; /* Number of attributes for each block on the *
198 * current processor *
199 * Type: int vector of length *
200 * Proc_Num_Elem_Blk */
201
202 INT *Elem_Blk_2_Matls{nullptr};
203 /* Mapping of element block NUMBERS to material*
204 * IDs *
205 * Type: int vector of length *
206 * Proc_Num_Elem_Blk */
207
208 /*---------------------------------------------------------------------------*/
209 /* VARIABLES THAT DEAL WITH SPECIFICATION OF NODE SETS */
210 /* THAT ARE THE DIFFERENT ON EACH PROCESSOR */
211 /*---------------------------------------------------------------------------*/
212
213 int *Proc_Num_Node_Sets{nullptr}; /* Number of node sets on the current proc */
214
215 INT *Proc_NS_List_Length{nullptr}; /* Total length of all the node set lists */
216
217 INT **Proc_NS_Ids{nullptr}; /* Node sets ids for the node sets in a given *
218 * processor *
219 * Type: int vector of length *
220 * Proc_Num_Node_Sets */
221
222 INT **Proc_NS_Count{nullptr}; /* Number of nodes in each node set defined on *
223 * the current processor. *
224 * Type: int vector of length *
225 * Proc_Num_Node_Sets */
226
227 INT **Proc_NS_DF_Count{nullptr};
228 /* Number of distribution factors associated *
229 * with a node set. *
230 * Type: int vector of length *
231 * Proc_Num_Node_Sets */
232
233 INT **Proc_NS_Pointers{nullptr}; /* Vector of pointers into Proc_NS_List for *
234 * each node set defined on the current proc *
235 * Type: int vector of length *
236 * Proc_Num_Node_Sets */
237
238 INT **Proc_NS_List{nullptr}; /* Node sets list record for the nodes sets in *
239 * a given processor *
240 * Type: int vector of length *
241 * Proc_NS_List_Length */
242
243 std::vector<std::vector<T>> Proc_NS_Dist_Fact{};
244 /* Node sets distribution factors for the node *
245 * sets on a given processor *
246 * Type: float vector of length *
247 * Proc_NS_List_Length */
248
249 INT **Proc_NS_GNMap_List{nullptr};
250 /* Map local node position to global nodeset node list position *
251 * in a given processor *
252 * Type: int vector of length *
253 * Proc_NS_List_Length */
254
255 /*---------------------------------------------------------------------------*/
256 /* VARIABLES THAT DEAL WITH SPECIFICATION OF SIDE SETS */
257 /* THAT ARE THE DIFFERENT ON EACH PROCESSOR */
258 /*---------------------------------------------------------------------------*/
259
260 int *Proc_Num_Side_Sets{nullptr}; /* Number of side sets on the current proc */
261
262 INT *Proc_SS_Elem_List_Length{nullptr};
263 /* Total length of all the side set node lists */
264 INT *Proc_SS_Side_List_Length{nullptr};
265 /* Total length of all the side set element *
266 * lists */
267
268 INT **Proc_SS_Ids{nullptr}; /* Side sets ids for side sets in a given *
269 * processor *
270 * Type: int vector of length *
271 * Proc_Num_Side_Sets */
272 INT **Proc_SS_Elem_Count{nullptr};
273 /* Side sets count record for elements (see the*
274 * EXODUS manual) for the side sets in a given *
275 * processor *
276 * Type: int vector of length *
277 * Proc_Num_Side_Sets */
278
279 INT **Proc_SS_DF_Pointers{nullptr};
280 /* Pointer into the distribution factors for *
281 * the side sets. *
282 * Type: int array of dimensions *
283 * Proc_Num_Side_Sets */
284
285 std::vector<std::vector<T>> Proc_SS_Dist_Fact{};
286 /* Pointer for storage of the distribution *
287 * factors. */
288
289 INT **Proc_SS_DF_Count{nullptr};
290 /* Count of the number of distribution *
291 * factors in this side set. *
292 * Type: int vector of length *
293 * Proc_Num_Side_Sets */
294
295 INT **Proc_SS_Side_Count{nullptr};
296 // Side sets count record for nodes (see the
297 // EXODUS manual) for the side sets in a given
298 // processor
299 // Type: int vector of length
300 // Proc_Num_Side_Sets
301
302 INT **Proc_SS_Elem_Pointers{nullptr};
303 /* Side sets pointer record for elements (see *
304 * the EXODUS manual) for the side sets in a *
305 * given processor *
306 * Type: int vector of length *
307 * Proc_Num_Side_Sets */
308
309 INT **Proc_SS_Side_Pointers{nullptr};
310 /* Side sets pointer record for nodes (see *
311 * the EXODUS manual) for the side sets in a *
312 * given processor *
313 * Type: int vector of length *
314 * Proc_Num_Side_Sets */
315
316 INT **Proc_SS_Elem_List{nullptr};
317 /* Side sets element list record for the side *
318 * sets in a given processor *
319 * Type: int vector of length *
320 * Proc_Num_Side_Sets */
321
322 INT **Proc_SS_Side_List{nullptr};
323 /* Side sets side list record for the side sets*
324 * in a given processor *
325 * Type: int vector of length *
326 * Proc_SS_Elem_List_Length */
327
328 INT **Proc_SS_GEMap_List{nullptr};
329 /* Map local element position to global sideset element list position *
330 * in a given processor *
331 * Type: int vector of length *
332 * Proc_SS_Elem_List_Length */
333
334 /*---------------------------------------------------------------------------*/
335 /* VARIABLES THAT DEAL WITH GENERAL INFORMATION THAT IS */
336 /* THE SAME ON EVERY PROCESSOR */
337 /*---------------------------------------------------------------------------*/
338
339 char **QA_Record{nullptr}; /* The QA Records from the original file */
340
341 char **Info_Record{nullptr}; /* The Information Records from the original *
342 * file */
343 INT *Coordinate_Frame_Ids{nullptr};
344 T *Coordinate_Frame_Coordinates{nullptr};
345 char *Coordinate_Frame_Tags{nullptr};
346
347 std::vector<ex_assembly> Assemblies{};
348
349 Globals() = default;
350
351 ~Globals()
352 {
353 safe_free((void **)&Proc_Num_Elem_Blk);
354 safe_free((void **)&Proc_Num_Node_Sets);
355 safe_free((void **)&Proc_Num_Side_Sets);
356 safe_free((void **)&Proc_NS_List_Length);
357 safe_free((void **)&Proc_SS_Elem_List_Length);
358
359 safe_free((void **)&Coor);
360
361 safe_free((void **)&Info_Record);
362 safe_free((void **)&GElem_Blks);
363 safe_free((void **)&Elem_Type);
364 safe_free((void **)&Elem_Type);
365 }
366 };