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.VectorArrayMPI distributed
VectorArray.Given a local
VectorArrayon each MPI rank, this wrapper class uses the event loop frompymor.tools.mpito build a global MPI distributed vector array from these local arrays.Instances of
MPIVectorArraycan 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.innermust 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
VectorSpaceisMPIVectorSpace.
- class pymor.vectorarrays.mpi.MPIVectorArrayAutoComm(space, impl, base=None, ind=None, _len=None)[source]¶
Bases:
MPIVectorArrayMPI distributed
VectorArray.This is a subclass of
MPIVectorArraywhich 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
VectorSpaceisMPIVectorSpaceAutoComm.
- class pymor.vectorarrays.mpi.MPIVectorArrayAutoCommImpl(obj_id, space)[source]¶
Bases:
MPIVectorArrayImplImplementation of a
VectorArray.The
VectorArraybase class defers all calls to interface methods to an internalimplobject of this type. Indexing, error checking or non-standard inner products are handled byVectorArray. Possible indices are passed to the methods ofVectorArrayImplasind,oindorxindparameters. These can either beNone, in case the array has not been indexed, asliceobject, or a Python list of non-negative numbers.
- class pymor.vectorarrays.mpi.MPIVectorArrayImpl(obj_id, space)[source]¶
Bases:
pymor.vectorarrays.interface.VectorArrayImplImplementation of a
VectorArray.The
VectorArraybase class defers all calls to interface methods to an internalimplobject of this type. Indexing, error checking or non-standard inner products are handled byVectorArray. Possible indices are passed to the methods ofVectorArrayImplasind,oindorxindparameters. These can either beNone, in case the array has not been indexed, asliceobject, or a Python list of non-negative numbers.Methods
- class pymor.vectorarrays.mpi.MPIVectorArrayNoComm(space, impl, base=None, ind=None, _len=None)[source]¶
Bases:
MPIVectorArrayMPI distributed
VectorArray.This is a subclass of
MPIVectorArraywhich 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
MPIVectorArrayAutoCommcannot be used either (for instance in the presence of shared DOFs).The associated
VectorSpaceisMPIVectorSpaceNoComm.
- class pymor.vectorarrays.mpi.MPIVectorArrayNoCommImpl(obj_id, space)[source]¶
Bases:
MPIVectorArrayImplImplementation of a
VectorArray.The
VectorArraybase class defers all calls to interface methods to an internalimplobject of this type. Indexing, error checking or non-standard inner products are handled byVectorArray. Possible indices are passed to the methods ofVectorArrayImplasind,oindorxindparameters. These can either beNone, in case the array has not been indexed, asliceobject, or a Python list of non-negative numbers.
- class pymor.vectorarrays.mpi.MPIVectorSpace(local_spaces)[source]¶
Bases:
pymor.vectorarrays.interface.VectorSpaceVectorSpaceofMPIVectorArrays.- Parameters:
local_spaces –
tupleof the differentVectorSpacesof the localVectorArrayson the MPI ranks. Alternatively, the length oflocal_spacesmay be 1, in which case the sameVectorSpaceis assumed for all ranks.
Methods
Create array from rank-local
VectorArrayinstances.Create a
VectorArrayof null vectors.- make_array(obj_id)[source]¶
Create array from rank-local
VectorArrayinstances.- Parameters:
obj_id –
ObjectIdof the MPI distributed instances ofclswrapped by this array.- Returns:
The newly created
MPIVectorArray.
- zeros(count=1, reserve=0)[source]¶
Create a
VectorArrayof null vectors.- Parameters:
count – The number of vectors.
reserve – Hint for the backend to which length the array will grow.
- Returns:
A
VectorArraycontainingcountvectors 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:
intint([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