/* * Copyright (c) 2005 Sandia Corporation. Under the terms of Contract * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement * retains certain rights in this software. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * * Neither the name of Sandia Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /***************************************************************************** * * exgcssc - ex_get_concat_side_set_node_count * * entry conditions - * input parameters: * int exoid exodus file id * * exit conditions - * int *side_set_node_cnt_list returned array of number of nodes for * side or face for all sidesets * revision history - * *****************************************************************************/ #include #include #include #include #include "exodusII.h" #include "exodusII_int.h" /*! \cond INTERNAL */ void *safe_free(void *array) { if (array != 0) free(array); return 0; } /* Generic error message for element type/node count mapping...*/ #define EL_NODE_COUNT_ERROR sprintf(errmsg, \ "Error: An element of type '%s' with %d nodes is not valid.",\ elem_blk_parms[i].elem_type,\ elem_blk_parms[i].num_nodes_per_elem);\ ex_err("ex_get_side_set_node_count",errmsg,EX_MSG);\ return(EX_FATAL);\ /* \endcond */ /*! \undoc */ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list) { size_t m; int ii, i, j, iss, ioff; int side_set_id; int num_side_sets, num_elem_blks, num_df, ndim; int tot_num_elem = 0, tot_num_ss_elem = 0, side, elem; int *elem_blk_ids = NULL; int *side_set_ids = NULL; int *ss_elem_ndx = NULL; int *side_set_elem_list = NULL; int *side_set_side_list = NULL; int elem_ctr; int num_elem_in_blk, num_nodes_per_elem, num_attr; float fdum; char *cdum, elem_type[MAX_STR_LENGTH+1]; struct elem_blk_parm *elem_blk_parms; char errmsg[MAX_ERR_LENGTH]; exerrval = 0; /* clear error code */ cdum = 0; /* initialize even though it is not used */ /* first check if any side sets are specified */ /* inquire how many side sets have been stored */ if ((ex_inquire(exoid, EX_INQ_SIDE_SETS, &num_side_sets, &fdum, cdum)) == -1) { sprintf(errmsg, "Error: failed to get number of side sets in file id %d",exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,exerrval); return(EX_FATAL); } if (num_side_sets == 0) { sprintf(errmsg, "Warning: no side sets defined in file id %d",exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,EX_WARN); return(EX_WARN); } if ((ex_inquire(exoid, EX_INQ_ELEM_BLK, &num_elem_blks, &fdum, cdum)) == -1) { sprintf(errmsg, "Error: failed to get number of element blocks in file id %d",exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,exerrval); return(EX_FATAL); } if ((ex_inquire(exoid, EX_INQ_ELEM, &tot_num_elem, &fdum, cdum)) == -1) { sprintf(errmsg, "Error: failed to get total number of elements in file id %d",exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,exerrval); return(EX_FATAL); } /* get the dimensionality of the coordinates; this is necessary to distinguish between 2d TRIs and 3d TRIs */ if ((ex_inquire(exoid, EX_INQ_DIM, &ndim, &fdum, cdum)) == -1) { sprintf(errmsg, "Error: failed to get dimensionality in file id %d",exoid); ex_err("ex_cvt_nodes_to_sides",errmsg,exerrval); return(EX_FATAL); } /* Allocate space for the element block ids */ if (!(elem_blk_ids=malloc(num_elem_blks*sizeof(int)))) { exerrval = EX_MEMFAIL; sprintf(errmsg, "Error: failed to allocate space for element block ids for file id %d", exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,exerrval); goto error_ret; } if (ex_get_ids(exoid, EX_ELEM_BLOCK, elem_blk_ids) == -1) { sprintf(errmsg, "Error: failed to get element block ids in file id %d", exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,EX_MSG); return(EX_FATAL); } /* Allocate space for the element block params */ if (!(elem_blk_parms=malloc(num_elem_blks*sizeof(struct elem_blk_parm)))) { exerrval = EX_MEMFAIL; sprintf(errmsg, "Error: failed to allocate space for element block params for file id %d", exoid); ex_err("ex_get_concat_side_set_node_count",errmsg,exerrval); goto error_ret; } elem_ctr = 0; for (i=0; i