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
.
Module Contents¶
- class pymor.vectorarrays.mpi.MPIVectorArray(space, impl, base=None, ind=None, _len=None)[source]¶
Bases:
pymor.vectorarrays.interface.VectorArray
MPI distributed
VectorArray
.Given a local
VectorArray
on each MPI rank, this wrapper class uses the event loop frompymor.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 seeMPIVectorArrayNoComm
).Note that resource cleanup is handled by
object.__del__
. Please be aware of the peculiarities of destructors in Python!The associated
VectorSpace
isMPIVectorSpace
.
- 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
isMPIVectorSpaceAutoComm
.
- class pymor.vectorarrays.mpi.MPIVectorArrayAutoCommImpl(obj_id, space)[source]¶
Bases:
MPIVectorArrayImpl
Implementation of a
VectorArray
.The
VectorArray
base class defers all calls to interface methods to an internalimpl
object of this type. Indexing, error checking or non-standard inner products are handled byVectorArray
. Possible indices are passed to the methods ofVectorArrayImpl
asind
,oind
orxind
parameters. These can either beNone
, in case the array has not been indexed, aslice
object, or a Python list of non-negative numbers.
- class pymor.vectorarrays.mpi.MPIVectorArrayImpl(obj_id, space)[source]¶
Bases:
pymor.vectorarrays.interface.VectorArrayImpl
Implementation of a
VectorArray
.The
VectorArray
base class defers all calls to interface methods to an internalimpl
object of this type. Indexing, error checking or non-standard inner products are handled byVectorArray
. Possible indices are passed to the methods ofVectorArrayImpl
asind
,oind
orxind
parameters. These can either beNone
, in case the array has not been indexed, aslice
object, or a Python list of non-negative numbers.Methods
- 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 raiseNotImplementedError
.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
isMPIVectorSpaceNoComm
.
- class pymor.vectorarrays.mpi.MPIVectorArrayNoCommImpl(obj_id, space)[source]¶
Bases:
MPIVectorArrayImpl
Implementation of a
VectorArray
.The
VectorArray
base class defers all calls to interface methods to an internalimpl
object of this type. Indexing, error checking or non-standard inner products are handled byVectorArray
. Possible indices are passed to the methods ofVectorArrayImpl
asind
,oind
orxind
parameters. These can either beNone
, in case the array has not been indexed, aslice
object, or a Python list of non-negative numbers.
- class pymor.vectorarrays.mpi.MPIVectorSpace(local_spaces)[source]¶
Bases:
pymor.vectorarrays.interface.VectorSpace
VectorSpace
ofMPIVectorArrays
.Parameters
- local_spaces
tuple
of the differentVectorSpaces
of the localVectorArrays
on the MPI ranks. Alternatively, the length oflocal_spaces
may be 1, in which case the sameVectorSpace
is assumed for all ranks.
Methods
Create array from rank-local
VectorArray
instances.Create a
VectorArray
of null vectors.- make_array(obj_id)[source]¶
Create array from rank-local
VectorArray
instances.Parameters
- obj_id
ObjectId
of the MPI distributed instances ofcls
wrapped by this array.
Returns
The newly created : class:
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
containingcount
vectors with each component zero.
- class pymor.vectorarrays.mpi.MPIVectorSpaceAutoComm(local_spaces)[source]¶
Bases:
MPIVectorSpace
- class pymor.vectorarrays.mpi.MPIVectorSpaceNoComm(local_spaces)[source]¶
Bases:
MPIVectorSpace
- class pymor.vectorarrays.mpi.RegisteredLocalSpace[source]¶
Bases:
int
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4