23 "vectorpostprocessor",
24 "The vectorpostprocessor on whose values we perform a least squares fit");
25 params.
addRequiredParam<std::string>(
"x_name",
"The name of the independent variable");
26 params.
addRequiredParam<std::string>(
"y_name",
"The name of the dependent variable");
27 params.
addRequiredParam<
unsigned int>(
"order",
"The order of the polynomial fit");
31 "Truncate the order of the fitted polynomial if an insufficient number of data points are " 32 "provided. If this is set to false, an error will be generated in that case.");
34 "x_scale", 1.0,
"Value used to scale x values (scaling is done after shifting)");
36 "x_shift", 0.0,
"Value used to shift x values (shifting is done before scaling)");
38 "y_scale", 1.0,
"Value used to scale y values (scaling is done after shifting)");
40 "y_shift", 0.0,
"Value used to shift y values (shifting is done before scaling)");
42 "Performs a polynomial least squares fit on the data contained in " 43 "another VectorPostprocessor and stores the full time history of the coefficients");
45 params.
set<
bool>(
"contains_complete_history") =
true;
53 _vpp_name(getParam<VectorPostprocessorName>(
"vectorpostprocessor")),
54 _order(parameters.
get<unsigned
int>(
"order")),
55 _truncate_order(parameters.
get<bool>(
"truncate_order")),
56 _x_name(getParam<
std::string>(
"x_name")),
57 _y_name(getParam<
std::string>(
"y_name")),
58 _x_values(getVectorPostprocessorValue(
"vectorpostprocessor", _x_name)),
59 _y_values(getVectorPostprocessorValue(
"vectorpostprocessor", _y_name)),
60 _x_scale(parameters.
get<
Real>(
"x_scale")),
61 _x_shift(parameters.
get<
Real>(
"x_shift")),
62 _y_scale(parameters.
get<
Real>(
"y_scale")),
63 _y_shift(parameters.
get<
Real>(
"y_shift"))
66 for (
unsigned int i = 0; i <
_coeffs.size(); ++i)
81 mooseError(
"In LeastSquresFitTimeHistory size of data in x_values and y_values must be equal");
83 mooseError(
"In LeastSquresFitTimeHistory size of data in x_values and y_values must be > 0");
99 mooseAssert(coeffs.size() ==
_coeffs.size(),
100 "Sizes of current coefficients and vector of coefficient vectors must match");
101 for (MooseIndex(coeffs) i = 0; i < coeffs.size(); ++i)
102 _coeffs[i]->push_back(coeffs[i]);
registerMooseObject("MooseApp", LeastSquaresFitHistory)
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
LeastSquaresFitHistory(const InputParameters ¶meters)
Class constructor.
std::vector< VectorPostprocessorValue * > _coeffs
Vector of vectors with the individual coefficients.
const VectorPostprocessorValue & _x_values
The variables with the x, y data to be fit.
const Real _x_scale
Values used to scale and or shift x and y data.
static InputParameters validParams()
const VectorPostprocessorValue & _y_values
virtual void generate()
Generate the fit.
const bool _truncate_order
Whether to truncate the polynomial order if an insufficient number of points is provided.
Least squares polynomial fit.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
std::string stringify(const T &t)
conversion to string
virtual void execute() override
Perform the least squares fit.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
LeastSquaresFitHistory is a VectorPostprocessor that performs a least squares fit on data calculated ...
const unsigned int _order
The order of the polynomial fit to be performed.
const std::vector< Real > & getCoefficients()
Const reference to the vector of coefficients of the least squares fit.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
static InputParameters validParams()
VectorPostprocessorValue * _times
Vector of times.
void ErrorVector unsigned int
virtual void initialize() override
Initialize, clears old results.