LCOV - code coverage report
Current view: top level - src/io - GmshUtil.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 0 5 0.0 %
Date: 2020-12-16 07:07:30 Functions: 0 1 0.0 %
Branches: 0 6 0.0 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
       3                 :            :  * storing and accessing finite element mesh data.
       4                 :            :  *
       5                 :            :  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
       6                 :            :  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
       7                 :            :  * retains certain rights in this software.
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "GmshUtil.hpp"
      17                 :            : 
      18                 :            : namespace moab
      19                 :            : {
      20                 :            : 
      21                 :            : // Indexed by position in Gmsh order, containing cooresponding
      22                 :            : // position in MOAB order.
      23                 :            : const int hex_27_node_order[] = { 0,  1,  2,  3,  4,  5,  6,  7,                   // corners
      24                 :            :                                   8,  11, 12, 9,  13, 10, 14, 15, 16, 19, 17, 18,  // edges
      25                 :            :                                   24, 20, 23, 21, 22, 25,                          // faces
      26                 :            :                                   26 };                                            // volume
      27                 :            : 
      28                 :            : const int tet_10_node_order[] = { 0, 1, 2, 3, 4, 5, 6, 7, 9, 8 };
      29                 :            : 
      30                 :            : // Indexed by position in MOAB order, containing cooresponding
      31                 :            : // position in Gmsh order.
      32                 :            : const int pri_15_node_order[] = {
      33                 :            :     0, 1, 2, 3, 4,  5,              // corners
      34                 :            :     6, 8, 9, 7, 10, 11, 12, 14, 13  // edges
      35                 :            : };
      36                 :            : const int pyr_13_node_order[] = {
      37                 :            :     0, 1, 2, 3, 4,             // corners
      38                 :            :     5, 8, 9, 6, 10, 7, 11, 12  // edges
      39                 :            : };
      40                 :            : 
      41                 :            : // List of GmshElemType structs, indexed by the VTK type number.
      42                 :            : const GmshElemType GmshUtil::gmshElemTypes[] = {
      43                 :            :     { 0, 0, MBMAXTYPE, 0, 0 },
      44                 :            :     { "line", 1, MBEDGE, 2, 0 },
      45                 :            :     { "triangle", 2, MBTRI, 3, 0 },
      46                 :            :     { "quadrangle", 3, MBQUAD, 4, 0 },
      47                 :            :     { "tetrahedron", 4, MBTET, 4, 0 },
      48                 :            :     { "hexahedron", 5, MBHEX, 8, 0 },
      49                 :            :     { "prism", 6, MBPRISM, 6, 0 },
      50                 :            :     { "pyramid", 7, MBPYRAMID, 5, 0 },
      51                 :            :     { "2nd order line", 8, MBEDGE, 3, 0 },
      52                 :            :     { "2nd order triangle", 9, MBTRI, 6, 0 },
      53                 :            :     { "2nd order quadrangle", 10, MBQUAD, 9, 0 },
      54                 :            :     { "2nd order tetrahedron", 11, MBTET, 10, tet_10_node_order },
      55                 :            :     { "2nd order hexahedron", 12, MBHEX, 27, hex_27_node_order },
      56                 :            :     { "2nd order prism", 13, MBMAXTYPE, 0, 0 },    // prism w/ mid-face nodes on quads but not tris
      57                 :            :     { "2nd order pyramid", 14, MBMAXTYPE, 0, 0 },  // pyramid w/ mid-face nodes on quad but not tris
      58                 :            :     { "point", 15, MBVERTEX, 1, 0 },               // point element (0-rad sphere element?) // will be skipped
      59                 :            :     { "2nd order quadrangle", 16, MBQUAD, 8, 0 },
      60                 :            :     { "2nd order hexahedron", 17, MBHEX, 20, hex_27_node_order },
      61                 :            :     { "2nd order prism", 18, MBPRISM, 15, pri_15_node_order },
      62                 :            :     { "2nd order pyramid", 19, MBPYRAMID, 13, pyr_13_node_order },
      63                 :            :     { "3rd order triangle", 20, MBMAXTYPE, 0, 0 },     // triangle w/ 2 nodes per edge
      64                 :            :     { "3rd order triangle", 21, MBMAXTYPE, 0, 0 },     //   "       " "   "    "   "   and mid-face node
      65                 :            :     { "4th order triangle", 22, MBMAXTYPE, 0, 0 },     // triangle w/ 3 nodes per edge
      66                 :            :     { "4th order triangle", 23, MBMAXTYPE, 0, 0 },     //   "       " "   "    "   "   and 3 mid-face nodes
      67                 :            :     { "5th order triangle", 24, MBMAXTYPE, 0, 0 },     // triangle w/ 4 nodes per edge
      68                 :            :     { "5th order triangle", 25, MBMAXTYPE, 0, 0 },     //   "       " "   "    "   "   and 6 mid-face nodes
      69                 :            :     { "3rd order edge", 26, MBMAXTYPE, 0, 0 },         // 4-node edge
      70                 :            :     { "4th order edge", 27, MBMAXTYPE, 0, 0 },         // 5-node edge
      71                 :            :     { "5th order edge", 28, MBMAXTYPE, 0, 0 },         // 6-node edge
      72                 :            :     { "3rd order tetrahedron", 29, MBMAXTYPE, 0, 0 },  // tet w/ 2 nodes per edge and 1 per face
      73                 :            :     { "4th order tetrahedron", 30, MBMAXTYPE, 0, 0 },  // tet w/ 3 nodes per edge, 3 per face, and 1 mid-voluem
      74                 :            :     { "5th order tetrahedron", 31, MBMAXTYPE, 0, 0 },  // tet w/ 4 nodes per edge, 6 per face, and 4 mid-voluem
      75                 :            :     { 0, 32, MBMAXTYPE, 0, 0 }
      76                 :            : };
      77                 :            : 
      78                 :            : const unsigned GmshUtil::numGmshElemType = sizeof( GmshUtil::gmshElemTypes ) / sizeof( GmshUtil::gmshElemTypes[0] );
      79                 :            : 
      80                 :            : // Define an array, indexed by EntityType and number of nodes,
      81                 :            : // containing the corresponding Gmsh element type.
      82                 :            : #define TWENTYEIGHT_ZEROS                                                                  \
      83                 :            :     {                                                                                      \
      84                 :            :         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 \
      85                 :            :     }
      86                 :            : const int MAX_NODES                    = 28;
      87                 :            : const int mb_to_gmsh_type[][MAX_NODES] = {
      88                 :            :     // 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
      89                 :            :     TWENTYEIGHT_ZEROS,                                                                            // MBVERTEX
      90                 :            :     { 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
      91                 :            :     { 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
      92                 :            :     { 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
      93                 :            :     TWENTYEIGHT_ZEROS,                                                                            // MBPOLYGON
      94                 :            :     { 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
      95                 :            :     { 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
      96                 :            :     { 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
      97                 :            :     TWENTYEIGHT_ZEROS,                                                                            // MBKNIFE
      98                 :            :     { 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
      99                 :            :     TWENTYEIGHT_ZEROS,                                                                            // MBPOLYHEDRON
     100                 :            :     TWENTYEIGHT_ZEROS,                                                                            // MBENTITYSET
     101                 :            :     TWENTYEIGHT_ZEROS
     102                 :            : };  // MBMAXTYPE
     103                 :            : 
     104                 :          0 : int GmshUtil::get_gmsh_type( EntityType type, unsigned num_nodes )
     105                 :            : {
     106         [ #  # ]:          0 :     if( num_nodes >= (unsigned)MAX_NODES ) return -1;
     107                 :            : 
     108                 :          0 :     int idx = mb_to_gmsh_type[type][num_nodes];
     109         [ #  # ]:          0 :     if( !idx ) return -1;
     110                 :            : 
     111         [ #  # ]:          0 :     return gmshElemTypes[idx].mb_type == MBMAXTYPE ? -1 : idx;
     112                 :            : }
     113                 :            : 
     114                 :            : }  // namespace moab

Generated by: LCOV version 1.11