Quinoa regression test code coverage report
Current view: top level - Control/Inciter - OutVar.hpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 38 40 95.0 %
Date: 2021-11-09 13:40:20 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 43 70 61.4 %

           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 "Keywords.hpp"
      16                 :            : #include "Centering.hpp"
      17                 :            : #include "Fields.hpp"
      18                 :            : #include "FunctionPrototypes.hpp"
      19                 :            : #include "ConfigureOutVar.hpp"
      20                 :            : 
      21                 :            : namespace inciter {
      22                 :            : namespace ctr {
      23                 :            : 
      24                 :            : //! Output variable
      25                 :            : struct OutVar {
      26                 :            :   using ncomp_t = kw::ncomp::info::expect::type;
      27                 :            :   using Centering = tk::Centering;
      28                 :            :   
      29                 :            :   char var;            //!< Variable name
      30                 :            :   ncomp_t field;       //!< Field ID
      31                 :            :   Centering centering; //!< Centering
      32                 :            :   std::string name;    //!< Human readable name (built-in, code knows it)
      33                 :            :   std::string alias;   //!< Alias (only user knows it)
      34                 :            :   std::string matvar;  //!< Material-based physics label + material id
      35                 :            :   tk::GetVarFn getvar; //!< Function to compute variable from numerical solution
      36                 :            : 
      37                 :            :   //! Constructor: initialize all state data
      38                 :            :   //! \param[in] v Variable name
      39                 :            :   //! \param[in] f Field ID
      40                 :            :   //! \param[in] c Variable centering
      41                 :            :   //! \param[in] n Human readable name
      42                 :            :   //! \param[in] a Alias
      43                 :            :   //! \param[in] m Material-based physics label + material id
      44                 :       2131 :   explicit OutVar( char v = 0,
      45                 :            :                    ncomp_t f = 0,
      46                 :            :                    Centering c = Centering::NODE,
      47                 :            :                    const std::string& n = {},
      48                 :            :                    const std::string& a = {},
      49                 :       2131 :                    const std::string& m = {} ) :
      50                 :            :     var(v), field(f), centering(c), name(n), alias(a), matvar(m),
      51 [ +  - ][ +  - ]:       6393 :     getvar(assignGetVars(name)) {}
                 [ +  - ]
      52                 :            : 
      53                 :            :   /** @name Pack/Unpack: Serialize OutVar object for Charm++ */
      54                 :            :   ///@{
      55                 :            :   //! Pack/Unpack serialize member function
      56                 :            :   //! \param[in,out] p Charm++'s PUP::er serializer object reference
      57                 :       2968 :   void pup( PUP::er& p ) {
      58                 :       2968 :     p | var;
      59                 :       2968 :     p | field;
      60                 :       2968 :     p | centering;
      61                 :       2968 :     p | name;
      62                 :       2968 :     p | alias;
      63                 :       2968 :     p | matvar;
      64                 :       2968 :     getvar = assignGetVars(name);
      65                 :       2968 :   }
      66                 :            :   //! Pack/Unpack serialize operator|
      67                 :            :   //! \param[in,out] p Charm++'s PUP::er serializer object reference
      68                 :            :   //! \param[in,out] v OutVar object reference
      69         [ +  - ]:       2968 :   friend void operator|( PUP::er& p, OutVar& v ) { v.pup(p); }
      70                 :            :   ///@}
      71                 :            : 
      72                 :            :   //! \brief Less-than operator for ordering, used by, e.g., std::set::insert
      73                 :            :   //! \param[in] outvar OutVar to compare
      74                 :            :   //! \return Boolean indicating if outvar is less than 'this'
      75                 :       2801 :   bool operator< ( const OutVar& outvar ) const {
      76         [ +  + ]:       2801 :     if (var < outvar.var)
      77                 :            :       return true;
      78 [ +  - ][ +  + ]:       2684 :     else if (var == outvar.var && field < outvar.field)
      79                 :            :       return true;
      80 [ +  - ][ +  + ]:       2559 :     else if (var == outvar.var && field == outvar.field &&
      81         [ +  - ]:       2527 :              centering < outvar.centering)
      82                 :            :       return true;
      83         [ +  + ]:       2559 :     else if (var == outvar.var && field == outvar.field &&
      84 [ +  - ][ +  - ]:       5086 :              centering == outvar.centering && name < outvar.name)
                 [ +  + ]
      85                 :            :       return true;
      86         [ +  + ]:       1408 :     else if (var == outvar.var && field == outvar.field &&
      87 [ +  - ][ +  - ]:       2784 :              centering == outvar.centering && name == outvar.name &&
         [ -  + ][ -  - ]
      88         [ -  - ]:          0 :              alias < outvar.alias)
      89                 :            :       return true;
      90         [ +  + ]:       1408 :     else if (var == outvar.var && field == outvar.field &&
      91 [ +  - ][ -  + ]:       1376 :              centering == outvar.centering && name == outvar.name &&
      92 [ +  - ][ -  - ]:       1408 :              alias == outvar.alias && matvar < outvar.matvar)
                 [ -  - ]
      93                 :          0 :       return true;
      94                 :            :     else
      95                 :            :       return false;
      96                 :            :   }
      97                 :            : 
      98                 :            :   //! Query if outvar is a request for an analytic solution
      99                 :            :   //! \return True if outvar is a request for an analytic solution
     100                 :     114577 :   bool analytic() const { return name.find("analytic") != std::string::npos; }
     101                 :            : 
     102                 :            :   //! Query if outvar is a request for a (multimat) primitive variable
     103                 :            :   //! \return True if outvar should be extracted from primitive variable data
     104                 :            :   //! \see deck::inciter::multimatvars
     105                 :      29404 :   bool primitive() const {
     106         [ +  - ]:      58808 :     return matvar.find('u') != std::string::npos ||
     107         [ +  - ]:      58808 :            matvar.find('U') != std::string::npos ||
     108         [ +  - ]:      58808 :            matvar.find('p') != std::string::npos ||
     109         [ +  + ]:      58808 :            matvar.find('P') != std::string::npos ||
     110 [ +  - ][ +  + ]:      84730 :            name.find("pressure") != std::string::npos ||
     111                 :      29404 :            name.find("velocity") != std::string::npos;
     112                 :            :   }
     113                 :            : };
     114                 :            : 
     115                 :            : //! \brief Pack/Unpack: Namespace-scope serialize OutVar object for Charm++
     116                 :            : //! \param[in,out] p Charm++'s PUP::er serializer object reference
     117                 :            : //! \param[in,out] v OutVar object reference
     118                 :            : inline void pup( PUP::er& p, OutVar& v ) { v.pup(p); }
     119                 :            : 
     120                 :            : #if defined(__clang__)
     121                 :            :   #pragma clang diagnostic push
     122                 :            :   #pragma clang diagnostic ignored "-Wunused-function"
     123                 :            : #endif
     124                 :            : 
     125                 :            : //! Operator << for writing OutVar to output streams
     126                 :            : //! \param[in,out] os Output stream to write to
     127                 :            : //! \param[in] outvar OutVar to write
     128                 :            : //! \return Updated output stream
     129         [ +  + ]:       2818 : static std::ostream& operator<< ( std::ostream& os, const OutVar& outvar ) {
     130         [ +  + ]:       2818 :   if (outvar.name.empty()) {
     131         [ +  + ]:        255 :     if (outvar.matvar.empty())  // depvar
     132                 :        177 :       os << outvar.var << outvar.field+1;
     133                 :            :     else                        // matvar
     134                 :            :       os << outvar.matvar;
     135                 :            :   } else                        // humanvar
     136                 :            :     os << outvar.name;
     137                 :       2818 :   return os;
     138                 :            : }
     139                 :            : 
     140                 :            : #if defined(__clang__)
     141                 :            :   #pragma clang diagnostic pop
     142                 :            : #endif
     143                 :            : 
     144                 :            : } // ctr::
     145                 :            : } // inciter::
     146                 :            : 
     147                 :            : #endif // OutVar_h

Generated by: LCOV version 1.14