pylops_mpi.basicoperators.MPISecondDerivative#
- class pylops_mpi.basicoperators.MPISecondDerivative(dims, sampling=1.0, kind='centered', edge=False, base_comm=<mpi4py.MPI.Intracomm object>, dtype=<class 'numpy.float64'>)[source]#
MPI Second Derivative
Apply a second derivative using a three-point stencil finite-difference approximation with
pylops_mpi.DistributedArray
. The Second Derivative is calculated alongaxis=0
.- Parameters:
- dims
int
ortuple
Number of samples for each dimension.
- sampling
float
, optional Sampling step \(\Delta x\).
- kind
str
, optional Derivative kind (
forward
,centered
, orbackward
).- edge
bool
, optional Use reduced order derivative at edges (
True
) or ignore them (False
). This is currently only available for centered derivative.- base_comm
mpi4py.MPI.Comm
, optional MPI Base Communicator. Defaults to
mpi4py.MPI.COMM_WORLD
.- dtype
str
, optional Type of elements in the input array.
- dims
- Attributes:
- shape
tuple
Operator shape
- shape
Notes
The MPISecondDerivative operator applies a second derivative to a
pylops_mpi.DistributedArray
using either a second-order forward, backward or a centered stencil.Similar to the concept of
pylops_mpi.basicoperators.MPIFirstDerivative
, ghosting is applied at each rank to include duplicated copies of border cells (ghost cells) from neighboring processes. These ghost cells enable each process to perform local computations independently, avoiding the necessity for direct communication with other processes. As a result, it becomes possible to calculate the Second Derivative of the entire distributed array efficiently.Now, for a one-dimensional DistributedArray, the second-order forward stencil is:
\[y[i] = (x[i+2] - 2 * x[i+1] + x[i]) / \mathbf{\Delta x}^2\]while the second-order backward stencil is:
\[y[i] = (x[i] - 2 * x[i-1] + x[i-2]) / \mathbf{\Delta x}^2\]and the second-order centered stencil is:
\[y[i] = (x[i+1] - 2 * x[i] + x[i-1]) / \mathbf{\Delta x}^2\]where \(y\) is a DistributedArray and \(x\) is a Ghosted array created by adding border cells of neighboring processes to the local array at each rank.
Methods
__init__
(dims[, sampling, kind, edge, ...])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