| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Trilinos: An Object-Oriented Solver Framework |
| 4 |
// |
| 5 |
// Copyright 2001-2024 NTESS and the Trilinos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include <stdlib.h> |
| 11 |
#include <stdio.h> |
| 12 |
#include "Teuchos_CommandLineProcessor.hpp" |
| 13 |
|
| 14 |
#include "create_inline_mesh.h" |
| 15 |
#include "pamgen_im_exodusII.h" |
| 16 |
#include "pamgen_im_ne_nemesisI.h" |
| 17 |
#include <string.h> |
| 18 |
#include "limits.h" |
| 19 |
|
| 20 |
void write_mesh_to_stdout(); |
| 21 |
void read_mesh_to_memory(); |
| 22 |
void free_memory(); |
| 23 |
|
| 24 |
void write_to_exodus(int proc_id,int num_procs,char * out_file_name); |
| 25 |
|
| 26 |
|
| 27 |
struct mesh_storage_struct{ |
| 28 |
int num_dim; |
| 29 |
int num_nodes; |
| 30 |
int num_elem; |
| 31 |
int num_elem_blk; |
| 32 |
int num_node_sets; |
| 33 |
int num_side_sets; |
| 34 |
int num_node_set_nodes; |
| 35 |
int num_node_set_dfs; |
| 36 |
int num_side_set_elements; |
| 37 |
int num_side_set_nodes; |
| 38 |
int num_side_set_dfs; |
| 39 |
int num_block_properties; |
| 40 |
int num_node_set_properties; |
| 41 |
int num_side_set_properties; |
| 42 |
|
| 43 |
char title[MAX_STR_LENGTH]; |
| 44 |
|
| 45 |
int version; |
| 46 |
double version_number; |
| 47 |
double * coord; |
| 48 |
|
| 49 |
char buffer[3][MAX_STR_LENGTH + 1]; |
| 50 |
char *bptr[3]; |
| 51 |
|
| 52 |
int * element_order_map ; |
| 53 |
|
| 54 |
int * global_element_numbers ; |
| 55 |
int * global_node_numbers ; |
| 56 |
|
| 57 |
/*block info*/ |
| 58 |
int * block_id ; |
| 59 |
char ** element_types ; |
| 60 |
int * elements ; |
| 61 |
int * nodes_per_element ; |
| 62 |
int * element_attributes ; |
| 63 |
int ** elmt_node_linkage ; |
| 64 |
|
| 65 |
/*side sets*/ |
| 66 |
int * side_set_id ; |
| 67 |
int * num_elements_in_side_set ; |
| 68 |
int * num_df_in_side_set ; |
| 69 |
int **side_set_elements ; |
| 70 |
int **side_set_faces ; |
| 71 |
|
| 72 |
/*node sets*/ |
| 73 |
int * node_set_id ; |
| 74 |
int * num_nodes_in_node_set ; |
| 75 |
int * num_df_in_node_set ; |
| 76 |
int **node_set_nodes ; |
| 77 |
|
| 78 |
/*qa*/ |
| 79 |
int num_qa_records; |
| 80 |
int num_info_records; |
| 81 |
char* qaRecord[100][4]; |
| 82 |
char** info_records ; |
| 83 |
|
| 84 |
/*nemesis data*/ |
| 85 |
int num_nodes_global; |
| 86 |
int num_elems_global; |
| 87 |
int num_elm_blks_global; |
| 88 |
int num_node_sets_global; |
| 89 |
int num_side_sets_global; |
| 90 |
int num_total_proc; |
| 91 |
int num_proc_in_file; |
| 92 |
char type[2]; |
| 93 |
|
| 94 |
/*nemesis data*/ |
| 95 |
/* global info*/ |
| 96 |
|
| 97 |
int * elem_blk_ids_global ; |
| 98 |
int * elem_blk_cnts_global ; |
| 99 |
|
| 100 |
int * ns_ids_global ; |
| 101 |
int * ns_cnts_global ; |
| 102 |
int * ns_df_cnts_global ; |
| 103 |
int * ss_ids_global ; |
| 104 |
int * ss_cnts_global ; |
| 105 |
int * ss_df_cnts_global ; |
| 106 |
|
| 107 |
/*parallel info*/ |
| 108 |
int num_internal_nodes; |
| 109 |
int num_border_nodes; |
| 110 |
int num_external_nodes; |
| 111 |
int num_internal_elems; |
| 112 |
int num_border_elems; |
| 113 |
int num_node_comm_maps; |
| 114 |
int num_elem_comm_maps; |
| 115 |
|
| 116 |
int * internal_elements ; |
| 117 |
int * border_elements ; |
| 118 |
int * internal_nodes ; |
| 119 |
int * border_nodes ; |
| 120 |
int * external_nodes ; |
| 121 |
|
| 122 |
int * node_cmap_node_cnts ; |
| 123 |
int * node_cmap_ids ; |
| 124 |
int * elem_cmap_elem_cnts ; |
| 125 |
int * elem_cmap_ids ; |
| 126 |
|
| 127 |
int ** comm_node_ids ; |
| 128 |
int ** comm_node_proc_ids ; |
| 129 |
int ** comm_elem_ids ; |
| 130 |
int ** comm_side_ids ; |
| 131 |
int ** comm_elem_proc_ids ; |
| 132 |
|
| 133 |
}mss; |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
/*****************************************************************************/ |
| 139 |
int main(int argc, char** argv) |
| 140 |
/*****************************************************************************/ |
| 141 |
{ |
| 142 |
int issz; |
| 143 |
int start_rank = 0; |
| 144 |
int end_rank = 0; |
| 145 |
char * out_file_name = NULL; |
| 146 |
FILE * infile = NULL; |
| 147 |
long size; |
| 148 |
char *file_char_array = NULL; |
| 149 |
|
| 150 |
// Teuchos-based optins |
| 151 |
Teuchos::CommandLineProcessor clp(false); |
| 152 |
|
| 153 |
int rank =0; |
| 154 |
clp.setOption("rank", &rank, "rank of processor"); |
| 155 |
int num_procs=1; |
| 156 |
clp.setOption("num_procs", &num_procs, "rank of processor"); |
| 157 |
int all = 0; |
| 158 |
clp.setOption("all", &all, "generate all meshes for number of processors"); |
| 159 |
int dimension = 3; |
| 160 |
clp.setOption("dimension", &dimension, "dimension"); |
| 161 |
std::string inFileName; |
| 162 |
clp.setOption("file", &inFileName, "mesh description file"); |
| 163 |
|
| 164 |
switch (clp.parse(argc, argv)) { |
| 165 |
case Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED: return EXIT_SUCCESS; |
| 166 |
case Teuchos::CommandLineProcessor::PARSE_ERROR: |
| 167 |
case Teuchos::CommandLineProcessor::PARSE_UNRECOGNIZED_OPTION: return EXIT_FAILURE; |
| 168 |
case Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL: break; |
| 169 |
} |
| 170 |
|
| 171 |
const char * file_name = inFileName.c_str(); |
| 172 |
|
| 173 |
if(rank < 0 || rank >= num_procs){ |
| 174 |
printf("rtpamgen: rank must be positive and between 0 and the number of processors %i\n",rank); |
| 175 |
exit(1); |
| 176 |
} |
| 177 |
|
| 178 |
if(num_procs < 0){ |
| 179 |
printf("rtpamgen: number of processors must be positive %i\n", num_procs); |
| 180 |
exit(1); |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
/*deal with all switch*/ |
| 185 |
end_rank = num_procs; |
| 186 |
if(!all){ |
| 187 |
start_rank = rank; |
| 188 |
end_rank = start_rank+1; |
| 189 |
} |
| 190 |
|
| 191 |
infile = fopen(file_name,"r"); |
| 192 |
if(!infile){ |
| 193 |
printf("unable to open input file "); |
| 194 |
return 1; |
| 195 |
} |
| 196 |
fseek(infile, 0, SEEK_END); |
| 197 |
size = ftell(infile); |
| 198 |
fseek(infile, 0, SEEK_SET); |
| 199 |
file_char_array = (char *)malloc(size + 1); |
| 200 |
file_char_array[size] = '\0'; |
| 201 |
fread(file_char_array, sizeof(char), size, infile); |
| 202 |
fclose(infile); |
| 203 |
|
| 204 |
/*create the out_file_name*/ |
| 205 |
out_file_name = (char*)malloc(MAX_STR_LENGTH+1); |
| 206 |
|
| 207 |
for( rank = start_rank; rank != end_rank; rank ++){ |
| 208 |
int cr_result; |
| 209 |
sprintf(out_file_name,"%s.exo.%i.%i",file_name,num_procs,rank); |
| 210 |
|
| 211 |
cr_result = Create_Pamgen_Mesh(file_char_array, |
| 212 |
dimension, |
| 213 |
rank, |
| 214 |
num_procs, |
| 215 |
INT_MAX); |
| 216 |
|
| 217 |
|
| 218 |
if (cr_result == ERROR_PARSING_DEFINITION){ |
| 219 |
int essz = getPamgenEchoStreamSize(); |
| 220 |
char * echo_char_array = (char *)malloc(essz+1); |
| 221 |
printf("PARSE ERROR\n"); |
| 222 |
echo_char_array[essz] = '\0'; |
| 223 |
echo_char_array = getPamgenEchoStream(echo_char_array); |
| 224 |
if(echo_char_array)printf(echo_char_array); |
| 225 |
if(cr_result == ERROR_CREATING_IMD)printf("ERROR Failure to create Inline_Mesh_Desc creation\n"); |
| 226 |
if(echo_char_array)free(echo_char_array); |
| 227 |
return 1; |
| 228 |
} |
| 229 |
|
| 230 |
if(cr_result == ERROR_CREATING_MS){ |
| 231 |
int essz = getPamgenErrorStreamSize(); |
| 232 |
char * error_char_array = (char *)malloc(essz+1); |
| 233 |
error_char_array[essz] = '\0'; |
| 234 |
error_char_array = getPamgenErrorStream(error_char_array); |
| 235 |
if(error_char_array)printf(error_char_array); |
| 236 |
printf("\nERROR Failure to create Mesh_Specification\n"); |
| 237 |
if(error_char_array)free(error_char_array); |
| 238 |
return 1; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
{ |
| 243 |
int wssz = getPamgenWarningStreamSize(); |
| 244 |
if(wssz){ |
| 245 |
char * warning_char_array = (char *)malloc(wssz+1); |
| 246 |
warning_char_array[wssz] = '\0'; |
| 247 |
warning_char_array = getPamgenWarningStream(warning_char_array); |
| 248 |
printf("WARNING Records\n"); |
| 249 |
printf(warning_char_array); |
| 250 |
free(warning_char_array); |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
{ |
| 256 |
issz = getPamgenInfoStreamSize(); |
| 257 |
if(issz){ |
| 258 |
char * info_char_array = (char *)malloc(issz+1); |
| 259 |
info_char_array[issz] = '\0'; |
| 260 |
info_char_array = getPamgenInfoStream(info_char_array); |
| 261 |
printf("INFO Records\n"); |
| 262 |
printf(info_char_array); |
| 263 |
free(info_char_array); |
| 264 |
} |
| 265 |
} |
| 266 |
|
| 267 |
read_mesh_to_memory(); |
| 268 |
|
| 269 |
write_mesh_to_stdout(); |
| 270 |
|
| 271 |
write_to_exodus(rank,num_procs,out_file_name); |
| 272 |
|
| 273 |
Delete_Pamgen_Mesh(); |
| 274 |
free_memory(); |
| 275 |
}/* end loop over all output ranks*/ |
| 276 |
|
| 277 |
if(file_char_array)free(file_char_array); |
| 278 |
if(out_file_name)free(out_file_name); |
| 279 |
} |
| 280 |
|
| 281 |
/*****************************************************************************/ |
| 282 |
void free_memory() |
| 283 |
/*****************************************************************************/ |
| 284 |
{ |
| 285 |
int i; |
| 286 |
int j; |
| 287 |
int b; |
| 288 |
for( i = 0; i < 100; i++){ |
| 289 |
for( j=0; j<4; j++){ |
| 290 |
free(mss.qaRecord[i][j]); |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
free(mss.coord); |
| 297 |
|
| 298 |
if (mss.num_elem){ |
| 299 |
free(mss.element_order_map); |
| 300 |
|
| 301 |
if (mss.num_elem){ |
| 302 |
free(mss.global_element_numbers); |
| 303 |
} |
| 304 |
|
| 305 |
if (mss.num_nodes){ |
| 306 |
free(mss.global_node_numbers); |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
/*block info*/ |
| 311 |
|
| 312 |
free(mss.block_id); |
| 313 |
free(mss.nodes_per_element); |
| 314 |
free(mss.element_attributes); |
| 315 |
free(mss.elements); |
| 316 |
|
| 317 |
|
| 318 |
for(i = 0; i < mss.num_elem_blk; i ++){ |
| 319 |
free(mss.element_types[i]); |
| 320 |
} |
| 321 |
|
| 322 |
/*connectivity*/ |
| 323 |
for(b = 0; b < mss.num_elem_blk; b++){ |
| 324 |
free(mss.elmt_node_linkage[b]); |
| 325 |
} |
| 326 |
free(mss.element_types); |
| 327 |
free(mss.elmt_node_linkage); |
| 328 |
|
| 329 |
|
| 330 |
if(mss.num_node_sets){ |
| 331 |
|
| 332 |
for(i = 0; i < mss.num_node_sets; i ++){ |
| 333 |
if(mss.num_nodes_in_node_set[i]) { |
| 334 |
free(mss.node_set_nodes[i]); |
| 335 |
} |
| 336 |
} |
| 337 |
free(mss.node_set_id); |
| 338 |
free(mss.num_nodes_in_node_set); |
| 339 |
free(mss.node_set_nodes); |
| 340 |
free(mss.num_df_in_node_set); |
| 341 |
|
| 342 |
} |
| 343 |
|
| 344 |
/*side sets*/ |
| 345 |
if(mss.num_side_sets){ |
| 346 |
|
| 347 |
for(i = 0; i < mss.num_side_sets; i ++){ |
| 348 |
|
| 349 |
free(mss.side_set_elements[i]); |
| 350 |
free(mss.side_set_faces[i]); |
| 351 |
|
| 352 |
} |
| 353 |
free(mss.side_set_id); |
| 354 |
free(mss.num_elements_in_side_set); |
| 355 |
free(mss.num_df_in_side_set); |
| 356 |
free(mss.side_set_elements); |
| 357 |
free(mss.side_set_faces); |
| 358 |
} |
| 359 |
|
| 360 |
|
| 361 |
if(mss.num_info_records) { |
| 362 |
for(i = 0; i < mss.num_info_records; i ++){ |
| 363 |
free(mss.info_records[i]); |
| 364 |
} |
| 365 |
free(mss.info_records); |
| 366 |
} |
| 367 |
|
| 368 |
|
| 369 |
/*nemesis data*/ |
| 370 |
/* global info*/ |
| 371 |
|
| 372 |
free(mss.elem_blk_ids_global); |
| 373 |
free(mss.elem_blk_cnts_global); |
| 374 |
|
| 375 |
free(mss.ns_ids_global); |
| 376 |
free(mss.ns_cnts_global); |
| 377 |
free(mss.ns_df_cnts_global); |
| 378 |
free(mss.ss_ids_global); |
| 379 |
free(mss.ss_cnts_global); |
| 380 |
free(mss.ss_df_cnts_global); |
| 381 |
|
| 382 |
free(mss.internal_elements); |
| 383 |
free(mss.border_elements); |
| 384 |
free(mss.internal_nodes); |
| 385 |
free(mss.border_nodes); |
| 386 |
free(mss.external_nodes); |
| 387 |
|
| 388 |
|
| 389 |
if(mss.num_node_comm_maps > 0){ |
| 390 |
|
| 391 |
for(j = 0; j < mss.num_node_comm_maps; j++) { |
| 392 |
free(mss.comm_node_ids[j]); |
| 393 |
free(mss.comm_node_proc_ids[j]); |
| 394 |
|
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
for(j = 0; j < mss.num_elem_comm_maps; j++) { |
| 399 |
free(mss.comm_elem_ids[j]); |
| 400 |
free(mss.comm_side_ids[j]); |
| 401 |
free(mss.comm_elem_proc_ids[j]); |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
}/*loop over num_elem_co*/ |
| 406 |
} |
| 407 |
|
| 408 |
|
| 409 |
free(mss.node_cmap_node_cnts); |
| 410 |
free(mss.node_cmap_ids); |
| 411 |
free(mss.comm_node_ids); |
| 412 |
free(mss.comm_node_proc_ids); |
| 413 |
|
| 414 |
free(mss.elem_cmap_elem_cnts); |
| 415 |
free(mss.elem_cmap_ids); |
| 416 |
free(mss.comm_elem_ids); |
| 417 |
free(mss.comm_side_ids); |
| 418 |
free(mss.comm_elem_proc_ids); |
| 419 |
|
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
/*****************************************************************************/ |
| 425 |
void read_mesh_to_memory() |
| 426 |
/*****************************************************************************/ |
| 427 |
{ |
| 428 |
int idum = 0; |
| 429 |
float fdum; |
| 430 |
int i; |
| 431 |
int j; |
| 432 |
int b; |
| 433 |
char * cdum = NULL; |
| 434 |
int error = 0; |
| 435 |
int id = 0; |
| 436 |
|
| 437 |
mss.bptr[0] = mss.buffer[0]; |
| 438 |
mss.bptr[1] = mss.buffer[1]; |
| 439 |
mss.bptr[2] = mss.buffer[2]; |
| 440 |
|
| 441 |
for(i = 0; i < 100; i++) |
| 442 |
for(j=0; j<4; j++) mss.qaRecord[i][j] = (char*)malloc(MAX_STR_LENGTH+1) ; |
| 443 |
|
| 444 |
|
| 445 |
error += im_ex_get_init ( id, |
| 446 |
mss.title, |
| 447 |
&mss.num_dim, |
| 448 |
&(mss.num_nodes), |
| 449 |
&mss.num_elem, |
| 450 |
&mss.num_elem_blk, |
| 451 |
&mss.num_node_sets, |
| 452 |
&mss.num_side_sets); |
| 453 |
|
| 454 |
|
| 455 |
error += im_ex_inquire(id, IM_EX_INQ_NS_NODE_LEN, (int*)&mss.num_node_set_nodes, |
| 456 |
&fdum, cdum); |
| 457 |
error += im_ex_inquire(id, IM_EX_INQ_NS_DF_LEN, (int*)&mss.num_node_set_dfs, |
| 458 |
&fdum, cdum); |
| 459 |
error += im_ex_inquire(id, IM_EX_INQ_SS_ELEM_LEN, (int*)&mss.num_side_set_elements, |
| 460 |
&fdum, cdum); |
| 461 |
error += im_ex_inquire(id, IM_EX_INQ_SS_NODE_LEN, (int*)&mss.num_side_set_nodes, |
| 462 |
&fdum, cdum); |
| 463 |
error += im_ex_inquire(id, IM_EX_INQ_SS_DF_LEN, (int*)&mss.num_side_set_dfs, |
| 464 |
&fdum, cdum); |
| 465 |
|
| 466 |
/* get version number*/ |
| 467 |
|
| 468 |
error += im_ex_inquire(id, IM_EX_INQ_API_VERS, &idum, &fdum, cdum); |
| 469 |
|
| 470 |
mss.version_number = (double) fdum; |
| 471 |
|
| 472 |
mss.version = (int) mss.version_number; |
| 473 |
|
| 474 |
/* get genesis-II parameters*/ |
| 475 |
|
| 476 |
error += im_ex_inquire(id, IM_EX_INQ_EB_PROP, (int*)&mss.num_block_properties, &fdum, cdum); |
| 477 |
|
| 478 |
error += im_ex_inquire(id, IM_EX_INQ_NS_PROP, (int*)&mss.num_node_set_properties, |
| 479 |
&fdum, cdum); |
| 480 |
|
| 481 |
error += im_ex_inquire(id, IM_EX_INQ_SS_PROP, (int*)&mss.num_side_set_properties, |
| 482 |
&fdum, cdum); |
| 483 |
|
| 484 |
mss.coord = (double *)malloc(mss.num_nodes*mss.num_dim*sizeof(double)); |
| 485 |
|
| 486 |
error += im_ex_get_coord(id,mss.coord,mss.coord+mss.num_nodes,mss.coord+2*mss.num_nodes); |
| 487 |
|
| 488 |
|
| 489 |
error += im_ex_get_coord_names (id, mss.bptr); |
| 490 |
|
| 491 |
if (mss.num_elem){ |
| 492 |
mss.element_order_map = (int *)malloc(mss.num_elem * sizeof(int)); |
| 493 |
error += im_ex_get_map(id, mss.element_order_map); |
| 494 |
|
| 495 |
if (mss.num_elem){ |
| 496 |
mss.global_element_numbers = (int *)malloc(mss.num_elem*sizeof(int)); |
| 497 |
error += im_ex_get_elem_num_map(id, mss.global_element_numbers); |
| 498 |
} |
| 499 |
|
| 500 |
if (mss.num_nodes){ |
| 501 |
mss.global_node_numbers = (int *)malloc(mss.num_nodes * sizeof(int)); |
| 502 |
error += im_ex_get_node_num_map(id, mss.global_node_numbers); |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
/*block info*/ |
| 507 |
|
| 508 |
mss.block_id = (int *)malloc(mss.num_elem_blk*sizeof(int)); |
| 509 |
mss.nodes_per_element = (int *)malloc(mss.num_elem_blk*sizeof(int)); |
| 510 |
mss.element_attributes = (int *)malloc(mss.num_elem_blk*sizeof(int)); |
| 511 |
mss.elements = (int *)malloc(mss.num_elem_blk*sizeof(int)); |
| 512 |
mss.element_types = (char **)malloc(mss.num_elem_blk*sizeof(char *)); |
| 513 |
mss.elmt_node_linkage = (int **)malloc(mss.num_elem_blk*sizeof(int*)); |
| 514 |
|
| 515 |
error += im_ex_get_elem_blk_ids(id, mss.block_id); |
| 516 |
|
| 517 |
for(i = 0; i < mss.num_elem_blk; i ++){ |
| 518 |
mss.element_types[i] = (char *)malloc((MAX_STR_LENGTH + 1)*sizeof(char)); |
| 519 |
error += im_ex_get_elem_block(id, |
| 520 |
mss.block_id[i], |
| 521 |
mss.element_types[i], |
| 522 |
(int*)&(mss.elements[i]), |
| 523 |
(int*)&(mss.nodes_per_element[i]), |
| 524 |
(int*)&(mss.element_attributes[i])); |
| 525 |
} |
| 526 |
|
| 527 |
/*connectivity*/ |
| 528 |
for(b = 0; b < mss.num_elem_blk; b++){ |
| 529 |
mss.elmt_node_linkage[b] = (int*)malloc(mss.nodes_per_element[b]*mss.elements[b]*sizeof(int)); |
| 530 |
error += im_ex_get_elem_conn(id,mss.block_id[b],mss.elmt_node_linkage[b]); |
| 531 |
} |
| 532 |
|
| 533 |
|
| 534 |
if(mss.num_node_sets){ |
| 535 |
mss.node_set_id = (int *) malloc(mss.num_node_sets*sizeof(int)); |
| 536 |
mss.num_nodes_in_node_set = (int *) malloc(mss.num_node_sets*sizeof(int)); |
| 537 |
mss.node_set_nodes = (int **)malloc(mss.num_node_sets*sizeof(int*)); |
| 538 |
mss.num_df_in_node_set = (int *) malloc(mss.num_node_sets*sizeof(int*)); |
| 539 |
|
| 540 |
error += im_ex_get_node_set_ids(id, mss.node_set_id); |
| 541 |
|
| 542 |
|
| 543 |
for(i = 0; i < mss.num_node_sets; i ++){ |
| 544 |
error += im_ex_get_node_set_param(id, mss.node_set_id[i], |
| 545 |
(int*)&mss.num_nodes_in_node_set[i], |
| 546 |
(int*)&mss.num_df_in_node_set[i]); |
| 547 |
|
| 548 |
mss.node_set_nodes[i] = NULL; |
| 549 |
|
| 550 |
if(mss.num_nodes_in_node_set[i]) { |
| 551 |
mss.node_set_nodes[i] = (int *)malloc(mss.num_nodes_in_node_set[i]*sizeof(int)); |
| 552 |
error += im_ex_get_node_set(id, mss.node_set_id[i], mss.node_set_nodes[i]); |
| 553 |
} |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
/*side sets*/ |
| 558 |
if(mss.num_side_sets){ |
| 559 |
mss.side_set_id = (int*)malloc(mss.num_side_sets*sizeof(int)); |
| 560 |
mss.num_elements_in_side_set = (int*)malloc(mss.num_side_sets*sizeof(int)); |
| 561 |
mss.num_df_in_side_set = (int*)malloc(mss.num_side_sets*sizeof(int)); |
| 562 |
mss.side_set_elements = (int**)malloc(mss.num_side_sets*sizeof(int *)); |
| 563 |
mss.side_set_faces = (int **)malloc(mss.num_side_sets*sizeof(int*)); |
| 564 |
|
| 565 |
error += im_ex_get_side_set_ids(id, mss.side_set_id); |
| 566 |
for(i = 0; i < mss.num_side_sets; i ++){ |
| 567 |
int ne = 0; |
| 568 |
error += im_ex_get_side_set_param(id, mss.side_set_id[i], |
| 569 |
(int*)&mss.num_elements_in_side_set[i], |
| 570 |
(int*)&mss.num_df_in_side_set[i]); |
| 571 |
|
| 572 |
ne = mss.num_elements_in_side_set[i]; |
| 573 |
mss.side_set_elements[i] = (int*)malloc(ne*sizeof(int)); |
| 574 |
mss.side_set_faces[i] = (int*)malloc(ne*sizeof(int)); |
| 575 |
if(ne){ |
| 576 |
error += im_ex_get_side_set(id, mss.side_set_id[i], |
| 577 |
mss.side_set_elements[i], |
| 578 |
mss.side_set_faces[i]); |
| 579 |
|
| 580 |
} |
| 581 |
} |
| 582 |
} |
| 583 |
|
| 584 |
error += im_ex_inquire(id, IM_EX_INQ_QA, (int*)&mss.num_qa_records, &fdum, cdum); |
| 585 |
|
| 586 |
if(mss.num_qa_records)error += im_ex_get_qa(id,mss.qaRecord); |
| 587 |
|
| 588 |
|
| 589 |
error += im_ex_inquire(id, IM_EX_INQ_INFO, (int*)&mss.num_info_records, &fdum, cdum); |
| 590 |
if(mss.num_info_records) { |
| 591 |
mss.info_records = (char **)malloc(mss.num_info_records*sizeof(char *));/*new std::string[num_info_records];*/ |
| 592 |
for(i = 0; i < mss.num_info_records; i ++){ |
| 593 |
mss.info_records[i] = (char *)malloc(MAX_STR_LENGTH+1); |
| 594 |
} |
| 595 |
error += im_ex_get_info(id, mss.info_records); |
| 596 |
} |
| 597 |
|
| 598 |
|
| 599 |
/*nemesis data*/ |
| 600 |
/* global info*/ |
| 601 |
if ( im_ne_get_init_global(id, &mss.num_nodes_global, &mss.num_elems_global, |
| 602 |
&mss.num_elm_blks_global, &mss.num_node_sets_global, |
| 603 |
&mss.num_side_sets_global) < 0 ) |
| 604 |
++error; |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
if ( im_ne_get_init_info(id, &mss.num_total_proc, &mss.num_proc_in_file, mss.type) < 0 ) |
| 609 |
++error; |
| 610 |
|
| 611 |
mss.elem_blk_ids_global = (int*)malloc(mss.num_elm_blks_global*sizeof(int)); |
| 612 |
mss.elem_blk_cnts_global = (int*)malloc(mss.num_elm_blks_global*sizeof(int)); |
| 613 |
|
| 614 |
if ( im_ne_get_eb_info_global(id,mss.elem_blk_ids_global,mss.elem_blk_cnts_global) < 0 ) |
| 615 |
++error; |
| 616 |
|
| 617 |
mss.ns_ids_global = (int *)malloc(mss.num_node_sets_global*sizeof(int)); |
| 618 |
mss.ns_cnts_global = (int *)malloc(mss.num_node_sets_global*sizeof(int)); |
| 619 |
mss.ns_df_cnts_global = (int *)malloc(mss.num_node_sets_global*sizeof(int)); |
| 620 |
mss.ss_ids_global = (int *)malloc(mss.num_side_sets_global*sizeof(int)); |
| 621 |
mss.ss_cnts_global = (int *)malloc(mss.num_side_sets_global*sizeof(int)); |
| 622 |
mss.ss_df_cnts_global = (int *)malloc(mss.num_side_sets_global*sizeof(int)); |
| 623 |
|
| 624 |
|
| 625 |
if ( mss.num_node_sets_global > 0 ) { |
| 626 |
if ( im_ne_get_ns_param_global(id,mss.ns_ids_global,mss.ns_cnts_global, |
| 627 |
mss.ns_df_cnts_global) < 0 )++error; |
| 628 |
} |
| 629 |
|
| 630 |
if ( mss.num_side_sets_global > 0 ) { |
| 631 |
if ( im_ne_get_ss_param_global(id,mss.ss_ids_global,mss.ss_cnts_global, |
| 632 |
mss.ss_df_cnts_global) < 0 ) ++error; |
| 633 |
} |
| 634 |
|
| 635 |
/*parallel info*/ |
| 636 |
if ( im_ne_get_loadbal_param( id, |
| 637 |
&mss.num_internal_nodes, |
| 638 |
&mss.num_border_nodes, |
| 639 |
&mss.num_external_nodes, |
| 640 |
&mss.num_internal_elems, |
| 641 |
&mss.num_border_elems, |
| 642 |
&mss.num_node_comm_maps, |
| 643 |
&mss.num_elem_comm_maps, |
| 644 |
0/*unused*/ ) < 0 )++error; |
| 645 |
|
| 646 |
mss.internal_elements = (int *)malloc(mss.num_internal_elems*sizeof(int)); |
| 647 |
mss.border_elements = (int *)malloc(mss.num_border_elems*sizeof(int)); |
| 648 |
mss.internal_nodes = (int *)malloc(mss.num_internal_nodes*sizeof(int)); |
| 649 |
mss.border_nodes = (int *)malloc(mss.num_border_nodes*sizeof(int)); |
| 650 |
mss.external_nodes = (int *)malloc(mss.num_external_nodes*sizeof(int)); |
| 651 |
|
| 652 |
if ( im_ne_get_elem_map( id, |
| 653 |
mss.internal_elements, |
| 654 |
mss.border_elements, |
| 655 |
0/* not used proc_id*/ ) < 0 )++error; |
| 656 |
|
| 657 |
if ( im_ne_get_node_map( id, |
| 658 |
mss.internal_nodes, |
| 659 |
mss.border_nodes, |
| 660 |
mss.external_nodes, |
| 661 |
0/* not used proc_id*/ ) < 0 )++error; |
| 662 |
|
| 663 |
|
| 664 |
if(mss.num_node_comm_maps > 0){ |
| 665 |
|
| 666 |
mss.node_cmap_node_cnts = (int*) malloc(mss.num_node_comm_maps*sizeof(int)); |
| 667 |
mss.node_cmap_ids = (int*) malloc(mss.num_node_comm_maps*sizeof(int)); |
| 668 |
mss.comm_node_ids = (int**)malloc(mss.num_node_comm_maps*sizeof(int*)); |
| 669 |
mss.comm_node_proc_ids = (int**)malloc(mss.num_node_comm_maps*sizeof(int*)); |
| 670 |
|
| 671 |
mss.elem_cmap_elem_cnts = (int*) malloc(mss.num_elem_comm_maps*sizeof(int)); |
| 672 |
mss.elem_cmap_ids = (int*) malloc(mss.num_elem_comm_maps*sizeof(int)); |
| 673 |
mss.comm_elem_ids = (int**)malloc(mss.num_elem_comm_maps*sizeof(int*)); |
| 674 |
mss.comm_side_ids = (int**)malloc(mss.num_elem_comm_maps*sizeof(int*)); |
| 675 |
mss.comm_elem_proc_ids = (int**)malloc(mss.num_elem_comm_maps*sizeof(int*)); |
| 676 |
|
| 677 |
if ( im_ne_get_cmap_params( id, |
| 678 |
mss.node_cmap_ids, |
| 679 |
(int*)mss.node_cmap_node_cnts, |
| 680 |
mss.elem_cmap_ids, |
| 681 |
(int*)mss.elem_cmap_elem_cnts, |
| 682 |
0/*not used proc_id*/ ) < 0 )++error; |
| 683 |
|
| 684 |
for(j = 0; j < mss.num_node_comm_maps; j++) { |
| 685 |
mss.comm_node_ids[j] = (int *)malloc(mss.node_cmap_node_cnts[j]*sizeof(int)); |
| 686 |
mss.comm_node_proc_ids[j] = (int *)malloc(mss.node_cmap_node_cnts[j]*sizeof(int)); |
| 687 |
if ( im_ne_get_node_cmap( id, |
| 688 |
mss.node_cmap_ids[j], |
| 689 |
mss.comm_node_ids[j], |
| 690 |
mss.comm_node_proc_ids[j], |
| 691 |
0/*not used proc_id*/ ) < 0 )++error; |
| 692 |
|
| 693 |
} |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
for(j = 0; j < mss.num_elem_comm_maps; j++) { |
| 698 |
mss.comm_elem_ids[j] = (int *)malloc(mss.elem_cmap_elem_cnts[j]*sizeof(int)); |
| 699 |
mss.comm_side_ids[j] = (int *)malloc(mss.elem_cmap_elem_cnts[j]*sizeof(int)); |
| 700 |
mss.comm_elem_proc_ids[j] = (int *)malloc(mss.elem_cmap_elem_cnts[j]*sizeof(int)); |
| 701 |
if ( im_ne_get_elem_cmap( id, |
| 702 |
mss.elem_cmap_ids[j], |
| 703 |
mss.comm_elem_ids[j], |
| 704 |
mss.comm_side_ids[j], |
| 705 |
mss.comm_elem_proc_ids[j], |
| 706 |
0 /*not used proc_id*/ ) < 0 )++error; |
| 707 |
|
| 708 |
|
| 709 |
}/*loop over num_elem_co*/ |
| 710 |
} |
| 711 |
} |
| 712 |
} |
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
/*****************************************************************************/ |
| 717 |
void write_mesh_to_stdout() |
| 718 |
/*****************************************************************************/ |
| 719 |
{ |
| 720 |
int i; |
| 721 |
int j; |
| 722 |
int b; |
| 723 |
int ict; |
| 724 |
int nct; |
| 725 |
|
| 726 |
printf("\nExodus header info:\nTitle: %s\nDimension %i \nNumber of Nodes %i \nNumber of Elements %i \nNumber of Element Blocks %i \nNumber of Node Sets %i \nNumber of Side Sets %i \n\n", |
| 727 |
mss.title, |
| 728 |
mss.num_dim, |
| 729 |
mss.num_nodes, |
| 730 |
mss.num_elem, |
| 731 |
mss.num_elem_blk, |
| 732 |
mss.num_node_sets, |
| 733 |
mss.num_side_sets); |
| 734 |
|
| 735 |
|
| 736 |
printf("num node set nodes %i\n",mss.num_node_set_nodes); |
| 737 |
printf("num node set dfs %i\n",mss.num_node_set_dfs); |
| 738 |
|
| 739 |
printf("num side set elements %i\n",mss.num_side_set_elements); |
| 740 |
printf("num side set nodes %i\n",mss.num_side_set_nodes); |
| 741 |
printf("num side set dfs %i\n",mss.num_side_set_dfs); |
| 742 |
|
| 743 |
/* get version number*/ |
| 744 |
printf("num block properties %i\n",mss.num_block_properties); |
| 745 |
printf("num node set properties %i\n",mss.num_node_set_properties); |
| 746 |
printf("num side set properties %i\n",mss.num_side_set_properties); |
| 747 |
|
| 748 |
|
| 749 |
printf("A taste of coords\n"); |
| 750 |
for(i = 0; i < mss.num_nodes && i < 10; i ++){ |
| 751 |
if(mss.num_dim == 3) printf("X %f Y %f Z %f \n",mss.coord[i],mss.coord[i+mss.num_nodes],mss.coord[i+2*mss.num_nodes]); |
| 752 |
if(mss.num_dim == 2) printf("X %f Y %f \n",mss.coord[i],mss.coord[i+mss.num_nodes]); |
| 753 |
} |
| 754 |
|
| 755 |
for(i = 0; i < mss.num_dim; i ++)printf("coord name %i %s\n",i,mss.bptr[i]); |
| 756 |
|
| 757 |
if (mss.num_elem){ |
| 758 |
|
| 759 |
printf ("A tast of map\n"); |
| 760 |
for(i = 0; i < mss.num_elem && i < 10; i ++)printf("map i=%i, val=%i\n",i,mss.element_order_map[i]); |
| 761 |
if (mss.num_elem){ |
| 762 |
printf ("A tast of global elem numbers\n"); |
| 763 |
for(i = 0; i < mss.num_elem && i < 10; i ++)printf("global el num i=%i, val=%i\n",i,mss.global_element_numbers[i]); |
| 764 |
} |
| 765 |
|
| 766 |
if (mss.num_nodes){ |
| 767 |
printf ("A tast of global elem numbers\n"); |
| 768 |
for(i = 0; i < mss.num_elem && i < 10; i ++)printf("global node num i=%i, val=%i\n",i,mss.global_node_numbers[i]); |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
/*block info*/ |
| 773 |
|
| 774 |
for(i = 0; i < mss.num_elem_blk; i ++){ |
| 775 |
printf("block i = %i has id %i \n",i,mss.block_id[i]); |
| 776 |
printf("block i = %i\n",i); |
| 777 |
printf("block id %i\n",mss.block_id[i]); |
| 778 |
printf("element_type %s\n",mss.element_types[i]); |
| 779 |
printf("num elements %i\n",mss.elements[i]); |
| 780 |
printf("nodes per element %i\n",mss.nodes_per_element[i]); |
| 781 |
printf("element attributes %i\n",mss.element_attributes[i]); |
| 782 |
} |
| 783 |
|
| 784 |
/*connectivity*/ |
| 785 |
for(b = 0; b < mss.num_elem_blk; b++){ |
| 786 |
for(ict = 0; ict < mss.elements[b] && ict < 10;ict++){ |
| 787 |
printf("block %i element %i connectivty ",mss.block_id[b],ict); |
| 788 |
for(nct = 0; nct < mss.nodes_per_element[b]; nct++){ |
| 789 |
printf("%i ",mss.elmt_node_linkage[b][nct+ict*mss.nodes_per_element[b]]); |
| 790 |
} |
| 791 |
printf("\n"); |
| 792 |
} |
| 793 |
} |
| 794 |
|
| 795 |
|
| 796 |
if(mss.num_node_sets){ |
| 797 |
for(i = 0; i < mss.num_node_sets; i ++){ |
| 798 |
printf("Nodeset i = %i id = %i has %i nodes\n",i,mss.node_set_id[i],mss.num_nodes_in_node_set[i]); |
| 799 |
for(j = 0; j < mss.num_nodes_in_node_set[i] && j < 10; j ++){ |
| 800 |
printf("nodeset node i=%i = %i\n",j,mss.node_set_nodes[i][j]); |
| 801 |
} |
| 802 |
} |
| 803 |
} |
| 804 |
|
| 805 |
/*side sets*/ |
| 806 |
if(mss.num_side_sets){ |
| 807 |
for(i = 0; i < mss.num_side_sets; i ++){ |
| 808 |
int ne = 0; |
| 809 |
printf("Side set index %i id %i has %i elements\n",i,mss.side_set_id[i],mss.num_elements_in_side_set[i]); |
| 810 |
ne = mss.num_elements_in_side_set[i]; |
| 811 |
if(ne){ |
| 812 |
for(j = 0; j < ne && j < 10; j ++){ |
| 813 |
printf("element %i and face %i\n",mss.side_set_elements[i][j],mss.side_set_faces[i][j]); |
| 814 |
} |
| 815 |
} |
| 816 |
} |
| 817 |
} |
| 818 |
|
| 819 |
printf("num qa records %i\n",mss.num_qa_records); |
| 820 |
|
| 821 |
for(i = 0; i < mss.num_qa_records; i ++){ |
| 822 |
printf("\nQA Record %i\n %s\n%s\n", |
| 823 |
i, |
| 824 |
mss.qaRecord[i][0], |
| 825 |
mss.qaRecord[i][1]); |
| 826 |
} |
| 827 |
|
| 828 |
printf("Num Info Records %i\n",mss.num_info_records); |
| 829 |
if(mss.num_info_records) { |
| 830 |
printf("Info Records\n"); |
| 831 |
for(i = 0; i < mss.num_info_records; i ++){ |
| 832 |
printf(mss.info_records[i]); |
| 833 |
} |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
/*nemesis data*/ |
| 838 |
/* global info*/ |
| 839 |
|
| 840 |
printf("Nemesis data\n"); |
| 841 |
printf("Num nodes global %i\n",mss.num_nodes_global); |
| 842 |
printf("Num elems global %i\n",mss.num_elems_global); |
| 843 |
printf("Num elm_blks global %i\n",mss.num_elm_blks_global); |
| 844 |
printf("Num node sets global %i\n",mss.num_node_sets_global); |
| 845 |
printf("Num side sets global %i\n",mss.num_side_sets_global); |
| 846 |
printf("Num total proc %i\n",mss.num_total_proc); |
| 847 |
printf("Num proc in file %i\n",mss.num_proc_in_file); |
| 848 |
|
| 849 |
for(i = 0; i < mss.num_elm_blks_global; i ++){ |
| 850 |
printf("element block index %i has id %i and %i elements\n",i,mss.elem_blk_ids_global[i],mss.elem_blk_cnts_global[i]); |
| 851 |
} |
| 852 |
|
| 853 |
if ( mss.num_node_sets_global > 0 ) { |
| 854 |
for(i = 0; i < mss.num_node_sets_global;i ++){ |
| 855 |
printf("global ns info for ns index %i id %i num_nodes = %i num_ns_df = %i\n",i,mss.ns_ids_global[i],mss.ns_cnts_global[i],mss.ns_df_cnts_global[i]); |
| 856 |
} |
| 857 |
} |
| 858 |
|
| 859 |
if ( mss.num_side_sets_global > 0 ) { |
| 860 |
for(i = 0; i < mss.num_side_sets_global;i ++){ |
| 861 |
printf("global ss info for ss index %i id %i num_elements = %i num_ss_df = %i\n",i,mss.ss_ids_global[i],mss.ss_cnts_global[i],mss.ss_df_cnts_global[i]); |
| 862 |
} |
| 863 |
|
| 864 |
} |
| 865 |
|
| 866 |
/*parallel info*/ |
| 867 |
|
| 868 |
printf("Loadbal params:\nnum_internal_nodes %i\nnum_border_nodes%i\nnum_external_nodes%i\nnum_internal_elems%i\nnum_border_elems%i\nnum_node_comm_maps%i\nnum_elem_comm_maps%i\n", |
| 869 |
mss.num_internal_nodes, |
| 870 |
mss.num_border_nodes, |
| 871 |
mss.num_external_nodes, |
| 872 |
mss.num_internal_elems, |
| 873 |
mss.num_border_elems, |
| 874 |
mss.num_node_comm_maps, |
| 875 |
mss.num_elem_comm_maps); |
| 876 |
|
| 877 |
for(i = 0; i < mss.num_internal_nodes && i < 10; i ++)printf("internal node i=%i = %i\n",i,mss.internal_nodes[i]); |
| 878 |
for(i = 0; i < mss.num_border_nodes && i < 10; i ++)printf("border node i=%i = %i\n",i, mss.border_nodes[i]); |
| 879 |
for(i = 0; i < mss.num_external_nodes && i < 10; i ++)printf("external node i=%i = %i\n",i,mss.external_nodes[i]); |
| 880 |
for(i = 0; i < mss.num_internal_elems && i < 10; i ++)printf("internal elem i=%i = %i\n",i,mss.internal_elements[i]); |
| 881 |
for(i = 0; i < mss.num_border_elems && i < 10; i ++)printf("border elem i=%i = %i\n",i, mss.border_elements[i]); |
| 882 |
|
| 883 |
if(mss.num_node_comm_maps > 0){ |
| 884 |
|
| 885 |
for(i =0; i < mss.num_node_comm_maps; i ++){ |
| 886 |
printf("node_cmap_id i = %i node_cmap_id = %i node_cmap_node_cnts = %i\n",i,mss.node_cmap_ids[i],mss.node_cmap_node_cnts[i]); |
| 887 |
} |
| 888 |
for(i =0; i < mss.num_elem_comm_maps; i ++){ |
| 889 |
printf("elem_cmap_id i = %i elem_cmap_id = %i elem_cmap_elem_cnts = %i\n",i,mss.elem_cmap_ids[i],mss.elem_cmap_elem_cnts[i]); |
| 890 |
} |
| 891 |
|
| 892 |
for(j = 0; j < mss.num_node_comm_maps; j++) { |
| 893 |
for(i = 0; i < mss.node_cmap_node_cnts[j] && i < 10;i ++){ |
| 894 |
printf("node_cmap_id i=%i = %i comm_node_ids = %i comm_node_proc_ids = %i\n", |
| 895 |
i, |
| 896 |
mss.node_cmap_ids[j], |
| 897 |
mss.comm_node_ids[j][i], |
| 898 |
mss.comm_node_proc_ids[j][i]); |
| 899 |
} |
| 900 |
} |
| 901 |
|
| 902 |
for(j = 0; j < mss.num_elem_comm_maps; j++) { |
| 903 |
for(i = 0; i < mss.elem_cmap_elem_cnts[j] && i < 10;i ++){ |
| 904 |
printf("elem_cmap_id i=%i = %i comm_elem_ids = %i comm_side_ids = %i comm_elem_proc_ids = %i\n", |
| 905 |
i, |
| 906 |
mss.elem_cmap_ids[j], |
| 907 |
mss.comm_elem_ids[j][i], |
| 908 |
mss.comm_side_ids[j][i], |
| 909 |
mss.comm_elem_proc_ids[j][i]); |
| 910 |
} |
| 911 |
|
| 912 |
}/*loop over num_elem_co*/ |
| 913 |
} |
| 914 |
} |
| 915 |
} |
| 916 |
|
| 917 |
// Because this clashes with pamgen's definition |
| 918 |
#undef MAX_ERR_LENGTH |
| 919 |
|
| 920 |
#include "exodusII.h" |
| 921 |
#include "ne_nemesisI.h" |
| 922 |
|
| 923 |
#define PERROR printf("error %i ec %i\n",error,ec);ec++; |
| 924 |
#undef PERROR |
| 925 |
#define PERROR ; |
| 926 |
/*****************************************************************************/ |
| 927 |
void write_to_exodus(int rank, int num_procs, char * out_file_name) |
| 928 |
/*****************************************************************************/ |
| 929 |
{ |
| 930 |
|
| 931 |
int exo_access = EX_CLOBBER; |
| 932 |
int cpu_word_size = sizeof(double); |
| 933 |
int io_word_size = sizeof(double); |
| 934 |
int out_id; |
| 935 |
int i; |
| 936 |
int b; |
| 937 |
int error = 0; |
| 938 |
|
| 939 |
ex_init_params exinit; |
| 940 |
|
| 941 |
out_id = ex_create(out_file_name, exo_access, &cpu_word_size, |
| 942 |
&io_word_size); |
| 943 |
|
| 944 |
if (out_id < 0){ |
| 945 |
printf("error opening file"); |
| 946 |
} |
| 947 |
|
| 948 |
strncpy( exinit.title, mss.title, MAX_LINE_LENGTH-1 ); |
| 949 |
exinit.title[MAX_LINE_LENGTH-1] = 0; |
| 950 |
exinit.num_dim = mss.num_dim; |
| 951 |
exinit.num_nodes = mss.num_nodes; |
| 952 |
exinit.num_edge = 0; |
| 953 |
exinit.num_edge_blk = 0; |
| 954 |
exinit.num_face = 0; |
| 955 |
exinit.num_face_blk = 0; |
| 956 |
exinit.num_elem = mss.num_elem; |
| 957 |
exinit.num_elem_blk = mss.num_elem_blk; |
| 958 |
exinit.num_node_sets = mss.num_node_sets; |
| 959 |
exinit.num_edge_sets = 0; |
| 960 |
exinit.num_face_sets = 0; |
| 961 |
exinit.num_side_sets = mss.num_side_sets; |
| 962 |
exinit.num_elem_sets = 0; |
| 963 |
exinit.num_node_maps = 0; |
| 964 |
exinit.num_edge_maps = 0; |
| 965 |
exinit.num_face_maps = 0; |
| 966 |
exinit.num_elem_maps = 0; |
| 967 |
|
| 968 |
|
| 969 |
PERROR; |
| 970 |
|
| 971 |
|
| 972 |
if ( ex_put_init_ext(out_id, &exinit) < 0 ) |
| 973 |
++error; |
| 974 |
PERROR; |
| 975 |
|
| 976 |
/* now write parallel global information*/ |
| 977 |
|
| 978 |
if ( ne_put_init_global( out_id, |
| 979 |
mss.num_nodes_global, |
| 980 |
mss.num_elems_global, |
| 981 |
mss.num_elm_blks_global, |
| 982 |
mss.num_node_sets_global, |
| 983 |
mss.num_side_sets_global ) < 0 ) |
| 984 |
++error; |
| 985 |
PERROR; |
| 986 |
|
| 987 |
if ( ne_put_init_info( out_id, mss.num_total_proc, mss.num_proc_in_file, |
| 988 |
mss.type ) < 0 ) |
| 989 |
++error; |
| 990 |
PERROR; |
| 991 |
|
| 992 |
if ( ne_put_eb_info_global(out_id,mss.elem_blk_ids_global,mss.elem_blk_cnts_global) < 0 ) |
| 993 |
++error; |
| 994 |
PERROR; |
| 995 |
|
| 996 |
if ( mss.num_node_sets_global > 0 ) { |
| 997 |
if ( ne_put_ns_param_global( out_id, |
| 998 |
mss.ns_ids_global, |
| 999 |
mss.ns_cnts_global, |
| 1000 |
mss.ns_df_cnts_global ) < 0 ) |
| 1001 |
++error; |
| 1002 |
} |
| 1003 |
PERROR; |
| 1004 |
|
| 1005 |
if ( mss.num_side_sets_global > 0 ) { |
| 1006 |
if ( ne_put_ss_param_global( out_id, |
| 1007 |
mss.ss_ids_global, |
| 1008 |
mss.ss_cnts_global, |
| 1009 |
mss.ss_df_cnts_global ) < 0 ) |
| 1010 |
++error; |
| 1011 |
} |
| 1012 |
PERROR; |
| 1013 |
|
| 1014 |
/*writingparallel info*/ |
| 1015 |
if ( ne_put_loadbal_param( out_id, |
| 1016 |
mss.num_internal_nodes, |
| 1017 |
mss.num_border_nodes, |
| 1018 |
mss.num_external_nodes, |
| 1019 |
mss.num_internal_elems, |
| 1020 |
mss.num_border_elems, |
| 1021 |
mss.num_node_comm_maps, |
| 1022 |
mss.num_elem_comm_maps, |
| 1023 |
rank ) < 0 ) |
| 1024 |
++error; |
| 1025 |
PERROR; |
| 1026 |
|
| 1027 |
if ( ne_put_cmap_params( out_id, |
| 1028 |
mss.node_cmap_ids, |
| 1029 |
(int*)mss.node_cmap_node_cnts, |
| 1030 |
mss.elem_cmap_ids, |
| 1031 |
(int*)mss.elem_cmap_elem_cnts, |
| 1032 |
rank ) < 0 ) |
| 1033 |
++error; |
| 1034 |
PERROR; |
| 1035 |
|
| 1036 |
if ( ne_put_elem_map( out_id, |
| 1037 |
mss.internal_elements, |
| 1038 |
mss.border_elements, |
| 1039 |
rank ) < 0 ) |
| 1040 |
++error; |
| 1041 |
PERROR; |
| 1042 |
|
| 1043 |
|
| 1044 |
if ( ne_put_node_map( out_id, |
| 1045 |
mss.internal_nodes, |
| 1046 |
mss.border_nodes, |
| 1047 |
mss.external_nodes, |
| 1048 |
rank ) < 0 ) |
| 1049 |
++error; |
| 1050 |
PERROR; |
| 1051 |
|
| 1052 |
for (i = 0; i < mss.num_node_comm_maps; i++) { |
| 1053 |
if ( ne_put_node_cmap( out_id, |
| 1054 |
mss.node_cmap_ids[i], |
| 1055 |
mss.comm_node_ids[i], |
| 1056 |
mss.comm_node_proc_ids[i], |
| 1057 |
rank ) < 0 ) |
| 1058 |
++error; |
| 1059 |
} |
| 1060 |
PERROR; |
| 1061 |
|
| 1062 |
|
| 1063 |
for (i = 0; i < mss.num_elem_comm_maps; i++) { |
| 1064 |
if ( ne_put_elem_cmap( out_id, |
| 1065 |
mss.elem_cmap_ids[i], |
| 1066 |
mss.comm_elem_ids[i], |
| 1067 |
mss.comm_side_ids[i], |
| 1068 |
mss.comm_elem_proc_ids[i], |
| 1069 |
rank ) < 0 ) |
| 1070 |
++error; |
| 1071 |
} |
| 1072 |
|
| 1073 |
PERROR; |
| 1074 |
|
| 1075 |
/*coords*/ |
| 1076 |
error += ex_put_coord(out_id, mss.coord, (mss.coord)+mss.num_nodes, (mss.coord)+2*mss.num_nodes); |
| 1077 |
PERROR; |
| 1078 |
error += ex_put_coord_names(out_id, mss.bptr); |
| 1079 |
PERROR; |
| 1080 |
/*map*/ |
| 1081 |
error += ex_put_map(out_id, mss.element_order_map); |
| 1082 |
PERROR; |
| 1083 |
error += ex_put_elem_num_map(out_id, mss.global_element_numbers); |
| 1084 |
PERROR; |
| 1085 |
error += ex_put_node_num_map(out_id, mss.global_node_numbers); |
| 1086 |
PERROR; |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
/*block info*/ |
| 1091 |
for(b = 0; b < mss.num_elem_blk; b++) |
| 1092 |
{ |
| 1093 |
int gpe = 0; |
| 1094 |
int fpe = 0; |
| 1095 |
error += ex_put_block( out_id, |
| 1096 |
EX_ELEM_BLOCK, |
| 1097 |
mss.block_id[b], |
| 1098 |
mss.element_types[b], |
| 1099 |
mss.elements[b], |
| 1100 |
mss.nodes_per_element[b], |
| 1101 |
gpe, fpe, |
| 1102 |
mss.element_attributes[b] ); /* num attr*/ |
| 1103 |
PERROR; |
| 1104 |
} |
| 1105 |
|
| 1106 |
/* write element connectivity information*/ |
| 1107 |
|
| 1108 |
for (b = 0; b < mss.num_elem_blk; b++) { |
| 1109 |
if ( mss.elements[b] > 0 ){ |
| 1110 |
error += ex_put_elem_conn(out_id,mss.block_id[b],mss.elmt_node_linkage[b]); |
| 1111 |
PERROR; |
| 1112 |
} |
| 1113 |
} |
| 1114 |
|
| 1115 |
|
| 1116 |
/* write in nodal boundary sets for the body.*/ |
| 1117 |
|
| 1118 |
for(i = 0; i < mss.num_node_sets; i++) { |
| 1119 |
error += ex_put_node_set_param(out_id, mss.node_set_id[i], |
| 1120 |
mss.num_nodes_in_node_set[i], |
| 1121 |
mss.num_df_in_node_set[i]); |
| 1122 |
PERROR; |
| 1123 |
if(mss.num_nodes_in_node_set[i]) |
| 1124 |
error += ex_put_node_set(out_id, mss.node_set_id[i], mss.node_set_nodes[i]); |
| 1125 |
PERROR; |
| 1126 |
|
| 1127 |
} |
| 1128 |
|
| 1129 |
for(i = 0; i < mss.num_side_sets; i++) { |
| 1130 |
error += ex_put_side_set_param(out_id, mss.side_set_id[i], |
| 1131 |
mss.num_elements_in_side_set[i], |
| 1132 |
mss.num_df_in_side_set[i]); |
| 1133 |
|
| 1134 |
PERROR; |
| 1135 |
if(mss.num_elements_in_side_set[i]) |
| 1136 |
error += ex_put_side_set(out_id, mss.side_set_id[i], |
| 1137 |
mss.side_set_elements[i], |
| 1138 |
mss.side_set_faces[i]); |
| 1139 |
PERROR; |
| 1140 |
} |
| 1141 |
|
| 1142 |
error += ex_put_qa(out_id, mss.num_qa_records, mss.qaRecord); |
| 1143 |
PERROR; |
| 1144 |
|
| 1145 |
ex_close(out_id); |
| 1146 |
|
| 1147 |
|
| 1148 |
} |