Walker test code coverage report
Current view: top level - DiffEq/OrnsteinUhlenbeck - ConfigureOrnsteinUhlenbeck.cpp (source / functions) Hit Total Coverage
Commit: test_coverage.info Lines: 33 33 100.0 %
Date: 2022-09-21 18:57:21 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 43 86 50.0 %

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

Generated by: LCOV version 1.14