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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// *****************************************************************************
/*!
  \file      src/IO/ExodusIIMeshWriter.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     ExodusII mesh-based data writer
  \details   ExodusII mesh-based data writer class declaration.
*/
// *****************************************************************************
#ifndef ExodusIIMeshWriter_h
#define ExodusIIMeshWriter_h

#include <cstddef><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <iosfwd><--- 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 <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "Types.hpp"
#include "UnsMesh.hpp"<--- Include file: "UnsMesh.hpp" not found.

namespace tk {

class UnsMesh;

//! ExodusII writer constructor modes
enum class ExoWriter { CREATE, OPEN };

//! ExodusII mesh-based data writer
//! \details Mesh writer class facilitating writing a mesh and associated
//!   mesh-based field data to a file in ExodusII format.
//! \see http://sourceforge.net/projects/exodusii
class ExodusIIMeshWriter {

  public:
    //! Constructor: create/open ExodusII file
    explicit ExodusIIMeshWriter( const std::string& filename,
                                 ExoWriter mode,
                                 int cpuwordsize = sizeof(double),
                                 int iowordsize = sizeof(double) );

    //! Destructor
    ~ExodusIIMeshWriter() noexcept;

    //! Write ExodusII mesh file taking a tk::UnsMesh object
    void writeMesh( const UnsMesh& mesh ) const;

    //! Write ExodusII mesh file taking inputs to a tk::UnsMesh object
    //! \tparam nnode 3 or 4, indicating a triangle or tetrahedron mesh
    //! \param[in] inpoel Element connectivity
    //! \param[in] coord Node coordinates
    template< std::size_t nnode >
    void writeMesh( const std::vector< std::size_t >& inpoel,
                    const UnsMesh::Coords& coord ) const
    {
      if (nnode == 4)
        writeMesh( tk::UnsMesh( inpoel, coord ) );
      else if (nnode == 3)
        writeMesh( tk::UnsMesh( coord, inpoel ) );
    }

    //!  Write time stamp to ExodusII file
    void writeTimeStamp( uint64_t it, tk::real time ) const;

    //! Write time values to ExodusII file
    void writeTimeValues( const std::vector< tk::real >& tv ) const;

    //! Write the names of nodal output variables to ExodusII file
    void writeNodeVarNames( const std::vector< std::string >& nv ) const;

    //! Write the names of element output variables to ExodusII file
    void writeElemVarNames( const std::vector< std::string >& ev ) const;

    //! \brief Write multiple node scalar fields to ExodusII file at multiple
    //!   time steps
    void writeNodeScalars(
      const std::vector< std::vector< std::vector< tk::real > > >& var ) const;

    //!  Write node scalar field to ExodusII file
    void writeNodeScalar( uint64_t it,
                          int varid,
                          const std::vector< tk::real >& var ) const;

    //!  Write elem scalar field to ExodusII file
    void writeElemScalar( uint64_t it,
                          int varid,
                          const std::vector< tk::real >& var ) const;

    //! Write element block to ExodusII file
    void writeElemBlock( int& elclass,
                         int64_t nnpe,
                         const std::string& eltype,
                         const std::vector< std::size_t >& inpoel ) const;

  private:
    //! Write ExodusII header
    void writeHeader( const UnsMesh& mesh ) const;

    //! Write nodes coordinates to ExodusII file
    void writeNodes( const UnsMesh& mesh ) const;

    //! Write element conectivity to ExodusII file
    void writeElements( const UnsMesh& mesh ) const;

    //! Write side sets and their face connectivity to ExodusII file
    void writeSidesets( const UnsMesh& mesh ) const;

    //! Write side sets and their node list to ExodusII file
    void writeNodesets( const UnsMesh& mesh ) const;

    const std::string m_filename;          //!< File name
    int m_outFile;                         //!< ExodusII file handle
};

} // tk::

#endif // ExodusIIMeshWriter_h