https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PiecewiseLinearFromVectorPostprocessor.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 "FEProblemBase.h"
12
15 VectorPostprocessorFunction,
16 "02/03/2024 00:00",
18
21{
23 params.addRequiredParam<VectorPostprocessorName>(
24 "vectorpostprocessor_name", "The name of the VectorPostprocessor 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 params.addParam<bool>(
33 "parallel_sync",
34 true,
35 "Whether or not this Function should be synced to all processors when running in parallel.");
36
37 MooseEnum component("x=0 y=1 z=2 time=3", "time");
38 params.addParam<MooseEnum>(
39 "component",
40 component,
41 "Component of the function evaluation point used to sample the VectorPostprocessor");
42
44 "Provides piecewise linear interpolation of from two columns of a VectorPostprocessor");
45
46 return params;
47}
48
50 const InputParameters & parameters)
51 : Function(parameters),
53 _argument_column(getVectorPostprocessorValue("vectorpostprocessor_name",
54 getParam<std::string>("argument_column"),
55 getParam<bool>("parallel_sync"))),
56 _value_column(getVectorPostprocessorValue("vectorpostprocessor_name",
57 getParam<std::string>("value_column"),
58 getParam<bool>("parallel_sync"))),
59 _component(getParam<MooseEnum>("component")),
60 _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
61 _last_update(
62 {std::numeric_limits<Real>::lowest(), libMesh::invalid_uint, libMesh::invalid_uint})
63{
64 try
65 {
66 _linear_interp = std::make_unique<LinearInterpolation>(_argument_column, _value_column);
67 }
68 catch (std::domain_error & e)
69 {
70 mooseError("In PiecewiseLinearFromVectorPostprocessor ", _name, ": ", e.what());
71 }
72}
73
74Real
76{
77 return valueInternal(t, p);
78}
79
82{
83 return valueInternal(t, p);
84}
85
86template <typename T, typename P>
87T
89{
90 if (_argument_column.empty())
91 return 0.0;
92
93 const std::tuple<Real, unsigned int, unsigned int> now = {
96 _fe_problem.nLinearIterations(/*nl_sys=*/0)};
97
98 if (now != _last_update)
99 {
101 _last_update = now;
102 }
103
104 const T x = _component == 3 ? t : p(_component);
105 return _linear_interp->sample(x);
106}
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", PiecewiseLinearFromVectorPostprocessor)
registerMooseObjectRenamed("MooseApp", VectorPostprocessorFunction, "02/03/2024 00:00", PiecewiseLinearFromVectorPostprocessor)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const override
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const override
Base class for function objects.
Definition Function.h:30
static InputParameters validParams()
Class constructor.
Definition Function.C:16
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Function which provides a piecewise continuous linear interpolation of a data set provided as two col...
PiecewiseLinearFromVectorPostprocessor(const InputParameters &parameters)
std::tuple< Real, unsigned int, unsigned int > _last_update
last iteration during which the linear interpolation was rebuilt
FEProblemBase & _fe_problem
used to get the current linear/non-linear iteration number
virtual Real value(Real t, const Point &p) const override
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero,...
auto raw_value(const Eigen::Map< T > &in)
const unsigned int invalid_uint
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real