Debian Codegraph @

packages/pamgen/mesh_spec_lt/pamgen_mesh_specification.C

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 #include <ctype.h>
11 #include <assert.h>
12
13 #include "pamgen_element_dictionary.h"
14 #include "pamgen_mesh_specification.h"
15 #include <string.h>
16 #include <time.h>
17 #include <map>
18 #include <vector>
19
20 namespace ms_lt{
21
22 Mesh_Specification * ms_lt::Mesh_Specification::first_ms_static_storage = NULL;
23
24
25 /*****************************************************************************/
26 Mesh_Specification::Mesh_Specification()
27 /*****************************************************************************/
28 {
29 Zero_Set();
30 suppress_warnings = false; //Must be here not in Zero_Set()
31 }
32
33 /*****************************************************************************/
34 Mesh_Specification::~Mesh_Specification()
35 /*****************************************************************************/
36 {
37 if(next)delete next;
38 Free();
39 }
40
41 /*****************************************************************************/
42 bool Mesh_Specification::Are_Warnings_Suppressed() const
43 /*****************************************************************************/
44 {
45 return suppress_warnings;
46 }
47
48 /*****************************************************************************/
49 void Mesh_Specification::Suppress_Warnings(long long logical)
50 /*****************************************************************************/
51 {
52 suppress_warnings=logical;
53 }
54
55 /*****************************************************************************/
56 void Mesh_Specification::Resize_Info_Store(long long value)
57 /*****************************************************************************/
58 // Resize the space for info records so more information
59 // can be appended to the database
60 // value is the new total size of the information section
61 {
62 int j;
63
64 int old_num_info_records = msia[NUM_INFO_RECORDS];
65 msia[NUM_INFO_RECORDS] = value;
66
67 std::string* old_info_strings = mspsa[INFO_STRINGS];
68 mspsa[INFO_STRINGS] = new std::string[msia[NUM_INFO_RECORDS]];
69
70 for(j = 0; j < old_num_info_records; j++) {
71 mspsa[INFO_STRINGS][j] = old_info_strings[j];
72 }
73
74 delete [] old_info_strings;
75 }
76
77
78 /*****************************************************************************/
79 void Mesh_Specification::Specify_Global_Information(const std::string &titl,
80 long long dimen,
81 long long n_nodes,
82 long long n_elements,
83 long long n_blocks,
84 long long num_ns,
85 long long num_ss,
86 long long num_qa,
87 long long num_info)
88 /*****************************************************************************/
89 {
90 int i;
91
92 Free();
93
94 title = titl;
95 msia[DIM] = dimen;
96 msia[NUM_NODES] = n_nodes;
97 msia[NUM_ELEMENTS] = n_elements;
98 msia[NUM_BLOCKS] = n_blocks;
99 msia[NUM_NODE_SETS] = num_ns;
100 msia[NUM_SIDE_SETS] = num_ss;
101
102
103 msia[NUM_PARENT_MESHES] = 1;
104
105 if(n_blocks)mspa[BLOCK_PARENT_MESHES] = new long long[n_blocks];
106 if(num_ns) mspa[NODESET_PARENT_MESHES] = new long long[num_ns];
107 if(num_ss) mspa[SIDESET_PARENT_MESHES] = new long long[num_ss];
108
109
110
111 if (msia[NUM_NODES] && msia[DIM])
112 coord = new double[msia[NUM_NODES] * msia[DIM]];
113
114 if (msia[NUM_ELEMENTS])
115 mspa[ELEM_ORDER_MAP] = new long long[msia[NUM_ELEMENTS]];
116
117 if (msia[NUM_BLOCKS] > 0)
118 {
119 mspa[BLOCK_ID] = new long long[msia[NUM_BLOCKS]];
120 mspa[ELEMENTS_IN_BLOCK] = new long long[msia[NUM_BLOCKS]];
121 mspa[NODES_PER_ELEMENT] = new long long[msia[NUM_BLOCKS]];
122 mspa[ELEMENT_ATTRIBUTES] = new long long[msia[NUM_BLOCKS]];
123 block_element_type = new Element_Type[msia[NUM_BLOCKS]];
124 mspsa[ELEMENT_TYPES] = new std::string[msia[NUM_BLOCKS]];
125
126 msppa[ELMT_NODE_LINKAGE] = new long long*[msia[NUM_BLOCKS]];
127 msppda[ATTRIBUTES] = new double*[msia[NUM_BLOCKS]];
128 }
129
130 // set indexes double dimensioned arrays to NULL
131
132 for (long long b = 0; b < msia[NUM_BLOCKS]; ++b)
133 {
134 mspa[BLOCK_ID][b] = 0;
135 mspa[BLOCK_PARENT_MESHES][b] = 0;
136 mspa[ELEMENTS_IN_BLOCK][b] = 0;
137 mspa[NODES_PER_ELEMENT][b] = 0;
138 mspa[ELEMENT_ATTRIBUTES][b] = 0;
139 block_element_type[b] = UNKNOWN_ELEMENT;
140
141 msppa[ELMT_NODE_LINKAGE][b] = NULL;
142 msppda[ATTRIBUTES][b] = NULL;
143 }
144
145 if (msia[NUM_NODE_SETS] > 0)
146 {
147 mspa[NODE_SET_ID] = new long long[msia[NUM_NODE_SETS]];
148 mspa[NUM_NODES_IN_NODE_SET] = new long long[msia[NUM_NODE_SETS]];
149 mspa[NUM_DF_IN_NODE_SET] = new long long[msia[NUM_NODE_SETS]];
150
151 msppa[NODE_SET_NODES] = new long long*[msia[NUM_NODE_SETS]];
152 msppda[NODE_SET_DF] = new double*[msia[NUM_NODE_SETS]];
153
154 for(i = 0; i < msia[NUM_NODE_SETS]; i++) {
155 mspa[NODESET_PARENT_MESHES][i] = 0;
156 mspa[NODE_SET_ID][i] = 0;
157 mspa[NUM_NODES_IN_NODE_SET][i] = 0;
158 mspa[NUM_DF_IN_NODE_SET][i] = 0;
159 msppa[NODE_SET_NODES][i] = NULL;
160 msppda[NODE_SET_DF][i] = NULL;
161 }
162 }
163
164 if (msia[NUM_SIDE_SETS] > 0)
165 {
166 mspa[SIDE_SET_ID] = new long long[msia[NUM_SIDE_SETS]];
167 mspa[NUM_ELEMENTS_IN_SIDE_SET] = new long long[msia[NUM_SIDE_SETS]];
168 mspa[NUM_NODES_IN_SIDE_SET] = new long long[msia[NUM_SIDE_SETS]];
169 mspa[NUM_DF_IN_SIDE_SET] = new long long[msia[NUM_SIDE_SETS]];
170
171 msppa[SIDE_SET_ELEMENTS] = new long long*[msia[NUM_SIDE_SETS]];
172 msppa[SIDE_SET_NODE_COUNTER] = new long long*[msia[NUM_SIDE_SETS]];
173 msppa[SIDE_SET_FACES] = new long long*[msia[NUM_SIDE_SETS]];
174 msppa[SIDE_SET_NODES] = new long long*[msia[NUM_SIDE_SETS]];
175 msppda[SIDE_SET_DF] = new double*[msia[NUM_SIDE_SETS]];
176
177 for (i = 0; i < msia[NUM_SIDE_SETS]; ++i)
178 {
179 mspa[SIDESET_PARENT_MESHES][i] = 0;
180 mspa[SIDE_SET_ID][i] = 0;
181 mspa[NUM_ELEMENTS_IN_SIDE_SET][i] = 0;
182 mspa[NUM_NODES_IN_SIDE_SET][i] = 0;
183 mspa[NUM_DF_IN_SIDE_SET][i] = 0;
184 msppa[SIDE_SET_ELEMENTS][i] = NULL;
185 msppa[SIDE_SET_NODE_COUNTER][i] = NULL;
186 msppa[SIDE_SET_FACES][i] = NULL;
187 msppa[SIDE_SET_NODES][i] = NULL;
188 msppda[SIDE_SET_DF][i] = NULL;
189 }
190 }
191
192 if (msia[NUM_ELEMENTS] > 0) mspa[GLOBAL_ELEMENT_NUMBERS] = new long long[msia[NUM_ELEMENTS]];
193 if (msia[NUM_NODES] > 0) mspa[GLOBAL_NODE_NUMBERS] = new long long[msia[NUM_NODES]];
194
195 mspsa[COORDINATE_NAMES] = new std::string[msia[DIM]];
196
197 msia[NUM_QA_RECORDS] = num_qa;
198 msia[NUM_INFO_RECORDS] = num_info;
199
200 if (num_qa > 0)
201 qa_strings = new std::string[num_qa][4];
202
203 if (num_info > 0)
204 mspsa[INFO_STRINGS] = new std::string[num_info];
205 }
206
207
208 /*****************************************************************************/
209 void Mesh_Specification::Specify_Block_Information(long long b,
210 long long id,
211 long long number_of_block_elements,
212 long long number_of_nodes_per_element,
213 long long number_of_element_attributes,
214 Element_Type type)
215 /*****************************************************************************/
216 {
217 assert(mspa[BLOCK_ID] != 0);
218 assert(mspa[ELEMENTS_IN_BLOCK] != 0);
219 assert(mspa[NODES_PER_ELEMENT] != 0);
220 assert(mspa[ELEMENT_ATTRIBUTES] != 0);
221 assert(block_element_type != 0);
222 assert(msppa[ELMT_NODE_LINKAGE] != 0);
223 assert(msppda[ATTRIBUTES] != 0);
224
225 mspa[BLOCK_ID][b] = id;
226 mspa[ELEMENTS_IN_BLOCK][b] = number_of_block_elements;
227 mspa[NODES_PER_ELEMENT][b] = number_of_nodes_per_element;
228 mspa[ELEMENT_ATTRIBUTES][b] = number_of_element_attributes;
229 block_element_type[b] = type;
230
231 msppa[ELMT_NODE_LINKAGE][b] = new long long[mspa[ELEMENTS_IN_BLOCK][b]*mspa[NODES_PER_ELEMENT][b]];
232 msppda[ATTRIBUTES][b] = new double[mspa[ELEMENTS_IN_BLOCK][b]*mspa[ELEMENT_ATTRIBUTES][b]];
233 }
234
235
236 /*****************************************************************************/
237 void Mesh_Specification::
238 Specify_Node_Set_Information(long long i,
239 long long id,
240 long long number_of_nodes_in_node_set,
241 long long number_of_df_in_node_set)
242 /*****************************************************************************/
243 {
244 assert(mspa[NODE_SET_ID]);
245 assert(mspa[NUM_NODES_IN_NODE_SET]);
246 assert(mspa[NUM_DF_IN_NODE_SET]);
247 assert(msppa[NODE_SET_NODES]);
248 assert(msppda[NODE_SET_DF]);
249
250 mspa[NODE_SET_ID][i] = id;
251 mspa[NUM_NODES_IN_NODE_SET][i] = number_of_nodes_in_node_set;
252 mspa[NUM_DF_IN_NODE_SET][i] = number_of_df_in_node_set;
253 msppa[NODE_SET_NODES][i] = new long long[number_of_nodes_in_node_set];
254 msppda[NODE_SET_DF][i] = new double[number_of_df_in_node_set];
255 }
256
257 /*****************************************************************************/
258 void Mesh_Specification::Specify_Side_Set_Information(long long i,
259 long long id,
260 long long number_of_faces_in_side_set,
261 long long number_of_nodes_in_side_set,
262 long long number_of_df_in_side_set)
263 /*****************************************************************************/
264 {
265 assert(mspa[SIDE_SET_ID]);
266 assert(mspa[NUM_ELEMENTS_IN_SIDE_SET]);
267 assert(mspa[NUM_NODES_IN_SIDE_SET]);
268 assert(mspa[NUM_DF_IN_SIDE_SET]);
269 assert(msppa[SIDE_SET_ELEMENTS]);
270 assert(msppa[SIDE_SET_NODE_COUNTER]);
271 assert(msppa[SIDE_SET_FACES]);
272 assert(msppa[SIDE_SET_NODES]);
273 assert(msppda[SIDE_SET_DF]);
274
275 mspa[SIDE_SET_ID][i] = id;
276 mspa[NUM_ELEMENTS_IN_SIDE_SET][i] = number_of_faces_in_side_set;
277 mspa[NUM_NODES_IN_SIDE_SET][i] = number_of_nodes_in_side_set;
278 mspa[NUM_DF_IN_SIDE_SET][i] = number_of_df_in_side_set;
279 msppa[SIDE_SET_ELEMENTS][i] = new long long[number_of_faces_in_side_set];
280 msppa[SIDE_SET_NODE_COUNTER][i] = new long long[number_of_faces_in_side_set];
281 msppa[SIDE_SET_FACES][i] = new long long[number_of_faces_in_side_set];
282 msppa[SIDE_SET_NODES][i] = new long long[number_of_nodes_in_side_set];
283 msppda[SIDE_SET_DF][i] = new double[number_of_df_in_side_set];
284 }
285
286 /*****************************************************************************/
287 void Mesh_Specification::Free_NonTransient_Storage()
288 /*****************************************************************************/
289 // Frees all storage except that which contains data required for an EXODUS
290 // time step dump. The data items retained are:
291 // long long *mspa[BLOCK_ID];
292 // long long *mspa[ELEMENTS_IN_BLOCK];
293 {
294 long long i, b;
295
296 delete[] coord;
297 delete[] mspa[ELEM_ORDER_MAP];
298 delete[] mspa[NODES_PER_ELEMENT];
299 delete[] mspa[ELEMENT_ATTRIBUTES];
300 delete[] block_element_type;
301
302 delete[] mspa[BLOCK_PARENT_MESHES];
303 delete[] mspa[NODESET_PARENT_MESHES];
304 delete[] mspa[SIDESET_PARENT_MESHES];
305
306
307 if (msppa[ELMT_NODE_LINKAGE]){
308 for (b = 0; b < msia[NUM_BLOCKS]; b++) {
309 if (msppa[ELMT_NODE_LINKAGE][b]) delete[] msppa[ELMT_NODE_LINKAGE][b];
310 }
311 delete[] msppa[ELMT_NODE_LINKAGE];
312 }
313
314 if (msppda[ATTRIBUTES]){
315 for (b = 0; b < msia[NUM_BLOCKS]; b++) {
316 if (msppda[ATTRIBUTES][b]) delete[] msppda[ATTRIBUTES][b];
317 }
318 delete[] msppda[ATTRIBUTES];
319 }
320
321
322 delete[] mspa[NODE_SET_ID];
323 delete[] mspa[NUM_NODES_IN_NODE_SET];
324 delete[] mspa[NUM_DF_IN_NODE_SET];
325 if (msppa[NODE_SET_NODES]){
326 for (i=0; i<msia[NUM_NODE_SETS]; i++){
327 delete[] msppa[NODE_SET_NODES][i];
328 delete[] msppda[NODE_SET_DF][i];
329 }
330 delete[] msppa[NODE_SET_NODES];
331 delete[] msppda[NODE_SET_DF];
332 }
333
334 delete[] mspa[SIDE_SET_ID];
335 delete[] mspa[NUM_ELEMENTS_IN_SIDE_SET];
336 delete[] mspa[NUM_NODES_IN_SIDE_SET];
337 delete[] mspa[NUM_DF_IN_SIDE_SET];
338
339 if (msppa[SIDE_SET_ELEMENTS]){
340 for (i=0; i<msia[NUM_SIDE_SETS]; i++){
341 delete[] msppa[SIDE_SET_ELEMENTS][i];
342 delete[] msppa[SIDE_SET_NODE_COUNTER][i];
343 delete[] msppa[SIDE_SET_NODES][i];
344 delete[] msppda[SIDE_SET_DF][i];
345 delete[] msppa[SIDE_SET_FACES][i];
346 }
347 }
348
349 delete[] msppa[SIDE_SET_ELEMENTS];
350 delete[] msppa[SIDE_SET_NODE_COUNTER];
351 delete[] msppa[SIDE_SET_FACES];
352 delete[] msppa[SIDE_SET_NODES];
353 delete[] msppda[SIDE_SET_DF];
354
355 delete[] qa_strings;
356
357 delete[] mspsa[INFO_STRINGS];
358
359 delete[] mspsa[COORDINATE_NAMES];
360
361 delete[] mspsa[ELEMENT_TYPES];
362
363 delete[] mspa[GLOBAL_ELEMENT_NUMBERS];
364 delete[] mspa[GLOBAL_NODE_NUMBERS];
365
366
367 if (mspa[NBR_PROC_LIST]) delete [] mspa[NBR_PROC_LIST];
368
369 //Parallel data
370 Free_Parallel_Data();
371 Free_Locational_Data();
372 Free_Global_Data();
373
374
375 msia[NUM_NODE_SETS] = 0;
376
377 msia[NUM_SIDE_SETS] = 0;
378
379
380 coord = NULL;
381 mspa[ELEM_ORDER_MAP] = NULL;
382
383 mspa[NODES_PER_ELEMENT] = NULL;
384 mspa[ELEMENT_ATTRIBUTES] = NULL;
385 block_element_type = NULL;
386
387 msppa[ELMT_NODE_LINKAGE] = NULL;
388 msppda[ATTRIBUTES] = NULL;
389
390 mspa[NODE_SET_ID] = NULL;
391 mspa[NUM_NODES_IN_NODE_SET] = NULL;
392 mspa[NUM_DF_IN_NODE_SET] = NULL;
393 msppa[NODE_SET_NODES] = NULL;
394 msppda[NODE_SET_DF] = NULL;
395
396 mspa[SIDE_SET_ID] = NULL;
397 mspa[NUM_ELEMENTS_IN_SIDE_SET] = NULL;
398 mspa[NUM_NODES_IN_SIDE_SET] = NULL;
399 mspa[NUM_DF_IN_SIDE_SET] = NULL;
400 msppa[SIDE_SET_ELEMENTS] = NULL;
401 msppa[SIDE_SET_NODE_COUNTER] = NULL;
402 msppa[SIDE_SET_FACES] = NULL;
403 msppa[SIDE_SET_NODES] = NULL;
404 msppda[SIDE_SET_DF] = NULL;
405
406 msia[NUM_QA_RECORDS] = 0;
407 msia[NUM_INFO_RECORDS] = 0;
408
409 qa_strings = NULL;
410 mspsa[INFO_STRINGS] = NULL;
411 mspsa[COORDINATE_NAMES] = NULL;
412 mspsa[ELEMENT_TYPES] = NULL;
413
414 mspa[GLOBAL_ELEMENT_NUMBERS] = NULL;
415 mspa[GLOBAL_NODE_NUMBERS] = NULL;
416
417 msia[NUM_EDGES] = 0;
418 msia[NUM_FACES] = 0;
419
420 msia[NUM_NBR_PROCS] = 0;
421 mspa[NBR_PROC_LIST] = NULL;
422
423 return;
424 }
425
426 /*****************************************************************************/
427 void Mesh_Specification::Zero_Set()
428 /*****************************************************************************/
429 // Set the mesh object to correspond to the empty mesh.
430 {
431
432 for(long long i = 0; i < NUM_MSIA;i ++)msia[i] = 0;
433 for(long long i = 0; i < NUM_MSPA;i ++)mspa[i] = NULL;
434 for(long long i = 0; i < NUM_MSPPA;i ++)msppa[i] = NULL;
435 for(long long i = 0; i < NUM_MSPPDA;i ++)msppda[i] = NULL;
436 for(long long i = 0; i < NUM_MSPSA;i ++)mspsa[i] = NULL;
437
438 next = NULL;
439
440 coord = NULL;
441 qa_strings = NULL;
442 block_element_type = NULL;
443
444 }
445
446 /*****************************************************************************/
447 void Mesh_Specification::Free()
448 /*****************************************************************************/
449 {
450 Free_NonTransient_Storage();
451 if (mspa[BLOCK_ID] != 0) delete [] mspa[BLOCK_ID];
452 if (mspa[ELEMENTS_IN_BLOCK] != 0) delete [] mspa[ELEMENTS_IN_BLOCK];
453
454 Zero_Set();
455 return;
456 }
457
458 /*****************************************************************************/
459 void Mesh_Specification::Parallel_Data_Size(long long i_num_internal_nodes,
460 long long i_num_border_nodes,
461 long long i_num_external_nodes,
462 long long i_num_internal_elems,
463 long long i_num_border_elems,
464 long long i_num_node_comm_maps,
465 long long i_num_elem_comm_maps)
466 /*****************************************************************************/
467 {
468 msia[NUM_INTERNAL_NODES] = i_num_internal_nodes;
469 msia[NUM_BORDER_NODES] = i_num_border_nodes;
470 msia[NUM_EXTERNAL_NODES] = i_num_external_nodes;
471 msia[NUM_INTERNAL_ELEMS] = i_num_internal_elems;
472 msia[NUM_BORDER_ELEMS] = i_num_border_elems;
473 msia[NUM_NODE_COMM_MAPS] = i_num_node_comm_maps;
474 msia[NUM_ELEM_COMM_MAPS] = i_num_elem_comm_maps;
475 Allocate_Locational_Data();
476 Allocate_LoadBal_Data();
477 }
478
479
480 /*****************************************************************************/
481 void Mesh_Specification::Allocate_Locational_Data()
482 /*****************************************************************************/
483 {
484 if(msia[NUM_INTERNAL_ELEMS]) mspa[INTERNAL_ELEMENTS] = new long long[msia[NUM_INTERNAL_ELEMS]];
485 if(msia[NUM_BORDER_ELEMS]) mspa[BORDER_ELEMENTS] = new long long[msia[NUM_BORDER_ELEMS]];
486
487 if(msia[NUM_INTERNAL_NODES]) mspa[INTERNAL_NODES] = new long long[msia[NUM_INTERNAL_NODES]];
488 if(msia[NUM_BORDER_NODES]) mspa[BORDER_NODES] = new long long[msia[NUM_BORDER_NODES]];
489 if(msia[NUM_EXTERNAL_NODES]) mspa[EXTERNAL_NODES] = new long long[msia[NUM_EXTERNAL_NODES]];
490 }
491
492 /*****************************************************************************/
493 void Mesh_Specification::Free_Locational_Data()
494 /*****************************************************************************/
495 {
496 if(msia[NUM_INTERNAL_ELEMS]) delete [] mspa[INTERNAL_ELEMENTS];// = new int[msia[NUM_INTERNAL_ELEMS]];
497 if(msia[NUM_BORDER_ELEMS]) delete [] mspa[BORDER_ELEMENTS];// = new int[msia[NUM_BORDER_ELEMS]];
498
499 if(msia[NUM_INTERNAL_NODES]) delete [] mspa[INTERNAL_NODES];// = new int[msia[NUM_INTERNAL_NODES]];
500 if(msia[NUM_BORDER_NODES]) delete [] mspa[BORDER_NODES];// = new int[msia[NUM_BORDER_NODES]];
501 if(msia[NUM_EXTERNAL_NODES]) delete [] mspa[EXTERNAL_NODES];// = new int[msia[NUM_EXTERNAL_NODES]];
502 }
503
504 /*****************************************************************************/
505 void Mesh_Specification::Allocate_LoadBal_Data()
506 /*****************************************************************************/
507 {
508 if(msia[NUM_NODE_COMM_MAPS]) {
509 mspa[NODE_CMAP_NODE_CNTS] = new long long[msia[NUM_NODE_COMM_MAPS]];
510 mspa[NODE_CMAP_IDS] = new long long[msia[NUM_NODE_COMM_MAPS]];
511 msppa[COMM_NODE_IDS] = new long long*[msia[NUM_NODE_COMM_MAPS]];
512 msppa[COMM_NODE_PROC_IDS] = new long long*[msia[NUM_NODE_COMM_MAPS]];
513 }
514
515 if(msia[NUM_ELEM_COMM_MAPS]) {
516 mspa[ELEM_CMAP_ELEM_CNTS] = new long long[msia[NUM_ELEM_COMM_MAPS]];
517 mspa[ELEM_CMAP_IDS] = new long long[msia[NUM_ELEM_COMM_MAPS]];
518 msppa[COMM_ELEM_IDS] = new long long*[msia[NUM_ELEM_COMM_MAPS]];
519 msppa[COMM_SIDE_IDS] = new long long*[msia[NUM_ELEM_COMM_MAPS]];
520 msppa[COMM_ELEM_PROC_IDS] = new long long*[msia[NUM_ELEM_COMM_MAPS]];
521 }
522 }
523
524 /*****************************************************************************/
525 void Mesh_Specification::Allocate_Global_Data()
526 /*****************************************************************************/
527 {
528 if( msia[NUM_ELM_BLKS_GLOBAL] ){
529 mspa[ELEM_BLK_IDS_GLOBAL] = new long long[msia[NUM_ELM_BLKS_GLOBAL]];
530 mspa[ELEM_BLK_CNTS_GLOBAL] = new long long[msia[NUM_ELM_BLKS_GLOBAL]];
531 }
532 if( msia[NUM_NODE_SETS_GLOBAL] ){
533 mspa[NS_IDS_GLOBAL] = new long long[msia[NUM_NODE_SETS_GLOBAL]];
534 mspa[NS_CNTS_GLOBAL] = new long long[msia[NUM_NODE_SETS_GLOBAL]];
535 mspa[NS_DF_CNTS_GLOBAL] = new long long[msia[NUM_NODE_SETS_GLOBAL]];
536 for(long long i = 0; i < msia[NUM_NODE_SETS_GLOBAL]; i++){
537 mspa[NS_IDS_GLOBAL][i] = 0;
538 mspa[NS_DF_CNTS_GLOBAL][i] = 0;
539 mspa[NS_DF_CNTS_GLOBAL][i] = 0;
540 }
541 }
542 if( msia[NUM_SIDE_SETS_GLOBAL] ){
543 mspa[SS_IDS_GLOBAL] = new long long[msia[NUM_SIDE_SETS_GLOBAL]];
544 mspa[SS_CNTS_GLOBAL] = new long long[msia[NUM_SIDE_SETS_GLOBAL]];
545 mspa[SS_DF_CNTS_GLOBAL] = new long long[msia[NUM_SIDE_SETS_GLOBAL]];
546 for(long long i = 0; i < msia[NUM_SIDE_SETS_GLOBAL];i ++){
547 mspa[SS_IDS_GLOBAL][i] = 0;
548 mspa[SS_CNTS_GLOBAL][i] = 0;
549 mspa[SS_DF_CNTS_GLOBAL][i] = 0;
550 }
551 }
552 }
553
554 /*****************************************************************************/
555 void Mesh_Specification::Free_Global_Data()
556 /*****************************************************************************/
557 {
558 if( msia[NUM_ELM_BLKS_GLOBAL] ){
559 delete [] mspa[ELEM_BLK_IDS_GLOBAL];// = new int[msia[NUM_ELM_BLKS_GLOBAL]];
560 delete [] mspa[ELEM_BLK_CNTS_GLOBAL];// = new int[msia[NUM_ELM_BLKS_GLOBAL]];
561 }
562 if( msia[NUM_NODE_SETS_GLOBAL] ){
563 delete [] mspa[NS_IDS_GLOBAL];// = new int[msia[NUM_NODE_SETS_GLOBAL]];
564 delete [] mspa[NS_CNTS_GLOBAL];// = new int[msia[NUM_NODE_SETS_GLOBAL]];
565 delete [] mspa[NS_DF_CNTS_GLOBAL];// = new int[msia[NUM_NODE_SETS_GLOBAL]];
566 }
567 if( msia[NUM_SIDE_SETS_GLOBAL] ){
568 delete [] mspa[SS_IDS_GLOBAL];// = new int[msia[NUM_SIDE_SETS_GLOBAL]];
569 delete [] mspa[SS_CNTS_GLOBAL];// = new int[msia[NUM_SIDE_SETS_GLOBAL]];
570 delete [] mspa[SS_DF_CNTS_GLOBAL];// = new int[msia[NUM_SIDE_SETS_GLOBAL]];
571 }
572 }
573
574 //DMH the Rank here is redundant...
575 /*****************************************************************************/
576 void Mesh_Specification::Global_Data_Size( long long Num_Nodes_Global, long long Num_Elems_Global,
577 long long Num_Elem_Blks, long long Num_Node_Sets,
578 long long Num_Side_Sets, long long Num_Total_Procs,
579 long long Rank)
580 /*****************************************************************************/
581 {
582 msia[NUM_NODES_GLOBAL] = Num_Nodes_Global;
583 msia[NUM_ELEMS_GLOBAL] = Num_Elems_Global;
584 msia[NUM_ELM_BLKS_GLOBAL] = Num_Elem_Blks;
585 msia[NUM_NODE_SETS_GLOBAL] = Num_Node_Sets;
586 msia[NUM_SIDE_SETS_GLOBAL] = Num_Side_Sets;
587 msia[NUM_TOTAL_PROC] = Num_Total_Procs;
588 msia[PROC_ID] = Rank;
589 msia[NUM_PROC_IN_FILE] = 1;
590 std::string fileType("p");
591 file_type = fileType;
592 Allocate_Global_Data();
593 }
594
595
596 /*****************************************************************************/
597 void Mesh_Specification::Allocate_Parallel_Data()
598 /*****************************************************************************/
599 {
600 for(long long i = 0; i < msia[NUM_NODE_COMM_MAPS]; i++) {
601 if(mspa[NODE_CMAP_NODE_CNTS][i]) {
602 msppa[COMM_NODE_IDS][i] = new long long[mspa[NODE_CMAP_NODE_CNTS][i]];
603 msppa[COMM_NODE_PROC_IDS][i] = new long long[mspa[NODE_CMAP_NODE_CNTS][i]];
604 }
605 }
606
607 for(long long i = 0; i < msia[NUM_ELEM_COMM_MAPS]; i++) {
608 if(mspa[ELEM_CMAP_ELEM_CNTS][i]) {
609 msppa[COMM_ELEM_IDS][i] = new long long[mspa[ELEM_CMAP_ELEM_CNTS][i]];
610 msppa[COMM_SIDE_IDS][i] = new long long[mspa[ELEM_CMAP_ELEM_CNTS][i]];
611 msppa[COMM_ELEM_PROC_IDS][i] = new long long[mspa[ELEM_CMAP_ELEM_CNTS][i]];
612 }
613 }
614
615 return;
616 }
617
618 /*****************************************************************************/
619 void Mesh_Specification::Free_Parallel_Data()
620 /*****************************************************************************/
621 {
622 for(long long i = 0; i < msia[NUM_NODE_COMM_MAPS]; i++) {
623 if(mspa[NODE_CMAP_NODE_CNTS][i]) {
624 delete [] msppa[COMM_NODE_IDS][i];// = new int[mspa[NODE_CMAP_NODE_CNTS][i]];
625 delete [] msppa[COMM_NODE_PROC_IDS][i];// = new int[mspa[NODE_CMAP_NODE_CNTS][i]];
626 }
627 }
628 delete [] msppa[COMM_NODE_IDS];
629 delete [] msppa[COMM_NODE_PROC_IDS];
630
631 for(long long i = 0; i < msia[NUM_ELEM_COMM_MAPS]; i++) {
632 if(mspa[ELEM_CMAP_ELEM_CNTS][i]) {
633 delete [] msppa[COMM_ELEM_IDS][i];// = new int[mspa[ELEM_CMAP_ELEM_CNTS][i]];
634 delete [] msppa[COMM_SIDE_IDS][i];// = new int[mspa[ELEM_CMAP_ELEM_CNTS][i]];
635 delete [] msppa[COMM_ELEM_PROC_IDS][i];// = new int[mspa[ELEM_CMAP_ELEM_CNTS][i]];
636 }
637 }
638 delete [] msppa[COMM_ELEM_IDS];
639 delete [] msppa[COMM_SIDE_IDS];
640 delete [] msppa[COMM_ELEM_PROC_IDS];
641
642 if(msia[NUM_NODE_COMM_MAPS]) {
643 delete [] mspa[NODE_CMAP_NODE_CNTS];// = new int[msia[NUM_NODE_COMM_MAPS]];
644 delete [] mspa[NODE_CMAP_IDS];// = new int[msia[NUM_NODE_COMM_MAPS]];
645 }
646
647 if(msia[NUM_ELEM_COMM_MAPS]) {
648 delete [] mspa[ELEM_CMAP_ELEM_CNTS];// = new int[msia[NUM_ELEM_COMM_MAPS]];
649 delete [] mspa[ELEM_CMAP_IDS];// = new int[msia[NUM_ELEM_COMM_MAPS]];
650 }
651
652 return;
653 }
654
655 /*****************************************************************************/
656 Mesh_Specification * Mesh_Specification::consolidateMS()
657 /*****************************************************************************/
658 {
659 if(this->Next() == NULL)return this;
660 ms_lt::Mesh_Specification * ndb = new ms_lt::Mesh_Specification();
661 if(!ndb)return ndb;
662 /*global info*/
663 {
664 long long nn = 0;
665 long long ne = 0;
666 long long nns = 0;
667 long long nss = 0;
668 long long nb = 0;
669 long long submesh_count = 0;
670 Mesh_Specification * ms = this;
671 while(ms){
672 nn += ms->getMSI(NUM_NODES);
673 ne += ms->getMSI(NUM_ELEMENTS);
674 nb += ms->getMSI(NUM_BLOCKS);
675 nns += ms->getMSI(NUM_NODE_SETS);
676 nss += ms->getMSI(NUM_SIDE_SETS);
677 ms = ms->Next();
678 }
679 ndb->Specify_Global_Information(std::string ("PAMGEN Consolidated Mesh"),
680 this->getMSI(DIM),
681 nn,//num nodes
682 ne,//num elements
683 nb,//num blocks
684 nns,//num node sets
685 nss,//num side sets
686 1,//num qa recs
687 0//num info recs
688 );
689
690 long long * bp = ndb->getMSP(ms_lt::Mesh_Specification::BLOCK_PARENT_MESHES);
691 long long * nsp = ndb->getMSP(ms_lt::Mesh_Specification::NODESET_PARENT_MESHES);
692 long long * ssp = ndb->getMSP(ms_lt::Mesh_Specification::SIDESET_PARENT_MESHES);
693
694 ms = this;
695 nb = 0;
696 nns = 0;
697 nss = 0;
698 while(ms){
699 for(int nbct = nb;nbct < nb+ ms->getMSI(NUM_BLOCKS);nbct++) bp[nbct] = submesh_count;
700 for(int nsct = nns;nsct < nns+ ms->getMSI(NUM_NODE_SETS);nsct++)nsp[nsct] = submesh_count;
701 for(int ssct = nss;ssct < nss+ ms->getMSI(NUM_SIDE_SETS);ssct++)ssp[ssct] = submesh_count;
702 nb += ms->getMSI(NUM_BLOCKS);
703 nns += ms->getMSI(NUM_NODE_SETS);
704 nss += ms->getMSI(NUM_SIDE_SETS);
705 submesh_count ++;
706 ms = ms->Next();
707 }
708 msia[ms_lt::Mesh_Specification::NUM_PARENT_MESHES] = submesh_count;
709 }
710
711
712 time_t tim = time(NULL);
713 char * s = ctime(&tim);
714 s[strlen(s)-1]=0;
715
716 typedef std::string QA_Record[4];
717 QA_Record * qa_recs = ndb->QA_Records();
718 qa_recs[0][0] = "PAMGEN";
719 qa_recs[0][1] = "PArallel Mesh GENerator";
720 qa_recs[0][2] = s;
721 qa_recs[0][3] = s;
722
723
724 std::string *coord_names = ndb->getMSPSA(ms_lt::Mesh_Specification::COORDINATE_NAMES);
725 coord_names[0] = "X";
726 coord_names[1] = "Y";
727 if(this->getMSI(DIM) ==3){
728 coord_names[2] = "Z";
729 }
730
731 /*copy coordinates*/
732 {
733 double * dest = ndb->Coord();
734 int dim = this->getMSI(DIM);
735 Mesh_Specification * ms = this;
736 long long total_nodes = ndb->getMSI(NUM_NODES);
737 long long tct = 0;
738 while (ms){
739 double * source = ms->Coord();
740 long long sub_total_nodes = ms->getMSI(NUM_NODES);
741 for(long long ict = 0; ict < sub_total_nodes;ict ++,tct ++){
742 for(int dct = 0; dct < dim; dct ++){
743 dest[tct + dct * total_nodes] = source[ict + dct * sub_total_nodes];
744 }
745 }
746 ms = ms->next;
747 }
748 }
749 //Side set information
750 {
751 long long nsct = 0;
752 long long the_num_side_set_nodes = 0;
753 Mesh_Specification * ms = this;
754 while(ms){
755 long long * ne_in_ss = ms->getMSP(NUM_ELEMENTS_IN_SIDE_SET);
756 long long * nn_in_ss = ms->getMSP(NUM_NODES_IN_SIDE_SET);
757 long long * ss_id = ms->getMSP(SIDE_SET_ID);
758
759 for(int ssct = 0; ssct < ms->getMSI(NUM_SIDE_SETS);ssct ++,nsct ++){
760 ndb->Specify_Side_Set_Information(nsct,//the index
761 ss_id[ssct],//the id
762 ne_in_ss[ssct],
763 nn_in_ss[ssct],
764 0);
765 the_num_side_set_nodes += nn_in_ss[ssct];
766 }
767 ms = ms->Next();
768 }
769 ndb->setMSI(ms_lt::Mesh_Specification::NUM_SIDE_SET_NODES,the_num_side_set_nodes);
770 }
771
772 {
773 long long * const * dside_set_elements = ndb->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_ELEMENTS);
774 long long * const * dside_set_faces = ndb->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_FACES);
775 long long * const * dside_set_nodes = ndb->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_NODES);
776 long long * const * dside_set_node_counter = ndb->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_NODE_COUNTER);
777 Mesh_Specification * ms = this;
778 int nsct = 0;
779 int node_offset = 0;
780 int element_offset = 0;
781 while(ms){
782 long long * ne_in_ss = ms->getMSP(NUM_ELEMENTS_IN_SIDE_SET);
783 long long * nn_in_ss = ms->getMSP(NUM_NODES_IN_SIDE_SET);
784
785 long long * const * sside_set_elements = ms->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_ELEMENTS);
786 long long * const * sside_set_faces = ms->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_FACES);
787 long long * const * sside_set_nodes = ms->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_NODES);
788 long long * const * sside_set_node_counter = ms->getMSPP(ms_lt::Mesh_Specification::SIDE_SET_NODE_COUNTER);
789 for(int ssct = 0; ssct < ms->getMSI(NUM_SIDE_SETS);ssct ++,nsct ++){
790 long long * sthe_elements = sside_set_elements[ssct];
791 long long * sthe_faces = sside_set_faces[ssct];
792 long long * sthe_nodes = sside_set_nodes[ssct];
793 long long * sthe_node_counter = sside_set_node_counter[ssct];
794
795 long long * dthe_elements = dside_set_elements[nsct];
796 long long * dthe_faces = dside_set_faces[nsct];
797 long long * dthe_nodes = dside_set_nodes[nsct];
798 long long * dthe_node_counter = dside_set_node_counter[nsct];
799
800 for(int tct = 0; tct < ne_in_ss[ssct];tct ++){
801 dthe_elements[tct] = sthe_elements[tct]+element_offset;
802 dthe_faces[tct] = sthe_faces[tct];
803 dthe_node_counter[tct] = sthe_node_counter[tct];
804 }
805 for(int nct = 0; nct < nn_in_ss[ssct];nct++){
806 dthe_nodes[nct] = sthe_nodes[nct]+node_offset;
807 }
808
809 }
810 node_offset += ms->getMSI(NUM_NODES);
811 element_offset += ms->getMSI(NUM_ELEMENTS);
812 ms = ms->Next();
813 }
814 }
815
816 //Node set information
817 {
818 long long nsct = 0;
819 Mesh_Specification * ms = this;
820 while(ms){
821 long long * nn_in_ns = ms->getMSP(NUM_NODES_IN_NODE_SET);
822 long long * ns_id = ms->getMSP(NODE_SET_ID);
823
824 for(int ct = 0; ct < ms->getMSI(NUM_NODE_SETS);ct ++,nsct ++){
825 ndb->Specify_Node_Set_Information(nsct,//the index
826 ns_id[ct],//the id
827 nn_in_ns[ct],
828 0);
829 }
830 ms = ms->Next();
831 }
832 }
833 // populate nodeset info
834 {
835 Mesh_Specification * ms = this;
836 int nsct = 0;
837 long long node_offset = 0;
838 long long * const * dnode_set_nodes = ndb->getMSPP(ms_lt::Mesh_Specification::NODE_SET_NODES);
839 while(ms){
840 long long * const * snode_set_nodes = ms->getMSPP(ms_lt::Mesh_Specification::NODE_SET_NODES);
841 long long * num_nodes_in_set = ms->getMSP(ms_lt::Mesh_Specification::NUM_NODES_IN_NODE_SET);
842
843 for(int ct = 0; ct < ms->getMSI(NUM_NODE_SETS);ct ++,nsct ++){
844 long long * dthe_nodes = dnode_set_nodes[nsct];
845 long long * sthe_nodes = snode_set_nodes[ct];
846 for(int nct = 0;nct < num_nodes_in_set[ct];nct ++){
847 dthe_nodes[nct] = sthe_nodes[nct]+node_offset;
848 }
849 }
850 node_offset += ms->getMSI(NUM_NODES);
851 ms = ms->Next();
852 }
853 }
854 //connectivity
855 {
856 int dim = this->getMSI(DIM);
857 Element_Type the_element_type = HEX8;
858 if(dim == 2){
859 the_element_type = QUAD4;
860 }
861
862 int block_count = 0;
863 int block_offset = 0;
864 int tblock_offset = 0;
865
866 Mesh_Specification * ms = this;
867 while(ms){
868 long long snb = ms->getMSI(ms_lt::Mesh_Specification::NUM_BLOCKS);
869 long long * sbids = ms->getMSP(ms_lt::Mesh_Specification::BLOCK_ID);
870 long long * seib = ms->getMSP(ms_lt::Mesh_Specification::ELEMENTS_IN_BLOCK);
871 long long * snpe = ms->getMSP(ms_lt::Mesh_Specification::NODES_PER_ELEMENT);
872 for(int bct = 0; bct < snb; bct ++,block_count ++){
873 ndb->Specify_Block_Information(block_count,// 0 based index
874 sbids[bct] + block_offset,// 1 base count
875 seib[bct],// element in block
876 snpe[bct],
877 0,// attributes
878 the_element_type);
879 tblock_offset = sbids[bct]+block_offset;
880 }
881 block_offset = tblock_offset;
882 ms = ms->Next();
883 }
884 }
885 //populate connectivity
886 {
887 int dim = this->getMSI(DIM);
888 int num_nodes_per_element = 8;
889 if(dim == 2){
890 num_nodes_per_element = 4;
891 }
892
893 int block_count = 0;
894 int node_offset = 0;
895 long long * const * dlinks = ndb->getMSPP(ms_lt::Mesh_Specification::ELMT_NODE_LINKAGE);
896 Mesh_Specification * ms = this;
897 while(ms){
898 long long * const * slinks = ms->getMSPP(ms_lt::Mesh_Specification::ELMT_NODE_LINKAGE);
899 long long snb = ms->getMSI(ms_lt::Mesh_Specification::NUM_BLOCKS);
900 for(int bct = 0; bct < snb; bct ++,block_count ++){
901 long long * sconn = slinks[bct];
902 long long * dconn = dlinks[block_count];
903 long long * elem_in_block = ms->getMSP(ms_lt::Mesh_Specification::ELEMENTS_IN_BLOCK);
904 for(int elct = 0; elct < elem_in_block[bct];elct ++){
905 for(int nct = 0; nct < num_nodes_per_element; nct ++){
906 dconn[elct*num_nodes_per_element+nct] = sconn[elct*num_nodes_per_element+nct]+node_offset;
907 }
908 }
909 }
910 node_offset += ms->getMSI(NUM_NODES);
911 ms = ms->Next();
912 }
913 }
914
915 //element types
916 {
917 int dim = this->getMSI(DIM);
918 std::string *el_types = ndb->getMSPSA(ms_lt::Mesh_Specification::ELEMENT_TYPES);
919 for(long long bct = 0; bct < ndb->getMSI(ms_lt::Mesh_Specification::NUM_BLOCKS);bct ++ ){
920 el_types[bct] = "QUAD";
921 if(dim==3){
922 el_types[bct] = "HEX";
923 }
924 }
925 }
926
927 //Global element numbers OFFSET IS WRONG SHOULD BE ACROSS ALL PROCS
928 {
929 long long * the_map = ndb->getMSP(ms_lt::Mesh_Specification::ELEM_ORDER_MAP);
930 long long * dglobal_element_numbers = ndb->getMSP(ms_lt::Mesh_Specification::GLOBAL_ELEMENT_NUMBERS);
931 long long element_offset = 0;
932 long long tict = 0;
933 Mesh_Specification * ms = this;
934 while(ms){
935 long long * sthe_map = ms->getMSP(ms_lt::Mesh_Specification::ELEM_ORDER_MAP);
936 long long * sglobal_element_numbers = ms->getMSP(ms_lt::Mesh_Specification::GLOBAL_ELEMENT_NUMBERS);
937 long long nels = ms->getMSI(NUM_ELEMENTS);
938 for(int ict = 0; ict < nels; ict++,tict++){
939 the_map[tict] = sthe_map[ict] + element_offset;
940 dglobal_element_numbers[tict] = sglobal_element_numbers[ict] + element_offset;
941 }
942
943 element_offset += ms->getMSI(NUM_ELEMS_GLOBAL);
944 ms = ms->Next();
945 }
946 }
947 //global node numbers OFFSET is WRONG SHOULD BE ACROSS ALL PROCESSORS
948 {
949 long long * dglobal_node_numbers = ndb->getMSP(ms_lt::Mesh_Specification::GLOBAL_NODE_NUMBERS);
950 long long node_offset = 0;
951 int tict = 0;
952 Mesh_Specification * ms = this;
953 while(ms){
954 long long * sglobal_node_numbers = ms->getMSP(ms_lt::Mesh_Specification::GLOBAL_NODE_NUMBERS);
955 long long nnodes = ms->getMSI(NUM_NODES);
956 for(int ict = 0; ict < nnodes; ict++,tict++){
957 dglobal_node_numbers[tict] = sglobal_node_numbers[ict] + node_offset;
958 }
959
960 node_offset += ms->getMSI(NUM_NODES_GLOBAL);
961 ms = ms->Next();
962 }
963 }
964
965
966 //global information
967 {
968 long long gnodes = 0;
969 long long gels = 0;
970 long long gblks = 0;
971 long long gns = 0;
972 long long gss = 0;
973 Mesh_Specification * ms = this;
974 while(ms){
975 gnodes += ms->getMSI(NUM_NODES_GLOBAL);
976 gels += ms->getMSI(NUM_ELEMS_GLOBAL);
977 gblks += ms->getMSI(NUM_ELM_BLKS_GLOBAL);
978 gns += ms->getMSI(NUM_NODE_SETS_GLOBAL);
979 gss += ms->getMSI(NUM_SIDE_SETS_GLOBAL);
980
981 ms = ms->Next();
982 }
983 ndb->Global_Data_Size(gnodes,
984 gels,
985 gblks,
986 gns,
987 gss,
988 this->getMSI(NUM_TOTAL_PROC),
989 this->getMSI(PROC_ID));
990
991 long long* elem_blk_ids_global = ndb->getMSP(ms_lt::Mesh_Specification::ELEM_BLK_IDS_GLOBAL);//Elem_Blk_Ids_Global();
992 for(long long bct = 0; bct < gblks; bct++)elem_blk_ids_global[bct] = bct+1;// add 1 for block index
993
994 }
995
996 // element block counts
997 {
998 long long* delem_blk_cnts_global = ndb->getMSP(ms_lt::Mesh_Specification::ELEM_BLK_CNTS_GLOBAL);
999 int blk_cnt = 0;
1000 Mesh_Specification * ms = this;
1001 while(ms){
1002 long long* sdelem_blk_cnts_global = ms->getMSP(ms_lt::Mesh_Specification::ELEM_BLK_CNTS_GLOBAL);
1003 int nblk = ms->getMSI(NUM_ELM_BLKS_GLOBAL);
1004 for(int ict = 0; ict < nblk; ict ++,blk_cnt++){
1005 delem_blk_cnts_global[blk_cnt] = sdelem_blk_cnts_global[ict];
1006 }
1007
1008 ms = ms->Next();
1009 }
1010
1011 }
1012
1013 // ns global info
1014 {
1015 long long* dns_ids_global = ndb->getMSP(ms_lt::Mesh_Specification::NS_IDS_GLOBAL);
1016 long long* dns_cnts_global = ndb->getMSP(ms_lt::Mesh_Specification::NS_CNTS_GLOBAL);
1017 long long* dns_df_cnts_global = ndb->getMSP(ms_lt::Mesh_Specification::NS_DF_CNTS_GLOBAL);
1018 int nsct = 0;
1019 Mesh_Specification * ms = this;
1020 while(ms){
1021 long long* sns_ids_global = ms->getMSP(ms_lt::Mesh_Specification::NS_IDS_GLOBAL);
1022 long long* sns_cnts_global = ms->getMSP(ms_lt::Mesh_Specification::NS_CNTS_GLOBAL);
1023 long long* sns_df_cnts_global = ms->getMSP(ms_lt::Mesh_Specification::NS_DF_CNTS_GLOBAL);
1024 int nns = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_SETS_GLOBAL);
1025 for(int ict = 0; ict < nns; ict ++,nsct ++){
1026 dns_ids_global[nsct] = sns_ids_global[ict];
1027 dns_cnts_global[nsct] = sns_cnts_global[ict];
1028 dns_df_cnts_global[nsct] = sns_df_cnts_global[ict];
1029 }
1030 ms = ms->Next();
1031 }
1032 }
1033
1034 //ss global info
1035 {
1036 long long* dss_ids_global = ndb->getMSP(ms_lt::Mesh_Specification::SS_IDS_GLOBAL);
1037 long long* dss_cnts_global = ndb->getMSP(ms_lt::Mesh_Specification::SS_CNTS_GLOBAL);
1038 long long* dss_df_cnts_global = ndb->getMSP(ms_lt::Mesh_Specification::SS_DF_CNTS_GLOBAL);
1039 int ssct = 0;
1040 Mesh_Specification * ms = this;
1041 while(ms){
1042 long long* sss_ids_global = ms->getMSP(ms_lt::Mesh_Specification::SS_IDS_GLOBAL);
1043 long long* sss_cnts_global = ms->getMSP(ms_lt::Mesh_Specification::SS_CNTS_GLOBAL);
1044 long long* sss_df_cnts_global = ms->getMSP(ms_lt::Mesh_Specification::SS_DF_CNTS_GLOBAL);
1045 int nss = ms->getMSI(ms_lt::Mesh_Specification::NUM_SIDE_SETS_GLOBAL);
1046 for(int ict = 0; ict < nss; ict ++,ssct ++){
1047 dss_ids_global[ssct] = sss_ids_global[ict];
1048 dss_cnts_global[ssct] = sss_cnts_global[ict];
1049 dss_df_cnts_global[ssct] = sss_df_cnts_global[ict];
1050 }
1051 ms = ms->Next();
1052 }
1053 }
1054
1055 //parallel data
1056 {
1057 int internal_node_list_size = 0;
1058 int border_node_list_size = 0;
1059 int internal_element_list_size = 0;
1060 int border_element_list_size = 0;
1061 std::map<long,std::vector < long > > node_proc_ids;
1062 std::map<long,std::vector < std::pair <long/*element*/,long/*face*/ > > > element_proc_ids;
1063 std::vector<long> elem_cmap_elem_cnts;
1064
1065 Mesh_Specification * ms = this;
1066 int node_offset = 0;
1067 int element_offset = 0;
1068 while(ms){
1069
1070 internal_node_list_size += ms->getMSI(NUM_INTERNAL_NODES);
1071 border_node_list_size += ms->getMSI(NUM_BORDER_NODES);
1072 internal_element_list_size += ms->getMSI(NUM_INTERNAL_ELEMS);
1073 border_element_list_size += ms->getMSI(NUM_BORDER_ELEMS);
1074
1075 long long * const * scnid = ms->getMSPP(ms_lt::Mesh_Specification::COMM_NODE_IDS);
1076 long long * const * sceid = ms->getMSPP(ms_lt::Mesh_Specification::COMM_ELEM_IDS);
1077 long long * const * scsid = ms->getMSPP(ms_lt::Mesh_Specification::COMM_SIDE_IDS);
1078
1079 {
1080 int nncm = ms->getMSI(NUM_NODE_COMM_MAPS);
1081 long long * ncmap_ids = ms->getMSP(NODE_CMAP_IDS);
1082 long long * ncmap_cnts = ms->getMSP(NODE_CMAP_NODE_CNTS);
1083 for(int ict = 0; ict < nncm; ict ++){
1084 long long proc_id = ncmap_ids[ict];
1085 long long nnodes = ncmap_cnts[ict];
1086
1087 for (long long nctr = 0; nctr < nnodes; nctr ++){
1088 (node_proc_ids[proc_id]).push_back(scnid[ict][nctr]+node_offset);
1089 assert(proc_id == ms->getMSPP(ms_lt::Mesh_Specification::COMM_NODE_PROC_IDS)[ict][nctr]);
1090 }
1091 }
1092 }
1093
1094
1095 {
1096 int necm = ms->getMSI(NUM_ELEM_COMM_MAPS);
1097 long long * ecmap_ids = ms->getMSP(ELEM_CMAP_IDS);
1098 long long * ecmap_cnts = ms->getMSP(ELEM_CMAP_ELEM_CNTS);
1099 for(int ict = 0; ict < necm; ict ++){
1100 long long proc_id = ecmap_ids[ict];
1101 long long nels = ecmap_cnts[ict];
1102 for(long long ectr = 0; ectr < nels;ectr++){
1103 (element_proc_ids[proc_id]).push_back(std::pair<long,long>(sceid[ict][ectr]+element_offset,scsid[ict][ectr]));
1104 assert(proc_id == ms->getMSPP(ms_lt::Mesh_Specification::COMM_ELEM_PROC_IDS)[ict][ectr]);
1105 }
1106 }
1107 }
1108
1109 node_offset += ms->getMSI(NUM_NODES);
1110 element_offset += ms->getMSI(NUM_ELEMENTS);
1111 ms = ms->Next();
1112 } /* while(ms)*/
1113
1114 ndb->Parallel_Data_Size(internal_node_list_size,
1115 border_node_list_size,
1116 0,//num_external_nodes,
1117 internal_element_list_size,
1118 border_element_list_size,
1119 node_proc_ids.size(),
1120 element_proc_ids.size()
1121 );
1122
1123 {
1124 long long * ncnc = ndb->getMSP(ms_lt::Mesh_Specification::NODE_CMAP_NODE_CNTS);
1125 long long * nci = ndb->getMSP(ms_lt::Mesh_Specification::NODE_CMAP_IDS);
1126 long long * ecec = ndb->getMSP(ms_lt::Mesh_Specification::ELEM_CMAP_ELEM_CNTS);
1127 long long * eci = ndb->getMSP(ms_lt::Mesh_Specification::ELEM_CMAP_IDS);
1128 std::map<long,std::vector<long>>::iterator mit;
1129 {
1130 int count = 0;
1131 for(mit = node_proc_ids.begin();mit != node_proc_ids.end();mit ++,count ++){
1132 ncnc[count] = (*mit).second.size();//node_cmap_node_cnts[count];
1133 nci[count] = (*mit).first;
1134 }
1135 }
1136 std::map<long,std::vector < std::pair < long,long > > >::iterator it;
1137
1138 {
1139 int count = 0;
1140 for(it = element_proc_ids.begin();it != element_proc_ids.end();it ++,count ++){
1141 ecec[count] = (*it).second.size();//elem_cmap_elem_cnts[count];
1142 eci[count] = (*it).first;
1143 }
1144 }
1145 }
1146
1147
1148 ndb->Allocate_Parallel_Data();
1149 {
1150
1151 long long * const * dcnid = ndb->getMSPP(ms_lt::Mesh_Specification::COMM_NODE_IDS);
1152 long long * const * dcnpid = ndb->getMSPP(ms_lt::Mesh_Specification::COMM_NODE_PROC_IDS);
1153 long long * const * dceid = ndb->getMSPP(ms_lt::Mesh_Specification::COMM_ELEM_IDS);
1154 long long * const * dcsid = ndb->getMSPP(ms_lt::Mesh_Specification::COMM_SIDE_IDS);
1155 long long * const * dcepid = ndb->getMSPP(ms_lt::Mesh_Specification::COMM_ELEM_PROC_IDS);
1156
1157 {
1158 std::map<long,std::vector<long>>::iterator mit;
1159 int lcount = 0;
1160 for(mit = node_proc_ids.begin();mit != node_proc_ids.end();mit ++,lcount ++){
1161 std::vector<long>::iterator vit;
1162 int count = 0;
1163 for(vit = (*mit).second.begin();vit != (*mit).second.end();vit ++,count ++){
1164 dcnid[lcount][count] = *vit;
1165 dcnpid[lcount][count] = (*mit).first;
1166 }
1167 }
1168 }
1169
1170 {
1171 std::map< long, std::vector < std::pair < long, long > > > :: iterator mit;
1172 int lcount = 0;
1173 for(mit = element_proc_ids.begin();mit != element_proc_ids.end();mit ++,lcount ++){
1174 std::vector< std::pair < long, long >>::iterator vit;
1175 int count = 0;
1176 for(vit = (*mit).second.begin();vit != (*mit).second.end();vit ++,count ++){
1177 dceid[lcount][count] = (*vit).first;
1178 dcsid[lcount][count] = (*vit).second;
1179 dcepid[lcount][count] = (*mit).first;
1180 }
1181 }
1182 }
1183 }
1184 }
1185
1186 //populate border nodes elements
1187 {
1188 long long * dint_elems = ndb->getMSP(ms_lt::Mesh_Specification::INTERNAL_ELEMENTS);
1189 long long * dint_nodes = ndb->getMSP(ms_lt::Mesh_Specification::INTERNAL_NODES);
1190 long long * dborder_elems = ndb->getMSP(ms_lt::Mesh_Specification::BORDER_ELEMENTS);
1191 long long * dborder_nodes = ndb->getMSP(ms_lt::Mesh_Specification::BORDER_NODES);
1192
1193 int nin = 0;
1194 int nbn = 0;
1195 int nie = 0;
1196 int nbe = 0;
1197
1198 Mesh_Specification * ms = this;
1199 int node_offset = 0;
1200 int element_offset = 0;
1201 while(ms){
1202 long long * sint_elems = ms->getMSP(ms_lt::Mesh_Specification::INTERNAL_ELEMENTS);
1203 long long * sint_nodes = ms->getMSP(ms_lt::Mesh_Specification::INTERNAL_NODES);
1204 long long * sborder_elems = ms->getMSP(ms_lt::Mesh_Specification::BORDER_ELEMENTS);
1205 long long * sborder_nodes = ms->getMSP(ms_lt::Mesh_Specification::BORDER_NODES);
1206
1207 int internal_node_list_size = ms->getMSI(NUM_INTERNAL_NODES);
1208 int border_node_list_size = ms->getMSI(NUM_BORDER_NODES);
1209 int internal_element_list_size = ms->getMSI(NUM_INTERNAL_ELEMS);
1210 int border_element_list_size = ms->getMSI(NUM_BORDER_ELEMS);
1211
1212 for(int ict = 0; ict < internal_node_list_size; ict ++, nin++){dint_nodes[nin] = sint_nodes[ict]+node_offset;}
1213 for(int ict = 0; ict < border_node_list_size; ict ++, nbn++){dborder_nodes[nbn] = sborder_nodes[ict]+node_offset;}
1214 for(int ict = 0; ict < internal_element_list_size; ict ++, nie++){dint_elems[nie] = sint_elems[ict]+element_offset;}
1215 for(int ict = 0; ict < border_element_list_size; ict ++, nbe++){dborder_elems[nbe] = sborder_elems[ict]+element_offset;}
1216
1217 node_offset += ms->getMSI(NUM_NODES);
1218 element_offset += ms->getMSI(NUM_ELEMENTS);
1219
1220 ms = ms->Next();
1221 }
1222 }
1223
1224
1225
1226
1227 return ndb;
1228 }
1229
1230
1231 }