Discretization Schemes¤
In xpektra, we define a discretization scheme which allows us to correctly define various differentiation operators. To do so, we need two information:
- The underlying grid in the physical space i.e if regular, staggered, etc.
- The differentiation formula to be used.
In order to facilitate this, we define a base class Scheme which provides the necessary infrastructure to define a discretization scheme.
xpektra.scheme.Scheme
¤
Abstract base class for a complete discretization strategy.
A Scheme is a self-contained object responsible for generating the discrete gradient operator based on a given spectral space.
The Scheme class is a base class for all the discretization schemes. One can create different discretization schemes by subclassing the Scheme class and implementing the formula method. The formula method should return the gradient operator field for a given wavenumber and grid spacing. In xpektra, we have implemented the CartesianScheme which takes a regular grid in physical space and returns the gradient operator field in spectral space.
xpektra.scheme.DiagonalScheme
¤
Base class for schemes operating on a uniform Cartesian grid where the differentiation is diagonal in Fourier space.
__init__(space: SpectralSpace)
¤
apply_gradient(u_hat: jaxlib._jax.Array) -> jaxlib._jax.Array
¤
Applies the gradient operator on the fly. Computes: grad_hat_ij = Dξ_i * u_hat_j
apply_symmetric_gradient(u_hat: jaxlib._jax.Array) -> jaxlib._jax.Array
¤
Applies the symmetric gradient operator on the fly. Computes: eps_hat_ij = 0.5 * (Dξ_i * u_hat_j + Dξ_j * u_hat_i)
apply_divergence(u_hat: jaxlib._jax.Array) -> jaxlib._jax.Array
¤
Applies the divergence operator on the fly. Computes: div_hat_i = Dξ_j * u_hat_ji
apply_laplacian(u_hat: jaxlib._jax.Array) -> jaxlib._jax.Array
¤
Applies the Laplacian operator on the fly. Computes: lap_hat = -|Dξ|^2 * u_hat
compute_gradient_operator(wavenumbers_mesh) -> jaxlib._jax.Array
¤
Builds the full gradient operator field using the scheme's formula.
is_compatible(transform)
¤
formula(xi, dx, iota, factor)
¤
The core formula for the discrete derivative in Fourier space. Must be implemented by concrete schemes.
To define the differentiation formula, we need to implement the formula method. The formula method should return the gradient operator field for a given wavenumber and grid spacing. In xpektra, we have various differentiation schemes available which can be used to define the differentiation formula.
xpektra.scheme.FourierScheme
¤
Class implementing the standard spectral 'Fourier' derivative.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit and \(\xi\) is the wavenumber.
xpektra.scheme.CentralDifference
¤
Implements the standard central difference scheme.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.
xpektra.scheme.ForwardDifference
¤
Implements the forward difference scheme.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.
xpektra.scheme.BackwardDifference
¤
Implements the backward difference scheme.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.
xpektra.scheme.RotatedDifference
¤
Implements the rotated finite difference scheme (Willot/HEX8R).
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.
xpektra.scheme.FourthOrderCentralDifference
¤
Implements the fourth order difference scheme.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.
xpektra.scheme.SixthOrderCentralDifference
¤
Implements the sixth order difference scheme.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.
xpektra.scheme.EighthOrderCentralDifference
¤
Implements the eighth order difference scheme.
formula(xi, dx, iota, factor)
¤
The formula is given by:
where \(\iota\) is the imaginary unit, \(\xi\) is the wavenumber and \(\Delta x\) is the grid spacing.