LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - StochasticResults.C (source / functions) Hit Total Coverage
Test: stochastic_tools Test Coverage Lines: 23 24 95.8 %
Date: 2017-11-21 14:52:30 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************/
       2             : /* MOOSE - Multiphysics Object Oriented Simulation Environment  */
       3             : /*                                                              */
       4             : /*          All contents are licensed under LGPL V2.1           */
       5             : /*             See LICENSE for full restrictions                */
       6             : /****************************************************************/
       7             : 
       8             : // Stocastic Tools Includes
       9             : #include "StochasticResults.h"
      10             : 
      11             : // MOOSE includes
      12             : #include "Sampler.h"
      13             : 
      14             : template <>
      15             : InputParameters
      16           2 : validParams<StochasticResults>()
      17             : {
      18           2 :   InputParameters params = validParams<GeneralVectorPostprocessor>();
      19           4 :   params.addClassDescription(
      20           2 :       "Storage container for stochastic simulation results coming from a Postprocessor.");
      21           2 :   params += validParams<SamplerInterface>();
      22           2 :   return params;
      23             : }
      24             : 
      25           1 : StochasticResults::StochasticResults(const InputParameters & parameters)
      26           2 :   : GeneralVectorPostprocessor(parameters), SamplerInterface(this)
      27             : {
      28           1 : }
      29             : 
      30             : void
      31           5 : StochasticResults::initialize()
      32             : {
      33             :   mooseAssert(_sampler, "The _sampler pointer must be initialized via the init() method.");
      34             : 
      35             :   // Resize and zero vectors to the correct size, this allows the SamplerPostprocessorTransfer
      36             :   // to set values in the vector directly.
      37          10 :   std::vector<DenseMatrix<Real>> data = _sampler->getSamples();
      38          45 :   for (auto i = beginIndex(data); i < data.size(); ++i)
      39          60 :     _sample_vectors[i]->resize(data[i].m(), 0);
      40           5 : }
      41             : 
      42             : VectorPostprocessorValue &
      43          60 : StochasticResults::getVectorPostprocessorValueByGroup(unsigned int group)
      44             : {
      45         120 :   if (group >= _sample_vectors.size())
      46           0 :     mooseError("The supplied sample index ", group, " does not exist.");
      47          60 :   return *_sample_vectors[group];
      48             : }
      49             : 
      50             : void
      51           1 : StochasticResults::init(Sampler & sampler)
      52             : {
      53           1 :   _sampler = &sampler;
      54             :   const std::vector<std::string> & names = _sampler->getSampleNames();
      55           1 :   _sample_vectors.resize(names.size());
      56           9 :   for (auto i = beginIndex(names); i < names.size(); ++i)
      57           4 :     _sample_vectors[i] = &declareVector(names[i]);
      58        1813 : }

Generated by: LCOV version 1.11