PolynomialInterpolation#

class fridom.framework.grid.cartesian.polynomial_interpolation.PolynomialInterpolation(order: int = 1)[source]#

Bases: InterpolationModule

Polynomial interpolation for cartesian grids.

Description#

Consider the following grid points:

\[x_i = (i - n/2) \Delta x, \quad i = 0, 1, \ldots, n\]

where \(n\) is the (odd) order of the polynomial interpolation. For example for \(n = 3\) we have the following grid points:

    We want to interpolate the field to this point (x=0)
                            ↓
        |   x_0   |   x_1   |   x_2   |   x_3   |
x/dx =     -3/2      -1/2       1/2       3/2

Let \(f_i\) be the field values at \(x_i\). We define the continuous extension of the field as:

\[f(x) = \sum_{i=0}^{n} \left( \prod_{j=0, j \neq i}^{n} \left( \frac{x - x_j}{x_i - x_j} f_i \right) \right)\]

By definition, \(f(x_i) = f_i\) holds. Finally, to interpolate the field to the point \(x=0\), we insert \(x=0\) into the above expression. Note that the grid spacing \(\Delta x\) cancels out.

\[f(0) = \sum_{i=0}^{n} c_i f_i\]

with the coefficients \(c_i\) given by:

\[c_i = \prod_{j=0, j \neq i}^{n} \frac{j-n/2}{j - i}\]
__init__(order: int = 1)[source]#

Methods

__init__([order])

disable()

Enabling the module means that it will be executed at each time step.

enable()

Enabling the module means that it will be executed at each time step.

interpolate(f, destination)

Interpolate the field to the destination position.

interpolate_axis(f, axis, destination)

is_enabled()

Return whether the module is enabled or not.

reset()

Stop and start the module.

setup(mset)

Start the module

start()

Start the module

stop()

Stop the module

update(mz)

Update the module

Attributes

diff_module

The differentiation module to be used by this module.

grid

The grid of the model settings

info

Return a dictionary with information about the time stepper.

interp_module

The interpolation module to be used by this module.

mset

The model settings

name

required_halo

name = 'Polynomial Interpolation'#
setup(mset: ModelSettingsBase) None[source]#

Start the module

Description#

This method is called by the ModelSettings.setup() and sets the ModelSettings as well as the differentiation and interpolation modules.

interpolate(f: FieldVariable, destination: Position) FieldVariable[source]#

Interpolate the field to the destination position.

Parameters#

ffr.FieldVariable

The field to interpolate.

destinationfr.grid.Position

The position to interpolate to.

Returns#

fr.FieldVariable

The interpolated field.

interpolate_axis(f: FieldVariable, axis: int, destination: AxisPosition) FieldVariable[source]#