https://mooseframework.inl.gov
VectorPostprocessorSampler.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
12 registerMooseObject("StochasticToolsApp", VectorPostprocessorSampler);
13 
16 {
18 
19  params.addRequiredParam<std::vector<ReporterName>>(
20  "vectors_names",
21  "The names of the vector-postprocessors and/or vector reporter values containing the column "
22  "data.");
23 
24  params.addClassDescription("The sampler uses vector postprocessors as inputs.");
25  return params;
26 }
27 
29  : Sampler(parameters)
30 {
31  for (auto & vpp_vec : getParam<std::vector<ReporterName>>("vectors_names"))
32  _data.emplace_back(&getReporterValueByName<std::vector<Real>>(vpp_vec));
33 
34  // set a non-zero value for number of rows to avoid error in rankConfig, the actual value will be
35  // set in executableSetup() and update via reinit()
36  setNumberOfRows(1);
37  setNumberOfCols(_data.size());
38 }
39 
40 void
42 {
43  const auto vsize = _data[0]->size();
44  for (const auto & vec : _data)
45  if (vec->size() != vsize)
46  paramError("vector_names", "Vectors must all be the same size.");
47 
48  setNumberOfRows(vsize);
49 }
50 
51 Real
53 {
54  // Checks to make sure that the row and column indices are not out of bounds
55  mooseAssert(row_index < _data[0]->size(), "row_index cannot be out of bounds of the data.");
56  mooseAssert(col_index < _data.size(), "col_index cannot be out of bounds of the data.");
57 
58  // Entering samples into the matrix
59  return (*_data[col_index])[row_index];
60 }
VectorPostprocessorSampler(const InputParameters &parameters)
void setNumberOfRows(dof_id_type n_rows)
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
const T & getParam(const std::string &name) const
const T & getReporterValueByName(const ReporterName &reporter_name, const std::size_t time_index=0)
std::vector< const std::vector< Real > * > _data
Storage of VPP data.
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Return the sample for the given row and column.
void executeSetUp() override
Set the number of rows and columns after postprocessor data is filled.
registerMooseObject("StochasticToolsApp", VectorPostprocessorSampler)
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void setNumberOfCols(dof_id_type n_cols)
void addClassDescription(const std::string &doc_string)
uint8_t dof_id_type