Quinoa all test code coverage report
Current view: top level - IO - PDFWriter.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 1 1 100.0 %
Date: 2024-04-29 14:42:33 Functions: 0 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/PDFWriter.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     PDF writer class declaration
       9                 :            :   \details   This file declares a PDF writer class that facilitates outputing
      10                 :            :     probability density functions (PDFs) into files in various formats using
      11                 :            :     various configurations.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef PDFWriter_h
      15                 :            : #define PDFWriter_h
      16                 :            : 
      17                 :            : #include <string>
      18                 :            : #include <iostream>
      19                 :            : 
      20                 :            : #include "Macro.hpp"
      21                 :            : #include "Writer.hpp"
      22                 :            : #include "UniPDF.hpp"
      23                 :            : #include "BiPDF.hpp"
      24                 :            : #include "TriPDF.hpp"
      25                 :            : #include "StatCtr.hpp"
      26                 :            : #include "Options/PDFCentering.hpp"
      27                 :            : #include "Options/TxtFloatFormat.hpp"
      28                 :            : 
      29                 :            : namespace tk {
      30                 :            : 
      31                 :            : //! PDFWriter : Writer
      32         [ -  + ]:        195 : class PDFWriter : public tk::Writer {
      33                 :            : 
      34                 :            :   public:
      35                 :            :     //! Constructor
      36                 :            :     explicit PDFWriter(
      37                 :            :       const std::string& filename,
      38                 :            :       tk::ctr::TxtFloatFormatType format = tk::ctr::TxtFloatFormatType::DEFAULT,
      39                 :            :       std::streamsize precision = std::cout.precision() );
      40                 :            : 
      41                 :            :     //! Write univariate PDF to text file
      42                 :            :     void writeTxt( const UniPDF& pdf, const tk::ctr::PDFInfo& info ) const;
      43                 :            : 
      44                 :            :     //! Write bivariate PDF to text file
      45                 :            :     void writeTxt( const BiPDF& pdf, const tk::ctr::PDFInfo& info ) const;
      46                 :            : 
      47                 :            :     //! Write trivariate PDF to text file
      48                 :            :     void writeTxt( const TriPDF& pdf, const tk::ctr::PDFInfo& info ) const;
      49                 :            : 
      50                 :            :     //! Write bivariate PDF to gmsh (text) file format
      51                 :            :     void writeGmshTxt( const BiPDF& pdf, const tk::ctr::PDFInfo& info,
      52                 :            :                        ctr::PDFCenteringType centering ) const;
      53                 :            : 
      54                 :            :     //! Write trivariate PDF to gmsh (text) file format
      55                 :            :     void writeGmshTxt( const TriPDF& pdf, const tk::ctr::PDFInfo& info,
      56                 :            :                        ctr::PDFCenteringType centering ) const;
      57                 :            : 
      58                 :            :     //! Write bivariate PDF to gmsh (binary) file format
      59                 :            :     void writeGmshBin( const BiPDF& pdf, const tk::ctr::PDFInfo& info,
      60                 :            :                        ctr::PDFCenteringType centering ) const;
      61                 :            : 
      62                 :            :     //! Write trivariate PDF to gmsh (binary) file format
      63                 :            :     void writeGmshBin( const TriPDF& pdf, const tk::ctr::PDFInfo& info,
      64                 :            :                        ctr::PDFCenteringType centering ) const;
      65                 :            : 
      66                 :            :     //! Write bivariate PDF to Exodus II file format
      67                 :            :     void writeExodusII( const BiPDF& pdf, const tk::ctr::PDFInfo& info,
      68                 :            :                         ctr::PDFCenteringType centering ) const;
      69                 :            : 
      70                 :            :     //! Write trivariate PDF to Exodus II file format
      71                 :            :     void writeExodusII( const TriPDF& pdf, const tk::ctr::PDFInfo& info,
      72                 :            :                         ctr::PDFCenteringType centering ) const;
      73                 :            : 
      74                 :            :   private:
      75                 :            :     //! Assert the number of sample space dimensions given
      76                 :            :     template< std::size_t size, class Container >
      77                 :            :     void assertSampleSpaceDimensions( [[maybe_unused]] const Container& c )
      78                 :            :     const {
      79                 :            :       Assert( c.size() == size,
      80                 :            :               "Number of sample space variables must equal " +
      81                 :            :               std::to_string( size ) + " in PDF writer." );
      82                 :            :     }
      83                 :            : 
      84                 :            :     //! Assert the number of sample space extents given
      85                 :            :     template< std::size_t size, class Container >
      86                 :            :     void assertSampleSpaceExtents( const Container& c ) const {
      87                 :            :       if (!c.empty())
      88                 :            :         Assert( c.size() == size*2,
      89                 :            :                 "PDF user-specified sample space extents must be defined by " +
      90                 :            :                 std::to_string( size*2 ) +" real numbers: minx, maxx, ..." );
      91                 :            :     }
      92                 :            : 
      93                 :            :     // Create Exodus II file
      94                 :            :     int createExFile() const;
      95                 :            : 
      96                 :            :     // Write Exodus II file header
      97                 :            :     void writeExHdr( int outFileId, int nnode, int nelem ) const;
      98                 :            : 
      99                 :            :     // Output probability density function as Exodus II results field
     100                 :            :     void writeExVar( int exoFile,
     101                 :            :                      ctr::PDFCenteringType centering,
     102                 :            :                      const std::vector< tk::real >& probability ) const;
     103                 :            : 
     104                 :            :     //! Query extents and other metadata of univariate PDF sample space
     105                 :            :     void extents( const UniPDF& pdf,
     106                 :            :                   const std::vector< tk::real >& uext,
     107                 :            :                   std::size_t& nbi,
     108                 :            :                   tk::real& min,
     109                 :            :                   tk::real& max,
     110                 :            :                   tk::real& binsize,
     111                 :            :                   std::array< long, 2*UniPDF::dim >& ext,
     112                 :            :                   std::vector< tk::real >& outpdf ) const;
     113                 :            : 
     114                 :            :     //! Query extents and other metadata of bivariate PDF sample space
     115                 :            :     void extents( const BiPDF& pdf,
     116                 :            :                   const std::vector< tk::real >& uext,
     117                 :            :                   std::size_t& nbix,
     118                 :            :                   std::size_t& nbiy,
     119                 :            :                   tk::real& xmin,
     120                 :            :                   tk::real& xmax,
     121                 :            :                   tk::real& ymin,
     122                 :            :                   tk::real& ymax,
     123                 :            :                   std::array< tk::real, BiPDF::dim >& binsize,
     124                 :            :                   std::array< long, 2*BiPDF::dim >& ext,
     125                 :            :                   std::vector< tk::real >& outpdf,
     126                 :            :                   ctr::PDFCenteringType centering ) const;
     127                 :            : 
     128                 :            :     //! Query extents and other metadata of trivariate PDF sample space
     129                 :            :     void extents( const TriPDF& pdf,
     130                 :            :                   const std::vector< tk::real >& uext,
     131                 :            :                   std::size_t& nbix,
     132                 :            :                   std::size_t& nbiy,
     133                 :            :                   std::size_t& nbiz,
     134                 :            :                   tk::real& xmin,
     135                 :            :                   tk::real& xmax,
     136                 :            :                   tk::real& ymin,
     137                 :            :                   tk::real& ymax,
     138                 :            :                   tk::real& zmin,
     139                 :            :                   tk::real& zmax,
     140                 :            :                   std::array< tk::real, TriPDF::dim >& binsize,
     141                 :            :                   std::array< long, 2*TriPDF::dim >& ext,
     142                 :            :                   std::vector< tk::real >& outpdf,
     143                 :            :                   ctr::PDFCenteringType centering ) const;
     144                 :            : };
     145                 :            : 
     146                 :            : } // tk::
     147                 :            : 
     148                 :            : #endif // PDFWriter_h

Generated by: LCOV version 1.14