Xyst test code coverage report
Current view: top level - IO - GmshMeshReader.hpp (source / functions) Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 100.0 % 8 8
Test Date: 2025-08-13 22:18:46 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 93.8 % 16 15

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

Generated by: LCOV version 2.0-1