moab
|
00001 00016 #include "GmshUtil.hpp" 00017 00018 namespace moab { 00019 00020 // Indexed by position in Gmsh order, containing cooresponding 00021 // position in MOAB order. 00022 const int hex_27_node_order[] = { 00023 0, 1, 2, 3, 4, 5, 6, 7, // corners 00024 8, 11, 12, 9, 13, 10, 14, 15, 16, 19, 17, 18, // edges 00025 24, 20, 23, 21, 22, 25, // faces 00026 26 }; // volume 00027 00028 const int tet_10_node_order[] = { 00029 0, 1, 2, 3, 00030 4, 5, 6, 00031 7, 9, 8 }; 00032 00033 // Indexed by position in MOAB order, containing cooresponding 00034 // position in Gmsh order. 00035 const int pri_15_node_order[] = { 00036 0, 1, 2, 3, 4, 5, // corners 00037 6, 8, 9, 7, 10, 11, 12, 14, 13 // edges 00038 }; 00039 const int pyr_13_node_order[] = { 00040 0, 1, 2, 3, 4, // corners 00041 5, 8, 9, 6, 10, 7, 11, 12 // edges 00042 }; 00043 00044 00045 // List of GmshElemType structs, indexed by the VTK type number. 00046 const GmshElemType GmshUtil::gmshElemTypes[] = { 00047 { 0, 0, MBMAXTYPE, 0, 0 }, 00048 { "line", 1, MBEDGE, 2, 0 }, 00049 { "triangle", 2, MBTRI, 3, 0 }, 00050 { "quadrangle", 3, MBQUAD, 4, 0 }, 00051 { "tetrahedron", 4, MBTET, 4, 0 }, 00052 { "hexahedron", 5, MBHEX, 8, 0 }, 00053 { "prism", 6, MBPRISM, 6, 0 }, 00054 { "pyramid", 7, MBPYRAMID, 5, 0 }, 00055 { "2nd order line", 8, MBEDGE, 3, 0 }, 00056 { "2nd order triangle", 9, MBTRI, 6, 0 }, 00057 { "2nd order quadrangle", 10, MBQUAD, 9, 0 }, 00058 { "2nd order tetrahedron", 11, MBTET, 10, tet_10_node_order }, 00059 { "2nd order hexahedron", 12, MBHEX, 27, hex_27_node_order }, 00060 { "2nd order prism", 13, MBMAXTYPE, 0, 0 }, // prism w/ mid-face nodes on quads but not tris 00061 { "2nd order pyramid", 14, MBMAXTYPE, 0, 0 }, // pyramid w/ mid-face nodes on quad but not tris 00062 { "point", 15, MBMAXTYPE, 0, 0 }, // point element (0-rad sphere element?) 00063 { "2nd order quadrangle", 16, MBQUAD, 8, 0 }, 00064 { "2nd order hexahedron", 17, MBHEX, 20, hex_27_node_order }, 00065 { "2nd order prism", 18, MBPRISM, 15, pri_15_node_order }, 00066 { "2nd order pyramid", 19, MBPYRAMID, 13, pyr_13_node_order }, 00067 { "3rd order triangle", 20, MBMAXTYPE, 0, 0 }, // triangle w/ 2 nodes per edge 00068 { "3rd order triangle", 21, MBMAXTYPE, 0, 0 }, // " " " " " " and mid-face node 00069 { "4th order triangle", 22, MBMAXTYPE, 0, 0 }, // triangle w/ 3 nodes per edge 00070 { "4th order triangle", 23, MBMAXTYPE, 0, 0 }, // " " " " " " and 3 mid-face nodes 00071 { "5th order triangle", 24, MBMAXTYPE, 0, 0 }, // triangle w/ 4 nodes per edge 00072 { "5th order triangle", 25, MBMAXTYPE, 0, 0 }, // " " " " " " and 6 mid-face nodes 00073 { "3rd order edge", 26, MBMAXTYPE, 0, 0 }, // 4-node edge 00074 { "4th order edge", 27, MBMAXTYPE, 0, 0 }, // 5-node edge 00075 { "5th order edge", 28, MBMAXTYPE, 0, 0 }, // 6-node edge 00076 { "3rd order tetrahedron", 29, MBMAXTYPE, 0, 0 }, // tet w/ 2 nodes per edge and 1 per face 00077 { "4th order tetrahedron", 30, MBMAXTYPE, 0, 0 }, // tet w/ 3 nodes per edge, 3 per face, and 1 mid-voluem 00078 { "5th order tetrahedron", 31, MBMAXTYPE, 0, 0 }, // tet w/ 4 nodes per edge, 6 per face, and 4 mid-voluem 00079 { 0, 32, MBMAXTYPE, 0, 0 } 00080 }; 00081 00082 const unsigned GmshUtil::numGmshElemType = sizeof(GmshUtil::gmshElemTypes) / sizeof(GmshUtil::gmshElemTypes[0]); 00083 00084 // Define an array, indexed by EntityType and number of nodes, 00085 // containing the corresponding Gmsh element type. 00086 #define TWENTYEIGHT_ZEROS { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 00087 const int MAX_NODES = 28; 00088 const int mb_to_gmsh_type[][MAX_NODES] = { 00089 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 00090 TWENTYEIGHT_ZEROS, // MBVERTEX 00091 { 0, 0, 1, 8,26,27,28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // MBEDGE 00092 { 0, 0, 0, 2, 0, 0, 9, 0, 0,20,21, 0,22, 0, 0,23, 0, 0, 0, 0, 0,25, 0, 0, 0, 0, 0, 0 }, // MBTRI 00093 { 0, 0, 0, 0, 3, 0, 0, 0,16,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // MBQUAD 00094 TWENTYEIGHT_ZEROS, // MBPOLYGON 00095 { 0, 0, 0, 0, 4, 0, 0, 0, 0, 0,11, 0, 0, 0, 0, 0, 0, 0, 0, 0,29, 0, 0, 0, 0, 0, 0, 0 }, // MBTET 00096 { 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0,19,14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // MBPYRAMID 00097 { 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0,18, 0, 0,13, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // MBWEDGE 00098 TWENTYEIGHT_ZEROS, // MBKNIFE 00099 { 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,17, 0, 0, 0, 0, 0, 0,12 }, // MBHEX 00100 TWENTYEIGHT_ZEROS, // MBPOLYHEDRON 00101 TWENTYEIGHT_ZEROS, // MBENTITYSET 00102 TWENTYEIGHT_ZEROS };// MBMAXTYPE 00103 00104 int GmshUtil::get_gmsh_type( EntityType type, unsigned num_nodes ) 00105 { 00106 if (num_nodes >= (unsigned)MAX_NODES) 00107 return -1; 00108 00109 int idx = mb_to_gmsh_type[type][num_nodes]; 00110 if (!idx) 00111 return -1; 00112 00113 return gmshElemTypes[idx].mb_type == MBMAXTYPE ? -1 : idx; 00114 } 00115 00116 00117 } // namespace moab