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
MPI distributed |
|
MPI distributed |
|
MPI distributed |
|
- class pymor.vectorarrays.mpi.MPIVectorArray(space, impl, base=None, ind=None, _len=None)[source]¶
Bases:
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.Methods
amax,append,axpy,check_ind,check_ind_unique,conj,copy,dofs,empty,full,gramian,inner,len_ind,len_ind_unique,lincomb,norm,norm2,ones,pairwise_inner,random,scal,sup_norm,to_numpy,zerosAttributes
- impl_type[source]¶
alias of
MPIVectorArrayImpl
- 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.Methods
amax,append,axpy,check_ind,check_ind_unique,conj,copy,dofs,empty,full,gramian,inner,len_ind,len_ind_unique,lincomb,norm,norm2,ones,pairwise_inner,random,scal,sup_norm,to_numpy,zerosAttributes
- impl_type[source]¶
alias of
MPIVectorArrayAutoCommImpl
- class pymor.vectorarrays.mpi.MPIVectorArrayAutoCommImpl(obj_id, space)[source]¶
Bases:
MPIVectorArrayImplAttributes
- class pymor.vectorarrays.mpi.MPIVectorArrayImpl(obj_id, space)[source]¶
Bases:
VectorArrayImplMethods
amax,append,axpy,conj,copy,delete,dofs,imag,inner,lincomb,norm2,pairwise_inner,real,scal,to_numpyAttributes
- 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.Methods
amax,append,axpy,check_ind,check_ind_unique,conj,copy,dofs,empty,full,gramian,inner,len_ind,len_ind_unique,lincomb,norm,norm2,ones,pairwise_inner,random,scal,sup_norm,to_numpy,zerosAttributes
- impl_type[source]¶
alias of
MPIVectorArrayNoCommImpl
- class pymor.vectorarrays.mpi.MPIVectorArrayNoCommImpl(obj_id, space)[source]¶
Bases:
MPIVectorArrayImplAttributes
- class pymor.vectorarrays.mpi.MPIVectorSpace(local_spaces)[source]¶
Bases:
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
empty,from_numpy,full,ones,randomAttributes
- array_type[source]¶
alias of
MPIVectorArray
- 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:
MPIVectorSpaceVectorSpaceforMPIVectorArrayAutoComm.Methods
empty,from_numpy,full,ones,randomAttributes
- array_type[source]¶
alias of
MPIVectorArrayAutoComm
- class pymor.vectorarrays.mpi.MPIVectorSpaceNoComm(local_spaces)[source]¶
Bases:
MPIVectorSpaceVectorSpaceforMPIVectorArrayNoComm.Methods
empty,from_numpy,full,ones,randomAttributes
- array_type[source]¶
alias of
MPIVectorArrayNoComm