Walker test code coverage report
Current view: top level - DiffEq - CoupledEq.hpp (source / functions) Hit Total Coverage
Commit: test_coverage.info Lines: 12 14 85.7 %
Date: 2022-09-21 13:52:12 Functions: 14 15 93.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 52 444 11.7 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/DiffEq/CoupledEq.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     Functionality for querying information on coupled equations
       9                 :            :   \details   Functionality for querying information on coupled equations.
      10                 :            : */
      11                 :            : // *****************************************************************************
      12                 :            : #ifndef CoupledEq_h
      13                 :            : #define CoupledEq_h
      14                 :            : 
      15                 :            : #include <limits>
      16                 :            : 
      17                 :            : namespace walker {
      18                 :            : 
      19                 :            : extern ctr::InputDeck g_inputdeck;
      20                 :            : 
      21                 :            : template< typename eq, typename coupledeq, typename id >
      22                 :         43 : void coupledInfo( std::size_t system,
      23                 :            :                   std::string&& coupled_eq_name,
      24                 :            :                   std::vector< std::pair< std::string, std::string > > nfo )
      25                 :            : // *****************************************************************************
      26                 :            : //  Query and generate info on coupled equations
      27                 :            : //! \tparam eq Tag of the equation that is coupled
      28                 :            : //! \tparam coupledeq Tag of the equation that is coupled to equation 'eq'
      29                 :            : //! \tparam id Tag to access the coupled equation 'eq' (relative) ids, see
      30                 :            : //!   tk::grm::couple in Control/Walker/InputDeck/Grammar.h
      31                 :            : //! \param[in] system Relative equation system id of equation 'eq'
      32                 :            : //! \param[in] coupled_eq_name Coupled equation name
      33                 :            : //! \param[in,out] nfo Info vector to augment
      34                 :            : // *****************************************************************************
      35                 :            : {
      36                 :            :   static_assert( !std::is_same< eq, coupledeq >::value,
      37                 :            :                  "Eq and coupled eq must differ" );
      38                 :            : 
      39                 :            :   const auto& coupled_eq =
      40                 :            :     g_inputdeck.template get< tag::param, eq, coupledeq >();
      41                 :            :   const auto& coupled_eq_id = g_inputdeck.template get< tag::param, eq, id >();
      42                 :            : 
      43                 :            :   Assert( coupled_eq.size() == coupled_eq_id.size(),
      44                 :            :           "Size mismatch in coupled eq configuration" );
      45                 :            : 
      46 [ +  - ][ +  - ]:         86 :   nfo.emplace_back( "coupled " + coupled_eq_name + " depvar",
         [ +  - ][ -  + ]
         [ -  + ][ -  - ]
                 [ -  - ]
      47         [ +  + ]:         86 :                     std::string( 1, coupled_eq[ system ] ) );
      48                 :            : 
      49         [ +  + ]:         43 :   if (coupled_eq[ system ] != '-' )
      50 [ +  - ][ +  - ]:         48 :     nfo.emplace_back( "coupled " + coupled_eq_name + " id",
         [ +  - ][ -  + ]
         [ -  + ][ -  - ]
                 [ -  - ]
      51                 :         48 :                       std::to_string( coupled_eq_id[ system ] ) );
      52                 :         43 : }
      53                 :            : 
      54                 :            : template< typename eq, typename coupledeq >
      55                 :            : bool coupled( std::size_t system )
      56                 :            : // *****************************************************************************
      57                 :            : //  Query if equation 'eq' is coupled to equation 'coupledeq'
      58                 :            : //! \tparam eq Tag of the equation that is coupled
      59                 :            : //! \tparam coupledeq Tag of the equation that is coupled to equation 'eq'
      60                 :            : //! \param[in] system Relative equation system id of equation 'eq'
      61                 :            : //! \return True if equation 'eq' is coupled to equation 'coupledeq'
      62                 :            : // *****************************************************************************
      63                 :            : {
      64                 :            :   static_assert( !std::is_same< eq, coupledeq >::value,
      65                 :            :                  "Eq and coupled eq must differ" );
      66                 :            : 
      67                 :            :   const auto& coupled_eq =
      68                 :            :     g_inputdeck.template get< tag::param, eq, coupledeq >();
      69                 :            : 
      70 [ +  + ][ +  + ]:        314 :   if (coupled_eq[ system ] != '-' ) return true; else return false;
         [ -  + ][ -  + ]
         [ -  - ][ -  + ]
         [ -  - ][ -  - ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ +  - ]
         [ -  - ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  - ]
         [ -  - ][ +  + ]
         [ -  + ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
      71                 :            : }
      72                 :            : 
      73                 :            : template< typename eq, typename coupledeq >
      74                 :            : char depvar( std::size_t system )
      75                 :            : // *****************************************************************************
      76                 :            : //  Query dependent variable of equation 'eq' coupled to equation 'coupledq'
      77                 :            : //! \tparam eq Tag of the equation that is coupled
      78                 :            : //! \tparam coupledeq Tag of the equation that is coupled to equation 'eq'
      79                 :            : //! \param[in] system Relative equation system id of equation 'eq'
      80                 :            : //! \return Character (dependent variable) of equation coupled to equation 'eq'
      81                 :            : //! \note If equation 'eq' is not coupled to equation 'coupledeq', '-' is
      82                 :            : //!   returned
      83                 :            : // *****************************************************************************
      84                 :            : {
      85                 :            :   static_assert( !std::is_same< eq, coupledeq >::value,
      86                 :            :                  "Eq and coupled eq must differ" );
      87                 :            : 
      88                 :            :   const auto& coupled_eq =
      89                 :            :     g_inputdeck.template get< tag::param, eq, coupledeq >();
      90                 :            : 
      91 [ -  - ][ -  - ]:        114 :   return coupled_eq[ system ];
         [ -  - ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  + ][ +  - ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
         [ -  - ][ -  - ]
      92                 :            : }
      93                 :            : 
      94                 :            : template< typename eq, typename coupledeq, typename id >
      95                 :            : std::size_t system_id( std::size_t system )
      96                 :            : // *****************************************************************************
      97                 :            : //  Query relative id of coupled equation of potentially multiple eqs
      98                 :            : //! \tparam eq Tag of the equation that is coupled
      99                 :            : //! \tparam coupledeq Tag of the equation that is coupled to equation 'eq'
     100                 :            : //! \tparam id Tag to access the coupled equation 'eq' (relative) ids, see
     101                 :            : //!   tk::grm::couple in Control/Walker/InputDeck/Grammar.h
     102                 :            : //! \param[in] system Relative equation system id of equation 'eq'
     103                 :            : //! \return Relative id of coupled equation of potentially multiple eqs
     104                 :            : //! \note If equation 'eq' is not coupled to equation 'coupledeq', we return a
     105                 :            : //!   large number which will hopefully trigger some problems in client code if
     106                 :            : //!   used. This is used to indicate "no coupling" so that client code can still
     107                 :            : //!   call this function even for an equation that is not coupled, without
     108                 :            : //!   chaning client code, compared to equations that are coupled. In other
     109                 :            : //!   words, calling this function on a coupledeq equation that is not coupled
     110                 :            : //!   is not an error.
     111                 :            : // *****************************************************************************
     112                 :            : {
     113                 :            :   static_assert( !std::is_same< eq, coupledeq >::value,
     114                 :            :                  "Eq and coupled eq must differ" );
     115                 :            : 
     116                 :            :   const auto& coupled_eq_id = g_inputdeck.template get< tag::param, eq, id >();
     117                 :            : 
     118                 :            :   if (coupled< eq, coupledeq >( system ))
     119                 :         72 :     return coupled_eq_id[ system ];
     120                 :            :   else
     121                 :            :     return std::numeric_limits< std::size_t >::max();
     122                 :            : }
     123                 :            : 
     124                 :            : template< typename eq, typename coupledeq, typename id >
     125         [ +  + ]:        132 : std::size_t offset( std::size_t system )
     126                 :            : // *****************************************************************************
     127                 :            : //  Query system offset of coupled equation in tk::Data array of all systems
     128                 :            : //! \tparam eq Tag of the equation that is coupled
     129                 :            : //! \tparam coupledeq Tag of the equation that is coupled to equation 'eq'
     130                 :            : //! \tparam id Tag to access the coupled equation 'eq' (relative) ids, see
     131                 :            : //!   tk::grm::couple in Control/Walker/InputDeck/Grammar.h
     132                 :            : //! \param[in] system Relative equation system id of equation 'eq'
     133                 :            : //! \return System offset of coupled equation in tk::Data array of all systems
     134                 :            : //! \note If equation 'eq' is not coupled to equation 'coupledeq', we return the
     135                 :            : //!   id of the coupled equation. In other words, calling this function on a
     136                 :            : //!   coupledeq equation that is not coupled is not an error.
     137                 :            : // *****************************************************************************
     138                 :            : {
     139                 :            :   static_assert( !std::is_same< eq, coupledeq >::value,
     140                 :            :                  "Eq and coupled eq must differ" );
     141                 :            : 
     142                 :            :   // Query relative id of coupled eq
     143                 :            :   auto cid = system_id< eq, coupledeq, id >( system );
     144                 :            : 
     145                 :            :   // Return offset for coupled eq
     146                 :            :   if (coupled< eq, coupledeq >( system ))
     147                 :         72 :     return g_inputdeck.get< tag::component >().offset< coupledeq >( cid );
     148                 :            :   else 
     149                 :            :     return cid;
     150                 :            : }
     151                 :            : 
     152                 :            : template< typename eq, typename coupledeq, typename id >
     153         [ -  - ]:          0 : std::size_t ncomp( std::size_t system )
     154                 :            : // *****************************************************************************
     155                 :            : //  Query number of components of coupled equation
     156                 :            : //! \tparam eq Tag of the equation that is coupled
     157                 :            : //! \tparam coupledeq Tag of the equation that is coupled to equation 'eq'
     158                 :            : //! \tparam id Tag to access the coupled equation 'eq' (relative) ids, see
     159                 :            : //!   tk::grm::couple in Control/Walker/InputDeck/Grammar.h
     160                 :            : //! \param[in] system Relative equation system id of equation 'eq'
     161                 :            : //! \return Number of scalar components of coupled equation
     162                 :            : //! \note If equation 'eq' is not coupled to equation 'coupledeq', we return the
     163                 :            : //!   id of the coupled equation. In other words, calling this function on a
     164                 :            : //!   coupledeq equation that is not coupled is not an error.
     165                 :            : // *****************************************************************************
     166                 :            : {
     167                 :            :   static_assert( !std::is_same< eq, coupledeq >::value,
     168                 :            :                  "Eq and coupled eq must differ" );
     169                 :            : 
     170                 :            :   // Query relative id of coupled eq
     171                 :            :   auto cid = system_id< eq, coupledeq, id >( system );
     172                 :            : 
     173                 :            :   // Return number of scalar components of coupled eq
     174                 :            :   if (coupled< eq, coupledeq >( system ))
     175                 :          0 :     return g_inputdeck.get< tag::component >().get< coupledeq >().at( cid );
     176                 :            :   else
     177                 :            :     return cid;
     178                 :            : }
     179                 :            : 
     180                 :            : } // walker::
     181                 :            : 
     182                 :            : #endif // CoupledEq_h

Generated by: LCOV version 1.14