Grid#
- class fridom.nonhydro.grid.cartesian.grid.Grid(N: list[int], L: list[float], periodic_bounds: list[bool] | None = None, domain_decomp: DomainDecomposition | None = None, diff_mod: DiffModule | None = None, interp_mod: InterpolationModule | None = None)[source]#
Bases:
Grid- __init__(N: list[int], L: list[float], periodic_bounds: list[bool] | None = None, domain_decomp: DomainDecomposition | None = None, diff_mod: DiffModule | None = None, interp_mod: InterpolationModule | None = None) None[source]#
Methods
__init__(N, L[, periodic_bounds, ...])create_array([pad, spectral, topo])Create an array.
create_random_array([seed, pad, spectral, topo])Create a random array.
cumulative_integral(field, axis[, direction])Compute the cumulative integral of a field along a given axis.
fft(arr[, padding, bc_types, positions, axes])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, axes])Perform an inverse (fast) fourier transform on the input array.
integrate(field[, axes])Integrate a scalar field over a given domain.
max(field[, axes])Compute the maximum of a field over the given axes.
min(field[, axes])Compute the minimum of a field over the given axes.
omega(k[, use_discrete])Compute the dispersion relation of the model.
pad(arr)Add halo padding to an array.
setup(mset[, req_halo, fft_module])Initialize the grid from the model settings.
sum(field[, axes])Sum a field over the given axes.
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
KSpectral meshgrid on the local domain.
LDomain size in each direction.
NGrid points in each direction.
XThe meshgrid of the grid points.
cell_centerThe position of the cell centers.
characteristic_functionThe characteristic function of the grid (1 inside the domain, 0 outside).
dVThe volume element of the grid.
diff_moduleThe differential operator module.
domain_decompThe domain decomposition object.
dxThe grid spacing in each dimension.
fourier_transform_availableIndicates whether the grid supports fast fourier transforms.
haloThe halo size of the grid.
infoReturn a dictionary with information about the grid.
interp_moduleThe interpolation operator module.
k_globalGlobal spectral k-vectors.
k_localSpectral k-vectors on the local domain.
mpi_availableIndicates whether the grid supports MPI parallelization.
msetThe model settings object.
n_dimsThe number of dimensions of the grid.
omega_analyticalAnalytical dispersion relation.
omega_space_discreteDispersion relation with space-discretization effects.
omega_time_discreteDispersion relation with space-time-discretization effects.
periodic_boundsA tuple of booleans indicating whether the grid is periodic in each dimension.
spectral_gridIndicates whether the grid is a spectral grid.
total_grid_pointsThe total number of grid points in the grid.
water_maskGet the water mask.
x_globalThe x-vector of the global grid points.
Examples using
fridom.nonhydro.grid.cartesian.Grid#- omega(k: tuple[float] | tuple[ndarray], use_discrete: bool = False) ndarray[source]#
Compute the dispersion relation of the model.
Parameters#
- ktuple[float] | tuple[ndarray]
The wave numbers
- use_discretebool (default: False)
Whether to include space-discretization effects.
Returns#
- ndarray
The dispersion relation (omega(k)).
- vec_q(s: int, use_discrete=True) State[source]#
Computes the eigenvector of the linear operator of the mode s.
Parameters#
- sint
The mode (which eigenvalue / eigenvector to compute).
- use_discretebool (default: True)
Whether to include space-discretization effects.
Returns#
- fr.VectorField
The eigenvector of the linear operator.
- vec_p(s: int, use_discrete=True) State[source]#
Computes the projection vector of the linear operator of the mode s.
Parameters#
- sint
The mode (which eigenvalue / eigenvector to compute).
- use_discretebool (default: True)
Whether to include space-discretization effects.
Returns#
- fr.VectorField
The projection vector of the linear operator.