Quinoa all test code coverage report
Current view: top level - PDE/CompFlow/Problem - FieldOutput.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 26 30 86.7 %
Date: 2025-12-08 20:34:58 Functions: 6 10 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 36 52.8 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/CompFlow/Problem/FieldOutput.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     Field outputs for single-material equation solver
       9                 :            :   \details   This file defines functions for field quantites to be output to
      10                 :            :     files for compressible single-material equations.
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef CompFlowFieldOutput_h
      14                 :            : #define CompFlowFieldOutput_h
      15                 :            : 
      16                 :            : #include "Fields.hpp"
      17                 :            : #include "EoS/EOS.hpp"
      18                 :            : #include "History.hpp"
      19                 :            : #include "FunctionPrototypes.hpp"
      20                 :            : #include "EoS/GetMatProp.hpp"
      21                 :            : #include "ContainerUtil.hpp"
      22                 :            : #include "Inciter/InputDeck/InputDeck.hpp"
      23                 :            : 
      24                 :            : namespace inciter {
      25                 :            : 
      26                 :            : extern ctr::InputDeck g_inputdeck;
      27                 :            : 
      28                 :            : //! Return a map that associates user-specified strings to functions
      29                 :            : std::map< std::string, tk::GetVarFn > CompFlowOutVarFn();
      30                 :            : 
      31                 :            : //! Return surface field names to be output to file
      32                 :            : std::vector< std::string > CompFlowSurfNames();
      33                 :            : 
      34                 :            : //! Return surface field output going to file
      35                 :            : std::vector< std::vector< tk::real > >
      36                 :            : CompFlowSurfOutput( const std::vector< EOS >& mat_blk,
      37                 :            :                     const std::map< int, std::vector< std::size_t > >& bnd,
      38                 :            :                     const tk::Fields& U );
      39                 :            : 
      40                 :            : //! Return element surface field output (on triangle faces) going to file
      41                 :            : std::vector< std::vector< tk::real > >
      42                 :            : CompFlowElemSurfOutput(
      43                 :            :   const std::vector< EOS >& mat_blk,
      44                 :            :   const std::map< int, std::vector< std::size_t > >& bface,
      45                 :            :   const std::vector< std::size_t >& triinpoel,
      46                 :            :   const tk::Fields& U );
      47                 :            : 
      48                 :            : //! Return time history field names to be output to file
      49                 :            : std::vector< std::string > CompFlowHistNames();
      50                 :            : 
      51                 :            : //! Return time history field output evaluated at time history points
      52                 :            : std::vector< std::vector< tk::real > >
      53                 :            : CompFlowHistOutput( const std::vector< EOS >& mat_blk,
      54                 :            :                     const std::vector< HistData >& h,
      55                 :            :                     const std::vector< std::size_t >& inpoel,
      56                 :            :                     const tk::Fields& U );
      57                 :            : 
      58                 :            : /** @name Functions that compute physics variables from the numerical solution for CompFlow */
      59                 :            : ///@{
      60                 :            : 
      61                 :            : #if defined(__clang__)
      62                 :            :   #pragma clang diagnostic push
      63                 :            :   #pragma clang diagnostic ignored "-Wunused-function"
      64                 :            : #endif
      65                 :            : 
      66                 :            : namespace compflow {
      67                 :            : 
      68                 :            : //! Compute density for output to file
      69                 :            : //! \note Must follow the signature in tk::GetVarFn
      70                 :            : //! \param[in] U Numerical solution
      71                 :            : //! \return Fluid density ready to be output to file
      72                 :            : static tk::GetVarFn::result_type
      73                 :       1619 : densityOutVar( const tk::Fields& U, std::size_t )
      74                 :            : {
      75                 :       1619 :   return U.extract_comp( 0 );
      76                 :            : }
      77                 :            : 
      78                 :            : //! Compute velocity component for output to file
      79                 :            : //! \note Must follow the signature in tk::GetVarFn
      80                 :            : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z
      81                 :            : //! \param[in] U Numerical solution
      82                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
      83                 :            : //! \return Velocity component ready to be output to file
      84                 :            : template< tk::ncomp_t dir >
      85                 :            : tk::GetVarFn::result_type
      86                 :       4797 : velocityOutVar( const tk::Fields& U, std::size_t rdof )
      87                 :            : {
      88                 :            :   using tk::operator/=;
      89 [ +  - ][ +  - ]:       9594 :   auto r = U.extract_comp( 0 ), u = U.extract_comp( (dir+1)*rdof );
      90         [ +  - ]:       4797 :   u /= r;
      91                 :       9594 :   return u;
      92                 :            : }
      93                 :            : 
      94                 :            : //! Compute volumetric total energy (energy per unit volume) for output to file
      95                 :            : //! \note Must follow the signature in tk::GetVarFn
      96                 :            : //! \param[in] U Numerical solution
      97                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
      98                 :            : //! \return Volumetric total energy ready to be output to file
      99                 :            : static tk::GetVarFn::result_type
     100                 :          0 : volumetricTotalEnergyOutVar( const tk::Fields& U, std::size_t rdof )
     101                 :            : {
     102                 :          0 :   return U.extract_comp( 4*rdof );
     103                 :            : }
     104                 :            : 
     105                 :            : //! Compute specific total energy (energy per unit mass) for output to file
     106                 :            : //! \note Must follow the signature in tk::GetVarFn
     107                 :            : //! \param[in] U Numerical solution
     108                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     109                 :            : //! \return Specific total energy ready to be output to file
     110                 :            : static tk::GetVarFn::result_type
     111                 :       1619 : specificTotalEnergyOutVar( const tk::Fields& U, std::size_t rdof )
     112                 :            : {
     113                 :            :   using tk::operator/=;
     114 [ +  - ][ +  - ]:       3238 :   auto r = U.extract_comp( 0 ), e = U.extract_comp( 4*rdof );
     115         [ +  - ]:       1619 :   e /= r;
     116                 :       3238 :   return e;
     117                 :            : }
     118                 :            : 
     119                 :            : //! Compute momentum component for output to file
     120                 :            : //! \note Must follow the signature in tk::GetVarFn
     121                 :            : //! \tparam dir Physical direction, encoded as 0:x, 1:y, 2:z
     122                 :            : //! \param[in] U Numerical solution
     123                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     124                 :            : //! \return Momentum component ready to be output to file
     125                 :            : template< tk::ncomp_t dir >
     126                 :            : tk::GetVarFn::result_type
     127                 :          0 : momentumOutVar( const tk::Fields& U, std::size_t rdof )
     128                 :            : {
     129                 :          0 :   return U.extract_comp( (dir+1)*rdof );
     130                 :            : }
     131                 :            : 
     132                 :            : //! Compute pressure for output to file
     133                 :            : //! \note Must follow the signature in tk::GetVarFn
     134                 :            : //! \param[in] U Numerical solution
     135                 :            : //! \param[in] rdof Number of reconstructed solution DOFs
     136                 :            : //! \return Pressure ready to be output to file
     137                 :            : static tk::GetVarFn::result_type
     138                 :       1619 : pressureOutVar( const tk::Fields& U, std::size_t rdof )
     139                 :            : {
     140                 :            :   using tk::operator/=;
     141         [ +  - ]:       3238 :   auto r = U.extract_comp( 0 ),
     142         [ +  - ]:       3238 :        u = U.extract_comp( 1*rdof ),
     143         [ +  - ]:       3238 :        v = U.extract_comp( 2*rdof ),
     144         [ +  - ]:       3238 :        w = U.extract_comp( 3*rdof ),
     145         [ +  - ]:       3238 :        re = U.extract_comp( 4*rdof );
     146         [ +  - ]:       1619 :   u /= r;
     147         [ +  - ]:       1619 :   v /= r;
     148         [ +  - ]:       1619 :   w /= r;
     149         [ +  - ]:       1619 :   auto p = r;
     150         [ +  + ]:     562324 :   for (std::size_t i=0; i<U.nunk(); ++i) {
     151                 :            :     // \brief This uses the old eos_pressure call for now, because we didn't 
     152                 :            :     // want to change the GetVarFn function signature right now. It's only in
     153                 :            :     // the single material CompFlow class, so it shouldn't need multi-material
     154                 :            :     // EOSs anyway.
     155         [ +  - ]:     560705 :     auto g = getmatprop< tag::gamma >();
     156         [ +  - ]:     560705 :     auto p_c = getmatprop< tag::pstiff >();
     157                 :    1121410 :     p[i] = (re[i] - 0.5 * r[i] * (u[i]*u[i] + v[i]*v[i] + w[i]*w[i]) - p_c)
     158                 :     560705 :                             * (g-1.0) - p_c;
     159                 :            : //    p[i] = m_mat_blk[0]->eos_pressure( sys, r[i], u[i], v[i], w[i], re[i] );
     160                 :            :   }
     161                 :       3238 :   return p;
     162                 :            : }
     163                 :            : 
     164                 :            : } // compflow::
     165                 :            : 
     166                 :            : #if defined(__clang__)
     167                 :            :   #pragma clang diagnostic pop
     168                 :            : #endif
     169                 :            : 
     170                 :            : //@}
     171                 :            : 
     172                 :            : } //inciter::
     173                 :            : 
     174                 :            : #endif // CompFlowFieldOutput_h

Generated by: LCOV version 1.14