Quinoa all test code coverage report
Current view: top level - PDE/CompFlow - RiemannFactory.hpp (source / functions) Hit Total Coverage
Commit: Quinoa_v0.3-957-gb4f0efae0 Lines: 3 3 100.0 %
Date: 2021-11-09 15:14:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 12 33.3 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/PDE/CompFlow/RiemannFactory.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     Register available Riemann solvers for single material compressible
       9                 :            :              hydrodynamics into a factory
      10                 :            :   \details   Register available Riemann solvers for single material compressible
      11                 :            :              hydrodynamics into a factory.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : #ifndef RiemannSolverFactory_h
      15                 :            : #define RiemannSolverFactory_h
      16                 :            : 
      17                 :            : #include <map>
      18                 :            : #include <functional>
      19                 :            : 
      20                 :            : #include "NoWarning/value_factory.hpp"
      21                 :            : 
      22                 :            : #include "Riemann/RiemannSolver.hpp"
      23                 :            : #include "Inciter/Options/Flux.hpp"
      24                 :            : 
      25                 :            : namespace inciter {
      26                 :            : 
      27                 :            : //! Factory for Riemann solvers
      28                 :            : //! \details This factory is used to store the constructors as a
      29                 :            : //!   std::function of specific Riemann solvers that can be invoked at a
      30                 :            : //!   later time compared to the point where the map is populated. The key
      31                 :            : //!   is an enum, uniquely idenfitying a specific Riemann solver. The value
      32                 :            : //!   is std::function storing a constructor to be invoked. The type of
      33                 :            : //!   object stored in std::function is a generic (base) class constructor,
      34                 :            : //!   which provides a polymorphyic interface (overridable functions) that
      35                 :            : //!   specific (child) Riemann solvers override, yielding runtime polymorphism.
      36                 :            : using CompFlowRiemannFactory =
      37                 :            :   std::map< ctr::FluxType, std::function< RiemannSolver() > >;
      38                 :            : 
      39                 :            : //! Functor to register a Riemann solver into the Riemann solver factory
      40                 :            : struct registerRiemannSolver {
      41                 :            :   //! Factory to which to register the Riemann solver
      42                 :            :   CompFlowRiemannFactory& factory;
      43                 :            :   //! Constructor
      44                 :            :   //! \param[in] f Factory
      45                 :            :   explicit registerRiemannSolver( CompFlowRiemannFactory& f ) : factory( f ) {}
      46                 :            :   //! \brief Function call operator templated on the type that implements
      47                 :            :   //!   a specific Riemann solver
      48         [ +  - ]:        160 :   template< typename U > void operator()( brigand::type_<U> ) {
      49                 :            :      // Function object holding the (default) constructor to be called later
      50                 :            :      // without bound arguments, since all specific Riemann solvers'
      51                 :            :      // constructors are compiler-generated (default) constructors, and thus
      52                 :            :      // taking no arguments.
      53                 :            :      std::function< U() > c = boost::value_factory< U >();
      54                 :            :      // Associate constructor function object to flux type in factory
      55 [ +  - ][ -  + ]:        160 :      factory.emplace( U::type(),
         [ -  + ][ -  - ]
                 [ -  - ]
      56                 :            :        std::bind(boost::value_factory< RiemannSolver >(), std::move(c)) );
      57                 :        160 :   }
      58                 :            : };
      59                 :            : 
      60                 :            : //! Register available Riemann solvers into a factory
      61                 :            : CompFlowRiemannFactory compflowRiemannSolvers();
      62                 :            : 
      63                 :            : } // inciter::
      64                 :            : 
      65                 :            : #endif // RiemannSolverFactory_h

Generated by: LCOV version 1.14