www.mooseframework.org
VectorPostprocessorFunction.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 
14 template <>
17 {
19  params.addRequiredRangeCheckedParam<unsigned int>(
20  "component",
21  "component < 3",
22  "Component of the function evaluation point used to sample the VectorPostprocessor");
23  params.addRequiredParam<VectorPostprocessorName>(
24  "vectorpostprocessor_name", "The name of the PointValueSampler that you want to use");
25  params.addRequiredParam<std::string>(
26  "argument_column",
27  "VectorPostprocessor column tabulating the abscissa of the sampled function");
28  params.addRequiredParam<std::string>("value_column",
29  "VectorPostprocessor column tabulating the "
30  "ordinate (function values) of the sampled "
31  "function");
32  return params;
33 }
34 
36  : Function(parameters),
38  _component(parameters.get<unsigned int>("component")),
39  _argument_column(getVectorPostprocessorValue("vectorpostprocessor_name",
40  getParam<std::string>("argument_column"))),
41  _value_column(getVectorPostprocessorValue("vectorpostprocessor_name",
42  getParam<std::string>("value_column")))
43 {
44  try
45  {
46  _linear_interp = libmesh_make_unique<LinearInterpolation>(_argument_column, _value_column);
47  }
48  catch (std::domain_error & e)
49  {
50  mooseError("In VectorPostprocessorFunction ", _name, ": ", e.what());
51  }
52 }
53 
54 Real
55 VectorPostprocessorFunction::value(Real /*t*/, const Point & p)
56 {
57  if (_argument_column.empty())
58  {
59  std::vector<Real> dummy{0};
60  _linear_interp->setData(dummy, dummy);
61  }
62  else
63  {
64  // TODO: figure out a way to only reinitialize the interpolation only once per ...linear
65  // iteration?
67  }
68  return _linear_interp->sample(p(_component));
69 }
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...
Function which provides a piecewise continuous linear interpolation of a data set provided as two col...
Base class for function objects.
Definition: Function.h:40
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 mooseError(Args &&... args) const
Definition: MooseObject.h:147
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
registerMooseObject("MooseApp", VectorPostprocessorFunction)
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:183
InputParameters validParams< Function >()
Definition: Function.C:14
VectorPostprocessorFunction(const InputParameters &parameters)