Functions System
Overview
Function
s are used to define functions depending only on spatial position and time: . These objects can serve a wide variety of purposes, including (but not limited to) the following:
defining initial conditions,
defining residual contributions (sources, boundary conditions, etc.), and
defining post-processing quantities.
Note that there are exceptions to the rule that Function
s only depend on space and time; for example, ParsedFunction may depend on post-processor values (which may depend on the solution) and scalar variable values.
Moose Function
s should override the following member functions
Real value(Real, Point)
- returning the value of the function at a point in space and timeReal value(ADReal, ADPoint)
- the AD enabled version of the above functionReal timeDerivative(Real, Point)
- retuning the derivative of the function with respect to the first argument (time)RealVectorValue gradient(Real, Point)
- the spatial derivative with respect to the second argument
For vector valued functions
RealVectorValue vectorValue(Real, Point)
- returning a vector value at a point in space and timeRealVectorValue vectorCurl(Real, Point)
- returning the curl of the function at a point in space and time
can be overridden. The optional Real integral()
and Real average()
methods can also be overridden. Note that two overloads exist for the value()
member function. This enables evaluation of functions with dual numbers. As most legacy function do not implement an AD overload of the value()
function, the Function
base class automatically provides one that uses the non-AD value()
, timeDerivative()
, and gradient()
member functions to construct an AD result. Check out PiecewiseBilinear
to see how to update a function to support AD by using a templated valueInternal()
function with virtual value()
forwarders.
Functions as Functors
Functions are Functors. Functors are an abstraction, a base class, for objects that can compute values at a location in space and time.
As Functors
, they may be specified to objects such as the FunctorElementalAux in their "functor" parameter. This vastly expands the number of objects that can use Functions
to compute spatial quantities.
When making a new object using Functions
to contribute back to MOOSE, we ask that you consider using Functors instead to naturally enable its use with variables and functor material properties.
Available Objects
- Moose App
- ADParsedFunctionFunction created by parsing a string
- ADPiecewiseLinearLinearly interpolates between pairs of x-y data
- Axisymmetric2D3DSolutionFunctionFunction for reading a 2D axisymmetric solution from file and mapping it to a 3D Cartesian model
- BicubicSplineFunctionDefine a bicubic spline function from interpolated data defined by input parameters.
- CoarsenedPiecewiseLinearPerform a point reduction of the tabulated data upon initialization, then evaluate using a linear interpolation.
- CompositeFunctionMultiplies an arbitrary set of functions together
- ConstantFunctionA function that returns a constant value as defined by an input parameter.
- ImageFunctionFunction with values sampled from an image or image stack.
- LinearCombinationFunctionReturns the linear combination of the functions
- ParsedFunctionFunction created by parsing a string
- ParsedGradFunctionDefines a function and its gradient using input file parameters.
- ParsedVectorFunctionReturn a vector component values based on string functions for each component.
- PeriodicFunctionProvides a periodic function by repeating a user-supplied base function in time and/or any of the three Cartesian coordinate directions
- PiecewiseBilinearInterpolates values from a csv file
- PiecewiseConstantDefines data using a set of x-y data pairs
- PiecewiseConstantFromCSVUses data read from CSV to assign values
- PiecewiseLinearLinearly interpolates between pairs of x-y data
- PiecewiseLinearFromVectorPostprocessorProvides piecewise linear interpolation of from two columns of a VectorPostprocessor
- PiecewiseMulticonstantPiecewiseMulticonstant performs constant interpolation on 1D, 2D, 3D or 4D data. The data_file specifies the axes directions and the function values. If a point lies outside the data range, the appropriate end value is used.
- PiecewiseMultilinearPiecewiseMultilinear performs linear interpolation on 1D, 2D, 3D or 4D data. The data_file specifies the axes directions and the function values. If a point lies outside the data range, the appropriate end value is used.
- SolutionFunctionFunction for reading a solution from file.
- SplineFunctionDefine a spline function from interpolated data defined by input parameters.
- VectorPostprocessorFunctionProvides piecewise linear interpolation of from two columns of a VectorPostprocessor
- Ferret App
- S3DFourierNoiseGenerate noise from a fourier series
- SDFourierNoiseGenerate noise from a fourier series
- Phase Field App
- FourierNoiseGenerate noise from a fourier series
Available Actions
- Moose App
- AddFunctionActionAdd a Function object to the simulation.