Walker test code coverage report
Current view: top level - DiffEq/OrnsteinUhlenbeck - ConfigureDiagOrnsteinUhlenbeck.cpp (source / functions) Hit Total Coverage
Commit: test_coverage.info Lines: 29 29 100.0 %
Date: 2022-09-21 13:52:12 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 47 112 42.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/DiffEq/OrnsteinUhlenbeck/ConfigureDiagOrnsteinUhlenbeck.cpp
       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 and compile configuration on the diagonal
       9                 :            :              Ornstein-Uhlenbeck SDE
      10                 :            :   \details   Register and compile configuration on the diagonal
      11                 :            :              Ornstein-Uhlenbeck SDE.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : 
      15                 :            : #include <set>
      16                 :            : #include <map>
      17                 :            : #include <vector>
      18                 :            : #include <string>
      19                 :            : #include <utility>
      20                 :            : 
      21                 :            : #include <brigand/algorithms/for_each.hpp>
      22                 :            : 
      23                 :            : #include "Tags.hpp"
      24                 :            : #include "CartesianProduct.hpp"
      25                 :            : #include "DiffEqFactory.hpp"
      26                 :            : #include "Walker/Options/DiffEq.hpp"
      27                 :            : #include "Walker/Options/InitPolicy.hpp"
      28                 :            : 
      29                 :            : #include "ConfigureDiagOrnsteinUhlenbeck.hpp"
      30                 :            : #include "DiagOrnsteinUhlenbeck.hpp"
      31                 :            : #include "DiagOrnsteinUhlenbeckCoeffPolicy.hpp"
      32                 :            : 
      33                 :            : namespace walker {
      34                 :            : 
      35                 :            : void
      36                 :        374 : registerDiagOrnsteinUhlenbeck( DiffEqFactory& f,
      37                 :            :                                std::set< ctr::DiffEqType >& t )
      38                 :            : // *****************************************************************************
      39                 :            : // Register diagonal Ornstein-Uhlenbeck SDE into DiffEq factory
      40                 :            : //! \param[in,out] f Differential equation factory to register to
      41                 :            : //! \param[in,out] t Counters for equation types registered
      42                 :            : // *****************************************************************************
      43                 :            : {
      44                 :            :   // Construct vector of vectors for all possible policies for SDE
      45                 :            :   using DiagOrnsteinUhlenbeckPolicies =
      46                 :            :     tk::cartesian_product< InitPolicies, DiagOrnsteinUhlenbeckCoeffPolicies >;
      47                 :            :   // Register SDE for all combinations of policies
      48                 :            :   brigand::for_each< DiagOrnsteinUhlenbeckPolicies >(
      49                 :        374 :     registerDiffEq< DiagOrnsteinUhlenbeck >( f, ctr::DiffEqType::DIAG_OU, t ) );
      50                 :        374 : }
      51                 :            : 
      52                 :            : std::vector< std::pair< std::string, std::string > >
      53                 :         15 : infoDiagOrnsteinUhlenbeck( std::map< ctr::DiffEqType, tk::ctr::ncomp_t >& cnt )
      54                 :            : // *****************************************************************************
      55                 :            : //  Return information on the diagonal Ornstein-Uhlenbeck SDE
      56                 :            : //! \param[inout] cnt std::map of counters for all differential equation types
      57                 :            : //! \return vector of string pairs describing the SDE configuration
      58                 :            : // *****************************************************************************
      59                 :            : {
      60         [ +  - ]:         15 :   auto c = ++cnt[ ctr::DiffEqType::DIAG_OU ];       // count eqs
      61                 :            :   --c;  // used to index vectors starting with 0
      62                 :            : 
      63                 :            :   std::vector< std::pair< std::string, std::string > > nfo;
      64                 :            : 
      65 [ +  - ][ +  - ]:         30 :   nfo.emplace_back( ctr::DiffEq().name( ctr::DiffEqType::DIAG_OU ), "" );
      66                 :            : 
      67         [ +  - ]:         15 :   nfo.emplace_back( "start offset in particle array", std::to_string(
      68 [ +  - ][ +  - ]:         15 :     g_inputdeck.get< tag::component >().offset< tag::diagou >(c) ) );
      69                 :         15 :   auto ncomp = g_inputdeck.get< tag::component >().get< tag::diagou >()[c];
      70 [ +  - ][ +  - ]:         15 :   nfo.emplace_back( "number of components", std::to_string( ncomp ) );
      71                 :            : 
      72         [ +  - ]:         15 :   nfo.emplace_back( "kind", "stochastic" );
      73                 :         15 :   nfo.emplace_back( "dependent variable", std::string( 1,
      74 [ +  - ][ +  - ]:         15 :     g_inputdeck.get< tag::param, tag::diagou, tag::depvar >()[c] ) );
      75         [ +  - ]:         15 :   nfo.emplace_back( "initialization policy", ctr::InitPolicy().name(
      76         [ +  - ]:         30 :     g_inputdeck.get< tag::param, tag::diagou, tag::initpolicy >()[c] ) );
      77         [ +  - ]:         15 :   nfo.emplace_back( "coefficients policy", ctr::CoeffPolicy().name(
      78         [ +  - ]:         30 :     g_inputdeck.get< tag::param, tag::diagou, tag::coeffpolicy >()[c] ) );
      79 [ +  - ][ -  + ]:         30 :   nfo.emplace_back( "random number generator", tk::ctr::RNG().name(
      80         [ +  - ]:         30 :     g_inputdeck.get< tag::param, tag::diagou, tag::rng >()[c] ) );
      81                 :            :   nfo.emplace_back(
      82 [ +  - ][ +  - ]:         30 :     "coeff sigmasq [" + std::to_string( ncomp ) + "]",
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
      83 [ +  - ][ +  - ]:         45 :     parameters( g_inputdeck.get< tag::param, tag::diagou, tag::mu >().at(c) ) );
                 [ -  + ]
      84 [ +  - ][ +  - ]:         30 :   nfo.emplace_back( "coeff theta [" + std::to_string( ncomp ) + "]",
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
      85 [ +  - ][ -  + ]:         30 :     parameters( g_inputdeck.get< tag::param, tag::diagou, tag::theta >().at(c) )
      86         [ +  - ]:         15 :   );
      87 [ +  - ][ +  - ]:         30 :   nfo.emplace_back( "coeff mu [" + std::to_string( ncomp ) + "]",
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  - ][ -  - ]
                 [ -  - ]
      88 [ +  - ][ +  - ]:         45 :     parameters( g_inputdeck.get< tag::param, tag::diagou, tag::mu >().at(c) ) );
                 [ -  + ]
      89                 :            : 
      90                 :            :   const auto& init = g_inputdeck.get< tag::param, tag::diagou, tag::init >();
      91         [ +  - ]:         15 :   spikes( nfo, init.get< tag::spike >().at(c) );
      92         [ +  - ]:         15 :   betapdfs( nfo, init.get< tag::betapdf >().at(c) );
      93                 :            : 
      94                 :         15 :   return nfo;
      95                 :            : }
      96                 :            : 
      97                 :            : }  // walker::

Generated by: LCOV version 1.14