pylops_mpi.basicoperators.MPIHalo#

class pylops_mpi.basicoperators.MPIHalo(dims, halo, proc_grid_shape=None, comm=<mpi4py.MPI.Intracomm object>, dtype=<class 'numpy.float64'>)[source]#

MPI Halo

Apply haloing to all dimensions of a flattened, 1-dimensional pylops_mpi.DistributedArray after local reshaping to a N-dimensional array.

The Halo operator is applied over a Cartesian process grid, where each rank owns a local block of the global N-dimensional array.

Parameters:
dimstuple

Number of samples for each dimension.

haloint or tuple

Number of halo samples to add around each local block. A scalar value applies the same halo to both sides of every axis. A tuple of length ndim applies a symmetric halo per axis. A tuple of length 2 * ndim specifies the halo to apply at the start and at the end for each axis.

proc_grid_shapetuple

Number of MPI ranks along each dimension.

commmpi4py.MPI.Comm, optional

MPI Base Communicator. Defaults to mpi4py.MPI.COMM_WORLD.

dtypestr, optional

Type of elements in the input array.

Attributes:
shapetuple

Operator shape

Notes

The MPIHalo operator extends each rank’s local array with a halo (ghost cells) of width halo along the haloed axes, providing the neighboring rank’s data for stencil-like operators. Ranks are arranged in an N-dimensional Cartesian grid as provided by proc_grid_shape, whereby each rank owns a contiguous block of the global array. The halo is normalised to a tuple of length 2 * ndim, containing one (minus, plus) halo-width pair for each axis. The tuple is flattened in axis order as

\[(h_{0,-}, h_{0,+}, h_{1,-}, h_{1,+}, \ldots)\]

where \(h_{i,-}`\) and \(h_{i,+}`\) represent the halo widths on the negative and positive side of the i-th axis, respectively. For convenience, halo may be provided as a scalar when the same symmetric halo is required along all axes, or as a tuple of length ndim when symmetric halos of different width are applied to different axis. Ghost cells on the global boundary of an axis are zero by default.

In the forward mode, each rank exchanges boundary slices with its left and right neighbors along each axis via MPI_Sendrecv. Ranks at a global boundary have MPI.PROC_NULL as their neighbor on that side, so those ghost regions remain zero and no exchange is attempted. Once the exchange is complete, local PyLops operators can be applied independently on each rank’s extended block, typically wrapped into a pylops_mpi.basicoperators.MPIBlockDiag operator.

In the adjoint mode, the reverse operation is performed the original local domain is extracted by removing the ghost cells.

Finally, note that the Halo operator is not linear operator per se; instead, it is meant to sandwitch any linear operator to implement equivalent behaviours to the serial version of such an operator.

Methods

__init__(dims, halo[, proc_grid_shape, ...])

adjoint()

Adjoint MPI LinearOperator

conj()

Complex conjugate operator

dot(x)

Matrix Vector Multiplication

matvec(x)

Matrix-vector multiplication.

rmatvec(x)

Adjoint Matrix-vector multiplication.

transpose()

Transposition of MPI LinearOperator