Walker test code coverage report
Current view: top level - Control/Walker/Options - CoeffPolicy.hpp (source / functions) Hit Total Coverage
Commit: test_coverage.info Lines: 33 33 100.0 %
Date: 2022-09-21 13:52:12 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 44 124 35.5 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Control/Walker/Options/CoeffPolicy.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     Differential equation coefficients policy options
       9                 :            :   \details   Differential equation coefficients policy options
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef CoeffPolicyOptions_h
      13                 :            : #define CoeffPolicyOptions_h
      14                 :            : 
      15                 :            : #include <brigand/sequences/list.hpp>
      16                 :            : #include <brigand/algorithms/for_each.hpp>
      17                 :            : 
      18                 :            : #include "Toggle.hpp"
      19                 :            : #include "Keywords.hpp"
      20                 :            : #include "PUPUtil.hpp"
      21                 :            : 
      22                 :            : namespace walker {
      23                 :            : namespace ctr {
      24                 :            : 
      25                 :            : //! Differential equation coefficients policy types
      26                 :            : enum class CoeffPolicyType : uint8_t { CONST_COEFF=0
      27                 :            :                                      , DECAY
      28                 :            :                                      , HOMOGENEOUS
      29                 :            :                                      , HOMOGENEOUS_DECAY
      30                 :            :                                      , MONTE_CARLO_HOMOGENEOUS_DECAY
      31                 :            :                                      , HYDROTIMESCALE
      32                 :            :                                      , CONST_SHEAR
      33                 :            :                                      , STATIONARY
      34                 :            :                                      , INSTANTANEOUS_VELOCITY
      35                 :            :                                      };
      36                 :            : 
      37                 :            : //! Pack/Unpack CoeffPolicyType: forward overload to generic enum class packer
      38                 :            : inline void operator|( PUP::er& p, CoeffPolicyType& e ) { PUP::pup( p, e ); }
      39                 :            : 
      40                 :            : //! CoeffPolicy options: outsource searches to base templated on enum type
      41         [ +  + ]:        303 : class CoeffPolicy : public tk::Toggle< CoeffPolicyType > {
      42                 :            : 
      43                 :            :   public:
      44                 :            :     //! Valid expected choices to make them also available at compile-time
      45                 :            :     using keywords = brigand::list< kw::constcoeff
      46                 :            :                                   , kw::decay
      47                 :            :                                   , kw::homogeneous
      48                 :            :                                   , kw::homdecay
      49                 :            :                                   , kw::montecarlo_homdecay
      50                 :            :                                   , kw::hydrotimescale
      51                 :            :                                   , kw::const_shear
      52                 :            :                                   , kw::stationary
      53                 :            :                                   , kw::inst_velocity
      54                 :            :                                   >;
      55                 :            : 
      56                 :            :     //! \brief Options constructor
      57                 :            :     //! \details Simply initialize in-line and pass associations to base, which
      58                 :            :     //!    will handle client interactions
      59                 :        303 :     explicit CoeffPolicy() :
      60                 :            :       tk::Toggle< CoeffPolicyType >(
      61                 :            :         //! Group, i.e., options, name
      62                 :            :         "Coefficients Policy",
      63                 :            :         //! Enums -> names
      64                 :        303 :         { { CoeffPolicyType::CONST_COEFF, kw::constcoeff::name() },
      65 [ -  + ][ -  - ]:        303 :           { CoeffPolicyType::DECAY, kw::decay::name() },
      66 [ -  + ][ -  - ]:        303 :           { CoeffPolicyType::HOMOGENEOUS, kw::homogeneous::name() },
      67 [ -  + ][ -  - ]:        303 :           { CoeffPolicyType::HOMOGENEOUS_DECAY, kw::homdecay::name() },
      68                 :            :           { CoeffPolicyType::MONTE_CARLO_HOMOGENEOUS_DECAY,
      69 [ -  + ][ -  - ]:        303 :             kw::montecarlo_homdecay::name() },
      70 [ -  + ][ -  - ]:        303 :           { CoeffPolicyType::HYDROTIMESCALE, kw::hydrotimescale::name() },
      71 [ -  + ][ -  - ]:        303 :           { CoeffPolicyType::CONST_SHEAR, kw::const_shear::name() },
      72 [ -  + ][ -  - ]:        303 :           { CoeffPolicyType::STATIONARY, kw::stationary::name() },
      73                 :            :           { CoeffPolicyType::INSTANTANEOUS_VELOCITY,
      74 [ -  + ][ -  - ]:        303 :             kw::inst_velocity::name() } },
      75                 :            :         //! keywords -> Enums
      76                 :        303 :         {  { kw::constcoeff::string(), CoeffPolicyType::CONST_COEFF },
      77 [ -  + ][ -  - ]:        303 :            { kw::decay::string(), CoeffPolicyType::DECAY },
      78 [ -  + ][ -  - ]:        303 :            { kw::homogeneous::string(), CoeffPolicyType::HOMOGENEOUS },
      79 [ -  + ][ -  - ]:        303 :            { kw::homdecay::string(), CoeffPolicyType::HOMOGENEOUS_DECAY },
      80 [ -  + ][ -  - ]:        303 :            { kw::montecarlo_homdecay::string(),
      81                 :            :              CoeffPolicyType::MONTE_CARLO_HOMOGENEOUS_DECAY },
      82 [ -  + ][ -  - ]:        303 :            { kw::hydrotimescale::string(), CoeffPolicyType::HYDROTIMESCALE },
      83 [ -  + ][ -  - ]:        303 :            { kw::const_shear::string(), CoeffPolicyType::CONST_SHEAR },
      84 [ -  + ][ -  - ]:        303 :            { kw::stationary::string(), CoeffPolicyType::STATIONARY },
      85 [ -  + ][ -  - ]:        303 :            { kw::inst_velocity::string(),
      86 [ +  - ][ +  - ]:      13029 :              CoeffPolicyType::INSTANTANEOUS_VELOCITY } } )
         [ +  - ][ +  + ]
         [ +  + ][ -  + ]
         [ +  + ][ +  + ]
         [ -  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ +  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
      87                 :            :     {
      88                 :            :       brigand::for_each< keywords >( assertPolicyCodes() );
      89                 :        303 :     }
      90                 :            : 
      91                 :            :     //! \brief Return policy code based on Enum
      92                 :            :     //! \param[in] p Enum value of the option requested
      93                 :            :     //! \return Policy code of the option
      94                 :            :     const std::string& code( CoeffPolicyType p ) const {
      95                 :            :       using tk::operator<<;
      96                 :            :       auto it = policy.find( p );
      97                 :            :       Assert( it != end(policy),
      98                 :            :               std::string("Cannot find policy code for physics \"") << p <<
      99                 :            :                 "\"" );
     100                 :      19344 :       return it->second;
     101                 :            :     }
     102                 :            : 
     103                 :            :   private:
     104                 :            :     //! Function object for ensuring the existence of policy codes
     105                 :            :     struct assertPolicyCodes {
     106                 :            :       //! \brief Function call operator templated on the type to assert the
     107                 :            :       //!   existence of a policy code
     108                 :            :       template< typename U > void operator()( brigand::type_<U> ) {
     109                 :            :         static_assert( tk::HasTypedef_code_v< typename U::info >,
     110                 :            :                        "Policy code undefined for keyword" );
     111                 :            :       }
     112                 :            :     };
     113                 :            : 
     114                 :            :     //! Enums -> policy code
     115                 :            :     std::map< CoeffPolicyType, std::string > policy {
     116                 :        303 :         { CoeffPolicyType::CONST_COEFF, *kw::constcoeff::code() }
     117                 :        303 :       , { CoeffPolicyType::DECAY, *kw::decay::code() }
     118                 :        303 :       , { CoeffPolicyType::HOMOGENEOUS, *kw::homogeneous::code() }
     119                 :        303 :       , { CoeffPolicyType::HOMOGENEOUS_DECAY, *kw::homdecay::code() }
     120                 :            :       , { CoeffPolicyType::MONTE_CARLO_HOMOGENEOUS_DECAY,
     121                 :        303 :           *kw::montecarlo_homdecay::code() }
     122                 :        303 :       , { CoeffPolicyType::HYDROTIMESCALE, *kw::hydrotimescale::code() }
     123                 :        303 :       , { CoeffPolicyType::CONST_SHEAR, *kw::const_shear::code() }
     124                 :        303 :       , { CoeffPolicyType::STATIONARY, *kw::stationary::code() }
     125                 :            :       , { CoeffPolicyType::INSTANTANEOUS_VELOCITY,
     126                 :        303 :           *kw::inst_velocity::code() }
     127         [ -  - ]:        303 :     };
     128                 :            : 
     129                 :            : };
     130                 :            : 
     131                 :            : } // ctr::
     132                 :            : } // walker::
     133                 :            : 
     134                 :            : #endif // CoeffPolicyOptions_h

Generated by: LCOV version 1.14