Functions System

Overview

Functions are used to define functions depending only on time and spatial position: . 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.

commentnote:Dependency on Solution Values

Note that there are exceptions to the rule that Functions 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 Functions should override the following member functions

  • Real value(Real, Point) - returning the value of the function at a point in space and time

  • Real value(ADReal, ADPoint) - the AD enabled version of the above function

  • Real 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 time

  • RealVectorValue curl(Real, Point) - returning the curl of the function at a point in space and time

  • Real div(Real, Point) - returning the divergence 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 FunctorAux in their "functor" parameter. This vastly expands the number of objects that can use Functions to compute spatial quantities.

commentnote

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.
  • ParsedVectorFunctionReturns a vector function based on string descriptions 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
  • Level Set App
  • LevelSetOlssonBubbleImplementation of 'bubble' ranging from 0 to 1.
  • LevelSetOlssonPlaneImplementation of a level set function to represent a plane.
  • LevelSetOlssonVortexA function for creating vortex velocity fields for level set equation benchmark problems.
  • Optimization App
  • NearestReporterCoordinatesFunctionThis Function finds the nearest point in the specified vectors of coordinates and returns the values specified in the vector of values at the index of the nearest point. All the vectors must be specified using either vector postprocessors or reporter vectors. This function interpolates linearly in time with transient data.
  • ParameterMeshFunctionOptimization function with parameters represented by a mesh and finite-element shape functions.
  • ParsedOptimizationFunctionFunction used for optimization that uses a parsed expression with parameter dependence.
  • Thermal Hydraulics App
  • CircularAreaHydraulicDiameterFunctionComputes hydraulic diameter for a circular area from its area function
  • CosineHumpFunctionComputes a cosine hump of a user-specified width and height
  • CosineTransitionFunctionComputes a cosine transtition of a user-specified width between two values
  • CubicTransitionFunctionComputes a cubic polynomial transition between two functions
  • GeneralizedCircumferenceComputes a generalized circumference from a function providing the area.
  • PiecewiseFunctionFunction which provides a piecewise representation of arbitrary functions
  • TimeRampFunctionRamps up to a value from another value over time.
  • Phase Field App
  • FourierNoiseGenerate noise from a fourier series
  • Reactor App
  • MultiControlDrumFunctionA function that returns an absorber fraction for multiple control drums application.
  • Stochastic Tools App
  • ScaledAbsDifferenceDRLRewardFunctionEvaluates a scaled absolute difference reward function for a process which is controlled by a Deep Reinforcement Learning based surrogate.
  • 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<activation_time; (b) 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.
  • Fluid Properties App
  • SaturationDensityFunctionComputes saturation density from temperature function
  • SaturationPressureFunctionComputes saturation pressure from temperature function and 2-phase fluid properties object
  • SaturationTemperatureFunctionComputes saturation temperature from pressure function and 2-phase fluid properties object
  • Functional Expansion Tools App
  • FunctionSeriesThis function uses a convolution of functional series (functional expansion or FX) to create a 1D, 2D, or 3D function

Available Actions