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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// *****************************************************************************
/*!
  \file      src/IO/PDFWriter.hpp
  \copyright 2012-2015 J. Bakosi,
             2016-2018 Los Alamos National Security, LLC.,
             2019-2021 Triad National Security, LLC.
             All rights reserved. See the LICENSE file for details.
  \brief     PDF writer class declaration
  \details   This file declares a PDF writer class that facilitates outputing
    probability density functions (PDFs) into files in various formats using
    various configurations.
*/
// *****************************************************************************
#ifndef PDFWriter_h
#define PDFWriter_h

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

#include "Macro.hpp"
#include "Writer.hpp"
#include "UniPDF.hpp"<--- Include file: "UniPDF.hpp" not found.
#include "BiPDF.hpp"<--- Include file: "BiPDF.hpp" not found.
#include "TriPDF.hpp"<--- Include file: "TriPDF.hpp" not found.
#include "StatCtr.hpp"
#include "Options/PDFCentering.hpp"
#include "Options/TxtFloatFormat.hpp"

namespace tk {

//! PDFWriter : Writer
class PDFWriter : public tk::Writer {

  public:
    //! Constructor
    explicit PDFWriter(
      const std::string& filename,
      tk::ctr::TxtFloatFormatType format = tk::ctr::TxtFloatFormatType::DEFAULT,
      std::streamsize precision = std::cout.precision() );

    //! Write univariate PDF to text file
    void writeTxt( const UniPDF& pdf, const tk::ctr::PDFInfo& info ) const;

    //! Write bivariate PDF to text file
    void writeTxt( const BiPDF& pdf, const tk::ctr::PDFInfo& info ) const;

    //! Write trivariate PDF to text file
    void writeTxt( const TriPDF& pdf, const tk::ctr::PDFInfo& info ) const;

    //! Write bivariate PDF to gmsh (text) file format
    void writeGmshTxt( const BiPDF& pdf, const tk::ctr::PDFInfo& info,
                       ctr::PDFCenteringType centering ) const;

    //! Write trivariate PDF to gmsh (text) file format
    void writeGmshTxt( const TriPDF& pdf, const tk::ctr::PDFInfo& info,
                       ctr::PDFCenteringType centering ) const;

    //! Write bivariate PDF to gmsh (binary) file format
    void writeGmshBin( const BiPDF& pdf, const tk::ctr::PDFInfo& info,
                       ctr::PDFCenteringType centering ) const;

    //! Write trivariate PDF to gmsh (binary) file format
    void writeGmshBin( const TriPDF& pdf, const tk::ctr::PDFInfo& info,
                       ctr::PDFCenteringType centering ) const;

    //! Write bivariate PDF to Exodus II file format
    void writeExodusII( const BiPDF& pdf, const tk::ctr::PDFInfo& info,
                        ctr::PDFCenteringType centering ) const;

    //! Write trivariate PDF to Exodus II file format
    void writeExodusII( const TriPDF& pdf, const tk::ctr::PDFInfo& info,
                        ctr::PDFCenteringType centering ) const;

  private:
    //! Assert the number of sample space dimensions given
    template< std::size_t size, class Container >
    void assertSampleSpaceDimensions( [[maybe_unused]] const Container& c )
    const {
      Assert( c.size() == size,
              "Number of sample space variables must equal " +
              std::to_string( size ) + " in PDF writer." );
    }

    //! Assert the number of sample space extents given
    template< std::size_t size, class Container >
    void assertSampleSpaceExtents( const Container& c ) const {
      if (!c.empty())
        Assert( c.size() == size*2,
                "PDF user-specified sample space extents must be defined by " +
                std::to_string( size*2 ) +" real numbers: minx, maxx, ..." );
    }

    // Create Exodus II file
    int createExFile() const;

    // Write Exodus II file header
    void writeExHdr( int outFileId, int nnode, int nelem ) const;

    // Output probability density function as Exodus II results field
    void writeExVar( int exoFile,
                     ctr::PDFCenteringType centering,
                     const std::vector< tk::real >& probability ) const;

    //! Query extents and other metadata of univariate PDF sample space
    void extents( const UniPDF& pdf,
                  const std::vector< tk::real >& uext,
                  std::size_t& nbi,
                  tk::real& min,
                  tk::real& max,
                  tk::real& binsize,
                  std::array< long, 2*UniPDF::dim >& ext,
                  std::vector< tk::real >& outpdf ) const;

    //! Query extents and other metadata of bivariate PDF sample space
    void extents( const BiPDF& pdf,
                  const std::vector< tk::real >& uext,
                  std::size_t& nbix,
                  std::size_t& nbiy,
                  tk::real& xmin,
                  tk::real& xmax,
                  tk::real& ymin,
                  tk::real& ymax,
                  std::array< tk::real, BiPDF::dim >& binsize,
                  std::array< long, 2*BiPDF::dim >& ext,
                  std::vector< tk::real >& outpdf,
                  ctr::PDFCenteringType centering ) const;

    //! Query extents and other metadata of trivariate PDF sample space
    void extents( const TriPDF& pdf,
                  const std::vector< tk::real >& uext,
                  std::size_t& nbix,
                  std::size_t& nbiy,
                  std::size_t& nbiz,
                  tk::real& xmin,
                  tk::real& xmax,
                  tk::real& ymin,
                  tk::real& ymax,
                  tk::real& zmin,
                  tk::real& zmax,
                  std::array< tk::real, TriPDF::dim >& binsize,
                  std::array< long, 2*TriPDF::dim >& ext,
                  std::vector< tk::real >& outpdf,
                  ctr::PDFCenteringType centering ) const;
};

} // tk::

#endif // PDFWriter_h