00001 /************************************************************************ 00002 File mmh_prism.h - internal information for mesh manipulation module 00003 for prismatic elements 00004 00005 Contains: 00006 - constants 00007 - data types 00008 - global variables (for the whole module) 00009 - function headers 00010 00011 ------------------------------ 00012 History: 00013 02.2002 - Krzysztof Banas, initial version 00014 *************************************************************************/ 00015 00016 #ifndef _mmh_prism_ 00017 #define _mmh_prism_ 00018 00019 00020 /*** CONSTANTS ***/ 00021 00022 #define MMC_MAX_NUM_MESH 10 /* maximal number of meshes */ 00023 00024 /* Other */ 00025 extern const int MMC_SAME_ORIENT; /* indicator for the same orientation */ 00026 extern const int MMC_OPP_ORIENT; /* indicator for the opposite orientation */ 00027 00028 00029 /*** DATA TYPES ***/ 00030 00031 /*** Mesh data structure (for prismatic elements but with provisions 00032 for hexahedral and tetrahedral elements) ***/ 00033 00034 /* structure with mesh parameters */ 00035 typedef struct { 00036 int nrno; /* number of active nodes */ 00037 int nmno; /* maximal index of initiated node */ 00038 int mxno; /* maximal available index of node */ 00039 int pfno; /* pointer to first free node space*/ 00040 int nred; /* number of active edges */ 00041 int nmed; /* maximal index of initiated edge */ 00042 int mxed; /* maximal available index of edge */ 00043 int pfed; /* pointer to first free edge space*/ 00044 int nrfa; /* number of active faces */ 00045 int nmfa; /* maximal index of initiated face */ 00046 int mxfa; /* maximal available index of face */ 00047 int pffa; /* pointer to first free face space */ 00048 int nrel; /* number of active elements */ 00049 int nmel; /* maximal index of initiated element */ 00050 int mxel; /* maximal available index of element */ 00051 int pfel; /* pointer to first free element space */ 00052 int maxgen; /* maximum generation level for elements */ 00053 int maxgendiff; /* maximum difference of generation levels */ 00054 /* for neighboring elements */ 00055 } mmt_meshp; 00056 00057 /* node structure */ 00058 typedef struct { 00059 double x; /* x-coor of the node (or -1e11 for free spaces ) */ 00060 double y; /* y-coor of the node (or next free space ID) */ 00061 double z; /* z-coor of the node */ 00062 } mmt_nodes; 00063 00064 /* edge structure */ 00065 typedef struct { 00066 int type; /* 1 (MMC_EDGE) - active edge */ 00067 /* <0 - inactive edge, number of attempted divisions */ 00068 /* 0 (MMC_FREE) - free space */ 00069 int node[2]; /* for active edges: node's IDs */ 00070 /* for free spaces: node[0] - the next free space */ 00071 /* for inactive edges: son's IDs */ 00072 int* elems; /* temporary table (not saved in dump files) storing */ 00073 /* the list of elements containing the edge */ 00074 } mmt_edges; 00075 00076 /* face structure */ 00077 typedef struct { 00078 int type; /* type and status of the face: */ 00079 /* 1 (MMC_EDGE) - 1D face for 2D elements, */ 00080 /* 2 (MMC_QUAD) - quadrilateral */ 00081 /* 3 (MMC_TRIA) - triangle, */ 00082 /* 0 (MMC_FREE) - free space */ 00083 /* >0 - active, not refined */ 00084 /* <0 - inactive, refined */ 00085 int bc; /* for boundary faces: bc flag for the face (obtained */ 00086 /* from mesh generator and interpreted by the problem */ 00087 /* dependent module) */ 00088 /* for interelement faces: the shift in node numbering */ 00089 /* between the face and its second neighbor (if it has */ 00090 /* different orientation than the face, */ 00091 /* 0 if only possible and for the same orientation) */ 00092 /* WARNING: for quadrilateral faces only shift=1 is currently implemented */ 00093 /* for free spaces: next free space's ID */ 00094 int edge[4]; /* edges' IDs - in proper order */ 00095 /* >0 - edge with the same orientation as face */ 00096 /* <0 - edge with opposite orientation */ 00097 int neig[2]; /* neighboring elements' global IDs */ 00098 /* (first neighbor has the same orientation */ 00099 /* as the face and ordering of its nodes */ 00100 /* defines ordering of nodes on the face) */ 00101 /* >0 - ID of equal size neighbor */ 00102 /* -1 (MMC_BIG_NGB) - indicates big neighbor */ 00103 /* 0 (MMC_BOUNDARY) - boundary (always second neighbor) */ 00104 /* -2 (MMC_SUB_BND) - inter-subdomain boundary */ 00105 int *sons; /* sons */ 00106 } mmt_faces; 00107 00108 /* element structure */ 00109 typedef struct { 00110 int type; /* 7 (MMC_TETRA) - tetrahedron */ 00111 /* 5 (MMC_PRISM) - prism */ 00112 /* 6 (MMC_BRICK) - brick */ 00113 /* 0 (MMC_FREE) - free space (face and sons not allocated) */ 00114 /* >0 - active, not refined */ 00115 /* <0 - inactive, refined */ 00116 int mate; /* material ID */ 00117 /* for free space: ID of the next free structure */ 00118 int fath; /* parent's global ID */ 00119 /* 0 (MMC_NO_FATH) - if the element has no parent */ 00120 int refi; /* type of the last refinement */ 00121 /* 0 (MMC_NOT_REF) - sons not allocated */ 00122 /* 1 (MMC_REF_TYP_ISO) - isotropic refinement */ 00123 int *face; /* faces' global IDs (sign=orientation)*/ 00124 int *sons; /* children */ 00125 } mmt_elems; 00126 00127 /* structure with mesh data */ 00128 typedef struct { 00129 int space_dim; /* number of space dimensions */ 00130 int monitor; /* printing flag */ 00131 mmt_meshp parm; /* structure with mesh parameters */ 00132 mmt_nodes *node; /* pointer to array of nodes */ 00133 mmt_edges *edge; /* pointer to array of edges */ 00134 mmt_faces *face; /* pointer to array of faces */ 00135 mmt_elems *elem; /* pointer to array of elements */ 00136 } mmt_mesh; 00137 00138 00139 00140 /*** GLOBAL VARIABLES for the whole module ***/ 00141 00142 extern int mmv_nr_meshes; /* the number of meshes in the problem */ 00143 extern int mmv_cur_mesh_id; /* ID of the current mesh */ 00144 extern mmt_mesh mmv_meshes[MMC_MAX_NUM_MESH]; /* array of meshes */ 00145 00146 00147 /*** FUNCTIONS DECLARATIONS - headers for internal functions ***/ 00148 00149 /* in file mms_prism_io.c: 00150 mmr_read_mesh - to dump-in mesh data stored by previous runs 00151 mmr_write_mesh - to dump-out mesh data in the standard HP_FEM format 00152 */ 00153 00157 extern int mmr_read_mesh( /* returns: >=0 - success code, <0 - error code */ 00158 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00159 char *Filename /* in: name of the file to read mesh data */ 00160 ); 00161 00165 extern int mmr_write_mesh( /* returns: >=0 - success code, <0 - error code */ 00166 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00167 char *Filename /* in: name of the file to write mesh data */ 00168 ); 00169 00170 /* in file mms_prism_io.c: 00171 mmr_import_mesh_grad - to read mesh data from input file created by 00172 "gradmesh" mesh generator (jkucwaj@zms.pk.edu.pl) 00173 and generate structured 3D mesh of prismatic elements 00174 */ 00175 00180 int mmr_import_mesh_grad( /* returns: >=0 - success code, <0 - error code */ 00181 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00182 char *Filename /* in: name of the file to read mesh data */ 00183 ); 00184 00185 /* in file mms_prism_datstr.c: 00186 mmr_select_mesh - to select the proper mesh 00187 mmr_get_mesh_i_params - to return mesh parameters 00188 */ 00189 00190 00194 extern mmt_mesh* mmr_select_mesh( /* returns pointer to the chosen mesh */ 00195 int Mesh_id /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00196 ); 00197 00201 int mmr_get_mesh_i_params( /* returns: >=0 - integer mesh parameter, 00202 <0 - error code */ 00203 mmt_mesh* Mesh, /* in: pointer to the mesh data structure */ 00204 int Num /* in: parameter number in control structure */ 00205 ); 00206 00207 /* in file mms_prism_util.c: 00208 mmr_create_edge_elems - to create for each edge a list of elements 00209 to which it belongs 00210 mmr_delete_edge_elems - to delete for each edge a list of elements 00211 to which it belongs 00212 00213 */ 00214 00219 int mmr_create_edge_elems( /* returns: 1-success, <=0-failure */ 00220 int Mesh_id, /* in: ID of the mesh to be used or 0 for the current mesh */ 00221 int Max_edge_id /* in: the range of edge IDs to consider or 0 for default */ 00222 ); 00223 00228 int mmr_delete_edge_elems( /* returns: 1-success, <=0-failure */ 00229 int Mesh_id, /* in: ID of the mesh to be used or 0 for the current mesh */ 00230 int Max_edge_id /* in: the range of edge IDs to consider or 0 for default */ 00231 ); 00232 00233 00234 /* in file mms_prism_ref.c: 00235 mmr_divide_el8_p - to break a prismatic element into 8 sons 00236 mmr_clust_el8_p - to cluster back a family of eight prisms 00237 */ 00238 00239 extern int mmr_divide_el8_p( /* returns: >=0 - success code, <0 - error code */ 00240 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00241 int El /* in: element ID */ 00242 ); 00243 00244 extern int mmr_clust_el8_p( /* returns: >=0 - success code, <0 - error code */ 00245 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00246 int El /* in: element ID */ 00247 ); 00248 00249 /* in file mms_prism_util.c: 00250 mmr_clust_fa4_t - to cluster back a family of 4 triangular faces 00251 mmr_clust_fa4_q - to cluster back a family of 4 quadrilateral faces 00252 mmr_divide_face4_t - to break a triangular face into 4 sons 00253 mmr_divide_face4_q - to divide a quadrilateral face into 4 sons 00254 */ 00255 00256 extern int mmr_divide_face4_t( /* returns: >=0 - success code, <0 - error code */ 00257 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00258 int Fa, /* in: face to be divided */ 00259 int* Face_sons, /* out: face's sons */ 00260 int* Sons_edges, /* out: created new edges */ 00261 int* New_nodes /* out: created new nodes */ 00262 ); 00263 00264 extern int mmr_divide_face4_q(/* returns: >=0 - success code, <0 - error code */ 00265 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00266 int Fa, /* in: face to be divided */ 00267 int* Face_sons, /* out: sons */ 00268 int* Sons_edges, /* out: created new edges */ 00269 int* New_nodes /* out: created new nodes */ 00270 ); 00271 00272 extern int mmr_clust_fa4_t( /* returns: >=0 - success code, <0 - error code */ 00273 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00274 int Face, /* in: face ID */ 00275 int* Face_sons /* in (optional): face sons' IDs */ 00276 ); 00277 00278 extern int mmr_clust_fa4_q( /* returns: >=0 - success code, <0 - error code */ 00279 int Mesh_id, /* in: mesh ID or 0 (MMC_CUR_MESH_ID) for the current mesh */ 00280 int Face, /* in: face ID */ 00281 int* Face_sons /* in (optional): face sons' IDs */ 00282 ); 00283 00284 00285 /* in file mms_util.c: 00286 mmr_chk_list - list manipulation 00287 mmr_ivector - to allocate space for vectors 00288 mmr_vec3_prod - to compute vector product of 3D vectors 00289 mmr_vec3_mxpr - to compute mixed vector product of 3D vectors 00290 mmr_vec3_length - to compute length of a 3D vector 00291 */ 00292 00297 extern int mmr_chk_list( /* returns: */ 00298 /* >0 - position on the list */ 00299 /* 0 - not found on the list */ 00300 int Num, /* number to be checked */ 00301 int* List, /* list of numbers */ 00302 int Ll /* length of the list */ 00303 ); 00304 00309 int *mmr_ivector(/* returns: pointer to array of integers */ 00310 int ncom, /* in: number of components */ 00311 char error_text[] /* in: text to print in case of error */ 00312 ); 00313 00317 extern void mmr_vec3_prod( 00318 double* vec_a, /* in: vector a */ 00319 double* vec_b, /* in: vector b */ 00320 double* vec_c /* out: vector product axb */ 00321 ); 00322 00326 extern double mmr_vec3_mxpr( /* returns: mixed product [a,b,c] */ 00327 double* vec_a, /* in: vector a */ 00328 double* vec_b, /* in: vector b */ 00329 double* vec_c /* in: vector c */ 00330 ); 00331 00335 extern double mmr_vec3_length( /* returns: vector length */ 00336 double* vec /* in: vector */ 00337 ); 00338 00339 #endif