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 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]
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]
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 internal impl object of this type. Indexing, error checking or non-standard inner products are handled by VectorArray. Possible indices are passed to the methods of VectorArrayImpl as ind, oind or xind parameters. These can either be None, in case the array has not been indexed, a slice object, or a Python list of non-negative numbers.

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: pymor.vectorarrays.interface.VectorArrayImpl

Implementation of a VectorArray.

The VectorArray base class defers all calls to interface methods to an internal impl object of this type. Indexing, error checking or non-standard inner products are handled by VectorArray. Possible indices are passed to the methods of VectorArrayImpl as ind, oind or xind parameters. These can either be None, in case the array has not been indexed, a slice object, or a Python list of non-negative numbers.

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]
abstract 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]
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 internal impl object of this type. Indexing, error checking or non-standard inner products are handled by VectorArray. Possible indices are passed to the methods of VectorArrayImpl as ind, oind or xind parameters. These can either be None, in case the array has not been indexed, a slice object, or a Python list of non-negative numbers.

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

Bases: pymor.vectorarrays.interface.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.

Methods

make_array

Create array from rank-local VectorArray instances.

zeros

Create a VectorArray of null vectors.

array_type[source]
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 : 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 containing count vectors with each component zero.

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

Bases: MPIVectorSpace

VectorSpace for MPIVectorArrayAutoComm.

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

Bases: MPIVectorSpace

VectorSpace for MPIVectorArrayNoComm.

array_type[source]
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