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) { struct ex_set set[1]; set[0].type = set_type; set[0].id = set_id; set[0].num_entry = num_entries_in_set; set[0].num_distribution_factor = num_dist_fact_in_set; set[0].entry_list = NULL; set[0].extra_list = NULL; set[0].distribution_factor_list = NULL; return ex_put_sets(exoid, 1, set); }
int cCreateEdgeFace( int argc, char* argv[] ) { int exoid; int appWordSize = 8; int diskWordSize = 8; /* int concatBlocks = ex_have_arg( argc, argv, "-pcab" ); */ int concatSets = ex_have_arg( argc, argv, "-pcset" ); int concatResult = ex_have_arg( argc, argv, "-pvpax" ); double t; ex_init_params modelParams = { "CreateEdgeFace Test", /* title */ 3, /* num_dim */ 12, /* num_nodes */ 20, /* num_edge */ 1, /* num_edge_blk */ 11, /* num_face */ 3, /* num_face_blk */ 3, /* num_elem */ 2, /* num_elem_blk */ 1, /* num_node_sets */ 1, /* num_edge_sets */ 1, /* num_face_sets */ 1, /* num_side_sets */ 2, /* num_elem_sets */ 1, /* num_node_map */ 1, /* num_edge_map */ 1, /* num_face_map */ 1, /* num_elem_map */ }; ex_block edgeBlocks[1]; ex_block faceBlocks[3]; ex_block elemBlocks[2]; ex_var_params varParams; ex_opts (EX_VERBOSE | EX_ABORT ); edgeBlocks[0].type = EX_EDGE_BLOCK; edgeBlocks[0].id = 100; edgeBlocks[0].num_entry = 20; edgeBlocks[0].num_nodes_per_entry = 2; edgeBlocks[0].num_attribute = 1; strcpy(edgeBlocks[0].topology, "EDGE2"); faceBlocks[0].type = EX_FACE_BLOCK; faceBlocks[0].id = 500; faceBlocks[0].num_entry = 2; faceBlocks[0].num_nodes_per_entry = 4; faceBlocks[0].num_attribute = 1; strcpy(faceBlocks[0].topology, "QUAD4"); faceBlocks[1].type = EX_FACE_BLOCK; faceBlocks[1].id = 600; faceBlocks[1].num_entry = 1; faceBlocks[1].num_nodes_per_entry = 4; faceBlocks[1].num_attribute = 1; strcpy(faceBlocks[1].topology, "QUAD4"); faceBlocks[2].type = EX_FACE_BLOCK; faceBlocks[2].id = 700; faceBlocks[2].num_entry = 8; faceBlocks[2].num_nodes_per_entry = 4; faceBlocks[2].num_attribute = 1; strcpy(faceBlocks[2].topology, "QUAD4"); elemBlocks[0].type = EX_ELEM_BLOCK; elemBlocks[0].id = 200; elemBlocks[0].num_entry = 2; elemBlocks[0].num_nodes_per_entry = 8; elemBlocks[0].num_edges_per_entry = 12; elemBlocks[0].num_faces_per_entry = 6; elemBlocks[0].num_attribute = 2; strcpy(elemBlocks[0].topology, "HEX8"); elemBlocks[1].type = EX_ELEM_BLOCK; elemBlocks[1].id = 201; elemBlocks[1].num_entry = 1; elemBlocks[1].num_nodes_per_entry = 4; elemBlocks[1].num_edges_per_entry = 0; elemBlocks[1].num_faces_per_entry = 0; elemBlocks[1].num_attribute = 0; strcpy(elemBlocks[1].topology, "TET4"); varParams.edge_var_tab = (int*)malloc(2 * sizeof(int)); varParams.face_var_tab = (int*)malloc(3 * sizeof(int)); varParams.elem_var_tab = (int*)malloc(2 * sizeof(int)); varParams.nset_var_tab = (int*)0; varParams.eset_var_tab = (int*)0; varParams.fset_var_tab = (int*)malloc(1 * sizeof(int)); varParams.sset_var_tab = (int*)0; varParams.elset_var_tab = (int*)0; varParams.num_glob = 2; varParams.num_node = 1; varParams.num_edge = 2; varParams.edge_var_tab[0] = 1; varParams.edge_var_tab[1] = 1; varParams.num_face = 1; varParams.face_var_tab[0] = 1; varParams.face_var_tab[1] = 1; varParams.face_var_tab[2] = 1; varParams.num_elem = 1; varParams.elem_var_tab[0] = 1; varParams.elem_var_tab[1] = 0; varParams.num_nset = 0; varParams.num_eset = 0;; varParams.num_fset = 1; varParams.fset_var_tab[0] = 1; varParams.num_sset = 0; varParams.num_elset = 0; exoid = ex_create( EX_TEST_FILENAME, EX_CLOBBER, &appWordSize, &diskWordSize ); if ( exoid <= 0 ) { fprintf( stderr, "Unable to open \"%s\" for writing.\n", EX_TEST_FILENAME ); return 1; } EXCHECK( ex_put_init_ext( exoid, &modelParams ), "Unable to initialize database.\n" ); { int blk; for ( blk = 0; blk < modelParams.num_edge_blk; ++blk ) { EXCHECK( ex_put_block_param( exoid, edgeBlocks[blk]), "Unable to write edge block" ); } for ( blk = 0; blk < modelParams.num_face_blk; ++blk ) { EXCHECK( ex_put_block_param( exoid, faceBlocks[blk]), "Unable to write face block" ); } for ( blk = 0; blk < modelParams.num_elem_blk; ++blk ) { EXCHECK( ex_put_block_param( exoid, elemBlocks[blk]), "Unable to write elem block" ); } } EXCHECK( ex_put_coord( exoid, (void*)coordsX, (void*)coordsY, (void*)coordsZ ), "Unable to write coordinates.\n" ); EXCHECK( ex_put_coord_names( exoid, (char**)coordsNames ), "Unable to write coordinate names.\n" ); /* =============== Connectivity ================== */ /* *** NEW API *** */ EXCHECK( ex_put_conn( exoid, EX_EDGE_BLOCK, edgeBlocks[0].id, ebconn1, 0, 0 ), "Unable to write edge block connectivity.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_conn( exoid, EX_FACE_BLOCK, faceBlocks[0].id, fbconn1, 0, 0 ), "Unable to write face block 1 connectivity.\n" ); EXCHECK( ex_put_conn( exoid, EX_FACE_BLOCK, faceBlocks[1].id, fbconn2, 0, 0 ), "Unable to write face block 2 connectivity.\n" ); EXCHECK( ex_put_conn( exoid, EX_FACE_BLOCK, faceBlocks[2].id, fbconn3, 0, 0 ), "Unable to write face block 3 connectivity.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_conn( exoid, EX_ELEM_BLOCK, elemBlocks[0].id, conn1, econn1, fconn1 ), "Unable to write elem block 1 connectivity.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_conn( exoid, EX_ELEM_BLOCK, elemBlocks[1].id, conn2, 0, 0 ), "Unable to write elem block 2 connectivity.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_names( exoid, EX_EDGE_BLOCK, (char**)edblk_names ), "Unable to write edge block names.\n" ); EXCHECK( ex_put_names( exoid, EX_FACE_BLOCK, (char**)fablk_names ), "Unable to write face block names.\n" ); EXCHECK( ex_put_names( exoid, EX_ELEM_BLOCK, (char**) eblk_names ), "Unable to write element block names.\n" ); /* =============== Number Maps ================== */ /* *** NEW API *** */ EXCHECK( ex_put_num_map( exoid, EX_NODE_MAP, 300, nmap1 ), "Unable to write node map.\n" ); EXCHECK( ex_put_num_map( exoid, EX_EDGE_MAP, 800, edmap1 ), "Unable to write edge map.\n" ); EXCHECK( ex_put_num_map( exoid, EX_FACE_MAP, 900, famap1 ), "Unable to write face map.\n" ); EXCHECK( ex_put_num_map( exoid, EX_ELEM_MAP, 400, emap1 ), "Unable to write element map.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_names( exoid, EX_NODE_MAP, (char**) nmap_names ), "Unable to write node map names.\n" ); EXCHECK( ex_put_names( exoid, EX_EDGE_MAP, (char**)edmap_names ), "Unable to write edge map names.\n" ); EXCHECK( ex_put_names( exoid, EX_FACE_MAP, (char**)famap_names ), "Unable to write face map names.\n" ); EXCHECK( ex_put_names( exoid, EX_ELEM_MAP, (char**) emap_names ), "Unable to write element map names.\n" ); /* =============== Attribute names ================ */ /* *** NEW API *** */ EXCHECK( ex_put_attr_names( exoid, EX_EDGE_BLOCK, edgeBlocks[0].id, (char**)edge_attr_names1 ), "Unable to write edge block 1 attribute names.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_attr_names( exoid, EX_FACE_BLOCK, faceBlocks[0].id, (char**)face_attr_names1 ), "Unable to write face block 1 attribute names.\n" ); EXCHECK( ex_put_attr_names( exoid, EX_FACE_BLOCK, faceBlocks[1].id, (char**)face_attr_names2 ), "Unable to write face block 1 attribute names.\n" ); EXCHECK( ex_put_attr_names( exoid, EX_FACE_BLOCK, faceBlocks[2].id, (char**)face_attr_names3 ), "Unable to write face block 1 attribute names.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_attr_names( exoid, EX_ELEM_BLOCK, elemBlocks[0].id, (char**)elem_attr_names1 ), "Unable to write elem block 1 attribute names.\n" ); /* =============== Attribute values =============== */ /* *** NEW API *** */ EXCHECK( ex_put_attr( exoid, EX_EDGE_BLOCK, edgeBlocks[0].id, edge_attr_values1 ), "Unable to write edge block 1 attribute values.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_attr( exoid, EX_FACE_BLOCK, faceBlocks[0].id, face_attr_values1 ), "Unable to write face block 1 attribute values.\n" ); EXCHECK( ex_put_attr( exoid, EX_FACE_BLOCK, faceBlocks[1].id, face_attr_values2 ), "Unable to write face block 1 attribute values.\n" ); EXCHECK( ex_put_attr( exoid, EX_FACE_BLOCK, faceBlocks[2].id, face_attr_values3 ), "Unable to write face block 1 attribute values.\n" ); /* *** NEW API *** */ EXCHECK( ex_put_attr( exoid, EX_ELEM_BLOCK, elemBlocks[0].id, elem_attr_values1 ), "Unable to write elem block 1 attribute values.\n" ); /* =============== Set parameters ================= */ /* *** NEW API *** */ EXCHECK( ex_put_names( exoid, EX_NODE_SET, (char**)nset_names ), "Unable to write node set names.\n" ); EXCHECK( ex_put_names( exoid, EX_EDGE_SET, (char**)eset_names ), "Unable to write edge set names.\n" ); EXCHECK( ex_put_names( exoid, EX_FACE_SET, (char**)fset_names ), "Unable to write face set names.\n" ); EXCHECK( ex_put_names( exoid, EX_SIDE_SET, (char**)sset_names ), "Unable to write side set names.\n" ); EXCHECK( ex_put_names( exoid, EX_ELEM_SET, (char**)elset_names ), "Unable to write element set names.\n" ); { ex_set allSets[1+1+1+1+2]; ex_set *nodeSets = &allSets[0]; ex_set *edgeSets = &allSets[1]; ex_set *faceSets = &allSets[2]; ex_set *sideSets = &allSets[3]; ex_set *elemSets = &allSets[4]; nodeSets[0].type = EX_NODE_SET; nodeSets[0].id = 1000; nodeSets[0].num_entry = 3; nodeSets[0].num_distribution_factor = 0; nodeSets[0].entry_list = nset_nodes; nodeSets[0].extra_list = NULL; nodeSets[0].distribution_factor_list = NULL; edgeSets[0].type = EX_EDGE_SET; edgeSets[0].id = 1200; edgeSets[0].num_entry = 6; edgeSets[0].num_distribution_factor = 6; edgeSets[0].entry_list = eset_edges; edgeSets[0].extra_list = eset_orient; edgeSets[0].distribution_factor_list = eset_df; faceSets[0].type = EX_FACE_SET; faceSets[0].id = 1400; faceSets[0].num_entry = 2; faceSets[0].num_distribution_factor = 0; faceSets[0].entry_list = fset_faces; faceSets[0].extra_list = fset_orient; faceSets[0].distribution_factor_list = NULL; sideSets[0].type = EX_SIDE_SET; sideSets[0].id = 1400; sideSets[0].num_entry = 5; sideSets[0].num_distribution_factor = 0; sideSets[0].entry_list = sset_elems; sideSets[0].extra_list = sset_sides; sideSets[0].distribution_factor_list = NULL; elemSets[0].type = EX_ELEM_SET; elemSets[0].id = 1800; elemSets[0].num_entry = 1; elemSets[0].num_distribution_factor = 0; elemSets[0].entry_list = &elset_elems[0]; elemSets[0].extra_list = NULL; elemSets[0].distribution_factor_list = NULL; elemSets[1].type = EX_ELEM_SET; elemSets[1].id = 1900; elemSets[1].num_entry = 1; elemSets[1].num_distribution_factor = 0; elemSets[1].entry_list = &elset_elems[1]; elemSets[1].extra_list = NULL; elemSets[1].distribution_factor_list = NULL; if ( concatSets ) { EXCHECK( ex_put_sets(exoid, 1+2+1+1+1, allSets), "Unable to output concatenated sets.\n" ); } else { EXCHECK( ex_put_sets( exoid, 1, nodeSets), "Unable to write node sets.\n" ); EXCHECK( ex_put_sets( exoid, 1, edgeSets), "Unable to write edge sets.\n" ); EXCHECK( ex_put_sets( exoid, 1, faceSets), "Unable to write face sets.\n" ); EXCHECK( ex_put_sets( exoid, 1, sideSets), "Unable to write side sets.\n" ); EXCHECK( ex_put_sets( exoid, 2, elemSets), "Unable to write element sets.\n" ); } } /* =============== Result variable params ========= */ /* *** NEW API *** */ if ( concatResult ) { EXCHECK( ex_put_all_var_param_ext( exoid, &varParams ), "Unable to write result variable parameter information.\n" ); } else { EXCHECK( ex_put_var_param( exoid, "G", 2 ), "Unable to write global result variable parameters.\n" ); EXCHECK( ex_put_var_param( exoid, "N", 1 ), "Unable to write nodal result variable parameters.\n" ); EXCHECK( ex_put_var_param( exoid, "E", 1 ), "Unable to write element result variable parameters.\n" ); EXCHECK( ex_put_var_param( exoid, "L", 2 ), "Unable to write edge result variable parameters.\n" ); EXCHECK( ex_put_var_param( exoid, "F", 1 ), "Unable to write face result variable parameters.\n" ); EXCHECK( ex_put_var_param( exoid, "A", 1 ), "Unable to write faceset result variable parameters.\n" ); } /* =============== Result variable names ========== */ /* *** NEW API *** */ EXCHECK( ex_put_var_name( exoid, "G", 1, "CALIBER" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "g", 2, "GUNPOWDER" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "N", 1, "RHO" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "l", 1, "GAMMA1" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "L", 2, "GAMMA2" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "f", 1, "PHI" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "E", 1, "EPSTRN" ), "Unable to write variable name.\n" ); EXCHECK( ex_put_var_name( exoid, "A", 1, "PHI0" ), "Unable to write variable name.\n" ); /* =============== Result variable values ========= */ t = 1.; /* *** NEW API *** */ EXCHECK( ex_put_time( exoid, 1, &t ), "Unable to write time value.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_GLOBAL, 1, 0/*N/A*/, 2, vals_glo_var[0] ), "Unable to write global var 1.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_EDGE_BLOCK, 1, 100, 20, vals_edge_var1eb1[0] ), "Unable to write edge block 1 var 1.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_EDGE_BLOCK, 2, 100, 20, vals_edge_var2eb1[0] ), "Unable to write edge block 1 var 2.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_FACE_BLOCK, 1, 500, 2, vals_face_var1fb1[0] ), "Unable to write face block 1 var 1.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_FACE_BLOCK, 1, 700, 8, vals_face_var1fb3[0] ), "Unable to write face block 3 var 1.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_ELEM_BLOCK, 1, 200, 2, vals_elem_var1eb1[0] ), "Unable to write elem block 1 var 1.\n" ); EXCHECK( ex_put_var( exoid, 1, EX_FACE_SET, 1, 1400, 2, vals_fset_var1fs1[0] ), "Unable to write face set 1 var 1.\n" ); t = 2.; EXCHECK( ex_put_time( exoid, 2, &t ), "Unable to write time value.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_GLOBAL, 1, 0/*N/A*/, 2, vals_glo_var[1] ), "Unable to write global var 1.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_EDGE_BLOCK, 1, 100, 20, vals_edge_var1eb1[1] ), "Unable to write edge block 1 var 1.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_EDGE_BLOCK, 2, 100, 20, vals_edge_var2eb1[1] ), "Unable to write edge block 1 var 2.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_FACE_BLOCK, 1, 500, 2, vals_face_var1fb1[1] ), "Unable to write face block 1 var 1.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_FACE_BLOCK, 1, 700, 8, vals_face_var1fb3[1] ), "Unable to write face block 3 var 1.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_ELEM_BLOCK, 1, 200, 2, vals_elem_var1eb1[1] ), "Unable to write elem block 1 var 1.\n" ); EXCHECK( ex_put_var( exoid, 2, EX_FACE_SET, 1, 1400, 2, vals_fset_var1fs1[1] ), "Unable to write face set 1 var 1.\n" ); EXCHECK( ex_put_nodal_var( exoid, 1, 1, 12, vals_nod_var[0] ), "Unable to write nodal var 1.\n" ); EXCHECK( ex_put_nodal_var( exoid, 2, 1, 12, vals_nod_var[1] ), "Unable to write nodal var 1.\n" ); EXCHECK( ex_close( exoid ), "Unable to close database.\n" ); return 0; }