Quinoa all test code coverage report
Current view: top level - Control/Inciter - OutVar.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 26 27 96.3 %
Date: 2025-05-30 09:37:40 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 30 63.3 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Control/Inciter/OutVar.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     Types and associated functions to deal with output variables
       9                 :            :   \details   Types and associated functions to deal with output variables.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef OutVar_h
      13                 :            : #define OutVar_h
      14                 :            : 
      15                 :            : #include "Types.hpp"
      16                 :            : #include "Centering.hpp"
      17                 :            : #include "Options/PDE.hpp"
      18                 :            : 
      19                 :            : namespace inciter {
      20                 :            : namespace ctr {
      21                 :            : 
      22                 :            : //! Output variable
      23                 :            : struct OutVar {
      24                 :            :   using Centering = tk::Centering;
      25                 :            :   
      26                 :            :   Centering centering;  //!< Centering
      27                 :            :   std::string name;     //!< Human readable name
      28                 :            :   std::string alias;    //!< user specified alias to the name
      29                 :            :   tk::ncomp_t field;    //!< Field ID
      30                 :            :   std::string varFnIdx; //!< Material-based physics label + material id
      31                 :            : 
      32                 :            :   //! Constructor: initialize all state data
      33                 :            :   //! \param[in] n Human readable name
      34                 :            :   //! \param[in] f Field ID
      35                 :            :   //! \param[in] c Variable centering
      36                 :            :   //! \param[in] vn Var function name
      37                 :       1554 :   explicit OutVar( Centering c = Centering::NODE,
      38                 :            :                    const std::string& n = {},
      39                 :            :                    const std::string& a = "",
      40                 :            :                    tk::ncomp_t f = 0,
      41                 :       1554 :                    const std::string& vn = "null" ) :
      42 [ +  - ][ +  - ]:       4662 :     centering(c), name(n), alias(a), field(f), varFnIdx(vn) {}
      43                 :            : 
      44                 :            :   /** @name Pack/Unpack: Serialize OutVar object for Charm++ */
      45                 :            :   ///@{
      46                 :            :   //! Pack/Unpack serialize member function
      47                 :            :   //! \param[in,out] p Charm++'s PUP::er serializer object reference
      48                 :       2790 :   void pup( PUP::er& p ) {
      49                 :       2790 :     p | centering;
      50                 :       2790 :     p | name;
      51                 :       2790 :     p | alias;
      52                 :       2790 :     p | field;
      53                 :       2790 :     p | varFnIdx;
      54                 :       2790 :   }
      55                 :            :   //! Pack/Unpack serialize operator|
      56                 :            :   //! \param[in,out] p Charm++'s PUP::er serializer object reference
      57                 :            :   //! \param[in,out] v OutVar object reference
      58         [ +  - ]:       2790 :   friend void operator|( PUP::er& p, OutVar& v ) { v.pup(p); }
      59                 :            :   ///@}
      60                 :            : 
      61                 :            :   //! Query if outvar is a request for an analytic solution
      62                 :            :   //! \return True if outvar is a request for an analytic solution
      63                 :      66948 :   bool analytic() const { return name.find("analytic") != std::string::npos; }
      64                 :            : 
      65                 :            :   //! Query if outvar is a request for a primitive variable
      66                 :            :   //! \param[in] iPDE PDE type
      67                 :            :   //! \return True if outvar should be extracted from primitive variable data
      68                 :            :   //! \details This function returns whether the requested variable is a part
      69                 :            :   //!   of the vector of primitive variables. This changes according to which
      70                 :            :   //!   system of PDEs is configured.
      71                 :      14037 :   bool primitive( const PDEType& iPDE ) const {
      72                 :            :     bool is_prim(false);
      73                 :            : 
      74         [ +  + ]:      14037 :     if (iPDE == PDEType::MULTISPECIES) {
      75         [ -  + ]:       1232 :       if (varFnIdx.find("temperature") != std::string::npos)
      76                 :            :       { is_prim = true; }
      77                 :            :     }
      78                 :            :     else {
      79         [ +  + ]:      23787 :       if (varFnIdx.find("pressure") != std::string::npos ||
      80 [ +  + ][ +  - ]:      18382 :           varFnIdx.find("velocity") != std::string::npos ||
      81                 :            :           varFnIdx.find("stress") != std::string::npos )
      82                 :            :       { is_prim = true; }
      83 [ +  + ][ +  - ]:       7508 :       else if ( name.length() == 2 &&
      84         [ +  - ]:       3862 :         (name.find('u') != std::string::npos ||
      85         [ +  - ]:       3862 :          name.find('U') != std::string::npos ||
      86         [ -  + ]:       3862 :          name.find('p') != std::string::npos ||
      87                 :       1931 :          name.find('P') != std::string::npos) )
      88                 :            :       { is_prim = true; }
      89                 :            :     }
      90                 :            : 
      91                 :      14037 :     return is_prim;
      92                 :            :   }
      93                 :            : };
      94                 :            : 
      95                 :            : //! \brief Pack/Unpack: Namespace-scope serialize OutVar object for Charm++
      96                 :            : //! \param[in,out] p Charm++'s PUP::er serializer object reference
      97                 :            : //! \param[in,out] v OutVar object reference
      98                 :            : inline void pup( PUP::er& p, OutVar& v ) { v.pup(p); }
      99                 :            : 
     100                 :            : #if defined(__clang__)
     101                 :            :   #pragma clang diagnostic push
     102                 :            :   #pragma clang diagnostic ignored "-Wunused-function"
     103                 :            : #endif
     104                 :            : 
     105                 :            : //! Operator << for writing OutVar to output streams
     106                 :            : //! \param[in,out] os Output stream to write to
     107                 :            : //! \param[in] outvar OutVar to write
     108                 :            : //! \return Updated output stream
     109         [ -  + ]:        627 : static std::ostream& operator<< ( std::ostream& os, const OutVar& outvar ) {
     110         [ -  + ]:        627 :   if (outvar.name.empty())
     111                 :          0 :     os << outvar.field+1;
     112                 :            :   else
     113                 :            :     os << outvar.name;
     114                 :        627 :   return os;
     115                 :            : }
     116                 :            : 
     117                 :            : #if defined(__clang__)
     118                 :            :   #pragma clang diagnostic pop
     119                 :            : #endif
     120                 :            : 
     121                 :            : } // ctr::
     122                 :            : } // inciter::
     123                 :            : 
     124                 :            : #endif // OutVar_h

Generated by: LCOV version 1.14