#include <stdio.h>
#include <stdlib.h>
void *my_calloc(size_t length, size_t size)
{
if (length == 0 || size == 0) {
return NULL;
}
return calloc(length, size);
}
int main(int argc, char **argv)
{
int i, j, k;
int CPU_word_size = 0;
int IO_word_size = 0;
float version;
&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);
int idum;
char *cdum = NULL;
printf("EXODUSII API; version %4.2f\n", version);
int num_dim, num_nodes, num_elem, num_elem_blk, num_node_sets;
int num_side_sets;
int error =
ex_get_init(exoid, title, &num_dim, &num_nodes, &num_elem, &num_elem_blk,
&num_node_sets, &num_side_sets);
printf("after ex_get_init, error = %3d\n", error);
printf("database parameters:\n");
printf("title = '%s'\n", title);
printf("num_dim = %3d\n", num_dim);
printf("num_nodes = %3d\n", num_nodes);
printf("num_elem = %3d\n", num_elem);
printf("num_elem_blk = %3d\n", num_elem_blk);
printf("num_node_sets = %3d\n", num_node_sets);
printf("num_side_sets = %3d\n", num_side_sets);
int *ids = (int *)my_calloc(num_elem_blk, sizeof(int));
int *num_elem_in_block = (int *)my_calloc(num_elem_blk, sizeof(int));
int *num_nodes_per_elem = (int *)my_calloc(num_elem_blk, sizeof(int));
int *num_attr = (int *)my_calloc(num_elem_blk, sizeof(int));
printf("\nafter ex_get_elem_blk_ids, error = %3d\n", error);
for (i = 0; i < num_elem_blk; i++) {
&(num_nodes_per_elem[i]), NULL, NULL, &(num_attr[i]));
printf("\nafter ex_get_elem_block, error = %d\n", error);
printf("element block id = %2d\n", ids[i]);
printf("element type = '%s'\n", elem_type);
printf("num_elem_in_block = %2d\n", num_elem_in_block[i]);
printf("num_nodes_per_elem = %2d\n", num_nodes_per_elem[i]);
printf("num_attr = %2d\n", num_attr[i]);
}
for (i = 0; i < num_elem_blk; i++) {
int *connect = (int *)my_calloc((num_nodes_per_elem[i] * num_elem_in_block[i]), sizeof(int));
printf("\nafter ex_get_elem_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);
}
free(ids);
free(num_elem_in_block);
free(num_nodes_per_elem);
free(num_attr);
ids = (int *)my_calloc(num_side_sets, sizeof(int));
printf("\nafter ex_get_side_set_ids, error = %3d\n", error);
for (i = 0; i < num_side_sets; i++) {
int num_sides_in_set;
int num_df_in_set;
printf("\nafter ex_get_side_set_param, error = %3d\n", error);
printf("side set %2d parameters:\n", ids[i]);
printf("num_sides = %3d\n", num_sides_in_set);
printf("num_dist_factors = %3d\n", num_df_in_set);
int num_elem_in_set = num_sides_in_set;
int *elem_list = (int *)my_calloc(num_elem_in_set, sizeof(int));
int *side_list = (int *)my_calloc(num_sides_in_set, sizeof(int));
int *node_ctr_list = (int *)my_calloc(num_elem_in_set, sizeof(int));
int *node_list = (int *)my_calloc(num_elem_in_set * 21, sizeof(int));
float *dist_fact = (float *)my_calloc(num_df_in_set, sizeof(float));
printf("\nafter ex_get_side_set, error = %3d\n", error);
printf("\nafter ex_get_side_set_node_list, error = %3d\n", error);
if (num_df_in_set > 0) {
printf("\nafter ex_get_side_set_dist_fact, error = %3d\n", error);
}
printf("element list for side set %2d\n", ids[i]);
for (j = 0; j < num_elem_in_set; j++) {
printf("%3d\n", elem_list[j]);
}
printf("side list for side set %2d\n", ids[i]);
for (j = 0; j < num_sides_in_set; j++) {
printf("%3d\n", side_list[j]);
}
int node_ctr = 0;
printf("node list for side set %2d\n", ids[i]);
for (k = 0; k < num_elem_in_set; k++) {
printf("%3d nodes for side %3d\n", node_ctr_list[k], k);
for (j = 0; j < node_ctr_list[k]; j++) {
printf("%3d\n", node_list[node_ctr + j]);
}
node_ctr += node_ctr_list[k];
}
if (num_df_in_set > 0) {
printf("dist factors for side set %2d\n", ids[i]);
for (j = 0; j < num_df_in_set; j++) {
printf("%5.3f\n", dist_fact[j]);
}
}
else {
printf("no dist factors for side set %2d\n", ids[i]);
}
free(elem_list);
free(side_list);
free(node_ctr_list);
free(node_list);
free(dist_fact);
}
free(ids);
int elem_list_len = 0;
int df_list_len = 0;
if (num_side_sets > 0) {
printf("\nafter ex_inquire: EX_INQ_SS_ELEM_LEN = %d\n", elem_list_len);
printf("\nafter ex_inquire: EX_INQ_SS_NODE_LEN = %d\n", node_list_len);
printf("\nafter ex_inquire: EX_INQ_SS_DF_LEN = %d\n", df_list_len);
}
ids = (int *)my_calloc(num_side_sets, sizeof(int));
int *num_elem_per_set = (int *)my_calloc(num_side_sets, sizeof(int));
int *num_df_per_set = (int *)my_calloc(num_side_sets, sizeof(int));
int *elem_ind = (int *)my_calloc(num_side_sets, sizeof(int));
int *df_ind = (int *)my_calloc(num_side_sets, sizeof(int));
int *elem_list = (int *)my_calloc(elem_list_len, sizeof(int));
int *side_list = (int *)my_calloc(elem_list_len, sizeof(int));
float *dist_fact = (float *)my_calloc(df_list_len, sizeof(float));
{
set_specs.num_entries_per_set = num_elem_per_set;
set_specs.num_dist_per_set = num_df_per_set;
set_specs.sets_entry_index = elem_ind;
set_specs.sets_dist_index = df_ind;
set_specs.sets_entry_list = elem_list;
set_specs.sets_extra_list = side_list;
set_specs.sets_dist_fact = dist_fact;
}
printf("\nafter ex_get_concat_side_sets, error = %3d\n", error);
printf("concatenated side set info\n");
printf("ids = \n");
for (i = 0; i < num_side_sets; i++) {
printf("%3d\n", ids[i]);
}
printf("num_elem_per_set = \n");
for (i = 0; i < num_side_sets; i++) {
printf("%3d\n", num_elem_per_set[i]);
}
printf("num_dist_per_set = \n");
for (i = 0; i < num_side_sets; i++) {
printf("%3d\n", num_df_per_set[i]);
}
printf("elem_ind = \n");
for (i = 0; i < num_side_sets; i++) {
printf("%3d\n", elem_ind[i]);
}
printf("dist_ind = \n");
for (i = 0; i < num_side_sets; i++) {
printf("%3d\n", df_ind[i]);
}
printf("elem_list = \n");
for (i = 0; i < elem_list_len; i++) {
printf("%3d\n", elem_list[i]);
}
printf("side_list = \n");
for (i = 0; i < elem_list_len; i++) {
printf("%3d\n", side_list[i]);
}
printf("dist_fact = \n");
for (i = 0; i < df_list_len; i++) {
printf("%5.3f\n", dist_fact[i]);
}
free(ids);
free(num_elem_per_set);
free(num_df_per_set);
free(df_ind);
free(elem_ind);
free(elem_list);
free(side_list);
free(dist_fact);
printf("\nafter ex_close, error = %3d\n", error);
return 0;
}
@ EX_SIDE_SET
Definition exodusII.h:278
@ EX_ELEM_BLOCK
Definition exodusII.h:275
@ EX_ABORT
Definition exodusII.h:392
@ EX_VERBOSE
Definition exodusII.h:390
@ EX_INQ_API_VERS
Definition exodusII.h:145
@ EX_INQ_SS_DF_LEN
Definition exodusII.h:164
@ EX_INQ_SS_NODE_LEN
Definition exodusII.h:155
@ EX_INQ_SS_ELEM_LEN
Definition exodusII.h:156
#define EX_READ
Definition exodusII.h:98
int ex_get_concat_sets(int exoid, ex_entity_type set_type, struct ex_set_specs *set_specs)
Definition ex_get_concat_sets.c:32
int ex_get_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int *set_entry_list, void_int *set_extra_list)
Definition ex_get_set.c:23
int ex_get_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id, void_int *num_entry_in_set, void_int *num_dist_fact_in_set)
Definition ex_get_set_param.c:36
int ex_get_side_set_node_list(int exoid, ex_entity_id side_set_id, void_int *side_set_node_cnt_list, void_int *side_set_node_list)
Definition ex_get_side_set_node_list.c:58
int ex_get_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id, void *set_dist_fact)
Definition ex_get_set_dist_fact.c:33
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_init(int exoid, char *title, void_int *num_dim, void_int *num_nodes, void_int *num_elem, void_int *num_elem_blk, void_int *num_node_sets, void_int *num_side_sets)
Definition ex_get_init.c:75
int ex_get_ids(int exoid, ex_entity_type obj_type, void_int *ids)
Definition ex_get_ids.c:101
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
int64_t ex_inquire_int(int exoid, ex_inquiry req_info)
Definition ex_inquire.c:1029
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
Definition exodusII.h:537
void_int * sets_ids
Definition exodusII.h:538