https://mooseframework.inl.gov
GFunction.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 
10 #include "GFunction.h"
11 #include "Sampler.h"
12 
13 registerMooseObject("StochasticToolsTestApp", GFunction);
14 
17 {
19 
20  params.addRequiredParam<std::vector<Real>>("q_vector", "q values for g-function");
21  params.addRequiredParam<SamplerName>(
22  "sampler", "The Sampler object to use to perform g-function evaluations.");
23  return params;
24 }
25 
27  : GeneralVectorPostprocessor(parameters),
28  _sampler(getSampler("sampler")),
29  _q_vector(getParam<std::vector<Real>>("q_vector")),
30  _values(declareVector("g_values"))
31 {
32  if (_q_vector.size() != _sampler.getNumberOfCols())
33  paramError("q_vector", "The 'q_vector' size must match the number of columns in the Sampler.");
34  for (const auto & q : _q_vector)
35  if (q < 0)
36  paramError("q_vector", "The 'q_vector' entries must be zero or positive.");
37 }
38 
39 void
41 {
44  {
45  std::vector<Real> x = _sampler.getNextLocalRow();
46  Real y = 1;
47  for (std::size_t i = 0; i < _q_vector.size(); ++i)
48  y *= (std::abs(4 * x[i] - 2) + _q_vector[i]) / (1 + _q_vector[i]);
49  _values.push_back(y);
50  }
51 }
52 
53 void
55 {
56  if (_parallel_type == "REPLICATED")
58 }
const std::vector< Real > & _q_vector
Definition: GFunction.h:25
const MooseEnum & _parallel_type
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
std::vector< Real > getNextLocalRow()
dof_id_type getLocalRowBegin() const
const std::vector< double > y
const Parallel::Communicator & _communicator
dof_id_type getNumberOfLocalRows() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
const std::vector< double > x
virtual void finalize() override
Definition: GFunction.C:54
VectorPostprocessorValue & _values
Definition: GFunction.h:26
void paramError(const std::string &param, Args... args) const
dof_id_type getLocalRowEnd() const
GFunction(const InputParameters &parameters)
Definition: GFunction.C:26
virtual void execute() override
Definition: GFunction.C:40
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
Definition: GFunction.C:16
registerMooseObject("StochasticToolsTestApp", GFunction)
Sampler & _sampler
Definition: GFunction.h:24
dof_id_type getNumberOfCols() const
uint8_t dof_id_type