Grid#

class fridom.framework.grid.spectral.grid.Grid(N: list[int], L: list[float], periodic_bounds: list[bool] | None = None, shared_axes=[0])[source]#

Bases: Grid

__init__(N: list[int], L: list[float], periodic_bounds: list[bool] | None = None, shared_axes=[0]) None[source]#

Methods

__init__(N, L[, periodic_bounds, shared_axes])

create_array([pad, spectral, topo])

Create an array.

create_random_array([seed, pad, spectral, topo])

Create a random array.

fft(arr[, padding, bc_types, positions])

Perform a (fast) fourier transform on the input array.

get_mesh([position, spectral])

Get the meshgrid of the grid points.

ifft(arr[, padding, bc_types, positions])

Perform an inverse (fast) fourier transform on the input array.

omega(k[, use_discrete])

Compute the dispersion relation of the model.

pad(arr)

Add halo padding to an array.

setup(mset)

Initialize the grid from the model settings.

sync(arr[, flat_axes])

Synchronize the halo (boundary) points of an array across all MPI ranks.

sync_multi(arrs)

Synchronize the halo (boundary) points of multiple arrays across all MPI ranks.

unpad(arr)

Remove the halo padding from an array.

vec_p(s[, use_discrete])

Computes the projection vector of the linear operator of the mode s.

vec_q(s[, use_discrete])

Computes the eigenvector of the linear operator of the mode s.

Attributes

K

Spectral meshgrid on the local domain.

L

Domain size in each direction.

N

Grid points in each direction.

X

The meshgrid of the grid points.

cell_center

The position of the cell centers.

dV

The volume element of the grid.

diff_module

The differential operator module.

domain_decomp

The domain decomposition object.

dx

The grid spacing in each dimension.

fourier_transform_available

Indicates whether the grid supports fast fourier transforms.

info

Return a dictionary with information about the grid.

interp_module

The interpolation operator module.

k_global

Global spectral k-vectors.

k_local

Spectral k-vectors on the local domain.

mpi_available

Indicates whether the grid supports MPI parallelization.

mset

The model settings object.

n_dims

The number of dimensions of the grid.

omega_analytical

Analytical dispersion relation.

omega_space_discrete

Dispersion relation with space-discretization effects.

omega_time_discrete

Dispersion relation with space-time-discretization effects.

periodic_bounds

A tuple of booleans indicating whether the grid is periodic in each dimension.

spectral_grid

Indicates whether the grid is a spectral grid.

total_grid_points

The total number of grid points in the grid.

water_mask

Get the water mask.

x_global

The x-vector of the global grid points.

setup(mset: ModelSettingsBase)[source]#

Initialize the grid from the model settings.

Parameters#

msetModelSettingsBase

The model settings object. This is for example needed to determine the required halo size.

get_mesh(position: Position | None = None, spectral: bool = False) tuple[ndarray][source]#

Get the meshgrid of the grid points.

Parameters#

positionPosition or None (default: None)

The position of the field.

spectralbool (default: False)

Whether to return the meshgrid of the spectral domain.

Returns#

tuple[ndarray]

The meshgrid of the grid points.

fft(arr: ndarray, padding=FFTPadding.NOPADDING, bc_types: tuple[BCType] | None = None, positions: tuple[AxisPosition] | None = None) ndarray[source]#

Perform a (fast) fourier transform on the input array.

Parameters#

arrndarray

The input array.

paddingFFTPadding (default: FFTPadding.NOPADDING)

The padding to apply to the array.

bc_typestuple[BCType] or None (default: None)

The boundary conditions to apply to each axis.

positionstuple[AxisPosition] or None (default: None)

The position of the field.

axestuple[int] or None (default: None)

The axes to transform.

Returns#

ndarray

The transformed array.

ifft(arr: ndarray, padding=FFTPadding.NOPADDING, bc_types: tuple[BCType] | None = None, positions: tuple[AxisPosition] | None = None) ndarray[source]#

Perform an inverse (fast) fourier transform on the input array.

Parameters#

arrndarray

The input array.

paddingFFTPadding (default: FFTPadding.NOPADDING)

The padding to apply to the array.

bc_typestuple[BCType] or None (default: None)

The boundary conditions to apply to each axis.

positionstuple[AxisPosition] or None (default: None)

The position of the field.

axestuple[int] or None (default: None)

The axes to transform.

Returns#

ndarray

The transformed array.