pymor.vectorarrays.mpi

Wrapper classes for building MPI distributed VectorArrays.

This module contains several wrapper classes which allow to transform single rank VectorArrays into MPI distributed VectorArrays which can be used on rank 0 like ordinary VectorArrays.

The implementations are based on the event loop provided by pymor.tools.mpi.

Classes

MPIVectorArray

MPI distributed VectorArray.

MPIVectorArrayAutoComm

MPI distributed VectorArray.

MPIVectorArrayAutoCommImpl

MPIVectorArrayImpl

MPIVectorArrayNoComm

MPI distributed VectorArray.

MPIVectorArrayNoCommImpl

MPIVectorSpace

VectorSpace of MPIVectorArrays.

MPIVectorSpaceAutoComm

VectorSpace for MPIVectorArrayAutoComm.

MPIVectorSpaceNoComm

VectorSpace for MPIVectorArrayNoComm.

RegisteredLocalSpace

class pymor.vectorarrays.mpi.MPIVectorArray(space, impl, base=None, ind=None, _len=None)[source]

Bases: VectorArray

MPI distributed VectorArray.

Given a local VectorArray on each MPI rank, this wrapper class uses the event loop from pymor.tools.mpi to build a global MPI distributed vector array from these local arrays.

Instances of MPIVectorArray can be used on rank 0 like any other (non-distributed) VectorArray.

Note, however, that the implementation of the local VectorArrays needs to be MPI aware. For instance, cls.inner must perform the needed MPI communication to sum up the local inner products and return the sums on rank 0.

Default implementations for all communication requiring interface methods are provided by MPIVectorArrayAutoComm (also see MPIVectorArrayNoComm).

Note that resource cleanup is handled by object.__del__. Please be aware of the peculiarities of destructors in Python!

The associated VectorSpace is MPIVectorSpace.

impl_type[source]

alias of MPIVectorArrayImpl

class pymor.vectorarrays.mpi.MPIVectorArrayAutoComm(space, impl, base=None, ind=None, _len=None)[source]

Bases: MPIVectorArray

MPI distributed VectorArray.

This is a subclass of MPIVectorArray which provides default implementations for all communication requiring interface methods for the case when the wrapped array is not MPI aware.

Note, however, that depending on the model these default implementations might lead to wrong results (for instance in the presence of shared DOFs).

The associated VectorSpace is MPIVectorSpaceAutoComm.

impl_type[source]

alias of MPIVectorArrayAutoCommImpl

class pymor.vectorarrays.mpi.MPIVectorArrayAutoCommImpl(obj_id, space)[source]

Bases: MPIVectorArrayImpl

amax(ind)[source]
dofs(dof_indices, ind)[source]
inner(other, ind, oind)[source]
norm(ind)[source]
norm2(ind)[source]
pairwise_inner(other, ind, oind)[source]
class pymor.vectorarrays.mpi.MPIVectorArrayImpl(obj_id, space)[source]

Bases: VectorArrayImpl

amax(ind)[source]
append(other, remove_from_other, oind)[source]
axpy(alpha, x, ind, xind)[source]
conj(ind)[source]
copy(deep, ind)[source]
delete(ind)[source]
dofs(dof_indices, ind)[source]
imag(ind)[source]
inner(other, ind, oind)[source]
lincomb(coefficients, ind)[source]
norm2(ind)[source]
pairwise_inner(other, ind, oind)[source]
real(ind)[source]
scal(alpha, ind)[source]
to_numpy(ensure_copy, ind)[source]
class pymor.vectorarrays.mpi.MPIVectorArrayNoComm(space, impl, base=None, ind=None, _len=None)[source]

Bases: MPIVectorArray

MPI distributed VectorArray.

This is a subclass of MPIVectorArray which overrides all communication requiring interface methods to raise NotImplementedError.

This is mainly useful as a security measure when wrapping arrays for which simply calling the respective method on the wrapped arrays would lead to wrong results and MPIVectorArrayAutoComm cannot be used either (for instance in the presence of shared DOFs).

The associated VectorSpace is MPIVectorSpaceNoComm.

impl_type[source]

alias of MPIVectorArrayNoCommImpl

class pymor.vectorarrays.mpi.MPIVectorArrayNoCommImpl(obj_id, space)[source]

Bases: MPIVectorArrayImpl

amax(ind)[source]
dofs(dof_indices, ind)[source]
inner(other, ind, oind)[source]
norm(ind)[source]
norm2(ind)[source]
pairwise_inner(other, ind, oind)[source]
class pymor.vectorarrays.mpi.MPIVectorSpace(local_spaces)[source]

Bases: VectorSpace

VectorSpace of MPIVectorArrays.

Parameters:

local_spaces – tuple of the different VectorSpaces of the local VectorArrays on the MPI ranks. Alternatively, the length of local_spaces may be 1, in which case the same VectorSpace is assumed for all ranks.

array_type[source]

alias of MPIVectorArray

make_array(obj_id)[source]

Create array from rank-local VectorArray instances.

Parameters:

obj_id – ObjectId of the MPI distributed instances of cls wrapped by this array.

Returns:

The newly created MPIVectorArray.

zeros(count=1, reserve=0)[source]

Create a VectorArray of null vectors.

Parameters:
  • count – The number of vectors.

  • reserve – Hint for the backend to which length the array will grow.

Returns:

A VectorArray containing count vectors with each component zero.

property dim[source]

The type of the None singleton.

class pymor.vectorarrays.mpi.MPIVectorSpaceAutoComm(local_spaces)[source]

Bases: MPIVectorSpace

VectorSpace for MPIVectorArrayAutoComm.

array_type[source]

alias of MPIVectorArrayAutoComm

property dim[source]

The type of the None singleton.

class pymor.vectorarrays.mpi.MPIVectorSpaceNoComm(local_spaces)[source]

Bases: MPIVectorSpace

VectorSpace for MPIVectorArrayNoComm.

array_type[source]

alias of MPIVectorArrayNoComm

property dim[source]

The type of the None singleton.

class pymor.vectorarrays.mpi.RegisteredLocalSpace[source]

Bases: int