Quinoa all test code coverage report
Current view: top level - IO - GmshMeshReader.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 4 4 100.0 %
Date: 2024-04-29 14:42:33 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/IO/GmshMeshReader.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Gmsh mesh reader class declaration
       9                 :            :   \details   Gmsh mesh reader class declaration. Currently, this class supports
      10                 :            :     line, triangle, tetrahedron, and point Gmsh element types.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef GmshMeshReader_h
      14                 :            : #define GmshMeshReader_h
      15                 :            : 
      16                 :            : #include <iosfwd>
      17                 :            : #include <map>
      18                 :            : 
      19                 :            : #include "Types.hpp"
      20                 :            : #include "Reader.hpp"
      21                 :            : #include "GmshMeshIO.hpp"
      22                 :            : #include "Exception.hpp"
      23                 :            : 
      24                 :            : namespace tk {
      25                 :            : 
      26                 :            : class UnsMesh;
      27                 :            : 
      28                 :            : //! Gmsh mesh reader
      29                 :            : //! \details Mesh reader class facilitating reading a mesh from a file saved by
      30                 :            : //!   the Gmsh mesh generator: http://geuz.org/gmsh.
      31                 :          7 : class GmshMeshReader : public Reader {
      32                 :            : 
      33                 :            :   public:
      34                 :            :     //! Constructor
      35                 :          7 :     explicit GmshMeshReader( const std::string& filename ) :
      36                 :            :       Reader(filename),
      37                 :            :       m_version( 0.0 ),                        // 0.0: uninitialized
      38                 :            :       m_datasize( 0 ),                         //   0: uninitialized
      39         [ +  - ]:          7 :       m_type( GmshFileType::UNDEFINED )        //  -1: uninitialized
      40                 :          7 :       {}
      41                 :            : 
      42                 :            :     //! Read Gmsh mesh
      43                 :            :     void readMesh( UnsMesh& mesh );
      44                 :            : 
      45                 :            :   private:
      46                 :            :     //! Read mandatory "$MeshFormat--$EndMeshFormat" section
      47                 :            :     void readMeshFormat();
      48                 :            : 
      49                 :            :     //! Read "$Nodes--$EndNodes" section
      50                 :            :     void readNodes( UnsMesh& mesh );
      51                 :            : 
      52                 :            :     //! Read "$Elements--$EndElements" section
      53                 :            :     void readElements( UnsMesh& mesh );
      54                 :            : 
      55                 :            :     //! Read "$PhysicalNames--$EndPhysicalNames" section
      56                 :            :     void readPhysicalNames() __attribute__ ((noreturn));
      57                 :            : 
      58                 :            :     //! \brief Mesh ASCII type query
      59                 :            :     //! \return true if member variable m_type indicates an ASCII mesh format
      60                 :            :     bool isASCII() const {
      61                 :            :       Assert( m_type != GmshFileType::UNDEFINED, "Mesh type is undefined");
      62                 :            :       return m_type == GmshFileType::ASCII ? true : false;
      63                 :            :     }
      64                 :            :     //! \brief Mesh binary type query
      65                 :            :     //! \return true if member variable m_type indicates an binary mesh format
      66                 :            :     bool isBinary() const {
      67                 :            :       Assert( m_type != GmshFileType::UNDEFINED, "Mesh type is undefined");
      68                 :            :       return m_type == GmshFileType::BINARY ? true : false;
      69                 :            :     }
      70                 :            : 
      71                 :            :     tk::real m_version;                 //!< Mesh version in mesh file
      72                 :            :     int m_datasize;                     //!< Data size in mesh file
      73                 :            :     GmshFileType m_type;                //!< Mesh file type: 0:ASCII, 1:binary
      74                 :            : 
      75                 :            :     //! \brief Gmsh element types and their corrseponding number of nodes
      76                 :            :     //! \details See Gmsh documentation for element ids as keys
      77                 :            :     const std::map< int, int > m_elemNodes {
      78                 :            :       { GmshElemType::LIN,   2 },  // 2-node line
      79                 :            :       { GmshElemType::TRI,   3 },  // 3-node triangle
      80                 :            :       { GmshElemType::TET,   4 },  // 4-node tetrahedron
      81                 :            :       { GmshElemType::PNT,   1 }   // 1-node point
      82                 :            :     };
      83                 :            : };
      84                 :            : 
      85                 :            : } // tk::
      86                 :            : 
      87                 :            : #endif // GmshMeshReader_h

Generated by: LCOV version 1.14