Walker test code coverage report
Current view: top level - Control/Walker/Options - CoeffPolicy.hpp (source / functions) Hit Total Coverage
Commit: test_coverage.info Lines: 40 44 90.9 %
Date: 2022-09-21 18:57:21 Functions: 12 12 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 40 90 44.4 %

           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                 :        422 : 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                 :            : 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         [ +  - ]:        606 :           { CoeffPolicyType::DECAY, kw::decay::name() },
      66         [ +  - ]:        606 :           { CoeffPolicyType::HOMOGENEOUS, kw::homogeneous::name() },
      67         [ +  - ]:        606 :           { CoeffPolicyType::HOMOGENEOUS_DECAY, kw::homdecay::name() },
      68                 :          0 :           { CoeffPolicyType::MONTE_CARLO_HOMOGENEOUS_DECAY,
      69         [ +  - ]:        606 :             kw::montecarlo_homdecay::name() },
      70         [ +  - ]:        606 :           { CoeffPolicyType::HYDROTIMESCALE, kw::hydrotimescale::name() },
      71         [ +  - ]:        606 :           { CoeffPolicyType::CONST_SHEAR, kw::const_shear::name() },
      72         [ +  - ]:        606 :           { CoeffPolicyType::STATIONARY, kw::stationary::name() },
      73                 :          0 :           { CoeffPolicyType::INSTANTANEOUS_VELOCITY,
      74         [ +  - ]:        606 :             kw::inst_velocity::name() } },
      75                 :            :         //! keywords -> Enums
      76                 :          0 :         {  { kw::constcoeff::string(), CoeffPolicyType::CONST_COEFF },
      77         [ +  - ]:        606 :            { kw::decay::string(), CoeffPolicyType::DECAY },
      78         [ +  - ]:        606 :            { kw::homogeneous::string(), CoeffPolicyType::HOMOGENEOUS },
      79         [ +  - ]:        606 :            { kw::homdecay::string(), CoeffPolicyType::HOMOGENEOUS_DECAY },
      80         [ +  - ]:        606 :            { kw::montecarlo_homdecay::string(),
      81                 :          0 :              CoeffPolicyType::MONTE_CARLO_HOMOGENEOUS_DECAY },
      82         [ +  - ]:        606 :            { kw::hydrotimescale::string(), CoeffPolicyType::HYDROTIMESCALE },
      83         [ +  - ]:        606 :            { kw::const_shear::string(), CoeffPolicyType::CONST_SHEAR },
      84         [ +  - ]:        606 :            { kw::stationary::string(), CoeffPolicyType::STATIONARY },
      85         [ +  - ]:        606 :            { kw::inst_velocity::string(),
      86 [ +  - ][ +  - ]:      16968 :              CoeffPolicyType::INSTANTANEOUS_VELOCITY } } )
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
         [ +  - ][ +  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
      87                 :            :     {
      88                 :        303 :       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                 :      19344 :     const std::string& code( CoeffPolicyType p ) const {
      95                 :            :       using tk::operator<<;
      96         [ +  - ]:      19344 :       auto it = policy.find( p );
      97 [ -  + ][ -  - ]:      19344 :       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                 :       2727 :       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                 :       2727 :       }
     112                 :            :     };
     113                 :            : 
     114                 :            :     //! Enums -> policy code
     115                 :            :     std::map< CoeffPolicyType, std::string > policy {
     116 [ +  - ][ +  - ]:        606 :         { CoeffPolicyType::CONST_COEFF, *kw::constcoeff::code() }
     117         [ +  - ]:        606 :       , { CoeffPolicyType::DECAY, *kw::decay::code() }
     118         [ +  - ]:        606 :       , { CoeffPolicyType::HOMOGENEOUS, *kw::homogeneous::code() }
     119         [ +  - ]:        606 :       , { CoeffPolicyType::HOMOGENEOUS_DECAY, *kw::homdecay::code() }
     120         [ +  - ]:        303 :       , { CoeffPolicyType::MONTE_CARLO_HOMOGENEOUS_DECAY,
     121                 :        303 :           *kw::montecarlo_homdecay::code() }
     122         [ +  - ]:        606 :       , { CoeffPolicyType::HYDROTIMESCALE, *kw::hydrotimescale::code() }
     123         [ +  - ]:        606 :       , { CoeffPolicyType::CONST_SHEAR, *kw::const_shear::code() }
     124         [ +  - ]:        606 :       , { CoeffPolicyType::STATIONARY, *kw::stationary::code() }
     125         [ +  - ]:        303 :       , { 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