Quinoa all test code coverage report
Current view: top level - Control/Options - PartitioningAlgorithm.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 13 22 59.1 %
Date: 2024-04-29 14:59:56 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 28 66 42.4 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Control/Options/PartitioningAlgorithm.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     Mesh partitioning algorithm options
       9                 :            :   \details   Mesh partitioning algorithm options
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef InciterPartitioningAlgorithmOptions_h
      13                 :            : #define InciterPartitioningAlgorithmOptions_h
      14                 :            : 
      15                 :            : #include <map>
      16                 :            : 
      17                 :            : #include <brigand/sequences/list.hpp>
      18                 :            : 
      19                 :            : #include "Toggle.hpp"
      20                 :            : #include "PUPUtil.hpp"
      21                 :            : 
      22                 :            : namespace tk {
      23                 :            : namespace ctr {
      24                 :            : 
      25                 :            : //! Mesh partitioning algorithm types
      26                 :            : enum class PartitioningAlgorithmType : uint8_t { RCB,
      27                 :            :                                                  RIB,
      28                 :            :                                                  HSFC,
      29                 :            :                                                  MJ,
      30                 :            :                                                  PHG };
      31                 :            : 
      32                 :            : //! \brief Pack/Unpack PartitioningAlgorithmType: forward overload to generic
      33                 :            : //!   enum class packer
      34                 :       1820 : inline void operator|( PUP::er& p, PartitioningAlgorithmType& e )
      35                 :       1820 : { PUP::pup( p, e ); }
      36                 :            : 
      37                 :            : //! \brief PartitioningAlgorithm options: outsource searches to base templated
      38                 :            : //!   on enum type
      39                 :            : class PartitioningAlgorithm : public tk::Toggle< PartitioningAlgorithmType > {
      40                 :            : 
      41                 :            :   public:
      42                 :            :     using ParamType = std::string;
      43                 :            : 
      44                 :            :     //! \brief Options constructor
      45                 :            :     //! \details Simply initialize in-line and pass associations to base, which
      46                 :            :     //!    will handle client interactions
      47                 :        977 :     explicit PartitioningAlgorithm() :
      48                 :            :       tk::Toggle< PartitioningAlgorithmType >(
      49                 :            :         //! Group, i.e., options, name
      50                 :            :         "Mesh partitioning algorithm",
      51                 :            :         //! Enums -> names
      52                 :          0 :         { { PartitioningAlgorithmType::RCB, "rcb" },
      53                 :          0 :           { PartitioningAlgorithmType::RIB, "rib" },
      54                 :          0 :           { PartitioningAlgorithmType::HSFC, "hsfc" },
      55                 :          0 :           { PartitioningAlgorithmType::MJ, "mj" },
      56                 :          0 :           { PartitioningAlgorithmType::PHG, "phg" } },
      57                 :            :         //! keywords -> Enums
      58                 :          0 :         { { "rcb", PartitioningAlgorithmType::RCB },
      59                 :          0 :           { "rib", PartitioningAlgorithmType::RIB },
      60                 :          0 :           { "hsfc", PartitioningAlgorithmType::HSFC },
      61                 :          0 :           { "mj", PartitioningAlgorithmType::MJ },
      62 [ +  - ][ +  - ]:      16609 :           { "phg", PartitioningAlgorithmType::PHG } } ) {}
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
         [ +  - ][ +  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
      63                 :            : 
      64                 :            :     //! \brief Return parameter based on Enum
      65                 :            :     //! \details Here 'parameter' is the library-specific identifier of the
      66                 :            :     //!    option, i.e., as the library identifies the given option
      67                 :            :     //! \param[in] m Enum value of the option requested
      68                 :            :     //! \return Library-specific parameter of the option
      69                 :        589 :     const ParamType& param( PartitioningAlgorithmType m ) const {
      70                 :            :       using tk::operator<<;
      71         [ +  - ]:        589 :       auto it = method.find( m );
      72 [ -  + ][ -  - ]:        589 :       Assert( it != end(method),
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
      73                 :            :               std::string("Cannot find parameter for PartitioningAlgorithm \"")
      74                 :            :               << m << "\"" );
      75                 :        589 :       return it->second;
      76                 :            :     }
      77                 :            : 
      78                 :            :     // Return true if partitioning algorithm is geometric
      79                 :            :     //! \param[in] m Enum value of the option requested
      80                 :            :     //! \return True if partitioning algorithm is geometric, false if it is not
      81                 :            :     bool geometric( PartitioningAlgorithmType m ) const {
      82                 :            :       if ( m == PartitioningAlgorithmType::RCB ||
      83                 :            :            m == PartitioningAlgorithmType::RIB ||
      84                 :            :            m == PartitioningAlgorithmType::HSFC ||
      85                 :            :            m == PartitioningAlgorithmType::MJ )
      86                 :            :         return true;
      87                 :            :       else
      88                 :            :        return false;
      89                 :            :     }
      90                 :            : 
      91                 :            :   private:
      92                 :            :     //! Enums -> Zoltan partitioning algorithm parameters
      93                 :            :     std::map< PartitioningAlgorithmType, ParamType > method {
      94         [ +  - ]:        977 :       { PartitioningAlgorithmType::RCB, "rcb" },
      95         [ +  - ]:        977 :       { PartitioningAlgorithmType::RIB, "rib" },
      96         [ +  - ]:        977 :       { PartitioningAlgorithmType::HSFC, "hsfc" },
      97         [ +  - ]:        977 :       { PartitioningAlgorithmType::MJ, "multijagged" },
      98         [ +  - ]:        977 :       { PartitioningAlgorithmType::PHG, "phg" }
      99                 :            :     };
     100                 :            : };
     101                 :            : 
     102                 :            : } // ctr::
     103                 :            : } // tk::
     104                 :            : 
     105                 :            : #endif // InciterPartitioningAlgorithmOptions_h

Generated by: LCOV version 1.14