www.mooseframework.org
VectorPostprocessorFunction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 
17 template <>
20 {
22  params.addRequiredRangeCheckedParam<unsigned int>(
23  "component",
24  "component < 3",
25  "Component of the function evaluation point used to sample the VectorPostprocessor");
26  params.addRequiredParam<VectorPostprocessorName>(
27  "vectorpostprocessor_name", "The name of the PointValueSampler that you want to use");
28  params.addRequiredParam<std::string>(
29  "argument_column",
30  "VectorPostprocessor column tabulating the abscissa of the sampled function");
31  params.addRequiredParam<std::string>("value_column",
32  "VectorPostprocessor column tabulating the "
33  "ordinate (function values) of the sampled "
34  "function");
35  return params;
36 }
37 
39  : Function(parameters),
41  _component(parameters.get<unsigned int>("component")),
42  _argument_column(getVectorPostprocessorValue("vectorpostprocessor_name",
43  getParam<std::string>("argument_column"))),
44  _value_column(getVectorPostprocessorValue("vectorpostprocessor_name",
45  getParam<std::string>("value_column")))
46 {
47  try
48  {
49  _linear_interp = libmesh_make_unique<LinearInterpolation>(_argument_column, _value_column);
50  }
51  catch (std::domain_error & e)
52  {
53  mooseError("In VectorPostprocessorFunction ", _name, ": ", e.what());
54  }
55 }
56 
57 Real
58 VectorPostprocessorFunction::value(Real /*t*/, const Point & p)
59 {
60  if (_argument_column.empty())
61  {
62  std::vector<Real> dummy{0};
63  _linear_interp->setData(dummy, dummy);
64  }
65  else
66  {
67  // TODO: figure out a way to only reinitialize the interpolation only once per ...linear
68  // iteration?
70  }
71  return _linear_interp->sample(p(_component));
72 }
virtual Real value(Real, const Point &pt) override
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Base class for function objects.
Definition: Function.h:46
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
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...
const VectorPostprocessorValue & _value_column
const VectorPostprocessorValue & _argument_column
std::unique_ptr< LinearInterpolation > _linear_interp
InputParameters validParams< VectorPostprocessorFunction >()
const std::string & _name
The name of this object, reference to value stored in InputParameters.
Definition: MooseObject.h:114
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
InputParameters validParams< Function >()
Definition: Function.C:19
VectorPostprocessorFunction(const InputParameters &parameters)