| 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 |
* testwtd - 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. |
| 28 |
* |
| 29 |
* |
| 30 |
*****************************************************************************/ |
| 31 |
|
| 32 |
#include "exodusII.h" |
| 33 |
#include <stdio.h> |
| 34 |
#include <stdlib.h> |
| 35 |
|
| 36 |
int main(int argc, char **argv) |
| 37 |
{ |
| 38 |
int exoid, num_dim, num_nodes, num_elem, num_elem_blk; |
| 39 |
int num_elem_in_block[10], num_nodes_per_elem[10]; |
| 40 |
int num_node_sets, num_side_sets, error; |
| 41 |
int i, j, k, m, *elem_map, *connect; |
| 42 |
int node_list[100], elem_list[100], side_list[100]; |
| 43 |
int ebids[100]; |
| 44 |
int num_qa_rec, num_info; |
| 45 |
int num_glo_vars, num_nod_vars, num_ele_vars; |
| 46 |
int *truth_tab; |
| 47 |
int whole_time_step, num_time_steps; |
| 48 |
int CPU_word_size, IO_word_size; |
| 49 |
int prop_array[2]; |
| 50 |
|
| 51 |
double *glob_var_vals, *nodal_var_vals, *elem_var_vals; |
| 52 |
double time_value; |
| 53 |
double x[100], y[100], z[100]; |
| 54 |
double attrib[1], dist_fact[100]; |
| 55 |
char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3]; |
| 56 |
char *prop_names[2]; |
| 57 |
|
| 58 |
ex_opts(EX_VERBOSE | EX_ABORT); |
| 59 |
|
| 60 |
/* Specify compute and i/o word size */ |
| 61 |
|
| 62 |
CPU_word_size = 8; /* double */ |
| 63 |
IO_word_size = 8; /* use double size (8 bytes) */ |
| 64 |
|
| 65 |
/* create EXODUS II file */ |
| 66 |
|
| 67 |
exoid = ex_create("test.exo", /* filename path */ |
| 68 |
EX_CLOBBER, /* create mode */ |
| 69 |
&CPU_word_size, /* CPU float word size in bytes */ |
| 70 |
&IO_word_size); /* I/O float word size in bytes */ |
| 71 |
printf("after ex_create for test.exo, exoid = %d\n", exoid); |
| 72 |
printf(" cpu word size: %d io word size: %d\n", CPU_word_size, IO_word_size); |
| 73 |
|
| 74 |
/* initialize file with parameters */ |
| 75 |
|
| 76 |
num_dim = 3; |
| 77 |
num_nodes = 26; |
| 78 |
num_elem = 5; |
| 79 |
num_elem_blk = 5; |
| 80 |
num_node_sets = 2; |
| 81 |
num_side_sets = 5; |
| 82 |
|
| 83 |
error = ex_put_init(exoid, "This is a test", num_dim, num_nodes, num_elem, num_elem_blk, |
| 84 |
num_node_sets, num_side_sets); |
| 85 |
|
| 86 |
printf("after ex_put_init, error = %d\n", error); |
| 87 |
|
| 88 |
/* write nodal coordinates values and names to database */ |
| 89 |
|
| 90 |
/* Quad #1 */ |
| 91 |
x[0] = 0.0; |
| 92 |
y[0] = 0.0; |
| 93 |
z[0] = 0.0; |
| 94 |
x[1] = 1.0; |
| 95 |
y[1] = 0.0; |
| 96 |
z[1] = 0.0; |
| 97 |
x[2] = 1.0; |
| 98 |
y[2] = 1.0; |
| 99 |
z[2] = 0.0; |
| 100 |
x[3] = 0.0; |
| 101 |
y[3] = 1.0; |
| 102 |
z[3] = 0.0; |
| 103 |
|
| 104 |
/* Quad #2 */ |
| 105 |
x[4] = 1.0; |
| 106 |
y[4] = 0.0; |
| 107 |
z[4] = 0.0; |
| 108 |
x[5] = 2.0; |
| 109 |
y[5] = 0.0; |
| 110 |
z[5] = 0.0; |
| 111 |
x[6] = 2.0; |
| 112 |
y[6] = 1.0; |
| 113 |
z[6] = 0.0; |
| 114 |
x[7] = 1.0; |
| 115 |
y[7] = 1.0; |
| 116 |
z[7] = 0.0; |
| 117 |
|
| 118 |
/* Hex #1 */ |
| 119 |
x[8] = 0.0; |
| 120 |
y[8] = 0.0; |
| 121 |
z[8] = 0.0; |
| 122 |
x[9] = 10.0; |
| 123 |
y[9] = 0.0; |
| 124 |
z[9] = 0.0; |
| 125 |
x[10] = 10.0; |
| 126 |
y[10] = 0.0; |
| 127 |
z[10] = -10.0; |
| 128 |
x[11] = 1.0; |
| 129 |
y[11] = 0.0; |
| 130 |
z[11] = -10.0; |
| 131 |
x[12] = 1.0; |
| 132 |
y[12] = 10.0; |
| 133 |
z[12] = 0.0; |
| 134 |
x[13] = 10.0; |
| 135 |
y[13] = 10.0; |
| 136 |
z[13] = 0.0; |
| 137 |
x[14] = 10.0; |
| 138 |
y[14] = 10.0; |
| 139 |
z[14] = -10.0; |
| 140 |
x[15] = 1.0; |
| 141 |
y[15] = 10.0; |
| 142 |
z[15] = -10.0; |
| 143 |
|
| 144 |
/* Tetra #1 */ |
| 145 |
x[16] = 0.0; |
| 146 |
y[16] = 0.0; |
| 147 |
z[16] = 0.0; |
| 148 |
x[17] = 1.0; |
| 149 |
y[17] = 0.0; |
| 150 |
z[17] = 5.0; |
| 151 |
x[18] = 10.0; |
| 152 |
y[18] = 0.0; |
| 153 |
z[18] = 2.0; |
| 154 |
x[19] = 7.0; |
| 155 |
y[19] = 5.0; |
| 156 |
z[19] = 3.0; |
| 157 |
|
| 158 |
/* Wedge #1 */ |
| 159 |
x[20] = 3.0; |
| 160 |
y[20] = 0.0; |
| 161 |
z[20] = 6.0; |
| 162 |
x[21] = 6.0; |
| 163 |
y[21] = 0.0; |
| 164 |
z[21] = 0.0; |
| 165 |
x[22] = 0.0; |
| 166 |
y[22] = 0.0; |
| 167 |
z[22] = 0.0; |
| 168 |
x[23] = 3.0; |
| 169 |
y[23] = 2.0; |
| 170 |
z[23] = 6.0; |
| 171 |
x[24] = 6.0; |
| 172 |
y[24] = 2.0; |
| 173 |
z[24] = 2.0; |
| 174 |
x[25] = 0.0; |
| 175 |
y[25] = 2.0; |
| 176 |
z[25] = 0.0; |
| 177 |
|
| 178 |
error = ex_put_coord(exoid, x, y, z); |
| 179 |
printf("after ex_put_coord, error = %d\n", error); |
| 180 |
|
| 181 |
coord_names[0] = "xcoor"; |
| 182 |
coord_names[1] = "ycoor"; |
| 183 |
coord_names[2] = "zcoor"; |
| 184 |
|
| 185 |
error = ex_put_coord_names(exoid, coord_names); |
| 186 |
printf("after ex_put_coord_names, error = %d\n", error); |
| 187 |
|
| 188 |
/* write element order map */ |
| 189 |
|
| 190 |
elem_map = (int *)calloc(num_elem, sizeof(int)); |
| 191 |
|
| 192 |
for (i = 1; i <= num_elem; i++) { |
| 193 |
elem_map[i - 1] = i; |
| 194 |
} |
| 195 |
|
| 196 |
error = ex_put_id_map(exoid, EX_ELEM_MAP, elem_map); |
| 197 |
printf("after ex_put_id_map, error = %d\n", error); |
| 198 |
|
| 199 |
free(elem_map); |
| 200 |
|
| 201 |
/* write element block parameters */ |
| 202 |
|
| 203 |
num_elem_in_block[0] = 1; |
| 204 |
num_elem_in_block[1] = 1; |
| 205 |
num_elem_in_block[2] = 1; |
| 206 |
num_elem_in_block[3] = 1; |
| 207 |
num_elem_in_block[4] = 1; |
| 208 |
|
| 209 |
num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads */ |
| 210 |
num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads */ |
| 211 |
num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes */ |
| 212 |
num_nodes_per_elem[3] = 4; /* elements in block #3 are 4-node tetras */ |
| 213 |
num_nodes_per_elem[4] = 6; /* elements in block #3 are 6-node wedges */ |
| 214 |
|
| 215 |
ebids[0] = 10; |
| 216 |
ebids[1] = 11; |
| 217 |
ebids[2] = 12; |
| 218 |
ebids[3] = 13; |
| 219 |
ebids[4] = 14; |
| 220 |
|
| 221 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[0], "quad", num_elem_in_block[0], |
| 222 |
num_nodes_per_elem[0], 0, 0, 1); |
| 223 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 224 |
|
| 225 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[1], "quad", num_elem_in_block[1], |
| 226 |
num_nodes_per_elem[0], 0, 0, 1); |
| 227 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 228 |
|
| 229 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[2], "hex", num_elem_in_block[2], |
| 230 |
num_nodes_per_elem[2], 0, 0, 1); |
| 231 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 232 |
|
| 233 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[3], "tetra", num_elem_in_block[3], |
| 234 |
num_nodes_per_elem[3], 0, 0, 1); |
| 235 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 236 |
|
| 237 |
error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[4], "wedge", num_elem_in_block[4], |
| 238 |
num_nodes_per_elem[4], 0, 0, 1); |
| 239 |
printf("after ex_put_elem_block, error = %d\n", error); |
| 240 |
|
| 241 |
/* write element block properties */ |
| 242 |
|
| 243 |
prop_names[0] = "MATL"; |
| 244 |
prop_names[1] = "DENSITY"; |
| 245 |
error = ex_put_prop_names(exoid, EX_ELEM_BLOCK, 2, prop_names); |
| 246 |
printf("after ex_put_prop_names, error = %d\n", error); |
| 247 |
|
| 248 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[0], "MATL", 10); |
| 249 |
printf("after ex_put_prop, error = %d\n", error); |
| 250 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[1], "MATL", 20); |
| 251 |
printf("after ex_put_prop, error = %d\n", error); |
| 252 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[2], "MATL", 30); |
| 253 |
printf("after ex_put_prop, error = %d\n", error); |
| 254 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[3], "MATL", 40); |
| 255 |
printf("after ex_put_prop, error = %d\n", error); |
| 256 |
error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[4], "MATL", 50); |
| 257 |
printf("after ex_put_prop, error = %d\n", error); |
| 258 |
|
| 259 |
/* write element connectivity */ |
| 260 |
|
| 261 |
connect = (int *)calloc(8, sizeof(int)); |
| 262 |
connect[0] = 1; |
| 263 |
connect[1] = 2; |
| 264 |
connect[2] = 3; |
| 265 |
connect[3] = 4; |
| 266 |
|
| 267 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[0], connect, NULL, NULL); |
| 268 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 269 |
|
| 270 |
connect[0] = 5; |
| 271 |
connect[1] = 6; |
| 272 |
connect[2] = 7; |
| 273 |
connect[3] = 8; |
| 274 |
|
| 275 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[1], connect, NULL, NULL); |
| 276 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 277 |
|
| 278 |
connect[0] = 9; |
| 279 |
connect[1] = 10; |
| 280 |
connect[2] = 11; |
| 281 |
connect[3] = 12; |
| 282 |
connect[4] = 13; |
| 283 |
connect[5] = 14; |
| 284 |
connect[6] = 15; |
| 285 |
connect[7] = 16; |
| 286 |
|
| 287 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[2], connect, NULL, NULL); |
| 288 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 289 |
|
| 290 |
connect[0] = 17; |
| 291 |
connect[1] = 18; |
| 292 |
connect[2] = 19; |
| 293 |
connect[3] = 20; |
| 294 |
|
| 295 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[3], connect, NULL, NULL); |
| 296 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 297 |
|
| 298 |
connect[0] = 21; |
| 299 |
connect[1] = 22; |
| 300 |
connect[2] = 23; |
| 301 |
connect[3] = 24; |
| 302 |
connect[4] = 25; |
| 303 |
connect[5] = 26; |
| 304 |
|
| 305 |
error = ex_put_conn(exoid, EX_ELEM_BLOCK, ebids[4], connect, NULL, NULL); |
| 306 |
printf("after ex_put_elem_conn, error = %d\n", error); |
| 307 |
|
| 308 |
free(connect); |
| 309 |
|
| 310 |
/* write element block attributes */ |
| 311 |
|
| 312 |
attrib[0] = 3.14159; |
| 313 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[0], attrib); |
| 314 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 315 |
|
| 316 |
attrib[0] = 6.14159; |
| 317 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[1], attrib); |
| 318 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 319 |
|
| 320 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[2], attrib); |
| 321 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 322 |
|
| 323 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[3], attrib); |
| 324 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 325 |
|
| 326 |
error = ex_put_attr(exoid, EX_ELEM_BLOCK, ebids[4], attrib); |
| 327 |
printf("after ex_put_elem_attr, error = %d\n", error); |
| 328 |
|
| 329 |
/* write individual node sets */ |
| 330 |
|
| 331 |
error = ex_put_set_param(exoid, EX_NODE_SET, 20, 5, 5); |
| 332 |
printf("after ex_put_node_set_param, error = %d\n", error); |
| 333 |
|
| 334 |
node_list[0] = 10; |
| 335 |
node_list[1] = 11; |
| 336 |
node_list[2] = 12; |
| 337 |
node_list[3] = 13; |
| 338 |
node_list[4] = 14; |
| 339 |
|
| 340 |
dist_fact[0] = 1.0; |
| 341 |
dist_fact[1] = 2.0; |
| 342 |
dist_fact[2] = 3.0; |
| 343 |
dist_fact[3] = 4.0; |
| 344 |
dist_fact[4] = 5.0; |
| 345 |
|
| 346 |
error = ex_put_set(exoid, EX_NODE_SET, 20, node_list, NULL); |
| 347 |
printf("after ex_put_node_set, error = %d\n", error); |
| 348 |
error = ex_put_set_dist_fact(exoid, EX_NODE_SET, 20, dist_fact); |
| 349 |
printf("after ex_put_node_set_dist_fact, error = %d\n", error); |
| 350 |
|
| 351 |
error = ex_put_set_param(exoid, EX_NODE_SET, 21, 3, 3); |
| 352 |
printf("after ex_put_node_set_param, error = %d\n", error); |
| 353 |
|
| 354 |
node_list[0] = 20; |
| 355 |
node_list[1] = 21; |
| 356 |
node_list[2] = 22; |
| 357 |
|
| 358 |
dist_fact[0] = 1.1; |
| 359 |
dist_fact[1] = 2.1; |
| 360 |
dist_fact[2] = 3.1; |
| 361 |
|
| 362 |
error = ex_put_set(exoid, EX_NODE_SET, 21, node_list, NULL); |
| 363 |
printf("after ex_put_node_set, error = %d\n", error); |
| 364 |
error = ex_put_set_dist_fact(exoid, EX_NODE_SET, 21, dist_fact); |
| 365 |
printf("after ex_put_node_set_dist_fact, error = %d\n", error); |
| 366 |
|
| 367 |
error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4); |
| 368 |
printf("after ex_put_prop, error = %d\n", error); |
| 369 |
error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5); |
| 370 |
printf("after ex_put_prop, error = %d\n", error); |
| 371 |
|
| 372 |
prop_array[0] = 1000; |
| 373 |
prop_array[1] = 2000; |
| 374 |
|
| 375 |
error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array); |
| 376 |
printf("after ex_put_prop_array, error = %d\n", error); |
| 377 |
|
| 378 |
/* write individual side sets */ |
| 379 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 30, 2, 4); |
| 380 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 381 |
|
| 382 |
/* side set #1 - quad */ |
| 383 |
|
| 384 |
elem_list[0] = 2; |
| 385 |
elem_list[1] = 2; |
| 386 |
|
| 387 |
side_list[0] = 4; |
| 388 |
side_list[1] = 2; |
| 389 |
|
| 390 |
dist_fact[0] = 30.0; |
| 391 |
dist_fact[1] = 30.1; |
| 392 |
dist_fact[2] = 30.2; |
| 393 |
dist_fact[3] = 30.3; |
| 394 |
|
| 395 |
error = ex_put_set(exoid, EX_SIDE_SET, 30, elem_list, side_list); |
| 396 |
printf("after ex_put_side_set, error = %d\n", error); |
| 397 |
|
| 398 |
error = ex_put_set_dist_fact(exoid, EX_SIDE_SET, 30, dist_fact); |
| 399 |
printf("after ex_put_side_set_dist_fact, error = %d\n", error); |
| 400 |
|
| 401 |
/* side set #2 - quad, spanning 2 elements */ |
| 402 |
|
| 403 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 31, 2, 4); |
| 404 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 405 |
|
| 406 |
elem_list[0] = 1; |
| 407 |
elem_list[1] = 2; |
| 408 |
|
| 409 |
side_list[0] = 2; |
| 410 |
side_list[1] = 3; |
| 411 |
|
| 412 |
dist_fact[0] = 31.0; |
| 413 |
dist_fact[1] = 31.1; |
| 414 |
dist_fact[2] = 31.2; |
| 415 |
dist_fact[3] = 31.3; |
| 416 |
|
| 417 |
error = ex_put_set(exoid, EX_SIDE_SET, 31, elem_list, side_list); |
| 418 |
printf("after ex_put_side_set, error = %d\n", error); |
| 419 |
|
| 420 |
error = ex_put_set_dist_fact(exoid, EX_SIDE_SET, 31, dist_fact); |
| 421 |
printf("after ex_put_side_set_dist_fact, error = %d\n", error); |
| 422 |
|
| 423 |
/* side set #3 - hex */ |
| 424 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 32, 7, 0); |
| 425 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 426 |
|
| 427 |
elem_list[0] = 3; |
| 428 |
elem_list[1] = 3; |
| 429 |
elem_list[2] = 3; |
| 430 |
elem_list[3] = 3; |
| 431 |
elem_list[4] = 3; |
| 432 |
elem_list[5] = 3; |
| 433 |
elem_list[6] = 3; |
| 434 |
|
| 435 |
side_list[0] = 5; |
| 436 |
side_list[1] = 3; |
| 437 |
side_list[2] = 3; |
| 438 |
side_list[3] = 2; |
| 439 |
side_list[4] = 4; |
| 440 |
side_list[5] = 1; |
| 441 |
side_list[6] = 6; |
| 442 |
|
| 443 |
error = ex_put_set(exoid, EX_SIDE_SET, 32, elem_list, side_list); |
| 444 |
printf("after ex_put_side_set, error = %d\n", error); |
| 445 |
|
| 446 |
/* side set #4 - tetras */ |
| 447 |
|
| 448 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 33, 4, 0); |
| 449 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 450 |
|
| 451 |
elem_list[0] = 4; |
| 452 |
elem_list[1] = 4; |
| 453 |
elem_list[2] = 4; |
| 454 |
elem_list[3] = 4; |
| 455 |
|
| 456 |
side_list[0] = 1; |
| 457 |
side_list[1] = 2; |
| 458 |
side_list[2] = 3; |
| 459 |
side_list[3] = 4; |
| 460 |
|
| 461 |
error = ex_put_set(exoid, EX_SIDE_SET, 33, elem_list, side_list); |
| 462 |
printf("after ex_put_side_set, error = %d\n", error); |
| 463 |
|
| 464 |
/* side set #5 - wedges */ |
| 465 |
|
| 466 |
error = ex_put_set_param(exoid, EX_SIDE_SET, 34, 5, 0); |
| 467 |
printf("after ex_put_side_set_param, error = %d\n", error); |
| 468 |
|
| 469 |
elem_list[0] = 5; |
| 470 |
elem_list[1] = 5; |
| 471 |
elem_list[2] = 5; |
| 472 |
elem_list[3] = 5; |
| 473 |
elem_list[4] = 5; |
| 474 |
|
| 475 |
side_list[0] = 1; |
| 476 |
side_list[1] = 2; |
| 477 |
side_list[2] = 3; |
| 478 |
side_list[3] = 4; |
| 479 |
side_list[4] = 5; |
| 480 |
|
| 481 |
error = ex_put_set(exoid, EX_SIDE_SET, 34, elem_list, side_list); |
| 482 |
printf("after ex_put_side_set, error = %d\n", error); |
| 483 |
|
| 484 |
error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100); |
| 485 |
printf("after ex_put_prop, error = %d\n", error); |
| 486 |
|
| 487 |
error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101); |
| 488 |
printf("after ex_put_prop, error = %d\n", error); |
| 489 |
|
| 490 |
/* END COMMENTED OUT SECTION */ |
| 491 |
|
| 492 |
/* write QA records */ |
| 493 |
|
| 494 |
num_qa_rec = 2; |
| 495 |
|
| 496 |
qa_record[0][0] = "TESTWTD"; |
| 497 |
qa_record[0][1] = "testwtd"; |
| 498 |
qa_record[0][2] = "07/07/93"; |
| 499 |
qa_record[0][3] = "15:41:33"; |
| 500 |
qa_record[1][0] = "FASTQ"; |
| 501 |
qa_record[1][1] = "fastq"; |
| 502 |
qa_record[1][2] = "07/07/93"; |
| 503 |
qa_record[1][3] = "16:41:33"; |
| 504 |
|
| 505 |
error = ex_put_qa(exoid, num_qa_rec, qa_record); |
| 506 |
printf("after ex_put_qa, error = %d\n", error); |
| 507 |
|
| 508 |
/* write information records */ |
| 509 |
|
| 510 |
num_info = 3; |
| 511 |
|
| 512 |
info[0] = "This is the first information record."; |
| 513 |
info[1] = "This is the second information record."; |
| 514 |
info[2] = "This is the third information record."; |
| 515 |
|
| 516 |
error = ex_put_info(exoid, num_info, info); |
| 517 |
printf("after ex_put_info, error = %d\n", error); |
| 518 |
|
| 519 |
/* write results variables parameters and names */ |
| 520 |
|
| 521 |
num_glo_vars = 1; |
| 522 |
|
| 523 |
var_names[0] = "glo_vars"; |
| 524 |
|
| 525 |
error = ex_put_variable_param(exoid, EX_GLOBAL, num_glo_vars); |
| 526 |
printf("after ex_put_variable_param, error = %d\n", error); |
| 527 |
error = ex_put_variable_names(exoid, EX_GLOBAL, num_glo_vars, var_names); |
| 528 |
printf("after ex_put_variable_names, error = %d\n", error); |
| 529 |
|
| 530 |
num_nod_vars = 2; |
| 531 |
|
| 532 |
var_names[0] = "nod_var0"; |
| 533 |
var_names[1] = "nod_var1"; |
| 534 |
|
| 535 |
error = ex_put_variable_param(exoid, EX_NODAL, num_nod_vars); |
| 536 |
printf("after ex_put_variable_param, error = %d\n", error); |
| 537 |
error = ex_put_variable_names(exoid, EX_NODAL, num_nod_vars, var_names); |
| 538 |
printf("after ex_put_variable_names, error = %d\n", error); |
| 539 |
|
| 540 |
num_ele_vars = 3; |
| 541 |
|
| 542 |
var_names[0] = "ele_var0"; |
| 543 |
var_names[1] = "ele_var1"; |
| 544 |
var_names[2] = "ele_var2"; |
| 545 |
|
| 546 |
error = ex_put_variable_param(exoid, EX_ELEM_BLOCK, num_ele_vars); |
| 547 |
printf("after ex_put_variable_param, error = %d\n", error); |
| 548 |
error = ex_put_variable_names(exoid, EX_ELEM_BLOCK, num_ele_vars, var_names); |
| 549 |
printf("after ex_put_variable_names, error = %d\n", error); |
| 550 |
|
| 551 |
/* write element variable truth table */ |
| 552 |
|
| 553 |
truth_tab = (int *)calloc((num_elem_blk * num_ele_vars), sizeof(int)); |
| 554 |
|
| 555 |
k = 0; |
| 556 |
for (i = 0; i < num_elem_blk; i++) { |
| 557 |
for (j = 0; j < num_ele_vars; j++) { |
| 558 |
truth_tab[k++] = 1; |
| 559 |
} |
| 560 |
} |
| 561 |
|
| 562 |
error = ex_put_truth_table(exoid, EX_ELEM_BLOCK, num_elem_blk, num_ele_vars, truth_tab); |
| 563 |
printf("after ex_put_elem_var_tab, error = %d\n", error); |
| 564 |
|
| 565 |
free(truth_tab); |
| 566 |
|
| 567 |
/* for each time step, write the analysis results; |
| 568 |
* the code below fills the arrays glob_var_vals, |
| 569 |
* nodal_var_vals, and elem_var_vals with values for debugging purposes; |
| 570 |
* obviously the analysis code will populate these arrays |
| 571 |
*/ |
| 572 |
|
| 573 |
whole_time_step = 1; |
| 574 |
num_time_steps = 10; |
| 575 |
|
| 576 |
glob_var_vals = (double *)calloc(num_glo_vars, CPU_word_size); |
| 577 |
nodal_var_vals = (double *)calloc(num_nodes, CPU_word_size); |
| 578 |
elem_var_vals = (double *)calloc(4, CPU_word_size); |
| 579 |
|
| 580 |
for (i = 0; i < num_time_steps; i++) { |
| 581 |
time_value = (double)(i + 1) / 100.; |
| 582 |
|
| 583 |
/* write time value */ |
| 584 |
|
| 585 |
error = ex_put_time(exoid, whole_time_step, &time_value); |
| 586 |
printf("after ex_put_time, error = %d\n", error); |
| 587 |
|
| 588 |
/* write global variables */ |
| 589 |
|
| 590 |
for (j = 0; j < num_glo_vars; j++) { |
| 591 |
glob_var_vals[j] = (float)(j + 2) * time_value; |
| 592 |
} |
| 593 |
|
| 594 |
error = ex_put_var(exoid, whole_time_step, EX_GLOBAL, 1, 1, num_glo_vars, glob_var_vals); |
| 595 |
printf("after ex_put_glob_vars, error = %d\n", error); |
| 596 |
|
| 597 |
/* write nodal variables */ |
| 598 |
|
| 599 |
for (k = 1; k <= num_nod_vars; k++) { |
| 600 |
for (j = 0; j < num_nodes; j++) { |
| 601 |
nodal_var_vals[j] = (float)k + ((float)(j + 1) * time_value); |
| 602 |
} |
| 603 |
|
| 604 |
error = ex_put_var(exoid, whole_time_step, EX_NODAL, k, 1, num_nodes, nodal_var_vals); |
| 605 |
printf("after ex_put_nodal_var, error = %d\n", error); |
| 606 |
} |
| 607 |
|
| 608 |
/* write element variables */ |
| 609 |
|
| 610 |
for (k = 1; k <= num_ele_vars; k++) { |
| 611 |
for (j = 0; j < num_elem_blk; j++) { |
| 612 |
for (m = 0; m < num_elem_in_block[j]; m++) { |
| 613 |
elem_var_vals[m] = (float)(k + 1) + (float)(j + 2) + ((float)(m + 1) * time_value); |
| 614 |
/* printf("elem_var_vals[%d]: %f\n",m,elem_var_vals[m]); */ |
| 615 |
} |
| 616 |
error = ex_put_var(exoid, whole_time_step, EX_ELEM_BLOCK, k, ebids[j], num_elem_in_block[j], |
| 617 |
elem_var_vals); |
| 618 |
printf("after ex_put_elem_var, error = %d\n", error); |
| 619 |
} |
| 620 |
} |
| 621 |
|
| 622 |
whole_time_step++; |
| 623 |
|
| 624 |
/* update the data file; this should be done at the end of every time step |
| 625 |
* to ensure that no data is lost if the analysis dies |
| 626 |
*/ |
| 627 |
error = ex_update(exoid); |
| 628 |
printf("after ex_update, error = %d\n", error); |
| 629 |
} |
| 630 |
free(glob_var_vals); |
| 631 |
free(nodal_var_vals); |
| 632 |
free(elem_var_vals); |
| 633 |
|
| 634 |
/* close the EXODUS files |
| 635 |
*/ |
| 636 |
error = ex_close(exoid); |
| 637 |
printf("after ex_close, error = %d\n", error); |
| 638 |
return 0; |
| 639 |
} |