https://mooseframework.inl.gov
FunctionValuePostprocessor.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 #include "Function.h"
12 
14 
17 {
19  params.addRequiredParam<FunctionName>("function",
20  "The function which supplies the postprocessor value.");
21 
22  params.addParam<std::vector<PostprocessorName>>(
23  "point",
24  "A set of three PostprocessorNames or constant values (or any mixture thereof) that will be "
25  "passed to the function in the space argument");
26 
27  params.addParam<Real>("scale_factor", 1, "A scale factor to be applied to the function");
28  params.addParam<std::vector<PostprocessorName>>(
29  "indirect_dependencies",
30  {},
31  "If the evaluated function depends on other postprocessors they must be listed here to "
32  "ensure proper dependency resolution");
33 
34  params.addParam<PostprocessorName>("time",
35  "The PostprocessorName or constant value that will be passed "
36  "to the function in the time argument.");
37  params.declareControllable("scale_factor");
38  params.addClassDescription(
39  "Computes the value of a supplied function at a single point (scalable)");
40  return params;
41 }
42 
44  : GeneralPostprocessor(parameters),
45  _function(getFunction("function")),
46  _scale_factor(getParam<Real>("scale_factor")),
47  _has_space_pp(isParamValid("point")),
48  _time_pp(nullptr)
49 {
50  if (isParamValid("time"))
52 
53  if (_has_space_pp)
54  {
55  if (coupledPostprocessors("point") != 3)
56  paramError("point", "Size must be 3");
57  _point.resize(3);
58  for (unsigned int j = 0; j < 3; ++j)
59  _point[j] = &getPostprocessorValue("point", j);
60  }
61 
62  const auto & indirect_dependencies =
63  getParam<std::vector<PostprocessorName>>("indirect_dependencies");
64  _depend_uo.insert(indirect_dependencies.begin(), indirect_dependencies.end());
65 }
66 
67 void
69 {
70 }
71 
72 void
74 {
75 }
76 
79 {
80  Point p;
81  if (_has_space_pp)
82  for (unsigned int j = 0; j < 3; ++j)
83  p(j) = *_point[j];
84  if (_time_pp)
85  return _scale_factor * _function.value(*_time_pp, p);
86  return _scale_factor * _function.value(_t, p);
87 }
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 ...
Definition: MooseBase.h:467
virtual PostprocessorValue getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
registerMooseObject("MooseApp", FunctionValuePostprocessor)
FunctionValuePostprocessor(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::set< std::string > _depend_uo
Depend UserObjects that to be used both for determining user object sorting and by AuxKernel for find...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
const PostprocessorValue & getPostprocessorValue(const std::string &param_name, const unsigned int index=0) const
doco-normal-methods-begin Retrieve the value of a Postprocessor or one of it&#39;s old or older values ...
const PostprocessorValue * _time_pp
a postprocessor that is passed to the time argument of _function (if provided)
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...
This postprocessor displays a single value which is supplied by a MooseFunction.
static InputParameters validParams()
static InputParameters validParams()
virtual void execute() override
Execute method.
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:230
std::vector< const PostprocessorValue * > _point
a vector of postprocessor values that are passed into the space argument of _function (if provided) ...
bool _has_space_pp
true of space postprocessors have been provided
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 optional parameter and a documentation string to the InputParameters object...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:209
std::size_t coupledPostprocessors(const std::string &param_name) const
Returns number of Postprocessors coupled under parameter name.
const Real & _scale_factor
a scale factor to scale the result of _function
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:30
const Function & _function
the function that will be evaluated and returned as pp value
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.