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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// *****************************************************************************
/*!
  \file      src/IO/GmshMeshWriter.hpp
  \copyright 2012-2015 J. Bakosi,
             2016-2018 Los Alamos National Security, LLC.,
             2019-2021 Triad National Security, LLC.,
             2022-2025 J. Bakosi
             All rights reserved. See the LICENSE file for details.
  \brief     Gmsh mesh writer class declaration
  \details   Gmsh mesh writer class declaration. Currently, this class supports
    line, triangle, tetrahedron, and point Gmsh element types.
*/
// *****************************************************************************
#ifndef GmshMeshWriter_h
#define GmshMeshWriter_h

#include <iosfwd><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <cstddef><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "Types.hpp"
#include "Writer.hpp"
#include "GmshMeshIO.hpp"

namespace tk {

class UnsMesh;

//! Gmsh mesh writer
//! \details Mesh writer class facilitating writing a mesh to a file readable by
//!   the Gmsh mesh generator: http://geuz.org/gmsh.
class GmshMeshWriter : public Writer {

  public:
    //! Constructor
    explicit GmshMeshWriter( const std::string& filename,
                             GmshFileType type = GmshFileType::BINARY,
                             tk::real version = 2.2,
                             int datasize = sizeof(double) );

    //! Write Gmsh mesh to file
    void writeMesh( const UnsMesh& mesh );

  private:
    //! Write "$Nodes--$EndNodes" section
    void writeNodes( const UnsMesh& mesh );

    //! Write "$Elements--$EndElements" section
    void writeElements( const UnsMesh& mesh );

    //! Write "$PhysicalNames--$EndPhysicalNames" section
    void writePhysicalNames();

    //! \brief Mesh ASCII type query
    //! \return true if member variable m_type indicates an ASCII mesh format
    bool isASCII() const {
      return m_type == GmshFileType::ASCII ? true : false;
    }
    //! \brief Mesh binary type query
    //! \return true if member variable m_type indicates an binary mesh format
    bool isBinary() const {
      return m_type == GmshFileType::BINARY ? true : false;
    }

    //! Write element block: element ids and connectivity (node list)
    void writeElemBlock( std::size_t nnpe,
                         GmshElemType type,
                         const std::vector< std::size_t >& inpoel );

    GmshFileType m_type;                //!< Mesh file type: 0:ASCII, 1:binary
};

} // tk::

#endif // GmshMeshWriter_h