22 "vectorpostprocessor",
23 "The vectorpostprocessor on whose values we perform a least squares fit");
24 params.
addRequiredParam<std::string>(
"x_name",
"The name of the independent variable");
25 params.
addRequiredParam<std::string>(
"y_name",
"The name of the dependent variable");
26 params.
addRequiredParam<
unsigned int>(
"order",
"The order of the polynomial fit");
30 "Truncate the order of the fitted polynomial if an insufficient number of data points are " 31 "provided. If this is set to false, an error will be generated in that case.");
32 params.
addParam<
unsigned int>(
"num_samples",
"The number of samples to be output");
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)");
41 params.
addParam<
Real>(
"sample_x_min",
"The minimum x value of the of samples to be output");
42 params.
addParam<
Real>(
"sample_x_max",
"The maximum x value of the of samples to be output");
43 MooseEnum output_type(
"Coefficients Samples",
"Coefficients");
45 "output", output_type,
"The quantity to output. Options are: " + output_type.
getRawNames());
46 params.
addClassDescription(
"Performs a polynomial least squares fit on the data contained in " 47 "another VectorPostprocessor");
54 _vpp_name(getParam<VectorPostprocessorName>(
"vectorpostprocessor")),
55 _order(parameters.
get<unsigned
int>(
"order")),
56 _truncate_order(parameters.
get<bool>(
"truncate_order")),
57 _x_name(getParam<
std::string>(
"x_name")),
58 _y_name(getParam<
std::string>(
"y_name")),
59 _x_values(getVectorPostprocessorValue(
"vectorpostprocessor", _x_name)),
60 _y_values(getVectorPostprocessorValue(
"vectorpostprocessor", _y_name)),
61 _output_type(getParam<
MooseEnum>(
"output")),
63 _x_scale(parameters.
get<
Real>(
"x_scale")),
64 _x_shift(parameters.
get<
Real>(
"x_shift")),
65 _y_scale(parameters.
get<
Real>(
"y_scale")),
66 _y_shift(parameters.
get<
Real>(
"y_shift")),
67 _have_sample_x_min(isParamValid(
"sample_x_min")),
68 _have_sample_x_max(isParamValid(
"sample_x_max")),
78 mooseError(
"In LeastSquaresFit num_samples parameter must be provided with output=Samples");
91 mooseWarning(
"In LeastSquaresFit num_samples parameter is unused with output=Coefficients");
120 mooseError(
"Size of data in x_values and y_values must be equal");
122 mooseError(
"Size of data in x_values and y_values must be > 0");
143 x_min = *(std::min_element(x_values.begin(), x_values.end()));
149 x_max = *(std::max_element(x_values.begin(), x_values.end()));
151 Real x_span = x_max - x_min;
const std::string _x_name
The name of the variables storing the x, y data.
const bool _truncate_order
Whether to truncate the polynomial order if an insufficient number of points is provided.
VectorPostprocessorValue * _sample_x
The variables used to write out samples of the least squares fit.
const VectorPostprocessorValue & _x_values
The variables with the x, y data to be fit.
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...
const VectorPostprocessorValue & _y_values
virtual Real sample(Real x) override
This function will take an independent variable input and will return the dependent variable based on...
VectorPostprocessorValue * _sample_y
unsigned int _num_samples
The number of samples to be taken.
std::string getRawNames() const
Method for returning the raw name strings for this instance.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
LeastSquaresFit(const InputParameters ¶meters)
Class constructor.
registerMooseObject("MooseApp", LeastSquaresFit)
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
virtual void initialize() override
Initialize, clears old results.
const std::string _y_name
const MooseEnum _output_type
The type of output.
bool _have_sample_x_min
Did the user specify the min and max x values for sampling?
static InputParameters validParams()
const Real _x_scale
Values used to scale and or shift x and y data.
Real _sample_x_min
The min and max x values for sampling.
virtual void generate()
Generate the fit.
LeastSquaresFit is a VectorPostprocessor that performs a least squares fit on data calculated in anot...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Least squares polynomial fit.
virtual void execute() override
Perform the least squares fit.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
const unsigned int _order
The order of the polynomial fit to be performed.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
const std::vector< Real > & getCoefficients()
Const reference to the vector of coefficients of the least squares fit.
VectorPostprocessorValue * _coeffs
The variable used to write out the coefficients of the fit.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void ErrorVector unsigned int