#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
int num_dim, num_nodes, num_elem_blk;
int *num_elem_in_block, *num_face_in_block, *num_nodes_per_elem, *num_edges_per_elem,
*num_faces_per_elem, *num_attr;
int error, nnodes;
int i, j, k;
int *connect, *fconnect;
int *ids, *nnpe, *nnpf;
int num_qa_rec, num_info;
int CPU_word_size, IO_word_size;
int idum;
float *x, *y, *z;
float version, fdum;
char *coord_names[3], *qa_record[2][4], *info[3];
char *block_names[10];
char *elem_type[10];
char *cdum = NULL;
CPU_word_size = 0;
IO_word_size = 0;
int exoid =
ex_open(
"test-nfaced.exo",
&CPU_word_size,
&IO_word_size,
&version);
printf("\nafter ex_open\n");
if (exoid < 0) {
exit(1);
}
printf("test.exo is an EXODUSII file; version %4.2f\n", version);
printf(" I/O word size %1d\n", IO_word_size);
printf("EXODUSII Library API; version %4.2f (%d)\n", version, idum);
{
printf("after ex_get_init, error = %3d\n", error);
printf("database parameters:\n");
printf(
"title = '%s'\n", par.
title);
printf(
"num_dim = %" PRId64
"\n", par.
num_dim);
printf(
"num_nodes = %" PRId64
"\n", par.
num_nodes);
printf(
"num_edge = %" PRId64
"\n", par.
num_edge);
printf(
"num_face = %" PRId64
"\n", par.
num_face);
printf(
"num_elem = %" PRId64
"\n", par.
num_elem);
}
assert(num_dim == 3);
x = (float *)calloc(num_nodes, sizeof(float));
y = (float *)calloc(num_nodes, sizeof(float));
z = (float *)calloc(num_nodes, sizeof(float));
printf("\nafter ex_get_coord, error = %3d\n", error);
printf("x, y, z coords = \n");
for (i = 0; i < num_nodes; i++) {
printf("%5.1f\t%5.1f\t%5.1f\n", x[i], y[i], z[i]);
}
free(x);
free(y);
free(z);
for (i = 0; i < num_dim; i++) {
}
printf("\nafter ex_get_coord_names, error = %3d\n", error);
printf("x coord name = '%s'\n", coord_names[0]);
printf("y coord name = '%s'\n", coord_names[1]);
printf("z coord name = '%s'\n", coord_names[2]);
for (i = 0; i < num_dim; i++) {
free(coord_names[i]);
}
if (num_elem_blk > 0) {
ids = (int *)calloc(num_elem_blk, sizeof(int));
num_elem_in_block = (int *)calloc(num_elem_blk, sizeof(int));
num_face_in_block = (int *)calloc(num_elem_blk, sizeof(int));
num_nodes_per_elem = (int *)calloc(num_elem_blk, sizeof(int));
num_edges_per_elem = (int *)calloc(num_elem_blk, sizeof(int));
num_faces_per_elem = (int *)calloc(num_elem_blk, sizeof(int));
num_attr = (int *)calloc(num_elem_blk, sizeof(int));
for (i = 0; i < num_elem_blk; i++) {
}
printf("\nafter ex_get_elem_blk_ids, error = %3d\n", error);
printf("\nafter ex_get_names, error = %3d\n", error);
for (i = 0; i < num_elem_blk; i++) {
if (strcmp(name, block_names[i]) != 0) {
printf("error in ex_get_name for block id %d\n", ids[i]);
}
&(num_nodes_per_elem[i]), &(num_edges_per_elem[i]),
&(num_faces_per_elem[i]), &(num_attr[i]));
printf("\nafter ex_get_elem_block, error = %d\n", error);
printf("element block id = %2d\n", ids[i]);
printf("element block type = '%s'\n", elem_type[i]);
printf("num_elem_in_block = %2d\n", num_elem_in_block[i]);
printf("num_total_nodes_per_block = %2d\n", num_nodes_per_elem[i]);
printf("num_total_edges_per_block = %2d\n", num_edges_per_elem[i]);
printf("num_total_faces_per_block = %2d\n", num_faces_per_elem[i]);
printf("num_attr = %2d\n", num_attr[i]);
printf("name = '%s'\n", block_names[i]);
}
}
for (i = 0; i < num_elem_blk; i++) {
if (num_elem_in_block[i] > 0) {
if (strcmp(elem_type[i], "NFACED") == 0 || strcmp(elem_type[i], "nfaced") == 0) {
int nfaces = 0;
connect = (int *)calloc((num_faces_per_elem[i]), sizeof(int));
nnpe = (int *)calloc(num_elem_in_block[i], sizeof(int));
printf("\nafter ex_get_entity_count_per_polyhedra, error = %d\n", error);
for (j = 0; j < num_elem_in_block[i]; j++) {
nfaces += nnpe[j];
}
assert(nfaces == num_faces_per_elem[i]);
printf("\nafter ex_get_conn, error = %d\n", error);
printf("face connectivity array for elem block %2d\n", ids[i]);
nfaces = 0;
for (j = 0; j < num_elem_in_block[i]; j++) {
printf("Element %d, %d faces:\t", j + 1, nnpe[j]);
for (k = 0; k < nnpe[j]; k++) {
printf("%3d ", connect[nfaces + k]);
}
printf("\n");
nfaces += nnpe[j];
}
&(num_nodes_per_elem[i]), NULL, NULL, &(num_attr[i]));
printf("\nafter ex_get_block (EX_FACE_BLOCK), error = %d\n", error);
printf("\nafter ex_get_names, error = %3d\n", error);
printf("\tface block id = %2d\n", ids[i]);
printf("\tface block type = '%s'\n", elem_type[i]);
printf("\tnum_face_in_block = %2d\n", num_face_in_block[i]);
printf("\tnum_total_nodes_per_block = %2d\n", num_nodes_per_elem[i]);
printf("\tnum_attr = %2d\n", num_attr[i]);
printf("\tname = '%s'\n", block_names[i]);
fconnect = (int *)calloc((num_nodes_per_elem[i]), sizeof(int));
nnpf = (int *)calloc(num_face_in_block[i], sizeof(int));
printf("\nafter ex_get_entity_count_per_polyhedra, error = %d\n", error);
nnodes = 0;
for (j = 0; j < num_face_in_block[i]; j++) {
nnodes += nnpf[j];
}
assert(nnodes == num_nodes_per_elem[i]);
printf("\nafter ex_get_conn, error = %d\n", error);
printf("node connectivity array for face block %2d\n", ids[i]);
nnodes = 0;
for (j = 0; j < num_face_in_block[i]; j++) {
printf("Face %d, %d nodes:\t", j + 1, nnpf[j]);
for (k = 0; k < nnpf[j]; k++) {
printf("%3d ", fconnect[nnodes + k]);
}
printf("\n");
nnodes += nnpf[j];
}
free(fconnect);
free(nnpe);
free(nnpf);
}
else {
connect = (int *)calloc((num_nodes_per_elem[i] * num_elem_in_block[i]), sizeof(int));
printf("\nafter ex_get_conn, error = %d\n", error);
printf("connect array for elem block %2d\n", ids[i]);
for (j = 0; j < num_nodes_per_elem[i]; j++) {
printf("%3d\n", connect[j]);
}
}
free(connect);
}
}
for (i = 0; i < num_elem_blk; i++) {
free(elem_type[i]);
free(block_names[i]);
}
if (num_elem_blk > 0) {
free(ids);
free(num_nodes_per_elem);
free(num_edges_per_elem);
free(num_faces_per_elem);
free(num_elem_in_block);
free(num_face_in_block);
free(num_attr);
}
for (i = 0; i < num_qa_rec; i++) {
for (j = 0; j < 4; j++) {
}
}
printf("\nafter ex_get_qa, error = %3d\n", error);
printf("QA records = \n");
for (i = 0; i < num_qa_rec; i++) {
for (j = 0; j < 4; j++) {
printf(" '%s'\n", qa_record[i][j]);
free(qa_record[i][j]);
}
}
printf("\nafter ex_inquire, error = %3d\n", error);
for (i = 0; i < num_info; i++) {
}
printf("\nafter ex_get_info, error = %3d\n", error);
printf("info records = \n");
for (i = 0; i < num_info; i++) {
printf(" '%s'\n", info[i]);
free(info[i]);
}
printf("\nafter ex_close, error = %3d\n", error);
return 0;
}
@ EX_FACE_BLOCK
Definition exodusII.h:273
@ EX_ELEM_BLOCK
Definition exodusII.h:275
@ EX_ABORT
Definition exodusII.h:392
@ EX_VERBOSE
Definition exodusII.h:390
@ EX_INQ_INFO
Definition exodusII.h:158
@ EX_INQ_LIB_VERS
Definition exodusII.h:165
@ EX_INQ_QA
Definition exodusII.h:157
#define EX_READ
Definition exodusII.h:98
int ex_get_coord_names(int exoid, char **coord_names)
Definition ex_get_coord_names.c:46
int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
Definition ex_get_coord.c:71
int ex_get_names(int exoid, ex_entity_type obj_type, char **names)
Definition ex_get_names.c:32
int ex_get_init_ext(int exoid, ex_init_params *info)
Definition ex_get_init_ext.c:81
int ex_get_block(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, char *elem_type, void_int *num_entries_this_blk, void_int *num_nodes_per_entry, void_int *num_edges_per_entry, void_int *num_faces_per_entry, void_int *num_attr_per_entry)
Definition ex_get_block.c:36
int ex_get_entity_count_per_polyhedra(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, int *entity_counts)
Definition ex_get_entity_count_per_polyhedra.c:26
int ex_get_ids(int exoid, ex_entity_type obj_type, void_int *ids)
Definition ex_get_ids.c:101
int ex_get_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, char *name)
Definition ex_get_name.c:33
int ex_get_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, void_int *nodeconn, void_int *edgeconn, void_int *faceconn)
Definition ex_get_conn.c:29
#define MAX_STR_LENGTH
Definition exodusII.h:409
#define MAX_LINE_LENGTH
Definition exodusII.h:415
int ex_get_info(int exoid, char **info)
Definition ex_get_info.c:48
int ex_opts(int options)
Definition ex_opts.c:56
int ex_inquire(int exoid, ex_inquiry req_info, void_int *ret_int, float *ret_float, char *ret_char)
Definition ex_inquire.c:1095
#define ex_open(path, mode, comp_ws, io_ws, version)
Definition exodusII.h:597
int ex_close(int exoid)
Definition ex_close.c:47
int ex_get_qa(int exoid, char *qa_record[][4])
Definition ex_get_qa.c:56
Definition exodusII.h:438
int64_t num_edge
Definition exodusII.h:442
int64_t num_node_sets
Definition exodusII.h:448
int64_t num_face
Definition exodusII.h:444
int64_t num_nodes
Definition exodusII.h:441
int64_t num_dim
Definition exodusII.h:440
int64_t num_elem
Definition exodusII.h:446
int64_t num_elem_blk
Definition exodusII.h:447
int64_t num_side_sets
Definition exodusII.h:451
char title[MAX_LINE_LENGTH+1]
Definition exodusII.h:439