Skip to content

Grid

The staggered-grid Geometry and its constructors, and the interpolation kernels between cell-center, vertex, and staggered velocity locations. See Grid generation for a narrative guide.

JustRelax.IGG Type
julia
IGG(me, dims, nprocs, coords, comm_cart)

Container for the Cartesian MPI topology returned by ImplicitGlobalGrid.init_global_grid.

This is typically created as:

julia
igg = IGG(init_global_grid(nx, ny, nz; init_MPI = true)...)

and then passed around so code can access the current rank, Cartesian coordinates, and communicator associated with the distributed grid decomposition.

source
JustRelax.lazy_grid Method
julia
lazy_grid(di, ni, Li; origin = ntuple(_ -> zero(T1), Val(N)))

Create cell-centered and vertex coordinates for a serial uniform grid.

di gives the spacing in each direction, ni the number of cells, and Li the physical lengths of the domain.

source
JustRelax.lazy_grid_MPI Method
julia
lazy_grid_MPI(di, ni; origin = ntuple(_ -> zero(T1), Val(N)))

Create local cell-centered and vertex coordinates for a uniform grid distributed with ImplicitGlobalGrid.

The returned coordinates are shifted by origin and correspond to the local MPI rank.

source
JustRelax.legacy_uniform_grid Method
julia
legacy_uniform_grid(ni, di)

Construct a uniform Geometry from grid sizes ni and cell spacings di.

This helper preserves the older API used by some solver code. In MPI mode the physical domain lengths are reconstructed from the global grid dimensions, so the resulting geometry matches the full distributed domain rather than only the local chunk.

source
JustRelax.velocity_grids Method
julia
velocity_grids(xci, xvi, di)

Build staggered velocity coordinates from cell-centered and vertex grids.

For each velocity component, the coordinate along that component lives on vertices, while the transverse directions are extended with one ghost point on either side. Both uniform spacings and nonuniform spacing vectors are supported in 2D and 3D.

Arguments

  • xci: Cell-centered coordinates in each direction.

  • xvi: Vertex coordinates in each direction.

  • di: Cell spacing as either scalars for a uniform grid or vectors for a nonuniform grid.

source
JustRelax.x_g Method
julia
x_g(idx, dxi, nxi_or_A)

Global x coordinate of local index idx on a grid with spacing dxi, given either the local axis length nxi or an array A sized along that axis. Accounts for the MPI domain decomposition and periodicity set up by init_global_grid (see IGG).

source
JustRelax.y_g Method
julia
y_g(idx, dxi, nxi_or_A)

Global y coordinate of local index idx, analogous to x_g.

source
JustRelax.z_g Method
julia
z_g(idx, dxi, nxi_or_A)

Global z coordinate of local index idx, analogous to x_g.

source
JustRelax.@dx Macro
julia
@dx(dx, I)

x spacing at grid index I, reading from dx — see @dxi.

source
JustRelax.@dxi Macro
julia
@dxi(dxi, I, J[, K])

Cell spacing (dx, dy[, dz]) at grid index (I, J[, K]), reading from dxi — a tuple of per-axis spacing that may be a constant Number (uniform grid) or an AbstractVector (non-uniform grid, indexed at I/J/K).

source
JustRelax.@dy Macro
julia
@dy(dy, J)

y spacing at grid index J, reading from dy — see @dxi.

source
JustRelax.@dz Macro
julia
@dz(dz, K)

z spacing at grid index K, reading from dz — see @dxi.

source
JustRelax.Geometry Method
julia
Geometry(TA, xvi::Vararg{<:AbstractVector, nDim})
Geometry(xvi::NTuple{nDim, <:AbstractVector})

Build a staggered grid from explicit vertex coordinates along each dimension.

This constructor is useful for refined or otherwise nonuniform meshes. Cell-centered coordinates, local spacings, and staggered velocity grids are derived from the supplied vertex coordinates. TA can be used to move the generated arrays to a target array type.

Arguments

  • TA: Array constructor used to materialize the coordinate arrays, for example Array or a backend-specific array type.

  • xvi: One vertex-coordinate vector per dimension.

source
JustRelax.Geometry Method
julia
Geometry(ni, li; origin = ntuple(_ -> 0.0, Val(nDim)))

Build a uniform staggered grid with ni cells and physical domain lengths li.

When ImplicitGlobalGrid has been initialized, the grid spacing is computed from the global grid dimensions and the returned coordinates correspond to the local MPI subdomain. Otherwise a serial grid covering the full domain is created.

Arguments

  • ni: Number of local grid cells in each direction.

  • li: Physical domain length in each direction.

Keywords

  • origin: Lower-left or lower-front corner of the domain.

Returns

  • A Geometry with cell-centered coordinates xci, vertex coordinates xvi, and staggered velocity coordinates xi_vel.
source
JustRelax.Geometry Type
julia
struct Geometry{nDim,V,D,T}

A staggered Cartesian grid in nDim dimensions.

Geometry stores the domain size, origin, cell spacing, cell-centered coordinates, vertex coordinates, and the staggered velocity grids used throughout JustRelax.

source
JustRelax.GeometryAnnulus Method
julia
GeometryAnnulus(TA, θv, rv)
GeometryAnnulus((θv, rv))

Build a staggered annular grid from explicit vertex-coordinate vectors in (θ, r) order. θv contains angular vertices and rv contains radial vertices. Cell-centered coordinates and local spacings are derived from these vectors. All values in θv must be given in radians.

TA is the array constructor used to materialize the generated coordinate arrays, such as Array or a backend-specific array type. The tuple form uses Array.

source
JustRelax.GeometryAnnulus Method
julia
GeometryAnnulus(ni, li; origin = ntuple(_ -> 0.0, Val(nDim)))

Build a uniform staggered annular grid in (θ, r) coordinate order.

For a two-dimensional annulus, ni = (nθ, nr), li = (lθ, lr), and origin = (θ₀, r₀). Thus, the first entries describe the angular direction and the second entries describe the radial direction. Both and θ₀ must be given in radians. When ImplicitGlobalGrid is initialized, the coordinates cover the local MPI subdomain; otherwise they cover the full domain.

Arguments

  • ni: Number of cells in each coordinate direction, ordered as (nθ, nr).

  • li: Coordinate extents, ordered as angular extent then radial extent.

Keywords

  • origin: Lower coordinate bounds, ordered as (θ₀, r₀).

Returns

  • A GeometryAnnulus with cell-centered, vertex, and staggered velocity coordinates in (θ, r) order.
source
JustRelax.GeometryAnnulus Type
julia
GeometryAnnulus{nDim,V,D,T} <: AbstractGrid{nDim,V,D,T}

A staggered annular grid whose first two coordinate directions are (θ, r): angular position followed by radius. Accordingly, xci[1] and xvi[1] contain angular coordinates in radians, while xci[2] and xvi[2] contain radial coordinates.

The grid stores its cell counts, coordinate extents, origin, spacings, cell-centered coordinates, vertex coordinates, and staggered velocity grids.

source
JustRelax.JustRelax2D.center2vertex! Method
julia
center2vertex!(vertex, center)
center2vertex!(vertex_yz, vertex_xz, vertex_xy, center_yz, center_xz, center_xy)

Interpolates the values at the cell center(s) onto vertex points. The 6-argument method interpolates the three shear-stress/strain-rate components of a 3D SymmetricTensor onto their respective face vertices.

source
JustRelax.JustRelax2D.interp_Vx_on_Vy! Method
julia
interp_Vx_on_Vy!(Vx_on_Vy, Vx)

Interpolates the values of Vx onto the grid points of Vy.

Arguments

  • Vx_on_Vy::AbstractArray: Vx at Vy grid points.

  • Vx::AbstractArray: Vx at its staggered grid points.

source
JustRelax.JustRelax2D.shear2center! Method
julia
shear2center!(A::SymmetricTensor)

Interpolate the shear components of A onto the cell centers, in place.

source
JustRelax.JustRelax2D.velocity2center! Method
julia
velocity2center!(Vx_c, Vy_c, Vx, Vy)

In-place interpolation of the velocity field Vx, Vy from a staggered grid with ghost nodes onto the pre-allocated Vx_c, Vy_c 2D arrays located at the cell centers.

source
JustRelax.JustRelax2D.velocity2center! Method
julia
velocity2center!(Vx_c, Vy_c, Vz_c, Vx, Vy, Vz)

In-place interpolation of the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the pre-allocated Vx_c, Vy_c, Vz_c 3D arrays located at the cell centers.

source
JustRelax.JustRelax2D.velocity2vertex! Method
julia
velocity2vertex!(Vx_v, Vy_v, Vx, Vy)

In-place interpolation of the velocity field Vx, Vy from a staggered grid with ghost nodes onto the pre-allocated Vx_v, Vy_v 2D arrays located at the grid vertices.

source
JustRelax.JustRelax2D.velocity2vertex! Method
julia
velocity2vertex!(Vx_v, Vy_v, Vz_v, Vx, Vy, Vz)

In-place interpolation of the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the pre-allocated Vx_d, Vy_d, Vz_d 3D arrays located at the grid vertices.

source
JustRelax.JustRelax2D.velocity2vertex Method
julia
velocity2vertex(Vx, Vy, Vz)

Interpolate the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the grid vertices.

source
JustRelax.JustRelax2D.vertex2center! Method
julia
vertex2center!(center, vertex)

Interpolates the values at the vertex onto center points.

source
JustRelax.JustRelax3D.center2vertex! Method
julia
center2vertex!(vertex, center)
center2vertex!(vertex_yz, vertex_xz, vertex_xy, center_yz, center_xz, center_xy)

Interpolates the values at the cell center(s) onto vertex points. The 6-argument method interpolates the three shear-stress/strain-rate components of a 3D SymmetricTensor onto their respective face vertices.

source
JustRelax.JustRelax3D.interp_Vx_on_Vy! Method
julia
interp_Vx_on_Vy!(Vx_on_Vy, Vx)

Interpolates the values of Vx onto the grid points of Vy.

Arguments

  • Vx_on_Vy::AbstractArray: Vx at Vy grid points.

  • Vx::AbstractArray: Vx at its staggered grid points.

source
JustRelax.JustRelax3D.shear2center! Method
julia
shear2center!(A::SymmetricTensor)

Interpolate the shear components of A onto the cell centers, in place.

source
JustRelax.JustRelax3D.velocity2center! Method
julia
velocity2center!(Vx_c, Vy_c, Vx, Vy)

In-place interpolation of the velocity field Vx, Vy from a staggered grid with ghost nodes onto the pre-allocated Vx_c, Vy_c 2D arrays located at the cell centers.

source
JustRelax.JustRelax3D.velocity2center! Method
julia
velocity2center!(Vx_c, Vy_c, Vz_c, Vx, Vy, Vz)

In-place interpolation of the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the pre-allocated Vx_c, Vy_c, Vz_c 3D arrays located at the cell centers.

source
JustRelax.JustRelax3D.velocity2vertex! Method
julia
velocity2vertex!(Vx_v, Vy_v, Vx, Vy)

In-place interpolation of the velocity field Vx, Vy from a staggered grid with ghost nodes onto the pre-allocated Vx_v, Vy_v 2D arrays located at the grid vertices.

source
JustRelax.JustRelax3D.velocity2vertex! Method
julia
velocity2vertex!(Vx_v, Vy_v, Vz_v, Vx, Vy, Vz)

In-place interpolation of the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the pre-allocated Vx_d, Vy_d, Vz_d 3D arrays located at the grid vertices.

source
JustRelax.JustRelax3D.velocity2vertex Method
julia
velocity2vertex(Vx, Vy, Vz)

Interpolate the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the grid vertices.

source
JustRelax.JustRelax3D.vertex2center! Method
julia
vertex2center!(center, vertex)

Interpolates the values at the vertex onto center points.

source