# Functional Expansion Tools

A MOOSE module for continuous, mesh-agnostic, high-fidelity, reduced-data MultiApp coupling

## Description

Functional expansions (FXs) are a methodology that represent information as moments of a functional series (Flusser et al., 2016). This is is related to a Fourier series representation of cyclic data. Moments are generated via numerical integration for each term in the functional series to represent the field of interest. These moments can then be used to reconstruct the field in a separate app (Wendt et al., 2018; Wendt and Kerby, 2017; Kerby et al., 2017).

Currently there are two main flavors of FX coupling available: interface and volumetric.

note:Nomenclature

In other contexts FXs have been identified using the initialism 'FE'. However, since MOOSE is a finite-element (FE) code, the initialism 'FX' is used throughout this module to prevent confusion.

warning:Displaced meshes

This module should only be used with non-displaced meshes.

### Interface Coupling

Interface-based coupling provides for the coupling between physically distinct solutions that share a common interface. FXs can be used to extract value and/or flux conditions at a boundary in one app, then be transferred as boundary conditions to the coupled app. These coupled boundaries represent the common interface between the two solutions.

### Volumetric Coupling

Volumetric-based coupling provides for coupling between solutions that share the same space with coupled yet separate physics. The field in one app can be collapsed into an FX, then the moment values are transferred to the other app to be used in its solution.

## Using this module

Set either FUNCTIONAL_EXPANSION_TOOLS := yes (or ALL_MODULES := yes) in the application makefile. The following objects will then be available for use:

### AuxKernels

NameDescription
FunctionSeriesToAuxExpands an FX into the named AuxVariable before the initial nonlinear solve.

### BCs

NameDescription
FXFluxBCProvides a strongly encouraged FX-based Neumann boundary condition.
FXValueBCProvides a fixed FX-based Dirichlet boundary condition.
FXValuePenaltyBCProvides a strongly encouraged FX-based Dirichlet boundary condition.

### Functions

NameDescription
FunctionSeriesThe workhorse of the FX tools module. This evaluates the terms of a function series, used both for capturing moments and expanding an FX. All other FX-based objects will depend on a FunctionSeries instance.

### Kernels

Although there are no kernels directly provided by this module (yet), these three from the framework itself have varying degrees of usefulness:

NameDescription
BodyForceMay be used to couple a FunctionSeries object directly to a solution, instead of using FunctionSeriesToAux and CoupledForce. If the BodyForce approach is used it is highly recommended to set enable_cache = true for the associated FunctionSeries object.
CoupledForceCouples an AuxVariable or Variable to the solution of another Variable. Useful in conjunction with FunctionSeriesToAux.
NullKernelMay be required for use in situation where no Variables or Kernels are needed. This may occur, for example, in an app that uses only the recommended FunctionSeriesToAux+CoupledForce approach.

### Transfers

NameDescription
MultiAppFXTransferThis transfers the FX coefficients, or moments, between named FX objects in the multi and sub apps. Supported objects that contain coefficients for transferring are instances of FunctionSeries and any FX...UserObject.

### UserObjects

NameDescription
FXBoundaryFluxUserObjectCaptures the moments of an FX representing the flux at a boundary.
FXBoundaryValueUserObjectCaptures the moments of an FX representing the value at a boundary.
FXVolumeUserObjectCaptures the moments of an FX representing the field value over a volume.

## Examples

Please refer to the examples included with the module for how these objects can be used.

## Supported Functional Series

This module currently supports FXs based on the 1D Legendre and 2D Zernike polynomial series. From these can be constructed 1D, 2D, or 3D Cartesian basis sets (Legendre only), or 3D cylindrical (Legendre + Zernike) basis sets. Nonseparable series, i.e. with fully-convolved cross terms, are used in this implementation. Examples for selecting FXs are shown in FunctionSeries.

Additional functional series, polynomial or otherwise, can be added by inheriting from the SingleSeriesBasisInterface class (found in the utils/ folder). The composite series (currently the Cartesian and CylindricalDuo classes) will then need updated to support the newly-available series.

Additional composite series, such as may be suitable for spherical or shell data, can be implemented by inheriting from the CompositeSeriesBasisInterface. The FunctionSeries class will need updated to support the newly-available series.

## Caveats

1. FXs are not recommended for spanning spaces with discontinuities (Ellis, 2017). - One example would be a space containing two distinct materials with significantly different properties - Instead, using multiple FXs, each over its own region of continuity, is the recommended approach

2. Increasing the order of an FX does not always result in an improved representation. Numerical integration of the FX moment can yield large errors if not enough quadrature points are included (Griesheimer, 2005).

## References

1. Matthew Shawn Ellis. Methods for Including Multiphysics Feedback in Monte Carlo Reactor Physics Calculations. PhD thesis, Massachusetts Institute of Technology, 2017.[BibTeX]
2. Jan Flusser, Tomáš Suk, and Barbara Zitová. 2D & 3D image analysis by moments. John Wiley & Sons, Inc., 2016. ISBN 1119039355.[BibTeX]
3. David Patrick Griesheimer. Functional Expansion Tallies for Monte Carlo Simulations. PhD thesis, University of Michigan, 2005.[BibTeX]
4. Leslie Kerby, Aaron G Tumulak, Jaakko Leppänen, and Ville Valtavirta. Preliminary Serpent—MOOSE Coupling and Implementation of Functional Expansion Tallies in Serpent. In International Conference on Mathematics & Computational Methods Applied to Nuclear Science and Engineering (M&C 2017). 2017.[BibTeX]
5. Brycen Wendt and Leslie Kerby. Multiapp transfers in the moose framework based on functional expansions. Transactions of the American Nuclear Society, 117(1):735–738, October 2017.[BibTeX]
6. Brycen Wendt, April Novak, Leslie Kerby, and Paul Romano. Integration of functional expansion methodologies as a moose module. In PHYSOR 2018: Reactor Physics paving the way towards more efficient systems. April 2018.[BibTeX]

## TODO

• Investigate the implementation of using NearestPointBase approach to easily equip multiple FXs

• Implement a Materials-derived FX-based class that can provide continuous material properties

• Implement a Kernel-derived class, a la BodyForce, that automatically sets enable_cache = true for the associated FunctionSeries object

• Add an error check in MultiAppFXTransfer for multiple objects of the same name but different type, i.e. if there are both a Function and UserObject with the same name (or other object types as they are added)

• Implement support in MutableCoefficientsInterface for multiple sets of FX coefficients

• Implement support for various types of FX derivations - Separable series - Various orthonormalizations

• Add more functional series - Fourier - Annular Zernike (0 < r <= 1) - Shell (r = 1) for 3D cylindrical boundary conditions (Zernike-based?) - Spherical harmonics + spherical composite series

• Add check to ensure we are working in an undisplaced mesh context

## BCs

• Moose App
• ConvectiveFluxBCDetermines boundary values via the initial and final values, flux, and exposure duration
• DGFunctionDiffusionDirichletBC
• DiffusionFluxBCComputes a boundary residual contribution consistent with the Diffusion Kernel. Does not impose a boundary condition; instead computes the boundary contribution corresponding to the current value of grad(u) and accumulates it in the residual vector.
• DirichletBCImposes the essential boundary condition , where is a constant, controllable value.
• EigenDirichletBCDirichlet BC for eigenvalue solvers
• FunctionDirichletBCImposes the essential boundary condition , where is a (possibly) time and space-dependent MOOSE Function.
• FunctionNeumannBCImposes the integrated boundary condition , where is a (possibly) time and space-dependent MOOSE Function.
• FunctionPenaltyDirichletBC
• FunctionPresetBCThe same as FunctionDirichletBC except the value is applied before the solve begins
• LagrangeVecDirichletBCImposes the essential boundary condition , where are constant, controllable values.
• LagrangeVecFunctionDirichletBCImposes the essential boundary condition , where components are calculated with functions.
• MatchedValueBCImplements a NodalBC which equates two different Variables' values on a specified boundary.
• NeumannBCImposes the integrated boundary condition , where is a constant, controllable value.
• OneDEqualValueConstraintBC
• PenaltyDirichletBCEnforces a Dirichlet boundary condition in a weak sense by penalizing differences between the current solution and the Dirichlet data.
• PostprocessorDirichletBC
• PostprocessorNeumannBC
• PresetBCSimilar to DirichletBC except the value is applied before the solve begins
• SinDirichletBCImposes a time-varying essential boundary condition , where varies from an given initial value at time to a given final value over a specified duration.
• SinNeumannBCImposes a time-varying flux boundary condition , where varies from an given initial value at time to a given final value over a specified duration.
• VacuumBC
• VectorNeumannBCImposes the integrated boundary condition , where is a user-defined, constant vector.
• WeakGradientBCComputes a boundary residual contribution consistent with the Diffusion Kernel. Does not impose a boundary condition; instead computes the boundary contribution corresponding to the current value of grad(u) and accumulates it in the residual vector.
• Periodic
• Rdg App
• AEFVBCA boundary condition kernel for the advection equation using a cell-centered finite volume method.
• Functional Expansion Tools App
• FXFluxBCSets a flux boundary condition, evaluated using a FunctionSeries instance. This does not fix the flux, but rather 'strongly encourages' flux agreement by penalizing the differences through contributions to the residual.
• FXValueBCImposes a fixed value boundary condition, evaluated using a FunctionSeries instance.
• FXValuePenaltyBCSets a value boundary condition, evaluated using a FunctionSeries instance. This does not fix the value, but rather 'strongly encourages' value agreement by penalizing the differences through contributions to the residual.
• XFEMApp
• CrackTipEnrichmentCutOffBCSimilar to DirichletBC except the value is applied before the solve begins
• Heat Conduction App
• ConvectiveFluxFunctionDetermines boundary value by fluid heat transfer coefficient and far-field temperature
• CoupledConvectiveFlux
• CoupledConvectiveHeatFluxBCConvective heat transfer boundary condition with temperature and heat transfer coefficent given by auxiliary variables.
• GapHeatTransferTransfers heat across a gap between two surfaces dependant on the gap geometry specified.
• HeatConductionBC
• Richards App
• Q2PPiecewiseLinearSinkSink of fluid, controlled by (pressure, bare_fluxes) interpolation. This is for use in Q2P models
• RichardsExcavAllows the user to set variable values at the face of an excavation. You must have defined the excavation start time, start position, etc, through the excav_geom_function
• RichardsHalfGaussianSink
• RichardsPiecewiseLinearSink
• Tensor Mechanics App
• CoupledPressureBCApplies a pressure from a variable on a given boundary in a given direction
• DashpotBC
• DisplacementAboutAxisImplements a boundary condition that enforces rotationaldisplacement around an axis on a boundary
• InteractionIntegralBenchmarkBC
• PresetAccelerationPrescribe acceleration on a given boundary in a given direction
• PresetDisplacementPrescribe the displacement on a given boundary in a given direction.
• PresetVelocity
• PressureApplies a pressure on a given boundary in a given direction
• StickyBCImposes the boundary condition if exceeds the bounds provided
• CavityPressure
• CoupledPressure
• Pressure
• Navier Stokes App
• EnergyFreeBC
• INSMomentumNoBCBCLaplaceFormThis class implements the 'No BC' boundary condition based on the 'Laplace' form of the viscous stress tensor.
• INSMomentumNoBCBCTractionFormThis class implements the 'No BC' boundary condition based on the 'traction' form of the viscous stress tensor.
• INSTemperatureNoBCBCThis class implements the 'No BC' boundary condition discussed by Griffiths, Papanastiou, and others.
• ImplicitNeumannBCThis class implements a form of the Neumann boundary condition in which the boundary term is treated 'implicitly'.
• MassFreeBC
• MomentumFreeBC
• MomentumFreeSlipBC
• NSEnergyInviscidSpecifiedBCThis class corresponds to the inviscid part of the 'natural' boundary condition for the energy equation.
• NSEnergyInviscidSpecifiedDensityAndVelocityBCThis class corresponds to the inviscid part of the 'natural' boundary condition for the energy equation.
• NSEnergyInviscidSpecifiedNormalFlowBCThis class corresponds to the inviscid part of the 'natural' boundary condition for the energy equation.
• NSEnergyInviscidSpecifiedPressureBCThis class corresponds to the inviscid part of the 'natural' boundary condition for the energy equation.
• NSEnergyInviscidUnspecifiedBCThis class corresponds to the inviscid part of the 'natural' boundary condition for the energy equation.
• NSEnergyViscousBCThis class couples together all the variables for the compressible Navier-Stokes equations to allow them to be used in derived IntegratedBC classes.
• NSEnergyWeakStagnationBCThe inviscid energy BC term with specified normal flow.
• NSImposedVelocityBCImpose Velocity BC.
• NSImposedVelocityDirectionBCThis class imposes a velocity direction component as a Dirichlet condition on the appropriate momentum equation.
• NSInflowThermalBCThis class is used on a boundary where the incoming flow values (rho, u, v, T) are all completely specified.
• NSMassSpecifiedNormalFlowBCThis class implements the mass equation boundary term with a specified value of rho*(u.n) imposed weakly.
• NSMassUnspecifiedNormalFlowBCThis class implements the mass equation boundary term with the rho*(u.n) boundary integral computed implicitly.
• NSMassWeakStagnationBCThe inviscid energy BC term with specified normal flow.
• NSMomentumConvectiveWeakStagnationBCThe convective part (sans pressure term) of the momentum equation boundary integral evaluated at specified stagnation temperature, stagnation pressure, and flow direction values.
• NSMomentumInviscidNoPressureImplicitFlowBCMomentum equation boundary condition used when pressure is not integrated by parts.
• NSMomentumInviscidSpecifiedNormalFlowBCMomentum equation boundary condition in which pressure is specified (given) and the value of the convective part is allowed to vary (is computed implicitly).
• NSMomentumInviscidSpecifiedPressureBCMomentum equation boundary condition in which pressure is specified (given) and the value of the convective part is allowed to vary (is computed implicitly).
• NSMomentumPressureWeakStagnationBCThis class implements the pressure term of the momentum equation boundary integral for use in weak stagnation boundary conditions.
• NSMomentumViscousBCThis class corresponds to the viscous part of the 'natural' boundary condition for the momentum equations.
• NSPenalizedNormalFlowBCThis class penalizes the the value of u.n on the boundary so that it matches some desired value.
• NSPressureNeumannBCThis kernel is appropriate for use with a 'zero normal flow' boundary condition in the context of the Euler equations.
• NSStagnationPressureBCThis Dirichlet condition imposes the condition p_0 = p_0_desired.
• NSStagnationTemperatureBCThis Dirichlet condition imposes the condition T_0 = T_0_desired.
• NSThermalBCNS thermal BC.
• Chemical Reactions App
• ChemicalOutFlowBCChemical flux boundary condition
• Porous Flow App
• PorousFlowHalfCubicSinkApplies a flux sink to a boundary. The base flux defined by PorousFlowSink is multiplied by a cubic.
• PorousFlowHalfGaussianSinkApplies a flux sink to a boundary. The base flux defined by PorousFlowSink is multiplied by a Gaussian.
• PorousFlowPiecewiseLinearSinkApplies a flux sink to a boundary. The base flux defined by PorousFlowSink is multiplied by a piecewise linear function.
• PorousFlowSinkApplies a flux sink to a boundary.

## Functions

• Moose App
• Axisymmetric2D3DSolutionFunctionFunction for reading a 2D axisymmetric solution from file and mapping it to a 3D Cartesian model
• BicubicSplineFunction
• CompositeFunctionMultiplies an arbitrary set of functions together
• ConstantFunction
• ImageFunctionFunction with values sampled from a given image stack
• LinearCombinationFunctionReturns the linear combination of the functions
• ParsedFunction
• ParsedVectorFunction
• 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.
• SolutionFunction
• SplineFunction
• TestSetupPostprocessorDataActionFunction
• VectorPostprocessorFunction
• Richards App
• RichardsExcavGeomThis function defines excavation geometry. It can be used to enforce pressures at the boundary of excavations, and to record fluid fluxes into excavations.
• 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.