#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define EXCHECK(funcall) \
do { \
if ((error = (funcall)) != NC_NOERR) { \
fprintf(stderr, "ERROR Calling " #funcall ", error = %d\n", error); \
ex_close(exoid); \
exit(-1); \
} \
} while (0)
int main(int argc, char **argv)
{
int error;
int exoid, num_dim, num_nodes, num_elem, num_elem_blk;
int num_elem_in_block[10], num_nodes_per_elem[10];
int num_nodes_in_nset[10];
int num_node_sets, num_side_sets;
int i, j, k, m, *elem_map, *connect;
int node_list[100];
int ebids[10], nsids[10];
int num_qa_rec, num_info;
int num_nod_vars, num_ele_vars, num_nset_vars;
int *truth_tab;
int whole_time_step, num_time_steps;
int CPU_word_size, IO_word_size;
int prop_array[2];
int elem_list[1], side_list[1];
float *nodal_var_vals, *elem_var_vals;
float *nset_var_vals;
float time_value;
float x[100];
float attrib[10], dist_fact[100];
char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3];
char *block_names[10], *set_names[10];
char *prop_names[2], *attrib_names[2];
char *title = "This is a test";
CPU_word_size = 0;
IO_word_size = 4;
&CPU_word_size,
&IO_word_size);
printf("after ex_create for oned.e, exoid = %d\n", exoid);
printf(" cpu word size: %d io word size: %d\n", CPU_word_size, IO_word_size);
num_dim = 1;
num_nodes = 10;
num_elem = 10;
num_elem_blk = 3;
num_node_sets = 2;
num_side_sets = 2;
EXCHECK(
ex_put_init(exoid, title, num_dim, num_nodes, num_elem, num_elem_blk, num_node_sets,
num_side_sets));
for (i = 0; i < num_nodes; i++) {
x[i] = exp((float)i / 10.0f);
}
coord_names[0] = "xcoor";
attrib_names[0] = "Node_attr_1";
elem_map = (int *)calloc(num_elem, sizeof(int));
for (i = 1; i <= num_elem; i++) {
elem_map[i - 1] = 10 * i;
}
free(elem_map);
block_names[0] = "left_side";
block_names[1] = "right_side";
block_names[2] = "center";
num_elem_in_block[0] = 4;
num_elem_in_block[1] = 5;
num_elem_in_block[2] = 1;
num_nodes_per_elem[0] = 2;
num_nodes_per_elem[1] = 2;
num_nodes_per_elem[2] = 1;
ebids[0] = 10;
ebids[1] = 20;
ebids[2] = 30;
num_nodes_per_elem[0], 0, 0, 1));
num_nodes_per_elem[1], 0, 0, 1));
num_nodes_per_elem[2], 0, 0, 0));
prop_names[0] = "DENSITY";
connect = (int *)calloc(20, sizeof(int));
for (i = 0; i < num_elem * 2; i += 2) {
connect[i] = i / 2 + 1;
connect[i + 1] = i / 2 + 2;
}
connect[0] = 5;
free(connect);
for (i = 0; i < num_elem; i++) {
attrib[i] = 3.14159 * i;
}
attrib_names[0] = "THICKNESS";
attrib_names[0] = "WIDTH";
num_nodes_in_nset[0] = 5;
num_nodes_in_nset[1] = 3;
nsids[0] = 20;
nsids[1] = 21;
node_list[0] = 1;
node_list[1] = 3;
node_list[2] = 5;
node_list[3] = 7;
node_list[4] = 9;
dist_fact[0] = 1.0;
dist_fact[1] = 2.0;
dist_fact[2] = 3.0;
dist_fact[3] = 4.0;
dist_fact[4] = 5.0;
node_list[0] = 2;
node_list[1] = 4;
node_list[2] = 6;
dist_fact[0] = 1.0;
dist_fact[1] = 2.0;
dist_fact[2] = 3.0;
set_names[0] = "all_odd_nodes";
set_names[1] = "some_even_nodes";
prop_array[0] = 1000;
prop_array[1] = 2000;
attrib_names[0] = "Nodeset_attribute";
elem_list[0] = 1;
side_list[0] = 1;
dist_fact[0] = 2.0;
elem_list[0] = 9;
side_list[0] = 2;
dist_fact[0] = 3.0;
set_names[0] = "left_boundary";
set_names[1] = "right_boundary";
num_qa_rec = 2;
qa_record[0][0] = "TESTWT";
qa_record[0][1] = "testwt";
qa_record[0][2] = "07/07/93";
qa_record[0][3] = "15:41:33";
qa_record[1][0] = "";
qa_record[1][1] = " ";
qa_record[1][2] = "";
qa_record[1][3] = " ";
num_info = 3;
info[0] = "This is the first information record.";
info[1] = "";
info[2] = " ";
num_nod_vars = 2;
var_names[0] = "node_variable_a_very_long_name_0";
var_names[1] = "nod_var1";
num_ele_vars = 3;
var_names[0] = "this_variable_name_is_short";
var_names[1] = "this_variable_name_is_just_right";
var_names[2] = "this_variable_name_is_tooooo_long";
num_nset_vars = 3;
var_names[0] = "ns_var0";
var_names[1] = "ns_var1";
var_names[2] = "ns_var2";
truth_tab = (int *)calloc((num_elem_blk * num_ele_vars), sizeof(int));
k = 0;
for (i = 0; i < num_elem_blk; i++) {
for (j = 0; j < num_ele_vars; j++) {
truth_tab[k++] = 1;
}
}
free(truth_tab);
whole_time_step = 1;
num_time_steps = 10;
nodal_var_vals = (float *)calloc(num_nodes, CPU_word_size);
elem_var_vals = (float *)calloc(num_elem, CPU_word_size);
nset_var_vals = (float *)calloc(10, CPU_word_size);
for (i = 0; i < num_time_steps; i++) {
time_value = (float)(i + 1) / 100.0f;
for (k = 1; k <= num_nod_vars; k++) {
for (j = 0; j < num_nodes; j++) {
nodal_var_vals[j] = (float)k + ((float)(j + 1) * time_value);
}
}
for (k = 1; k <= num_ele_vars; k++) {
for (j = 0; j < num_elem_blk; j++) {
for (m = 0; m < num_elem_in_block[j]; m++) {
elem_var_vals[m] = (float)(k + 1) + (float)(j + 2) + ((float)(m + 1) * time_value);
}
elem_var_vals));
}
}
for (k = 1; k <= num_nset_vars; k++) {
for (j = 0; j < num_node_sets; j++) {
for (m = 0; m < num_nodes_in_nset[j]; m++) {
nset_var_vals[m] = (float)(k + 3) + (float)(j + 4) + ((float)(m + 1) * time_value);
}
nset_var_vals));
}
}
whole_time_step++;
}
free(nodal_var_vals);
free(elem_var_vals);
free(nset_var_vals);
return 0;
}
#define EXCHECK(funcall)
Definition ex_copy.c:15
@ EX_SIDE_SET
Definition exodusII.h:278
@ EX_NODE_SET
Definition exodusII.h:270
@ EX_NODAL
Definition exodusII.h:268
@ EX_ELEM_MAP
Definition exodusII.h:280
@ EX_ELEM_BLOCK
Definition exodusII.h:275
@ EX_ABORT
Definition exodusII.h:392
@ EX_VERBOSE
Definition exodusII.h:390
#define EX_CLOBBER
Definition exodusII.h:101
int ex_put_set_param(int exoid, ex_entity_type set_type, ex_entity_id set_id, int64_t num_entries_in_set, int64_t num_dist_fact_in_set)
Definition ex_put_set_param.c:39
int ex_put_names(int exoid, ex_entity_type obj_type, char *const names[])
Definition ex_put_names.c:37
int ex_put_conn(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const void_int *node_conn, const void_int *elem_edge_conn, const void_int *elem_face_conn)
Definition ex_put_conn.c:44
int ex_put_one_attr(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int attrib_index, const void *attrib)
Definition ex_put_one_attr.c:37
int ex_put_prop_names(int exoid, ex_entity_type obj_type, int num_props, char **prop_names)
Definition ex_put_prop_names.c:97
int ex_put_coord_names(int exoid, char *const coord_names[])
Definition ex_put_coord_names.c:46
int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *z_coor)
Definition ex_put_coord.c:87
int ex_put_prop(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, const char *prop_name, ex_entity_id value)
Definition ex_put_prop.c:77
int ex_put_attr(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const void *attrib)
Definition ex_put_attr.c:37
int ex_put_prop_array(int exoid, ex_entity_type obj_type, const char *prop_name, const void_int *values)
Definition ex_put_prop_array.c:71
int ex_put_init(int exoid, const char *title, int64_t num_dim, int64_t num_nodes, int64_t num_elem, int64_t num_elem_blk, int64_t num_node_sets, int64_t num_side_sets)
Definition ex_put_init.c:53
int ex_put_attr_param(int exoid, ex_entity_type obj_type, ex_entity_id obj_id, int num_attrs)
Definition ex_put_attr_param.c:35
int ex_put_block(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, const char *entry_descrip, int64_t num_entries_this_blk, int64_t num_nodes_per_entry, int64_t num_edges_per_entry, int64_t num_faces_per_entry, int64_t num_attr_per_entry)
Definition ex_put_block.c:47
int ex_put_set_dist_fact(int exoid, ex_entity_type set_type, ex_entity_id set_id, const void *set_dist_fact)
Definition ex_put_set_dist_fact.c:37
int ex_put_set(int exoid, ex_entity_type set_type, ex_entity_id set_id, const void_int *set_entry_list, const void_int *set_extra_list)
Definition ex_put_set.c:41
int ex_put_attr_names(int exoid, ex_entity_type blk_type, ex_entity_id blk_id, char **names)
int ex_put_id_map(int exoid, ex_entity_type map_type, const void_int *map)
Definition ex_put_id_map.c:37
int ex_put_time(int exoid, int time_step, const void *time_value)
Definition ex_put_time.c:51
int ex_put_variable_names(int exoid, ex_entity_type obj_type, int num_vars, char *const var_names[])
Definition ex_put_variable_names.c:125
int ex_put_variable_param(int exoid, ex_entity_type obj_type, int num_vars)
Definition ex_put_variable_param.c:124
int ex_put_truth_table(int exoid, ex_entity_type obj_type, int num_blk, int num_var, const int *var_tab)
Definition ex_put_truth_table.c:67
int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index, ex_entity_id obj_id, int64_t num_entries_this_obj, const void *var_vals)
Definition ex_put_var.c:77
int ex_set_max_name_length(int exoid, int length)
Definition ex_utils.c:255
#define ex_create(path, mode, comp_ws, io_ws)
Definition exodusII.h:591
int ex_put_qa(int exoid, int num_qa_records, char *qa_record[][4])
Definition ex_put_qa.c:63
int ex_opts(int options)
Definition ex_opts.c:56
int ex_put_info(int exoid, int num_info, char *const info[])
Definition ex_put_info.c:73
int ex_close(int exoid)
Definition ex_close.c:47
int ex_update(int exoid)
Definition ex_update.c:30