Function objects allow you to evaluate analytic expressions based on the spactial location and time .
You can create a custom
Functionobject by inheriting from Function and overriding the virtual
Functions can be accessed in MOOSE objects (BCs, ICs, Materials, etc.) by calling
getFunction("name"), where "name" matches a name from the input file.
MOOSE has several built-in
Each of these types has a "function" parameter which is set in the input file, and controls which
Functionobject is used.
ParsedFunctionobjects are defined by strings directly in the input file, e.g.:
value = 'x*x+sin(y*t)'
Functionobject is added via
addParam(), a default can be provided.
Both constant values and parsed function strings can be used as default.
... // Adding a Function with a default constant params.addParam<FunctionName>("pressure_grad", "0.5", "doc"); // Adding a Function with a default parsed function params.addParam<FunctionName>("power_history", "t+100*sin(y)", "doc"); ...
ConstantFunctionobject is automatically constructed based on the default value if a function name is not supplied in the input file.
Input File Syntax
Functions are declared in the Function block.
ParsedFunctionallows you to provide a string specifying the function.
You can use constants (like
alpha), and define their value.
Common expressions like
After you have declared a
Function, you can use them in objects like
... [Functions] active = 'bc_func' [./bc_func] type = ParsedFunction value = 'sin(alpha*pi*x)' vars = 'alpha' vals = '16' [../]  [BCs] active = 'all' [./all] type = FunctionDirichletBC variable = u boundary = '1 2' function = bc_func [../] 
Example 13: Custom Functions
In Example 13, two functions are created:
ParsedFunctionthat will be used to define a Dirichlet boundary condition
A custom C++
Functionobject that defines a forcing function for the diffusion equation.
Look at Example 13
Further Function Documentation
- Moose App
- Axisymmetric2D3DSolutionFunctionFunction for reading a 2D axisymmetric solution from file and mapping it to a 3D Cartesian model
- CompositeFunctionMultiplies an arbitrary set of functions together
- ImageFunctionFunction with values sampled from a given image stack
- LinearCombinationFunctionReturns the linear combination of the functions
- PiecewiseBilinearInterpolates values from a csv file
- PiecewiseConstantDefines data using a set of x-y data pairs
- PiecewiseLinearLinearly interpolates between pairs of x-y data
- 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.
- Functional Expansion Tools App
- FunctionSeriesThis function uses a convolution of functional series (functional expansion or FX) to create a 1D, 2D, or 3D function
- Navier Stokes App
- WedgeFunctionFunction which computes the exact solution for Jeffery-Hamel flow in a wedge.
- Level Set App
- LevelSetOlssonBubbleImplementation of 'bubble' ranging from 0 to 1.
- LevelSetOlssonVortexA function for creating vortex velocity fields for level set equation benchmark problems.
- Porous Flow App
- MovingPlanarFrontThis function defines the position of a moving front. The front is an infinite plane with normal pointing from start_posn to end_posn. The front's distance from start_posn is defined by 'distance', so if the 'distance' function is time dependent, the front's position will change with time. Roughly speaking, the function returns true_value for points lying in between start_posn and start_posn + distance. Precisely speaking, two planes are constructed, both with normal pointing from start_posn to end_posn. The first plane passes through start_posn; the second plane passes through end_posn. Given a point p and time t, this function returns false_value if ANY of the following are true: (a) t
=deactivation_time; (c) p is 'behind' start_posn (ie, p lies on one side of the start_posn plane and end_posn lies on the other side); (d) p is 'ahead' of the front (ie, p lies one one side of the front and start_posn lies on the other side); (e) the distance between p and the front is greater than active_length. Otherwise, the point is 'in the active zone' and the function returns true_value.
- Moose App