20 "File holding data for use with PiecewiseMultiInterpolation. Format: any empty line and any " 22 "beginning with # are ignored, all other lines are assumed to contain relevant information. " 23 "The file must begin with specification of the grid. This is done through lines containing " 24 "the keywords: AXIS X; AXIS Y; AXIS Z; or AXIS T. Immediately following the keyword line " 25 "must be a space-separated line of real numbers which define the grid along the specified " 26 "axis. These data must be monotonically increasing. After all the axes and their grids " 27 "have been specified, there must be a line that is DATA. Following that line, function " 28 "values are given in the correct order (they may be on individual lines, or be " 29 "space-separated on a number of lines). When the function is evaluated, f[i,j,k,l] " 30 "corresponds to the i + j*Ni + k*Ni*Nj + l*Ni*Nj*Nk data value. Here i>=0 corresponding to " 31 "the index along the first AXIS, j>=0 corresponding to the index along the second AXIS, etc, " 32 "and Ni = number of grid points along the first AXIS, etc.");
38 _gridded_data(
std::make_unique<
GriddedData>(getParam<FileName>(
"data_file"))),
39 _dim(_gridded_data->getDim())
45 for (
unsigned int i = 0; i <
_dim; ++i)
46 for (
unsigned int j = 1; j <
_grid[i].size(); ++j)
48 mooseError(
"PiecewiseMultiInterpolation needs monotonically-increasing axis data. Axis ",
50 " contains non-monotonicity at value ",
57 "PiecewiseMultiInterpolation needs the AXES to be independent. Check the AXIS lines in " 70 for (
unsigned int i = 0; i <
_dim; ++i)
73 point_in_grid[i] = p(
_axes[i]);
74 else if (
_axes[i] == 3)
81 PiecewiseMultiInterpolation::pointInGrid<false>(
const Real &,
const Point &)
const;
83 PiecewiseMultiInterpolation::pointInGrid<true>(
const ADReal &,
const ADPoint &)
const;
88 return sample(pointInGrid<false>(t, p));
94 return sample(pointInGrid<true>(t, p));
100 mooseError(
"The AD variant of 'sample' needs to be implemented");
106 unsigned int & lower_x,
107 unsigned int & upper_x)
const 109 int N = in_arr.size();
115 else if (x >= in_arr[
N - 1])
123 std::vector<double>::iterator up = std::lower_bound(in_arr.begin(), in_arr.end(), x);
128 upper_x =
static_cast<unsigned int>(std::distance(in_arr.begin(), up));
129 if (in_arr[upper_x] == x)
132 lower_x = upper_x - 1;
Container for holding a function defined on a grid of arbitrary dimension.
Base class for function objects.
static InputParameters validParams()
Create new PiecewiseMultiInterpolation object.
std::unique_ptr< GriddedData > _gridded_data
object to provide function evaluations at points on the grid
std::vector< std::vector< Real > > _grid
the grid
Moose::GenericType< GridPoint, is_ad > pointInGrid(const Moose::GenericType< Real, is_ad > &t, const Moose::GenericType< Point, is_ad > &p) const
convert cartesian+time coordinates into grid coordinates
DualNumber< Real, DNDerivativeType, true > ADReal
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
Utility class template for a semidynamic vector with a maximum size N and a chosen dynamic size...
void getNeighborIndices(std::vector< Real > in_arr, Real x, unsigned int &lower_x, unsigned int &upper_x) const
Operates on monotonically increasing in_arr.
std::vector< int > _axes
_axes specifies how to embed the grid into the MOOSE coordinate frame if _axes[i] = 0 then the i_th a...
virtual ~PiecewiseMultiInterpolation()
unsigned int _dim
dimension of the grid
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
PiecewiseMultiInterpolation(const InputParameters ¶meters)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual Real value(Real t, const Point &pt) const override
Given t and p, return the interpolated value.
virtual Real sample(const GridPoint &pt) const =0
This does the core work.
static InputParameters validParams()
Class constructor.