MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 #include "GmshUtil.hpp" 00017 00018 namespace moab 00019 { 00020 00021 // Indexed by position in Gmsh order, containing cooresponding 00022 // position in MOAB order. 00023 const int hex_27_node_order[] = { 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[] = { 0, 1, 2, 3, 4, 5, 6, 7, 9, 8 }; 00029 00030 // Indexed by position in MOAB order, containing cooresponding 00031 // position in Gmsh order. 00032 const int pri_15_node_order[] = { 00033 0, 1, 2, 3, 4, 5, // corners 00034 6, 8, 9, 7, 10, 11, 12, 14, 13 // edges 00035 }; 00036 const int pyr_13_node_order[] = { 00037 0, 1, 2, 3, 4, // corners 00038 5, 8, 9, 6, 10, 7, 11, 12 // edges 00039 }; 00040 00041 // List of GmshElemType structs, indexed by the VTK type number. 00042 const GmshElemType GmshUtil::gmshElemTypes[] = { 00043 { 0, 0, MBMAXTYPE, 0, 0 }, 00044 { "line", 1, MBEDGE, 2, 0 }, 00045 { "triangle", 2, MBTRI, 3, 0 }, 00046 { "quadrangle", 3, MBQUAD, 4, 0 }, 00047 { "tetrahedron", 4, MBTET, 4, 0 }, 00048 { "hexahedron", 5, MBHEX, 8, 0 }, 00049 { "prism", 6, MBPRISM, 6, 0 }, 00050 { "pyramid", 7, MBPYRAMID, 5, 0 }, 00051 { "2nd order line", 8, MBEDGE, 3, 0 }, 00052 { "2nd order triangle", 9, MBTRI, 6, 0 }, 00053 { "2nd order quadrangle", 10, MBQUAD, 9, 0 }, 00054 { "2nd order tetrahedron", 11, MBTET, 10, tet_10_node_order }, 00055 { "2nd order hexahedron", 12, MBHEX, 27, hex_27_node_order }, 00056 { "2nd order prism", 13, MBMAXTYPE, 0, 0 }, // prism w/ mid-face nodes on quads but not tris 00057 { "2nd order pyramid", 14, MBMAXTYPE, 0, 0 }, // pyramid w/ mid-face nodes on quad but not tris 00058 { "point", 15, MBVERTEX, 1, 0 }, // point element (0-rad sphere element?) // will be skipped 00059 { "2nd order quadrangle", 16, MBQUAD, 8, 0 }, 00060 { "2nd order hexahedron", 17, MBHEX, 20, hex_27_node_order }, 00061 { "2nd order prism", 18, MBPRISM, 15, pri_15_node_order }, 00062 { "2nd order pyramid", 19, MBPYRAMID, 13, pyr_13_node_order }, 00063 { "3rd order triangle", 20, MBMAXTYPE, 0, 0 }, // triangle w/ 2 nodes per edge 00064 { "3rd order triangle", 21, MBMAXTYPE, 0, 0 }, // " " " " " " and mid-face node 00065 { "4th order triangle", 22, MBMAXTYPE, 0, 0 }, // triangle w/ 3 nodes per edge 00066 { "4th order triangle", 23, MBMAXTYPE, 0, 0 }, // " " " " " " and 3 mid-face nodes 00067 { "5th order triangle", 24, MBMAXTYPE, 0, 0 }, // triangle w/ 4 nodes per edge 00068 { "5th order triangle", 25, MBMAXTYPE, 0, 0 }, // " " " " " " and 6 mid-face nodes 00069 { "3rd order edge", 26, MBMAXTYPE, 0, 0 }, // 4-node edge 00070 { "4th order edge", 27, MBMAXTYPE, 0, 0 }, // 5-node edge 00071 { "5th order edge", 28, MBMAXTYPE, 0, 0 }, // 6-node edge 00072 { "3rd order tetrahedron", 29, MBMAXTYPE, 0, 0 }, // tet w/ 2 nodes per edge and 1 per face 00073 { "4th order tetrahedron", 30, MBMAXTYPE, 0, 0 }, // tet w/ 3 nodes per edge, 3 per face, and 1 mid-voluem 00074 { "5th order tetrahedron", 31, MBMAXTYPE, 0, 0 }, // tet w/ 4 nodes per edge, 6 per face, and 4 mid-voluem 00075 { 0, 32, MBMAXTYPE, 0, 0 } }; 00076 00077 const unsigned GmshUtil::numGmshElemType = sizeof( GmshUtil::gmshElemTypes ) / sizeof( GmshUtil::gmshElemTypes[0] ); 00078 00079 // Define an array, indexed by EntityType and number of nodes, 00080 // containing the corresponding Gmsh element type. 00081 #define TWENTYEIGHT_ZEROS \ 00082 { \ 00083 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 \ 00084 } 00085 const int MAX_NODES = 28; 00086 const int mb_to_gmsh_type[][MAX_NODES] = { 00087 // 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 00088 TWENTYEIGHT_ZEROS, // MBVERTEX 00089 { 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 00090 { 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 00091 { 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 00092 TWENTYEIGHT_ZEROS, // MBPOLYGON 00093 { 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 00094 { 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 00095 { 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 00096 TWENTYEIGHT_ZEROS, // MBKNIFE 00097 { 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 00098 TWENTYEIGHT_ZEROS, // MBPOLYHEDRON 00099 TWENTYEIGHT_ZEROS, // MBENTITYSET 00100 TWENTYEIGHT_ZEROS }; // MBMAXTYPE 00101 00102 int GmshUtil::get_gmsh_type( EntityType type, unsigned num_nodes ) 00103 { 00104 if( num_nodes >= (unsigned)MAX_NODES ) return -1; 00105 00106 int idx = mb_to_gmsh_type[type][num_nodes]; 00107 if( !idx ) return -1; 00108 00109 return gmshElemTypes[idx].mb_type == MBMAXTYPE ? -1 : idx; 00110 } 00111 00112 } // namespace moab