Zoltan2
Loading...
Searching...
No Matches
Zoltan2_PamgenMeshStructure.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// Zoltan2: A package of combinatorial algorithms for scientific computing
6// Copyright 2012 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Karen Devine (kddevin@sandia.gov)
39// Erik Boman (egboman@sandia.gov)
40// Siva Rajamanickam (srajama@sandia.gov)
41//
42// ***********************************************************************
43//
44// @HEADER
45
46/* \file Zoltan2_PamgenMeshStructure.hpp
47* \brief A class for copying the state of a Pamgen mesh for easy access
48*/
49
50#ifndef PAMGEN_MESH_STRUCTURE
51#define PAMGEN_MESH_STRUCTURE
52
53#ifdef HAVE_ZOLTAN2_PAMGEN
54
55#include <Pamgen_config.h>
56#include <create_inline_mesh.h>
57#include <limits.h>
58#include <pamgen_im_exodusII.h>
59#include <pamgen_im_ne_nemesisI.h>
60
61
62class PamgenMesh{
63public:
64
65 /* \brief Destructor */
66 ~PamgenMesh(); // free memory
67
68 /* \bried Method for calling the Pamgen Mesh constructor
69 * \param[in] file_data is the input file describing the pamgen mesh read into a char array
70 * \param[in] dimension is the dimension of the problem, i.e. 1,2, or 3
71 * \param[in] comm is the process communicator
72 */
73 void createMesh(char * file_data, int dimension, const RCP<const Comm<int>> &comm);
74
75 /* \bried Method for copying the state of a Pamgen mesh once it has been created
76 */
77 void storeMesh(); // read mesh to memory
78
79 /* Metod for computing the coordinates of the element centers */
80 void computeElementCoordinates();
81
82 int num_dim;
83 int num_nodes;
84 int num_elem;
85 int num_elem_blk;
86 int num_node_sets;
87 int num_side_sets;
88 int num_node_set_nodes;
89 int num_node_set_dfs;
90 int num_side_set_elements;
91 int num_side_set_nodes;
92 int num_side_set_dfs;
93 int num_block_properties;
94 int num_node_set_properties;
95 int num_side_set_properties;
96
97 char title[MAX_STR_LENGTH];
98
99 int version;
100 double version_number;
101 double * coord;
102 double * element_coord;
103
104 char buffer[3][MAX_STR_LENGTH + 1];
105 char *bptr[3];
106
107 int * element_order_map ;
108
109 int * global_element_numbers ;
110 int * global_node_numbers ;
111
112 /*block info*/
113 int * block_id ;
114 char ** element_types ;
115 int * elements ;
116 int * nodes_per_element ;
117 int * element_attributes ;
118 int ** elmt_node_linkage ;
119
120 /*side sets*/
121 int * side_set_id ;
122 int * num_elements_in_side_set ;
123 int * num_df_in_side_set ;
124 int **side_set_elements ;
125 int **side_set_faces ;
126
127 /*node sets*/
128 int * node_set_id ;
129 int * num_nodes_in_node_set ;
130 int * num_df_in_node_set ;
131 int **node_set_nodes ;
132
133 /*qa*/
134 int num_qa_records;
135 int num_info_records;
136 char* qaRecord[100][4];
137 char** info_records ;
138
139 /*nemesis data*/
140 int num_nodes_global;
141 int num_elems_global;
142 int num_elm_blks_global;
143 int num_node_sets_global;
144 int num_side_sets_global;
145 int num_total_proc;
146 int num_proc_in_file;
147 char type[2];
148
149 /*nemesis data
150 global info*/
151
152 int * elem_blk_ids_global ;
153 int * elem_blk_cnts_global ;
154
155 int * ns_ids_global ;
156 int * ns_cnts_global ;
157 int * ns_df_cnts_global ;
158 int * ss_ids_global ;
159 int * ss_cnts_global ;
160 int * ss_df_cnts_global ;
161
162 /*parallel info*/
163 int num_internal_nodes;
164 int num_border_nodes;
165 int num_external_nodes;
166 int num_internal_elems;
167 int num_border_elems;
168 int num_node_comm_maps;
169 int num_elem_comm_maps;
170
171 int * internal_elements ;
172 int * border_elements ;
173 int * internal_nodes ;
174 int * border_nodes ;
175 int * external_nodes ;
176
177 int * node_cmap_node_cnts ;
178 int * node_cmap_ids ;
179 int * elem_cmap_elem_cnts ;
180 int * elem_cmap_ids ;
181
182 int ** comm_node_ids ;
183 int ** comm_node_proc_ids ;
184 int ** comm_elem_ids ;
185 int ** comm_side_ids ;
186 int ** comm_elem_proc_ids ;
187
188};
189
190
191PamgenMesh::~PamgenMesh()
192{
193 // free mesh
194 Delete_Pamgen_Mesh();
195
196 // free storage
197 int i;
198 int j;
199 int b;
200 for( i = 0; i < 100; i++){
201 for( j=0; j<4; j++){
202 free(this->qaRecord[i][j]);
203 }
204 }
205
206 free(this->coord); // free vertex coords
207 free(this->element_coord);
208
209
210 if (this->num_elem){
211 free(this->element_order_map);
212
213 if (this->num_elem){
214 free(this->global_element_numbers);
215 }
216
217 if (this->num_nodes){
218 free(this->global_node_numbers);
219 }
220
221
222 /*block info*/
223 free(this->block_id);
224 free(this->nodes_per_element);
225 free(this->element_attributes);
226 free(this->elements);
227
228
229 for(i = 0; i < this->num_elem_blk; i ++){
230 free(this->element_types[i]);
231 }
232
233 /*connectivity*/
234 for(b = 0; b < this->num_elem_blk; b++){
235 free(this->elmt_node_linkage[b]);
236 }
237 free(this->element_types);
238 free(this->elmt_node_linkage);
239
240
241 if(this->num_node_sets){
242
243 for(i = 0; i < this->num_node_sets; i ++){
244 if(this->num_nodes_in_node_set[i]) {
245 free(this->node_set_nodes[i]);
246 }
247 }
248 free(this->node_set_id);
249 free(this->num_nodes_in_node_set);
250 free(this->node_set_nodes);
251 free(this->num_df_in_node_set);
252
253 }
254
255 /*side sets*/
256 if(this->num_side_sets){
257
258 for(i = 0; i < this->num_side_sets; i ++){
259
260 free(this->side_set_elements[i]);
261 free(this->side_set_faces[i]);
262
263 }
264 free(this->side_set_id);
265 free(this->num_elements_in_side_set);
266 free(this->num_df_in_side_set);
267 free(this->side_set_elements);
268 free(this->side_set_faces);
269 }
270
271
272 if(this->num_info_records) {
273 for(i = 0; i < this->num_info_records; i ++){
274 free(this->info_records[i]);
275 }
276 free(this->info_records);
277 }
278
279
280 /*nemesis data
281 global info */
282 free(this->elem_blk_ids_global);
283 free(this->elem_blk_cnts_global);
284
285 free(this->ns_ids_global);
286 free(this->ns_cnts_global);
287 free(this->ns_df_cnts_global);
288 free(this->ss_ids_global);
289 free(this->ss_cnts_global);
290 free(this->ss_df_cnts_global);
291
292 free(this->internal_elements);
293 free(this->border_elements);
294 free(this->internal_nodes);
295 free(this->border_nodes);
296 free(this->external_nodes);
297
298 if(this->num_node_comm_maps > 0){
299
300 for(j = 0; j < this->num_node_comm_maps; j++) {
301 free(this->comm_node_ids[j]);
302 free(this->comm_node_proc_ids[j]);
303
304 }
305
306
307 for(j = 0; j < this->num_elem_comm_maps; j++) {
308 free(this->comm_elem_ids[j]);
309 free(this->comm_side_ids[j]);
310 free(this->comm_elem_proc_ids[j]);
311
312 }/*loop over num_elem_co*/
313 }
314
315 if(this->num_node_comm_maps > 0)
316 {
317 free(this->node_cmap_node_cnts);
318 free(this->node_cmap_ids);
319 free(this->comm_node_ids);
320 free(this->comm_node_proc_ids);
321
322 free(this->elem_cmap_elem_cnts);
323 free(this->elem_cmap_ids);
324 free(this->comm_elem_ids);
325 free(this->comm_side_ids);
326 free(this->comm_elem_proc_ids);
327 }
328
329 }
330
331}
332
333void PamgenMesh::storeMesh()
334{
335
336 int idum = 0;
337 float fdum;
338 int i;
339 int j;
340 int b;
341 char * cdum = NULL;
342 int error = 0;
343 int id = 0;
344
345 this->bptr[0] = this->buffer[0];
346 this->bptr[1] = this->buffer[1];
347 this->bptr[2] = this->buffer[2];
348
349 for(i = 0; i < 100; i++)
350 for(j=0; j<4; j++) this->qaRecord[i][j] = (char*)malloc(MAX_STR_LENGTH+1) ;
351
352
353 error += im_ex_get_init ( id,
354 this->title,
355 &this->num_dim,
356 &(this->num_nodes),
357 &this->num_elem,
358 &this->num_elem_blk,
359 &this->num_node_sets,
360 &this->num_side_sets);
361
362
363 error += im_ex_inquire(id, IM_EX_INQ_NS_NODE_LEN, (int*)&this->num_node_set_nodes,
364 &fdum, cdum);
365 error += im_ex_inquire
366 (id, IM_EX_INQ_NS_DF_LEN, (int*)&this->num_node_set_dfs,
367 &fdum, cdum);
368 error += im_ex_inquire(id, IM_EX_INQ_SS_ELEM_LEN, (int*)&this->num_side_set_elements,
369 &fdum, cdum);
370 error += im_ex_inquire(id, IM_EX_INQ_SS_NODE_LEN, (int*)&this->num_side_set_nodes,
371 &fdum, cdum);
372 error += im_ex_inquire(id, IM_EX_INQ_SS_DF_LEN, (int*)&this->num_side_set_dfs,
373 &fdum, cdum);
374
375 /* get version number */
376
377 error += im_ex_inquire(id, IM_EX_INQ_API_VERS, &idum, &fdum, cdum);
378
379 this->version_number = (double) fdum;
380
381 this->version = (int) this->version_number;
382
383 /* get genesis-II parameters */
384
385 error += im_ex_inquire(id, IM_EX_INQ_EB_PROP, (int*)&this->num_block_properties, &fdum, cdum);
386
387 error += im_ex_inquire(id, IM_EX_INQ_NS_PROP, (int*)&this->num_node_set_properties,
388 &fdum, cdum);
389
390 error += im_ex_inquire(id, IM_EX_INQ_SS_PROP, (int*)&this->num_side_set_properties,
391 &fdum, cdum);
392
393 this->coord = (double *)malloc(this->num_nodes*this->num_dim*sizeof(double));
394
395 error += im_ex_get_coord(id,this->coord,this->coord+this->num_nodes,this->coord+2*this->num_nodes);
396
397
398 error += im_ex_get_coord_names (id, this->bptr);
399
400 if (this->num_elem){
401 this->element_order_map = (int *)malloc(this->num_elem * sizeof(int));
402 error += im_ex_get_map(id, this->element_order_map);
403
404 if (this->num_elem){
405 this->global_element_numbers = (int *)malloc(this->num_elem*sizeof(int));
406 error += im_ex_get_elem_num_map(id, this->global_element_numbers);
407 }
408
409 if (this->num_nodes){
410 this->global_node_numbers = (int *)malloc(this->num_nodes * sizeof(int));
411 error += im_ex_get_node_num_map(id, this->global_node_numbers);
412 }
413
414
415 /*block info*/
416
417 this->block_id = (int *)malloc(this->num_elem_blk*sizeof(int));
418 this->nodes_per_element = (int *)malloc(this->num_elem_blk*sizeof(int));
419 this->element_attributes = (int *)malloc(this->num_elem_blk*sizeof(int));
420 this->elements = (int *)malloc(this->num_elem_blk*sizeof(int));
421 this->element_types = (char **)malloc(this->num_elem_blk*sizeof(char *));
422 this->elmt_node_linkage = (int **)malloc(this->num_elem_blk*sizeof(int*));
423
424 error += im_ex_get_elem_blk_ids(id, this->block_id);
425
426 for(i = 0; i < this->num_elem_blk; i ++){
427 this->element_types[i] = (char *)malloc((MAX_STR_LENGTH + 1)*sizeof(char));
428 error += im_ex_get_elem_block(id,
429 this->block_id[i],
430 this->element_types[i],
431 (int*)&(this->elements[i]),
432 (int*)&(this->nodes_per_element[i]),
433 (int*)&(this->element_attributes[i]));
434 }
435
436 /*connectivity*/
437 for(b = 0; b < this->num_elem_blk; b++){
438 this->elmt_node_linkage[b] = (int*)malloc(this->nodes_per_element[b]*this->elements[b]*sizeof(int));
439 error += im_ex_get_elem_conn(id,this->block_id[b],this->elmt_node_linkage[b]);
440 }
441
442
443 if(this->num_node_sets){
444 this->node_set_id = (int *) malloc(this->num_node_sets*sizeof(int));
445 this->num_nodes_in_node_set = (int *) malloc(this->num_node_sets*sizeof(int));
446 this->node_set_nodes = (int **)malloc(this->num_node_sets*sizeof(int*));
447 this->num_df_in_node_set = (int *) malloc(this->num_node_sets*sizeof(int*));
448
449 error += im_ex_get_node_set_ids(id, this->node_set_id);
450
451
452 for(i = 0; i < this->num_node_sets; i ++){
453 error += im_ex_get_node_set_param(id, this->node_set_id[i],
454 (int*)&this->num_nodes_in_node_set[i],
455 (int*)&this->num_df_in_node_set[i]);
456
457 this->node_set_nodes[i] = NULL;
458
459 if(this->num_nodes_in_node_set[i]) {
460 this->node_set_nodes[i] = (int *)malloc(this->num_nodes_in_node_set[i]*sizeof(int));
461 error += im_ex_get_node_set(id, this->node_set_id[i], this->node_set_nodes[i]);
462 }
463 }
464 }
465
466 /*side sets*/
467 if(this->num_side_sets){
468 this->side_set_id = (int*)malloc(this->num_side_sets*sizeof(int));
469 this->num_elements_in_side_set = (int*)malloc(this->num_side_sets*sizeof(int));
470 this->num_df_in_side_set = (int*)malloc(this->num_side_sets*sizeof(int));
471 this->side_set_elements = (int**)malloc(this->num_side_sets*sizeof(int *));
472 this->side_set_faces = (int **)malloc(this->num_side_sets*sizeof(int*));
473
474 error += im_ex_get_side_set_ids(id, this->side_set_id);
475 for(i = 0; i < this->num_side_sets; i ++){
476 int ne = 0;
477 error += im_ex_get_side_set_param(id, this->side_set_id[i],
478 (int*)&this->num_elements_in_side_set[i],
479 (int*)&this->num_df_in_side_set[i]);
480
481 ne = this->num_elements_in_side_set[i];
482 this->side_set_elements[i] = (int*)malloc(ne*sizeof(int));
483 this->side_set_faces[i] = (int*)malloc(ne*sizeof(int));
484 if(ne){
485 error += im_ex_get_side_set(id, this->side_set_id[i],
486 this->side_set_elements[i],
487 this->side_set_faces[i]);
488
489 }
490 }
491 }
492
493 error += im_ex_inquire(id, IM_EX_INQ_QA, (int*)&this->num_qa_records, &fdum, cdum);
494
495 if(this->num_qa_records)error += im_ex_get_qa(id,this->qaRecord);
496
497
498 error += im_ex_inquire(id, IM_EX_INQ_INFO, (int*)&this->num_info_records, &fdum, cdum);
499 if(this->num_info_records) {
500 this->info_records = (char **)malloc(this->num_info_records*sizeof(char *));/*new std::string[num_info_records];*/
501 for(i = 0; i < this->num_info_records; i ++){
502 this->info_records[i] = (char *)malloc(MAX_STR_LENGTH+1);
503 }
504 error += im_ex_get_info(id, this->info_records);
505 }
506
507
508 /*nemesis data
509 global info*/
510 if ( im_ne_get_init_global(id, &this->num_nodes_global, &this->num_elems_global,
511 &this->num_elm_blks_global, &this->num_node_sets_global,
512 &this->num_side_sets_global) < 0 )
513 ++error;
514
515
516
517 if ( im_ne_get_init_info(id, &this->num_total_proc, &this->num_proc_in_file, this->type) < 0 )
518 ++error;
519
520 this->elem_blk_ids_global = (int*)malloc(this->num_elm_blks_global*sizeof(int));
521 this->elem_blk_cnts_global = (int*)malloc(this->num_elm_blks_global*sizeof(int));
522
523 if ( im_ne_get_eb_info_global(id,this->elem_blk_ids_global,this->elem_blk_cnts_global) < 0 )
524 ++error;
525
526 this->ns_ids_global = (int *)malloc(this->num_node_sets_global*sizeof(int));
527 this->ns_cnts_global = (int *)malloc(this->num_node_sets_global*sizeof(int));
528 this->ns_df_cnts_global = (int *)malloc(this->num_node_sets_global*sizeof(int));
529 this->ss_ids_global = (int *)malloc(this->num_side_sets_global*sizeof(int));
530 this->ss_cnts_global = (int *)malloc(this->num_side_sets_global*sizeof(int));
531 this->ss_df_cnts_global = (int *)malloc(this->num_side_sets_global*sizeof(int));
532
533
534 if ( this->num_node_sets_global > 0 ) {
535 if ( im_ne_get_ns_param_global(id,this->ns_ids_global,this->ns_cnts_global,
536 this->ns_df_cnts_global) < 0 )++error;
537 }
538
539 if ( this->num_side_sets_global > 0 ) {
540 if ( im_ne_get_ss_param_global(id,this->ss_ids_global,this->ss_cnts_global,
541 this->ss_df_cnts_global) < 0 ) ++error;
542 }
543
544 /*parallel info*/
545 if ( im_ne_get_loadbal_param( id,
546 &this->num_internal_nodes,
547 &this->num_border_nodes,
548 &this->num_external_nodes,
549 &this->num_internal_elems,
550 &this->num_border_elems,
551 &this->num_node_comm_maps,
552 &this->num_elem_comm_maps,
553 0/*unused*/ ) < 0 )++error;
554
555 this->internal_elements = (int *)malloc(this->num_internal_elems*sizeof(int));
556 this->border_elements = (int *)malloc(this->num_border_elems*sizeof(int));
557 this->internal_nodes = (int *)malloc(this->num_internal_nodes*sizeof(int));
558 this->border_nodes = (int *)malloc(this->num_border_nodes*sizeof(int));
559 this->external_nodes = (int *)malloc(this->num_external_nodes*sizeof(int));
560
561 if ( im_ne_get_elem_map( id,
562 this->internal_elements,
563 this->border_elements,
564 0/* not used proc_id*/ ) < 0 )++error;
565
566 if ( im_ne_get_node_map( id,
567 this->internal_nodes,
568 this->border_nodes,
569 this->external_nodes,
570 0/* not used proc_id*/ ) < 0 )++error;
571
572
573 if(this->num_node_comm_maps > 0){
574
575 this->node_cmap_node_cnts = (int*) malloc(this->num_node_comm_maps*sizeof(int));
576 this->node_cmap_ids = (int*) malloc(this->num_node_comm_maps*sizeof(int));
577 this->comm_node_ids = (int**)malloc(this->num_node_comm_maps*sizeof(int*));
578 this->comm_node_proc_ids = (int**)malloc(this->num_node_comm_maps*sizeof(int*));
579
580 this->elem_cmap_elem_cnts = (int*) malloc(this->num_elem_comm_maps*sizeof(int));
581 this->elem_cmap_ids = (int*) malloc(this->num_elem_comm_maps*sizeof(int));
582 this->comm_elem_ids = (int**)malloc(this->num_elem_comm_maps*sizeof(int*));
583 this->comm_side_ids = (int**)malloc(this->num_elem_comm_maps*sizeof(int*));
584 this->comm_elem_proc_ids = (int**)malloc(this->num_elem_comm_maps*sizeof(int*));
585
586 if ( im_ne_get_cmap_params( id,
587 this->node_cmap_ids,
588 (int*)this->node_cmap_node_cnts,
589 this->elem_cmap_ids,
590 (int*)this->elem_cmap_elem_cnts,
591 0/*not used proc_id*/ ) < 0 )++error;
592
593 for(j = 0; j < this->num_node_comm_maps; j++) {
594 this->comm_node_ids[j] = (int *)malloc(this->node_cmap_node_cnts[j]*sizeof(int));
595 this->comm_node_proc_ids[j] = (int *)malloc(this->node_cmap_node_cnts[j]*sizeof(int));
596 if ( im_ne_get_node_cmap( id,
597 this->node_cmap_ids[j],
598 this->comm_node_ids[j],
599 this->comm_node_proc_ids[j],
600 0/*not used proc_id*/ ) < 0 )++error;
601
602 }
603
604
605
606 for(j = 0; j < this->num_elem_comm_maps; j++) {
607 this->comm_elem_ids[j] = (int *)malloc(this->elem_cmap_elem_cnts[j]*sizeof(int));
608 this->comm_side_ids[j] = (int *)malloc(this->elem_cmap_elem_cnts[j]*sizeof(int));
609 this->comm_elem_proc_ids[j] = (int *)malloc(this->elem_cmap_elem_cnts[j]*sizeof(int));
610 if ( im_ne_get_elem_cmap( id,
611 this->elem_cmap_ids[j],
612 this->comm_elem_ids[j],
613 this->comm_side_ids[j],
614 this->comm_elem_proc_ids[j],
615 0 /*not used proc_id*/ ) < 0 )++error;
616
617
618 }/*loop over num_elem_co*/
619 }
620 }
621
622 // compute element center coordinates
623 this->computeElementCoordinates();
624}
625
626void PamgenMesh::computeElementCoordinates()
627{
628 this->element_coord = (double * )malloc(this->num_dim * this->num_elem * sizeof(double));
629 memset(this->element_coord, 0, this->num_dim * this->num_elem * sizeof(double));
630
631 // loop over elements
632 int n_id = 0;
633
634 int el_count = 0;
635 for(int i = 0; i < this->num_elem_blk; i++)
636 {
637 int els = this->elements[i];
638 int nperel = this->nodes_per_element[i];
639 // nodes for el
640 int * connect = this->elmt_node_linkage[i]; // get node con
641
642 for(int j = 0; j < els; j++)
643 {
644
645 // sum
646 for(int k = 0; k < nperel; k++)
647 {
648 n_id = connect[j*nperel + k]-1;
649 for(int l = 0; l < this->num_dim; l++)
650 element_coord[el_count + l * this->num_elem] += this->coord[n_id + l *this->num_nodes];
651 }
652
653 // complete average
654 for(int k = 0; k < this->num_dim; k++)
655 element_coord[el_count + k*this->num_elem] /= nperel;
656
657 el_count ++;
658 }
659 }
660
661}
662
663void PamgenMesh::createMesh(char * file_data, int dimension, const RCP<const Comm<int>> &comm)
664{
665 int rank = comm->getRank();
666 int nproc = comm->getSize();
667 long long cr_result = Create_Pamgen_Mesh(file_data, dimension, rank, nproc, INT_MAX);
668
669 if (cr_result == ERROR_PARSING_DEFINITION){
670 long long essz = getPamgenEchoStreamSize();
671 char * echo_char_array = (char *)malloc(essz+1);
672 printf("PARSE ERROR\n");
673 echo_char_array[essz] = '\0';
674 echo_char_array = getPamgenEchoStream(echo_char_array);
675 if(echo_char_array)printf("%s",echo_char_array);
676 if(cr_result == ERROR_CREATING_IMD)printf("ERROR Failure to create Inline_Mesh_Desc creation\n");
677 if(echo_char_array)free(echo_char_array);
678 }
679
680 if(cr_result == ERROR_CREATING_MS){
681 long long essz = getPamgenErrorStreamSize();
682 char * error_char_array = (char *)malloc(essz+1);
683 error_char_array[essz] = '\0';
684 error_char_array = getPamgenErrorStream(error_char_array);
685 if(error_char_array)printf("%s",error_char_array);
686 printf("\nERROR Failure to create Mesh_Specification\n");
687 if(error_char_array)free(error_char_array);
688 }
689
690
691 long long wssz = getPamgenWarningStreamSize();
692 if(wssz){
693 char * warning_char_array = (char *)malloc(wssz+1);
694 warning_char_array[wssz] = '\0';
695 warning_char_array = getPamgenWarningStream(warning_char_array);
696 printf("WARNING Records\n");
697 printf("%s",warning_char_array);
698 free(warning_char_array);
699 }
700
701
702// int issz = getPamgenInfoStreamSize();
703// if(issz){
704// char * info_char_array = (char *)malloc(issz+1);
705// info_char_array[issz] = '\0';
706// info_char_array = getPamgenInfoStream(info_char_array);
707// printf("INFO Records\n");
708// printf("%s",info_char_array);
709// free(info_char_array);
710// }
711
712}
713
714#endif
715
716#endif