| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
/***************************************************************************** |
| 9 |
* |
| 10 |
* testwt2 - test write an ExodusII database file |
| 11 |
* |
| 12 |
* author - Sandia National Laboratories |
| 13 |
* Larry A. Schoof - Original |
| 14 |
* Vic Yarberry - Added headers and error logging |
| 15 |
* 7/7/93 Modified for use with Exodus 2.00 |
| 16 |
* |
| 17 |
* |
| 18 |
* environment - UNIX |
| 19 |
* |
| 20 |
* entry conditions - |
| 21 |
* |
| 22 |
* exit conditions - |
| 23 |
* |
| 24 |
* revision history - |
| 25 |
* |
| 26 |
* This is a test program for the C binding of the EXODUS II |
| 27 |
* database write routines. It tests multiple simultaneous output files. |
| 28 |
* |
| 29 |
* |
| 30 |
*****************************************************************************/ |
| 31 |
|
| 32 |
#include "exodusII.h" |
| 33 |
#include <stdio.h> |
| 34 |
#include <stdlib.h> |
| 35 |
int main(int argc, char **argv) |
| 36 |
{ |
| 37 |
int exoid, num_dim, num_nodes, num_elem, num_elem_blk; |
| 38 |
int exoid2, num_dim2, num_nodes2, num_elem2, num_elem_blk2; |
| 39 |
int num_elem_in_block[10], num_node_sets, num_nodes_per_elem[10]; |
| 40 |
int num_elem_in_block2[10], num_node_sets2, num_nodes_per_elem2[10]; |
| 41 |
int num_side_sets, error; |
| 42 |
int num_side_sets2; |
| 43 |
int i, j, k, m; |
| 44 |
int *elem_map, *connect, node_list[100], elem_list[100], side_list[100]; |
| 45 |
int *elem_map2, *connect2, node_list2[100], elem_list2[100], side_list2[100]; |
| 46 |
int ebids[10]; |
| 47 |
int ebids2[10]; |
| 48 |
int num_qa_rec, num_info; |
| 49 |
int num_qa_rec2, num_info2; |
| 50 |
int num_glo_vars, num_nod_vars, num_ele_vars; |
| 51 |
int num_glo_vars2, num_nod_vars2, num_ele_vars2; |
| 52 |
int *truth_tab; |
| 53 |
int whole_time_step, num_time_steps; |
| 54 |
int CPU_word_size, IO_word_size; |
| 55 |
int prop_array[2]; |
| 56 |
|
| 57 |
float *glob_var_vals, *nodal_var_vals, *elem_var_vals; |
| 58 |
float time_value; |
| 59 |
float time_value2; |
| 60 |
float x[100], y[100], z[100]; |
| 61 |
float attrib[1], dist_fact[100]; |
| 62 |
float attrib2[1], dist_fact2[100]; |
| 63 |
char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3]; |
| 64 |
char *coord_names2[3], *qa_record2[2][4], *info2[3], *var_names2[3]; |
| 65 |
char *prop_names[2]; |
| 66 |
|
| 67 |
ex_opts(EX_VERBOSE | EX_ABORT); |
| 68 |
|
| 69 |
/* Specify compute and i/o word size */ |
| 70 |
|
| 71 |
CPU_word_size = 0; /* sizeof(float) */ |
| 72 |
IO_word_size = 4; /* (4 bytes) */ |
| 73 |
|
| 74 |
/* create EXODUS II files (a "regular" and a "history") */ |
| 75 |
|
| 76 |
exoid = ex_create("test.exo", /* filename path */ |
| 77 |
EX_CLOBBER, /* create mode */ |
| 78 |
&CPU_word_size, /* CPU float word size in bytes */ |
| 79 |
&IO_word_size); /* I/O float word size in bytes */ |
| 80 |
printf("after ex_create for test.exo, exoid = %d\n", exoid); |
| 81 |
printf(" cpu word size: %d io word size: %d\n", CPU_word_size, IO_word_size); |
| 82 |
|
| 83 |
exoid2 = ex_create("test2.exo", /* filename path */ |
| 84 |
EX_CLOBBER, /* create mode */ |
| 85 |
&CPU_word_size, /* CPU float word size in bytes */ |
| 86 |
&IO_word_size); /* I/O float word size in bytes */ |
| 87 |
printf("after ex_create for test2.exo, exoid = %d\n", exoid2); |
| 88 |
|
| 89 |
/* initialize file with parameters */ |
| 90 |
|
| 91 |
num_dim = 3; |
| 92 |
num_nodes = 26; |
| 93 |
num_elem = 5; |
| 94 |
num_elem_blk = 5; |
| 95 |
num_node_sets = 2; |
| 96 |
num_side_sets = 5; |
| 97 |
|
| 98 |
error = ex_put_init(exoid, "This is a test", num_dim, num_nodes, num_elem, num_elem_blk, |
| 99 |
num_node_sets, num_side_sets); |
| 100 |
|
| 101 |
printf("after ex_put_init, error = %d\n", error); |
| 102 |
|
| 103 |
/* initialize file 2 with parameters */ |
| 104 |
|
| 105 |
num_dim2 = 3; |
| 106 |
num_nodes2 = 26; |
| 107 |
num_elem2 = 5; |
| 108 |
num_elem_blk2 = 5; |
| 109 |
num_node_sets2 = 2; |
| 110 |
num_side_sets2 = 5; |
| 111 |
|
| 112 |
error = ex_put_init(exoid2, "This is test 2", num_dim2, num_nodes2, num_elem2, num_elem_blk2, |
| 113 |
num_node_sets2, num_side_sets2); |
| 114 |
|
| 115 |
printf("after ex_put_init (2), error = %d\n", error); |
| 116 |
|
| 117 |
/* write nodal coordinates values and names to database */ |
| 118 |
|
| 119 |
/* Quad #1 */ |
| 120 |
x[0] = 0.0; |
| 121 |
y[0] = 0.0; |
| 122 |
z[0] = 0.0; |
| 123 |
x[1] = 1.0; |
| 124 |
y[1] = 0.0; |
| 125 |
z[1] = 0.0; |
| 126 |
x[2] = 1.0; |
| 127 |
y[2] = 1.0; |
| 128 |
z[2] = 0.0; |
| 129 |
x[3] = 0.0; |
| 130 |
y[3] = 1.0; |
| 131 |
z[3] = 0.0; |
| 132 |
|
| 133 |
/* Quad #2 */ |
| 134 |
x[4] = 1.0; |
| 135 |
y[4] = 0.0; |
| 136 |
z[4] = 0.0; |
| 137 |
x[5] = 2.0; |
| 138 |
y[5] = 0.0; |
| 139 |
z[5] = 0.0; |
| 140 |
x[6] = 2.0; |
| 141 |
y[6] = 1.0; |
| 142 |
z[6] = 0.0; |
| 143 |
x[7] = 1.0; |
| 144 |
y[7] = 1.0; |
| 145 |
z[7] = 0.0; |
| 146 |
|
| 147 |
/* Hex #1 */ |
| 148 |
x[8] = 0.0; |
| 149 |
y[8] = 0.0; |
| 150 |
z[8] = 0.0; |
| 151 |
x[9] = 10.0; |
| 152 |
y[9] = 0.0; |
| 153 |
z[9] = 0.0; |
| 154 |
x[10] = 10.0; |
| 155 |
y[10] = 0.0; |
| 156 |
z[10] = -10.0; |
| 157 |
x[11] = 1.0; |
| 158 |
y[11] = 0.0; |
| 159 |
z[11] = -10.0; |
| 160 |
x[12] = 1.0; |
| 161 |
y[12] = 10.0; |
| 162 |
z[12] = 0.0; |
| 163 |
x[13] = 10.0; |
| 164 |
y[13] = 10.0; |
| 165 |
z[13] = 0.0; |
| 166 |
x[14] = 10.0; |
| 167 |
y[14] = 10.0; |
| 168 |
z[14] = -10.0; |
| 169 |
x[15] = 1.0; |
| 170 |
y[15] = 10.0; |
| 171 |
z[15] = -10.0; |
| 172 |
|
| 173 |
/* Tetra #1 */ |
| 174 |
x[16] = 0.0; |
| 175 |
y[16] = 0.0; |
| 176 |
z[16] = 0.0; |
| 177 |
x[17] = 1.0; |
| 178 |
y[17] = 0.0; |
| 179 |
z[17] = 5.0; |
| 180 |
x[18] = 10.0; |
| 181 |
y[18] = 0.0; |
| 182 |
z[18] = 2.0; |
| 183 |
x[19] = 7.0; |
| 184 |
y[19] = 5.0; |
| 185 |
z[19] = 3.0; |
| 186 |
|
| 187 |
/* Wedge #1 */ |
| 188 |
x[20] = 3.0; |
| 189 |
y[20] = 0.0; |
| 190 |
z[20] = 6.0; |
| 191 |
x[21] = 6.0; |
| 192 |
y[21] = 0.0; |
| 193 |
z[21] = 0.0; |
| 194 |
x[22] = 0.0; |
| 195 |
y[22] = 0.0; |
| 196 |
z[22] = 0.0; |
| 197 |
x[23] = 3.0; |
| 198 |
y[23] = 2.0; |
| 199 |
z[23] = 6.0; |
| 200 |
x[24] = 6.0; |
| 201 |
y[24] = 2.0; |
| 202 |
z[24] = 2.0; |
| 203 |
x[25] = 0.0; |
| 204 |
y[25] = 2.0; |
| 205 |
z[25] = 0.0; |
| 206 |
|
| 207 |
error = ex_put_coord(exoid, x, y, z); |
| 208 |
printf("after ex_put_coord, error = %d\n", error); |
| 209 |
|
| 210 |
/* write nodal coordinates values and names to database 2 */ |
| 211 |
|
| 212 |
error = ex_put_coord(exoid2, x, y, z); |
| 213 |
printf("after ex_put_coord (2), error = %d\n", error); |
| 214 |
|
| 215 |
coord_names[0] = "xcoor"; |
| 216 |
coord_names[1] = "ycoor"; |
| 217 |
coord_names[2] = "zcoor"; |
| 218 |
|
| 219 |
error = ex_put_coord_names(exoid, coord_names); |
| 220 |
printf("after ex_put_coord_names, error = %d\n", error); |
| 221 |
|
| 222 |
coord_names2[0] = "xcoor"; |
| 223 |
coord_names2[1] = "ycoor"; |
| 224 |
coord_names2[2] = "zcoor"; |
| 225 |
|
| 226 |
error = ex_put_coord_names(exoid2, coord_names2); |
| 227 |
printf("after ex_put_coord_names (2), error = %d\n", error); |
| 228 |
|
| 229 |
/* write element order map */ |
| 230 |
|
| 231 |
elem_map = (int *)calloc(num_elem, sizeof(int)); |
| 232 |
|
| 233 |
for (i = 1; i <= num_elem; i++) { |
| 234 |
elem_map[i - 1] = i; |
| 235 |
} |
| 236 |
|
| 237 |
error = ex_put_id_map(exoid, EX_ELEM_MAP, elem_map); |
| 238 |
printf("after ex_put_id_map, error = %d\n", error); |
| 239 |
|
| 240 |
free(elem_map); |
| 241 |
|
| 242 |
elem_map2 = (int *)calloc(num_elem2, sizeof(int)); |
| 243 |
|
| 244 |
for (i = 1; i <= num_elem2; i++) { |
| 245 |
elem_map2[i - 1] = i; |
| 246 |
} |
| 247 |
|
| 248 |
error = ex_put_id_map(exoid2, EX_ELEM_MAP, elem_map2); |
| 249 |
printf("after ex_put_id_map (2), error = %d\n", error); |
| 250 |
|
| 251 |
free(elem_map2); |
| 252 |
|
| 253 |
/* write element block parameters */ |
| 254 |
|
| 255 |
num_elem_in_block[0] = 1; |
| 256 |
num_elem_in_block[1] = 1; |
| 257 |
num_elem_in_block[2] = 1; |
| 258 |
num_elem_in_block[3] = 1; |
| 259 |
num_elem_in_block[4] = 1; |
| 260 |
|
| 261 |
num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads */ |
| 262 |
num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads */ |
| 263 |
num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes */ |
| 264 |
num_nodes_per_elem[3] = 4; /* elements in block #3 are 4-node tetras */ |
| 265 |
num_nodes_per_elem[4] = 6; /* elements in block #3 are 6-node wedges */ |
| 266 |
|
| 267 |
ebids[0] = 10; |
| 268 |
ebids[1] = 11; |
| 269 |
ebids[2] = 12; |
| 270 |
ebids[3] = 13; |
| 271 |
ebids[4] = 14; |
| 272 |
|
| 273 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[0], "quad", num_elem_in_block[0], |
| 274 |
num_nodes_per_elem[0], 0, 0, 1); |
| 275 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 276 |
|
| 277 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[1], "quad", num_elem_in_block[1], |
| 278 |
num_nodes_per_elem[1], 0, 0, 1); |
| 279 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 280 |
|
| 281 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[2], "hex", num_elem_in_block[2], |
| 282 |
num_nodes_per_elem[2], 0, 0, 1); |
| 283 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 284 |
|
| 285 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[3], "tetra", num_elem_in_block[3], |
| 286 |
num_nodes_per_elem[3], 0, 0, 1); |
| 287 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 288 |
|
| 289 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[4], "wedge", num_elem_in_block[4], |
| 290 |
num_nodes_per_elem[4], 0, 0, 1); |
| 291 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 292 |
|
| 293 |
/* write element block properties */ |
| 294 |
|
| 295 |
prop_names[0] = "MATL"; |
| 296 |
prop_names[1] = "DENSITY"; |
| 297 |
error = ex_put_prop_names(exoid, EX_ELEM_BLOCK, 2, prop_names); |
| 298 |
printf("after ex_put_prop_names, error = %d\n", error); |
| 299 |
|
| 300 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[0], "MATL", 10); |
| 301 |
printf("after ex_put_prop, error = %d\n", error); |
| 302 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[1], "MATL", 20); |
| 303 |
printf("after ex_put_prop, error = %d\n", error); |
| 304 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[2], "MATL", 30); |
| 305 |
printf("after ex_put_prop, error = %d\n", error); |
| 306 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[3], "MATL", 40); |
| 307 |
printf("after ex_put_prop, error = %d\n", error); |
| 308 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[4], "MATL", 50); |
| 309 |
printf("after ex_put_prop, error = %d\n", error); |
| 310 |
|
| 311 |
num_elem_in_block2[0] = 1; |
| 312 |
num_elem_in_block2[1] = 1; |
| 313 |
num_elem_in_block2[2] = 1; |
| 314 |
num_elem_in_block2[3] = 1; |
| 315 |
num_elem_in_block2[4] = 1; |
| 316 |
|
| 317 |
num_nodes_per_elem2[0] = 4; /* elements in block #1 are 4-node quads */ |
| 318 |
num_nodes_per_elem2[1] = 4; /* elements in block #2 are 4-node quads */ |
| 319 |
num_nodes_per_elem2[2] = 8; /* elements in block #3 are 8-node hexes */ |
| 320 |
num_nodes_per_elem2[3] = 4; /* elements in block #3 are 4-node tetras */ |
| 321 |
num_nodes_per_elem2[4] = 6; /* elements in block #3 are 6-node wedges */ |
| 322 |
|
| 323 |
ebids2[0] = 10; |
| 324 |
ebids2[1] = 11; |
| 325 |
ebids2[2] = 12; |
| 326 |
ebids2[3] = 13; |
| 327 |
ebids2[4] = 14; |
| 328 |
|
| 329 |
error = ex_put_block(exoid2, EX_ELEM_BLOCK, ebids2[0], "quad", num_elem_in_block2[0], |
| 330 |
num_nodes_per_elem2[0], 0, 0, 1); |
| 331 |
printf("after ex_put_elem_block (2), error = %d\n", error); |
| 332 |
|
| 333 |
error = ex_put_block(exoid2, EX_ELEM_BLOCK, ebids2[1], "quad", num_elem_in_block2[1], |
| 334 |
num_nodes_per_elem2[1], 0, 0, 1); |
| 335 |
printf("after ex_put_elem_blocki (2), error = %d\n", error); |
| 336 |
|
| 337 |
error = ex_put_block(exoid2, EX_ELEM_BLOCK, ebids2[2], "hex", num_elem_in_block2[2], |
| 338 |
num_nodes_per_elem2[2], 0, 0, 1); |
| 339 |
printf("after ex_put_elem_blocki (2), error = %d\n", error); |
| 340 |
|
| 341 |
error = ex_put_block(exoid2, EX_ELEM_BLOCK, ebids2[3], "tetra", num_elem_in_block2[3], |
| 342 |
num_nodes_per_elem2[3], 0, 0, 1); |
| 343 |
printf("after ex_put_elem_block (2), error = %d\n", error); |
| 344 |
|
| 345 |
error = ex_put_block(exoid2, EX_ELEM_BLOCK, ebids2[4], "wedge", num_elem_in_block2[4], |
| 346 |
num_nodes_per_elem2[4], 0, 0, 1); |
| 347 |
printf("after ex_put_elem_block (2), error = %d\n", error); |
| 348 |
|
| 349 |
/* write element block properties for file 2 */ |
| 350 |
|
| 351 |
prop_names[0] = "MATL"; |
| 352 |
prop_names[1] = "DENSITY"; |
| 353 |
error = ex_put_prop_names(exoid2, EX_ELEM_BLOCK, 2, prop_names); |
| 354 |
printf("after ex_put_prop_names (2), error = %d\n", error); |
| 355 |
|
| 356 |
error = ex_put_prop(exoid2, EX_ELEM_BLOCK, ebids[0], "MATL", 100); |
| 357 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 358 |
error = ex_put_prop(exoid2, EX_ELEM_BLOCK, ebids[1], "MATL", 200); |
| 359 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 360 |
error = ex_put_prop(exoid2, EX_ELEM_BLOCK, ebids[2], "MATL", 300); |
| 361 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 362 |
error = ex_put_prop(exoid2, EX_ELEM_BLOCK, ebids[3], "MATL", 400); |
| 363 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 364 |
error = ex_put_prop(exoid2, EX_ELEM_BLOCK, ebids[4], "MATL", 500); |
| 365 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 366 |
|
| 367 |
/* write element connectivity */ |
| 368 |
|
| 369 |
connect = (int *)calloc(8, sizeof(int)); |
| 370 |
connect[0] = 1; |
| 371 |
connect[1] = 2; |
| 372 |
connect[2] = 3; |
| 373 |
connect[3] = 4; |
| 374 |
|
| 375 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[0], connect, NULL, NULL); |
| 376 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 377 |
|
| 378 |
connect[0] = 5; |
| 379 |
connect[1] = 6; |
| 380 |
connect[2] = 7; |
| 381 |
connect[3] = 8; |
| 382 |
|
| 383 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[1], connect, NULL, NULL); |
| 384 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 385 |
|
| 386 |
connect[0] = 9; |
| 387 |
connect[1] = 10; |
| 388 |
connect[2] = 11; |
| 389 |
connect[3] = 12; |
| 390 |
connect[4] = 13; |
| 391 |
connect[5] = 14; |
| 392 |
connect[6] = 15; |
| 393 |
connect[7] = 16; |
| 394 |
|
| 395 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[2], connect, NULL, NULL); |
| 396 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 397 |
|
| 398 |
connect[0] = 17; |
| 399 |
connect[1] = 18; |
| 400 |
connect[2] = 19; |
| 401 |
connect[3] = 20; |
| 402 |
|
| 403 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[3], connect, NULL, NULL); |
| 404 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 405 |
|
| 406 |
connect[0] = 21; |
| 407 |
connect[1] = 22; |
| 408 |
connect[2] = 23; |
| 409 |
connect[3] = 24; |
| 410 |
connect[4] = 25; |
| 411 |
connect[5] = 26; |
| 412 |
|
| 413 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[4], connect, NULL, NULL); |
| 414 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 415 |
|
| 416 |
free(connect); |
| 417 |
|
| 418 |
connect2 = (int *)calloc(8, sizeof(int)); |
| 419 |
connect2[0] = 1; |
| 420 |
connect2[1] = 2; |
| 421 |
connect2[2] = 3; |
| 422 |
connect2[3] = 4; |
| 423 |
|
| 424 |
error = ex_put_conn(exoid2, EX_ELEM_BLOCK, ebids2[0], connect2, NULL, NULL); |
| 425 |
printf("after ex_put_elem_conn (2), error = %d\n", error); |
| 426 |
|
| 427 |
connect2[0] = 5; |
| 428 |
connect2[1] = 6; |
| 429 |
connect2[2] = 7; |
| 430 |
connect2[3] = 8; |
| 431 |
|
| 432 |
error = ex_put_conn(exoid2, EX_ELEM_BLOCK, ebids2[1], connect2, NULL, NULL); |
| 433 |
printf("after ex_put_elem_conn (2), error = %d\n", error); |
| 434 |
|
| 435 |
connect2[0] = 9; |
| 436 |
connect2[1] = 10; |
| 437 |
connect2[2] = 11; |
| 438 |
connect2[3] = 12; |
| 439 |
connect2[4] = 13; |
| 440 |
connect2[5] = 14; |
| 441 |
connect2[6] = 15; |
| 442 |
connect2[7] = 16; |
| 443 |
|
| 444 |
error = ex_put_conn(exoid2, EX_ELEM_BLOCK, ebids2[2], connect2, NULL, NULL); |
| 445 |
printf("after ex_put_elem_conn (2), error = %d\n", error); |
| 446 |
|
| 447 |
connect2[0] = 17; |
| 448 |
connect2[1] = 18; |
| 449 |
connect2[2] = 19; |
| 450 |
connect2[3] = 20; |
| 451 |
|
| 452 |
error = ex_put_conn(exoid2, EX_ELEM_BLOCK, ebids2[3], connect2, NULL, NULL); |
| 453 |
printf("after ex_put_elem_conn (2), error = %d\n", error); |
| 454 |
|
| 455 |
connect2[0] = 21; |
| 456 |
connect2[1] = 22; |
| 457 |
connect2[2] = 23; |
| 458 |
connect2[3] = 24; |
| 459 |
connect2[4] = 25; |
| 460 |
connect2[5] = 26; |
| 461 |
|
| 462 |
error = ex_put_conn(exoid2, EX_ELEM_BLOCK, ebids2[4], connect2, NULL, NULL); |
| 463 |
printf("after ex_put_elem_conn (2), error = %d\n", error); |
| 464 |
|
| 465 |
free(connect2); |
| 466 |
|
| 467 |
/* write element block attributes */ |
| 468 |
|
| 469 |
attrib[0] = 3.14159; |
| 470 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[0], attrib); |
| 471 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 472 |
|
| 473 |
attrib[0] = 6.14159; |
| 474 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[1], attrib); |
| 475 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 476 |
|
| 477 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[2], attrib); |
| 478 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 479 |
|
| 480 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[3], attrib); |
| 481 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 482 |
|
| 483 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[4], attrib); |
| 484 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 485 |
|
| 486 |
attrib2[0] = 3.; |
| 487 |
error = ex_put_attr(exoid2, EX_ELEM_BLOCK, ebids2[0], attrib2); |
| 488 |
printf("after ex_put_elem_attr (2), error = %d\n", error); |
| 489 |
|
| 490 |
attrib2[0] = 6.; |
| 491 |
error = ex_put_attr(exoid2, EX_ELEM_BLOCK, ebids2[1], attrib2); |
| 492 |
printf("after ex_put_elem_attr (2), error = %d\n", error); |
| 493 |
|
| 494 |
error = ex_put_attr(exoid2, EX_ELEM_BLOCK, ebids2[2], attrib2); |
| 495 |
printf("after ex_put_elem_attr (2), error = %d\n", error); |
| 496 |
|
| 497 |
error = ex_put_attr(exoid2, EX_ELEM_BLOCK, ebids2[3], attrib2); |
| 498 |
printf("after ex_put_elem_attr (2), error = %d\n", error); |
| 499 |
|
| 500 |
error = ex_put_attr(exoid2, EX_ELEM_BLOCK, ebids2[4], attrib2); |
| 501 |
printf("after ex_put_elem_attr (2), error = %d\n", error); |
| 502 |
|
| 503 |
/* write individual node sets */ |
| 504 |
|
| 505 |
error = ex_put_set_param(exoid, EX_NODE_SET, 20, 5, 5); |
| 506 |
printf("after ex_put_node_set_param, error = %d\n", error); |
| 507 |
|
| 508 |
node_list[0] = 10; |
| 509 |
node_list[1] = 11; |
| 510 |
node_list[2] = 12; |
| 511 |
node_list[3] = 13; |
| 512 |
node_list[4] = 14; |
| 513 |
|
| 514 |
dist_fact[0] = 1.0; |
| 515 |
dist_fact[1] = 2.0; |
| 516 |
dist_fact[2] = 3.0; |
| 517 |
dist_fact[3] = 4.0; |
| 518 |
dist_fact[4] = 5.0; |
| 519 |
|
| 520 |
error = ex_put_set(exoid, EX_NODE_SET, 20, node_list, NULL); |
| 521 |
printf("after ex_put_node_set, error = %d\n", error); |
| 522 |
error = ex_put_set_dist_fact(exoid, EX_NODE_SET, 20, dist_fact); |
| 523 |
printf("after ex_put_node_set, error = %d\n", error); |
| 524 |
|
| 525 |
error = ex_put_set_param(exoid, EX_NODE_SET, 21, 3, 3); |
| 526 |
printf("after ex_put_node_set_param, error = %d\n", error); |
| 527 |
|
| 528 |
node_list[0] = 20; |
| 529 |
node_list[1] = 21; |
| 530 |
node_list[2] = 22; |
| 531 |
|
| 532 |
dist_fact[0] = 1.1; |
| 533 |
dist_fact[1] = 2.1; |
| 534 |
dist_fact[2] = 3.1; |
| 535 |
|
| 536 |
error = ex_put_set(exoid, EX_NODE_SET, 21, node_list, NULL); |
| 537 |
printf("after ex_put_node_set, error = %d\n", error); |
| 538 |
error = ex_put_set_dist_fact(exoid, EX_NODE_SET, 21, dist_fact); |
| 539 |
printf("after ex_put_node_set, error = %d\n", error); |
| 540 |
|
| 541 |
error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4); |
| 542 |
printf("after ex_put_prop, error = %d\n", error); |
| 543 |
|
| 544 |
error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5); |
| 545 |
printf("after ex_put_prop, error = %d\n", error); |
| 546 |
|
| 547 |
prop_array[0] = 1000; |
| 548 |
prop_array[1] = 2000; |
| 549 |
|
| 550 |
error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array); |
| 551 |
printf("after ex_put_prop_array, error = %d\n", error); |
| 552 |
|
| 553 |
/* file 2 */ |
| 554 |
error = ex_put_set_param(exoid2, EX_NODE_SET, 20, 5, 5); |
| 555 |
printf("after ex_put_node_set_param (2), error = %d\n", error); |
| 556 |
|
| 557 |
node_list2[0] = 10; |
| 558 |
node_list2[1] = 11; |
| 559 |
node_list2[2] = 12; |
| 560 |
node_list2[3] = 13; |
| 561 |
node_list2[4] = 14; |
| 562 |
|
| 563 |
dist_fact2[0] = 1.0; |
| 564 |
dist_fact2[1] = 2.0; |
| 565 |
dist_fact2[2] = 3.0; |
| 566 |
dist_fact2[3] = 4.0; |
| 567 |
dist_fact2[4] = 5.0; |
| 568 |
|
| 569 |
error = ex_put_set(exoid2, EX_NODE_SET, 20, node_list2, NULL); |
| 570 |
printf("after ex_put_node_set (2), error = %d\n", error); |
| 571 |
error = ex_put_set_dist_fact(exoid2, EX_NODE_SET, 20, dist_fact2); |
| 572 |
printf("after ex_put_node_set (2), error = %d\n", error); |
| 573 |
|
| 574 |
error = ex_put_set_param(exoid2, EX_NODE_SET, 21, 3, 3); |
| 575 |
printf("after ex_put_node_set_param (2), error = %d\n", error); |
| 576 |
|
| 577 |
node_list2[0] = 20; |
| 578 |
node_list2[1] = 21; |
| 579 |
node_list2[2] = 22; |
| 580 |
|
| 581 |
dist_fact2[0] = 1.1; |
| 582 |
dist_fact2[1] = 2.1; |
| 583 |
dist_fact2[2] = 3.1; |
| 584 |
|
| 585 |
error = ex_put_set(exoid2, EX_NODE_SET, 21, node_list2, NULL); |
| 586 |
printf("after ex_put_node_set (2), error = %d\n", error); |
| 587 |
error = ex_put_set_dist_fact(exoid2, EX_NODE_SET, 21, dist_fact2); |
| 588 |
printf("after ex_put_node_set (2), error = %d\n", error); |
| 589 |
|
| 590 |
error = ex_put_prop(exoid2, EX_NODE_SET, 20, "FACE", 4); |
| 591 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 592 |
|
| 593 |
error = ex_put_prop(exoid2, EX_NODE_SET, 21, "FACE", 5); |
| 594 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 595 |
|
| 596 |
prop_array[0] = 1000; |
| 597 |
prop_array[1] = 2000; |
| 598 |
|
| 599 |
error = ex_put_prop_array(exoid2, EX_NODE_SET, "VELOCITY", prop_array); |
| 600 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 601 |
|
| 602 |
/* write individual side sets */ |
| 603 |
|
| 604 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 30, 2, 4); |
| 605 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 606 |
|
| 607 |
elem_list[0] = 2; |
| 608 |
elem_list[1] = 2; |
| 609 |
|
| 610 |
side_list[0] = 4; |
| 611 |
side_list[1] = 2; |
| 612 |
|
| 613 |
dist_fact[0] = 30.0; |
| 614 |
dist_fact[1] = 30.1; |
| 615 |
dist_fact[2] = 30.2; |
| 616 |
dist_fact[3] = 30.3; |
| 617 |
|
| 618 |
error = ex_put_set(exoid, EX_SIDE_SET, 30, elem_list, side_list); |
| 619 |
printf("after ex_put_side_set, error = %d\n", error); |
| 620 |
|
| 621 |
error = ex_put_set_dist_fact(exoid, EX_SIDE_SET, 30, dist_fact); |
| 622 |
printf("after ex_put_side_set_dist_fact, error = %d\n", error); |
| 623 |
|
| 624 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 31, 2, 4); |
| 625 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 626 |
|
| 627 |
elem_list[0] = 1; |
| 628 |
elem_list[1] = 2; |
| 629 |
|
| 630 |
side_list[0] = 2; |
| 631 |
side_list[1] = 3; |
| 632 |
|
| 633 |
dist_fact[0] = 31.0; |
| 634 |
dist_fact[1] = 31.1; |
| 635 |
dist_fact[2] = 31.2; |
| 636 |
dist_fact[3] = 31.3; |
| 637 |
|
| 638 |
error = ex_put_set(exoid, EX_SIDE_SET, 31, elem_list, side_list); |
| 639 |
printf("after ex_put_side_set, error = %d\n", error); |
| 640 |
|
| 641 |
error = ex_put_set_dist_fact(exoid, EX_SIDE_SET, 31, dist_fact); |
| 642 |
printf("after ex_put_side_set_dist_fact, error = %d\n", error); |
| 643 |
|
| 644 |
/* side set #3 - hex */ |
| 645 |
|
| 646 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 32, 7, 0); |
| 647 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 648 |
|
| 649 |
elem_list[0] = 3; |
| 650 |
elem_list[1] = 3; |
| 651 |
elem_list[2] = 3; |
| 652 |
elem_list[3] = 3; |
| 653 |
elem_list[4] = 3; |
| 654 |
elem_list[5] = 3; |
| 655 |
elem_list[6] = 3; |
| 656 |
|
| 657 |
side_list[0] = 5; |
| 658 |
side_list[1] = 3; |
| 659 |
side_list[2] = 3; |
| 660 |
side_list[3] = 2; |
| 661 |
side_list[4] = 4; |
| 662 |
side_list[5] = 1; |
| 663 |
side_list[6] = 6; |
| 664 |
|
| 665 |
error = ex_put_set(exoid, EX_SIDE_SET, 32, elem_list, side_list); |
| 666 |
printf("after ex_put_side_set, error = %d\n", error); |
| 667 |
|
| 668 |
/* side set #4 - tetras */ |
| 669 |
|
| 670 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 33, 4, 0); |
| 671 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 672 |
|
| 673 |
elem_list[0] = 4; |
| 674 |
elem_list[1] = 4; |
| 675 |
elem_list[2] = 4; |
| 676 |
elem_list[3] = 4; |
| 677 |
|
| 678 |
side_list[0] = 1; |
| 679 |
side_list[1] = 2; |
| 680 |
side_list[2] = 3; |
| 681 |
side_list[3] = 4; |
| 682 |
|
| 683 |
error = ex_put_set(exoid, EX_SIDE_SET, 33, elem_list, side_list); |
| 684 |
printf("after ex_put_side_set, error = %d\n", error); |
| 685 |
|
| 686 |
/* side set #5 - wedges */ |
| 687 |
|
| 688 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 34, 5, 0); |
| 689 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 690 |
|
| 691 |
elem_list[0] = 5; |
| 692 |
elem_list[1] = 5; |
| 693 |
elem_list[2] = 5; |
| 694 |
elem_list[3] = 5; |
| 695 |
elem_list[4] = 5; |
| 696 |
|
| 697 |
side_list[0] = 1; |
| 698 |
side_list[1] = 2; |
| 699 |
side_list[2] = 3; |
| 700 |
side_list[3] = 4; |
| 701 |
side_list[4] = 5; |
| 702 |
|
| 703 |
error = ex_put_set(exoid, EX_SIDE_SET, 34, elem_list, side_list); |
| 704 |
printf("after ex_put_side_set, error = %d\n", error); |
| 705 |
|
| 706 |
/* file 2 */ |
| 707 |
error = ex_put_set_param(exoid2, EX_SIDE_SET, 30, 2, 4); |
| 708 |
printf("after ex_put_side_set_param (2), error = %d\n", error); |
| 709 |
|
| 710 |
elem_list2[0] = 2; |
| 711 |
elem_list2[1] = 2; |
| 712 |
|
| 713 |
side_list2[0] = 4; |
| 714 |
side_list2[1] = 2; |
| 715 |
|
| 716 |
dist_fact2[0] = 30.0; |
| 717 |
dist_fact2[1] = 30.1; |
| 718 |
dist_fact2[2] = 30.2; |
| 719 |
dist_fact2[3] = 30.3; |
| 720 |
|
| 721 |
error = ex_put_set(exoid2, EX_SIDE_SET, 30, elem_list2, side_list2); |
| 722 |
printf("after ex_put_side_set (2), error = %d\n", error); |
| 723 |
|
| 724 |
error = ex_put_set_dist_fact(exoid2, EX_SIDE_SET, 30, dist_fact2); |
| 725 |
printf("after ex_put_side_set_dist_fact (2), error = %d\n", error); |
| 726 |
|
| 727 |
error = ex_put_set_param(exoid2, EX_SIDE_SET, 31, 2, 4); |
| 728 |
printf("after ex_put_side_set_param (2), error = %d\n", error); |
| 729 |
|
| 730 |
elem_list2[0] = 1; |
| 731 |
elem_list2[1] = 2; |
| 732 |
|
| 733 |
side_list2[0] = 2; |
| 734 |
side_list2[1] = 3; |
| 735 |
|
| 736 |
dist_fact2[0] = 31.0; |
| 737 |
dist_fact2[1] = 31.1; |
| 738 |
dist_fact2[2] = 31.2; |
| 739 |
dist_fact2[3] = 31.3; |
| 740 |
|
| 741 |
error = ex_put_set(exoid2, EX_SIDE_SET, 31, elem_list2, side_list2); |
| 742 |
printf("after ex_put_side_set (2), error = %d\n", error); |
| 743 |
|
| 744 |
error = ex_put_set_dist_fact(exoid2, EX_SIDE_SET, 31, dist_fact2); |
| 745 |
printf("after ex_put_side_set_dist_fact (2), error = %d\n", error); |
| 746 |
|
| 747 |
/* side set #3 - hex */ |
| 748 |
|
| 749 |
error = ex_put_set_param(exoid2, EX_SIDE_SET, 32, 7, 0); |
| 750 |
printf("after ex_put_side_set_param (2), error = %d\n", error); |
| 751 |
|
| 752 |
elem_list2[0] = 3; |
| 753 |
elem_list2[1] = 3; |
| 754 |
elem_list2[2] = 3; |
| 755 |
elem_list2[3] = 3; |
| 756 |
elem_list2[4] = 3; |
| 757 |
elem_list2[5] = 3; |
| 758 |
elem_list2[6] = 3; |
| 759 |
|
| 760 |
side_list2[0] = 5; |
| 761 |
side_list2[1] = 3; |
| 762 |
side_list2[2] = 3; |
| 763 |
side_list2[3] = 2; |
| 764 |
side_list2[4] = 4; |
| 765 |
side_list2[5] = 1; |
| 766 |
side_list2[6] = 6; |
| 767 |
|
| 768 |
error = ex_put_set(exoid2, EX_SIDE_SET, 32, elem_list2, side_list2); |
| 769 |
printf("after ex_put_side_set (2), error = %d\n", error); |
| 770 |
|
| 771 |
/* side set #4 - tetras */ |
| 772 |
|
| 773 |
error = ex_put_set_param(exoid2, EX_SIDE_SET, 33, 4, 0); |
| 774 |
printf("after ex_put_side_set_param (2), error = %d\n", error); |
| 775 |
|
| 776 |
elem_list2[0] = 4; |
| 777 |
elem_list2[1] = 4; |
| 778 |
elem_list2[2] = 4; |
| 779 |
elem_list2[3] = 4; |
| 780 |
|
| 781 |
side_list2[0] = 1; |
| 782 |
side_list2[1] = 2; |
| 783 |
side_list2[2] = 3; |
| 784 |
side_list2[3] = 4; |
| 785 |
|
| 786 |
error = ex_put_set(exoid2, EX_SIDE_SET, 33, elem_list2, side_list2); |
| 787 |
printf("after ex_put_side_set (2), error = %d\n", error); |
| 788 |
|
| 789 |
/* side set #5 - wedges */ |
| 790 |
|
| 791 |
error = ex_put_set_param(exoid2, EX_SIDE_SET, 34, 5, 0); |
| 792 |
printf("after ex_put_side_set_param (2), error = %d\n", error); |
| 793 |
|
| 794 |
elem_list2[0] = 5; |
| 795 |
elem_list2[1] = 5; |
| 796 |
elem_list2[2] = 5; |
| 797 |
elem_list2[3] = 5; |
| 798 |
elem_list2[4] = 5; |
| 799 |
|
| 800 |
side_list2[0] = 1; |
| 801 |
side_list2[1] = 2; |
| 802 |
side_list2[2] = 3; |
| 803 |
side_list2[3] = 4; |
| 804 |
side_list2[4] = 5; |
| 805 |
|
| 806 |
error = ex_put_set(exoid2, EX_SIDE_SET, 34, elem_list2, side_list2); |
| 807 |
printf("after ex_put_side_set (2), error = %d\n", error); |
| 808 |
|
| 809 |
error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100); |
| 810 |
printf("after ex_put_prop, error = %d\n", error); |
| 811 |
|
| 812 |
error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101); |
| 813 |
printf("after ex_put_prop, error = %d\n", error); |
| 814 |
|
| 815 |
error = ex_put_prop(exoid2, EX_SIDE_SET, 30, "COLOR", 100); |
| 816 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 817 |
|
| 818 |
error = ex_put_prop(exoid2, EX_SIDE_SET, 31, "COLOR", 101); |
| 819 |
printf("after ex_put_prop (2), error = %d\n", error); |
| 820 |
|
| 821 |
/* write QA records */ |
| 822 |
|
| 823 |
num_qa_rec = 2; |
| 824 |
|
| 825 |
qa_record[0][0] = "TESTWT2"; |
| 826 |
qa_record[0][1] = "testwt2"; |
| 827 |
qa_record[0][2] = "07/07/93"; |
| 828 |
qa_record[0][3] = "15:41:33"; |
| 829 |
qa_record[1][0] = "FASTQ"; |
| 830 |
qa_record[1][1] = "fastq"; |
| 831 |
qa_record[1][2] = "07/07/93"; |
| 832 |
qa_record[1][3] = "16:41:33"; |
| 833 |
|
| 834 |
error = ex_put_qa(exoid, num_qa_rec, qa_record); |
| 835 |
printf("after ex_put_qa, error = %d\n", error); |
| 836 |
|
| 837 |
num_qa_rec2 = 2; |
| 838 |
|
| 839 |
qa_record2[0][0] = "TESTWT2"; |
| 840 |
qa_record2[0][1] = "testwt2"; |
| 841 |
qa_record2[0][2] = "07/07/93"; |
| 842 |
qa_record2[0][3] = "15:41:33"; |
| 843 |
qa_record2[1][0] = "FASTQ"; |
| 844 |
qa_record2[1][1] = "fastq"; |
| 845 |
qa_record2[1][2] = "07/07/93"; |
| 846 |
qa_record2[1][3] = "16:41:33"; |
| 847 |
|
| 848 |
error = ex_put_qa(exoid2, num_qa_rec2, qa_record2); |
| 849 |
printf("after ex_put_qa (2), error = %d\n", error); |
| 850 |
|
| 851 |
/* write information records */ |
| 852 |
|
| 853 |
num_info = 3; |
| 854 |
|
| 855 |
info[0] = "This is the first information record."; |
| 856 |
info[1] = "This is the second information record."; |
| 857 |
info[2] = "This is the third information record."; |
| 858 |
|
| 859 |
error = ex_put_info(exoid, num_info, info); |
| 860 |
printf("after ex_put_info, error = %d\n", error); |
| 861 |
|
| 862 |
num_info2 = 3; |
| 863 |
|
| 864 |
info2[0] = "This is the first information record."; |
| 865 |
info2[1] = "This is the second information record."; |
| 866 |
info2[2] = "This is the third information record."; |
| 867 |
|
| 868 |
error = ex_put_info(exoid2, num_info2, info2); |
| 869 |
printf("after ex_put_info (2), error = %d\n", error); |
| 870 |
|
| 871 |
/* write results variables parameters and names */ |
| 872 |
|
| 873 |
num_glo_vars = 1; |
| 874 |
|
| 875 |
var_names[0] = "glo_vars"; |
| 876 |
|
| 877 |
error = ex_put_variable_param(exoid, EX_GLOBAL, num_glo_vars); |
| 878 |
printf("after ex_put_variable_param, error = %d\n", error); |
| 879 |
error = ex_put_variable_names(exoid, EX_GLOBAL, num_glo_vars, var_names); |
| 880 |
printf("after ex_put_variable_names, error = %d\n", error); |
| 881 |
|
| 882 |
num_glo_vars2 = 1; |
| 883 |
|
| 884 |
var_names2[0] = "glo_vars"; |
| 885 |
|
| 886 |
error = ex_put_variable_param(exoid2, EX_GLOBAL, num_glo_vars2); |
| 887 |
printf("after ex_put_variable_param (2), error = %d\n", error); |
| 888 |
error = ex_put_variable_names(exoid2, EX_GLOBAL, num_glo_vars2, var_names2); |
| 889 |
printf("after ex_put_variable_names (2), error = %d\n", error); |
| 890 |
|
| 891 |
num_nod_vars = 2; |
| 892 |
|
| 893 |
var_names[0] = "nod_var0"; |
| 894 |
var_names[1] = "nod_var1"; |
| 895 |
|
| 896 |
error = ex_put_variable_param(exoid, EX_NODAL, num_nod_vars); |
| 897 |
printf("after ex_put_variable_param, error = %d\n", error); |
| 898 |
error = ex_put_variable_names(exoid, EX_NODAL, num_nod_vars, var_names); |
| 899 |
printf("after ex_put_variable_names, error = %d\n", error); |
| 900 |
|
| 901 |
num_nod_vars2 = 2; |
| 902 |
|
| 903 |
var_names2[0] = "nod_var0"; |
| 904 |
var_names2[1] = "nod_var1"; |
| 905 |
|
| 906 |
error = ex_put_variable_param(exoid2, EX_NODAL, num_nod_vars2); |
| 907 |
printf("after ex_put_variable_param (2), error = %d\n", error); |
| 908 |
error = ex_put_variable_names(exoid2, EX_NODAL, num_nod_vars2, var_names2); |
| 909 |
printf("after ex_put_variable_names (2), error = %d\n", error); |
| 910 |
|
| 911 |
num_ele_vars = 3; |
| 912 |
|
| 913 |
var_names[0] = "ele_var0"; |
| 914 |
var_names[1] = "ele_var1"; |
| 915 |
var_names[2] = "ele_var2"; |
| 916 |
|
| 917 |
error = ex_put_variable_param(exoid, EX_ELEM_BLOCK, num_ele_vars); |
| 918 |
printf("after ex_put_variable_param, error = %d\n", error); |
| 919 |
error = ex_put_variable_names(exoid, EX_ELEM_BLOCK, num_ele_vars, var_names); |
| 920 |
printf("after ex_put_variable_names, error = %d\n", error); |
| 921 |
|
| 922 |
num_ele_vars2 = 3; |
| 923 |
|
| 924 |
var_names2[0] = "ele_var20"; |
| 925 |
var_names2[1] = "ele_var21"; |
| 926 |
var_names2[2] = "ele_var22"; |
| 927 |
|
| 928 |
error = ex_put_variable_param(exoid2, EX_ELEM_BLOCK, num_ele_vars2); |
| 929 |
printf("after ex_put_variable_param (2), error = %d\n", error); |
| 930 |
error = ex_put_variable_names(exoid2, EX_ELEM_BLOCK, num_ele_vars, var_names); |
| 931 |
printf("after ex_put_variable_names (2), error = %d\n", error); |
| 932 |
|
| 933 |
/* write element variable truth table */ |
| 934 |
|
| 935 |
truth_tab = (int *)calloc((num_elem_blk * num_ele_vars), sizeof(int)); |
| 936 |
|
| 937 |
k = 0; |
| 938 |
for (i = 0; i < num_elem_blk; i++) { |
| 939 |
for (j = 0; j < num_ele_vars; j++) { |
| 940 |
truth_tab[k++] = 1; |
| 941 |
} |
| 942 |
} |
| 943 |
|
| 944 |
error = ex_put_truth_table(exoid, EX_ELEM_BLOCK, num_elem_blk, num_ele_vars, truth_tab); |
| 945 |
printf("after ex_put_elem_var_tab, error = %d\n", error); |
| 946 |
|
| 947 |
error = ex_put_truth_table(exoid2, EX_ELEM_BLOCK, num_elem_blk, num_ele_vars, truth_tab); |
| 948 |
printf("after ex_put_elem_var_tab (2), error = %d\n", error); |
| 949 |
|
| 950 |
free(truth_tab); |
| 951 |
|
| 952 |
/* for each time step, write the analysis results; |
| 953 |
* the code below fills the arrays hist_var_vals, glob_var_vals, |
| 954 |
* nodal_var_vals, and elem_var_vals with values for debugging purposes; |
| 955 |
* obviously the analysis code will populate these arrays |
| 956 |
*/ |
| 957 |
|
| 958 |
whole_time_step = 1; |
| 959 |
num_time_steps = 10; |
| 960 |
|
| 961 |
glob_var_vals = (float *)calloc(num_glo_vars, sizeof(float)); |
| 962 |
nodal_var_vals = (float *)calloc(num_nodes, sizeof(float)); |
| 963 |
elem_var_vals = (float *)calloc(4, sizeof(float)); |
| 964 |
|
| 965 |
for (i = 0; i < num_time_steps; i++) { |
| 966 |
time_value = (float)(i + 1) / 100.; |
| 967 |
time_value2 = (float)(i + 1) / 100.; |
| 968 |
|
| 969 |
/* write time value to regular file */ |
| 970 |
|
| 971 |
error = ex_put_time(exoid, whole_time_step, &time_value); |
| 972 |
printf("after ex_put_time, error = %d\n", error); |
| 973 |
|
| 974 |
error = ex_put_time(exoid2, whole_time_step, &time_value2); |
| 975 |
printf("after ex_put_time (2), error = %d\n", error); |
| 976 |
|
| 977 |
/* write global variables */ |
| 978 |
|
| 979 |
for (j = 0; j < num_glo_vars; j++) { |
| 980 |
glob_var_vals[j] = (float)(j + 2) * time_value; |
| 981 |
} |
| 982 |
|
| 983 |
error = ex_put_var(exoid, whole_time_step, EX_GLOBAL, 1, 1, num_glo_vars, glob_var_vals); |
| 984 |
printf("after ex_put_glob_vars, error = %d\n", error); |
| 985 |
|
| 986 |
error = ex_put_var(exoid2, whole_time_step, EX_GLOBAL, 1, 1, num_glo_vars, glob_var_vals); |
| 987 |
printf("after ex_put_glob_vars (2), error = %d\n", error); |
| 988 |
|
| 989 |
/* write nodal variables */ |
| 990 |
|
| 991 |
for (k = 1; k <= num_nod_vars; k++) { |
| 992 |
for (j = 0; j < num_nodes; j++) { |
| 993 |
nodal_var_vals[j] = (float)k + ((float)(j + 1) * time_value); |
| 994 |
} |
| 995 |
|
| 996 |
error = ex_put_var(exoid, whole_time_step, EX_NODAL, k, 1, num_nodes, nodal_var_vals); |
| 997 |
printf("after ex_put_nodal_var, error = %d\n", error); |
| 998 |
|
| 999 |
error = ex_put_var(exoid2, whole_time_step, EX_NODAL, k, 1, num_nodes, nodal_var_vals); |
| 1000 |
printf("after ex_put_nodal_var (2), error = %d\n", error); |
| 1001 |
} |
| 1002 |
|
| 1003 |
/* write element variables */ |
| 1004 |
|
| 1005 |
for (k = 1; k <= num_ele_vars; k++) { |
| 1006 |
for (j = 0; j < num_elem_blk; j++) { |
| 1007 |
for (m = 0; m < num_elem_in_block[j]; m++) { |
| 1008 |
elem_var_vals[m] = (float)(k + 1) + (float)(j + 2) + ((float)(m + 1) * time_value); |
| 1009 |
/* printf("elem_var_vals[%d]: %f\n",m,elem_var_vals[m]); */ |
| 1010 |
} |
| 1011 |
error = ex_put_var(exoid, whole_time_step, EX_ELEM_BLOCK, k, ebids[j], num_elem_in_block[j], |
| 1012 |
elem_var_vals); |
| 1013 |
printf("after ex_put_elem_var, error = %d\n", error); |
| 1014 |
|
| 1015 |
error = ex_put_var(exoid2, whole_time_step, EX_ELEM_BLOCK, k, ebids[j], |
| 1016 |
num_elem_in_block[j], elem_var_vals); |
| 1017 |
printf("after ex_put_elem_var (2), error = %d\n", error); |
| 1018 |
} |
| 1019 |
} |
| 1020 |
|
| 1021 |
whole_time_step++; |
| 1022 |
|
| 1023 |
/* update the data file; this should be done at the end of every time step |
| 1024 |
* to ensure that no data is lost if the analysis dies |
| 1025 |
*/ |
| 1026 |
error = ex_update(exoid); |
| 1027 |
printf("after ex_update, error = %d\n", error); |
| 1028 |
error = ex_update(exoid2); |
| 1029 |
printf("after ex_update (2), error = %d\n", error); |
| 1030 |
} |
| 1031 |
free(glob_var_vals); |
| 1032 |
free(nodal_var_vals); |
| 1033 |
free(elem_var_vals); |
| 1034 |
|
| 1035 |
/* close the EXODUS files |
| 1036 |
*/ |
| 1037 |
error = ex_close(exoid); |
| 1038 |
printf("after ex_close, error = %d\n", error); |
| 1039 |
error = ex_close(exoid2); |
| 1040 |
printf("after ex_close (2), error = %d\n", error); |
| 1041 |
return 0; |
| 1042 |
} |