www.mooseframework.org
ConstantVectorPostprocessor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
13 
16 {
18  params.addClassDescription(
19  "Populate constant VectorPostprocessorValue directly from input file.");
20  params.addParam<std::vector<std::string>>("vector_names",
21  std::vector<std::string>(1, "value"),
22  "Names of the column vectors in this object");
23  params.addRequiredParam<std::vector<std::vector<Real>>>(
24  "value",
25  "Vector values this object will have. Leading dimension must be equal to leading dimension "
26  "of vector_names parameter.");
27 
28  return params;
29 }
30 
32  : GeneralVectorPostprocessor(parameters)
33 {
34  std::vector<std::string> names = getParam<std::vector<std::string>>("vector_names");
35  unsigned int nvec = names.size();
36 
37  _value.resize(nvec);
38  for (unsigned int j = 0; j < nvec; ++j)
39  _value[j] = &declareVector(names[j]);
40 
41  std::vector<std::vector<Real>> v = getParam<std::vector<std::vector<Real>>>("value");
42  if (v.size() != nvec)
43  paramError("value",
44  "Leading dimension must be equal to leading dimension of vector_names parameter.");
45 
46  if (processor_id() == 0)
47  {
48  for (unsigned int j = 0; j < nvec; ++j)
49  {
50  unsigned int ne = v[j].size();
51  _value[j]->resize(ne);
52  for (unsigned int l = 0; l < ne; ++l)
53  (*_value[j])[l] = v[j][l];
54  }
55  }
56 }
57 
58 void
60 {
61 }
62 
63 void
65 {
66 }
static InputParameters validParams()
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual void execute() override
Execute method.
static InputParameters validParams()
std::vector< VectorPostprocessorValue * > _value
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
registerMooseObject("MooseApp", ConstantVectorPostprocessor)
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
ConstantVectorPostprocessor(const InputParameters &parameters)
processor_id_type processor_id() const