www.mooseframework.org
PiecewiseLinear.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 
10 #include "PiecewiseLinear.h"
11 
13 registerMooseObjectRenamed("MooseApp", ADPiecewiseLinear, "02/03/2024 00:00", PiecewiseLinear);
14 
17 {
19  params.addParam<bool>(
20  "extrap", false, "If true, extrapolates when sample point is outside of abscissa range");
21  params.addClassDescription("Linearly interpolates between pairs of x-y data");
22  return params;
23 }
24 
26  : PiecewiseLinearBase(parameters)
27 {
28  if (isRawDataLoaded())
29  {
30  this->buildInterpolation(this->template getParam<bool>("extrap"));
32  }
33 }
34 
35 void
37 {
40  this->buildInterpolation(this->template getParam<bool>("extrap"));
41  else if (!isRawDataLoaded())
42  mooseError("Data has still not been loaded at setup time. Something has gone wrong during "
43  "Function initialization, contact a developer");
44 }
registerMooseObjectRenamed("MooseApp", ADPiecewiseLinear, "02/03/2024 00:00", PiecewiseLinear)
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Function which provides a piecewise continuous linear interpolation of a provided (x...
void initialSetup() override
Needed to process data from user objects that are not available at construction.
static InputParameters validParams()
Base class for functions which provides a piecewise continuous linear interpolation of an (x...
PiecewiseLinear(const InputParameters &parameters)
void initialSetup() override
Needed to load data from user objects that are not available at construction.
void buildInterpolation(const bool extrap=false)
Builds the linear interpolation object from the x/y data.
bool isRawDataLoaded() const
Returns whether the raw data has been loaded already.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
registerMooseObject("MooseApp", PiecewiseLinear)
bool _interpolation_created
Whether the interpolation has been created.