https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PiecewiseMulticonstant.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 "GriddedData.h"
12
14registerMooseObjectAliased("MooseApp", PiecewiseMulticonstant, "PiecewiseMultiConstant");
15
18{
20
21 MultiMooseEnum direction("left=0 right=1");
23 "direction", direction, "Direction to look to find value for each interpolation dimension.");
24
26 "PiecewiseMulticonstant performs constant interpolation on 1D, 2D, 3D or 4D "
27 "data. The data_file specifies the axes directions and the function "
28 "values. If a point lies outside the data range, the appropriate end "
29 "value is used.");
30 return params;
31}
32
34 : PiecewiseMultiInterpolation(parameters), _direction(getParam<MultiMooseEnum>("direction"))
35{
36 if (_direction.size() != _dim)
37 mooseError("Parameter direction must have a size identical to ", _dim);
38}
39
41PiecewiseMulticonstant::value(const ADReal & t, const ADPoint & p) const
42{
43 // piecewise constant derivatives are zero everywhere (ignore discontinuities)
45}
46
47Real
49{
50 GridIndex left(_dim);
51 GridIndex right(_dim);
52 GridIndex arg(_dim);
53 for (unsigned int i = 0; i < _dim; ++i)
54 {
55 getNeighborIndices(_grid[i], pt[i], left[i], right[i]);
56 if (_direction.get(i) == 0)
57 arg[i] = left[i];
58 else
59 arg[i] = right[i];
60 }
61
62 // return the point
63 return _gridded_data->evaluateFcn(arg);
64}
65
66RealGradient
67PiecewiseMulticonstant::gradient(Real, const Point &) const
68{
69 return 0.0;
70}
71
72Real
74{
75 return 0.0;
76}
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", PiecewiseMulticonstant)
registerMooseObjectAliased("MooseApp", PiecewiseMulticonstant, "PiecewiseMultiConstant")
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 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.
unsigned int get(unsigned int i) const
Indexing operator Operator to retrieve the id of an item from the MultiMooseEnum.
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
Uses GriddedData to define data on a grid, and does linear interpolation on that data to provide func...
std::unique_ptr< GriddedData > _gridded_data
object to provide function evaluations at points on the grid
static InputParameters validParams()
Create new PiecewiseMultiInterpolation object.
std::vector< std::vector< Real > > _grid
the grid
unsigned int _dim
dimension of the grid
void getNeighborIndices(std::vector< Real > in_arr, Real x, unsigned int &lower_x, unsigned int &upper_x) const
Operates on monotonically increasing in_arr.
Uses GriddedData to define data on a grid, and does linear interpolation on that data to provide func...
MultiMooseEnum _direction
direction where to look for value if interpolation order is constant
PiecewiseMulticonstant(const InputParameters &parameters)
virtual Real timeDerivative(Real t, const Point &p) const override
Get the time derivative of the function.
virtual ADReal value(const ADReal &t, const ADPoint &p) const override
Override this to evaluate the scalar function at point (t,x,y,z), using dual numbers by default this ...
static InputParameters validParams()
virtual Real sample(const GridPoint &pt) const override
This does the core work.
virtual RealGradient gradient(Real t, const Point &p) const override
Function objects can optionally provide a gradient at a point.
auto raw_value(const Eigen::Map< T > &in)