An class template to encapsulate a MultiVector. A MultiVector is a collection of \(N\) vectors belonging to the same finite-dimensional vector space, where usual notion of vector size denotes the dimension of the vector space. Note that this in the mathematical sense and not in the sense of an multi-dimensional array.The MultiVector is stored contiguously with the vector index being the fastest index, or in other words a matrix of size \(M \times N\) in row major format with \(M \) denoting the dimension of the vector space (size of individual vector). More...
#include <MultiVector.h>
Public Types | |
using | Storage = dftefe::utils::MemoryStorage< ValueType, memorySpace > |
using | value_type = typename Storage::value_type |
using | pointer = typename Storage::pointer |
using | reference = typename Storage::reference |
using | const_reference = typename Storage::const_reference |
using | iterator = typename Storage::iterator |
using | const_iterator = typename Storage::const_iterator |
Public Member Functions | |
MultiVector ()=default | |
Default Constructor. More... | |
~MultiVector ()=default | |
Default Destructor. More... | |
MultiVector (const size_type size, const size_type numVectors, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const ValueType initVal=utils::Types< ValueType >::zero) | |
Constructor for serial MultiVector with vector size, number of vectors and initial value arguments. More... | |
MultiVector (std::unique_ptr< typename MultiVector< ValueType, memorySpace >::Storage > storage, size_type numVectors, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext) | |
Constructor for a \serial MultiVector with a predefined MultiVector::Storage (i.e., utils::MemoryStorage). This constructor transfers the ownership of the input Storage to the MultiVector. This is useful when one does not want to allocate new memory and instead use memory allocated in the MultiVector::Storage (i.e., utils::MemoryStorage). The locallyOwnedSize, ghostSize, etc., are automatically set using the size of the input Storage object. More... | |
MultiVector (std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > mpiPatternP2P, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const size_type numVectors, const ValueType initVal=utils::Types< ValueType >::zero) | |
Constructor for a distributed MultiVector based on an input MPIPatternP2P. More... | |
MultiVector (std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > mpiPatternP2P, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const size_type numVectors, const ValueType min, const ValueType max) | |
Constructor for a distributed random MultiVector based on an input MPIPatternP2P. More... | |
MultiVector (std::unique_ptr< typename MultiVector< ValueType, memorySpace >::Storage > &storage, std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > mpiPatternP2P, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const size_type numVectors) | |
Constructor for a distributed MultiVector with a predefined MultiVector::Storage (i.e., utils::MemoryStorage) and MPIPatternP2P. This constructor transfers the ownership of the input Storage to the MultiVector. This is useful when one does not want to allocate new memory and instead use memory allocated in the input MultiVector::Storage (i.e., utils::MemoryStorage). More... | |
MultiVector (const std::pair< global_size_type, global_size_type > locallyOwnedRange, const std::vector< global_size_type > &ghostIndices, const utils::mpi::MPIComm &mpiComm, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const size_type numVectors, ValueType initVal=utils::Types< ValueType >::zero) | |
Constructor for a \distributed MultiVector based on locally owned and ghost indices. More... | |
MultiVector (const std::pair< global_size_type, global_size_type > locallyOwnedRange, const utils::mpi::MPIComm &mpiComm, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const size_type numVectors, const ValueType initVal=utils::Types< ValueType >::zero) | |
Constructor for a special case of distributed MultiVector where none none of the processors have any ghost indices. More... | |
MultiVector (const global_size_type globalSize, const utils::mpi::MPIComm &mpiComm, std::shared_ptr< LinAlgOpContext< memorySpace > > linAlgOpContext, const size_type numVectors, const ValueType initVal=utils::Types< ValueType >::zero) | |
Constructor for a distributed MultiVector based on total number of global indices. The resulting MultiVector will not contain any ghost indices on any of the processors. Internally, the vector is divided to ensure as much equitable distribution across all the processors much as possible. More... | |
MultiVector (const MultiVector &u) | |
Copy constructor. More... | |
MultiVector (const MultiVector &u, const ValueType initVal=utils::Types< ValueType >::zero) | |
Copy constructor with reinitialisation. More... | |
MultiVector (MultiVector &&u) noexcept | |
Move constructor. More... | |
MultiVector & | operator= (const MultiVector &u) |
Copy assignment operator. More... | |
MultiVector & | operator= (MultiVector &&u) |
Move assignment operator. More... | |
iterator | begin () |
Return iterator pointing to the beginning of MultiVector data. More... | |
const_iterator | begin () const |
Return iterator pointing to the beginning of MultiVector data. More... | |
iterator | end () |
Return iterator pointing to the end of MultiVector data. More... | |
const_iterator | end () const |
Return iterator pointing to the end of MultiVector data. More... | |
ValueType * | data () |
Return the raw pointer to the MultiVector data. More... | |
const ValueType * | data () const |
Return the constant raw pointer to the MultiVector data. More... | |
void | setValue (const ValueType val) |
Set all entries of the MultiVector to a given value. More... | |
std::vector< double > | l2Norms () const |
Returns \( l_2 \) norms of all the \(N\) vectors in the MultiVector. More... | |
std::vector< double > | lInfNorms () const |
Returns \( l_{\inf} \) norms of all the \(N\) vectors in the MultiVector. More... | |
size_type | getNumberComponents () const |
Returns the nunber of vectors in this multi-vector. More... | |
void | updateGhostValues (const size_type communicationChannel=0) |
void | accumulateAddLocallyOwned (const size_type communicationChannel=0) |
void | updateGhostValuesBegin (const size_type communicationChannel=0) |
void | updateGhostValuesEnd () |
void | accumulateAddLocallyOwnedBegin (const size_type communicationChannel=0) |
void | accumulateAddLocallyOwnedEnd () |
bool | isCompatible (const MultiVector< ValueType, memorySpace > &rhs) const |
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > | getMPIPatternP2P () const |
std::shared_ptr< LinAlgOpContext< memorySpace > > | getLinAlgOpContext () const |
global_size_type | globalSize () const |
size_type | localSize () const |
size_type | locallyOwnedSize () const |
size_type | ghostSize () const |
size_type | numVectors () const |
Protected Attributes | |
std::unique_ptr< Storage > | d_storage |
std::shared_ptr< LinAlgOpContext< memorySpace > > | d_linAlgOpContext |
VectorAttributes | d_vectorAttributes |
size_type | d_localSize |
global_size_type | d_globalSize |
size_type | d_locallyOwnedSize |
size_type | d_ghostSize |
size_type | d_numVectors |
std::unique_ptr< utils::mpi::MPICommunicatorP2P< ValueType, memorySpace > > | d_mpiCommunicatorP2P |
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > | d_mpiPatternP2P |
An class template to encapsulate a MultiVector. A MultiVector is a collection of \(N\) vectors belonging to the same finite-dimensional vector space, where usual notion of vector size denotes the dimension of the vector space. Note that this in the mathematical sense and not in the sense of an multi-dimensional array.The MultiVector is stored contiguously with the vector index being the fastest index, or in other words a matrix of size \(M \times N\) in row major format with \(M \) denoting the dimension of the vector space (size of individual vector).
This class handles both serial and distributed MultiVector in a unfied way. There are different constructors provided for the serial and distributed case.
The serial MultiVector, as the name suggests, resides entirely in a processor.
The distributed MultiVector, on the other hand, is distributed across a set of processors. The storage of each of the \(N\) vectors in the distributed MultiVector in a processor follows along similar lines to a distributed Vector object and comprises of two parts:
The global size of each vector in the distributed MultiVector (i.e., the number of unique indices across all the processors) is simply termed as size. Additionally, we define localSize = locallyOwnedSize + ghostSize.
We handle the serial MultiVector as a special case of the distributed MultiVector, wherein size = locallyOwnedSize and ghostSize = 0.
template | parameter ValueType defines underlying datatype being stored in the MultiVector (i.e., int, double, complex<double>, etc.) |
template | parameter memorySpace defines the MemorySpace (i.e., HOST or DEVICE) in which the MultiVector must reside. |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::const_iterator = typename Storage::const_iterator |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::const_reference = typename Storage::const_reference |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::iterator = typename Storage::iterator |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::pointer = typename Storage::pointer |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::reference = typename Storage::reference |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::Storage = dftefe::utils::MemoryStorage<ValueType, memorySpace> |
using dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::value_type = typename Storage::value_type |
|
default |
Default Constructor.
|
default |
Default Destructor.
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | const size_type | size, |
const size_type | numVectors, | ||
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const ValueType | initVal = utils::Types<ValueType>::zero |
||
) |
Constructor for serial MultiVector with vector size, number of vectors and initial value arguments.
Constructor for a serial MultiVector using size, numVectors and init value.
[in] | size | size of each vector in the MultiVector |
[in] | numVectors | number of vectors in the MultiVector |
[in] | initVal | initial value of elements of the MultiVector |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | std::unique_ptr< typename MultiVector< ValueType, memorySpace >::Storage > | storage, |
size_type | numVectors, | ||
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext | ||
) |
Constructor for a \serial MultiVector with a predefined MultiVector::Storage (i.e., utils::MemoryStorage). This constructor transfers the ownership of the input Storage to the MultiVector. This is useful when one does not want to allocate new memory and instead use memory allocated in the MultiVector::Storage (i.e., utils::MemoryStorage). The locallyOwnedSize, ghostSize, etc., are automatically set using the size of the input Storage object.
Constructor for a \serial MultiVector with a predefined MultiVector::Storage (i.e., utils::MemoryStorage). This constructor transfers the ownership of the input Storage to the MultiVector. This is useful when one does not want to allocate new memory and instead use memory allocated in the MultiVector::Storage (i.e., utils::MemoryStorage).
[in] | storage | unique_ptr to MultiVector::Storage whose ownership is to be transfered to the MultiVector |
[in] | numVectors | number of vectors in the MultiVector |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
storage
to the internal data member of the MultiVector. Thus, after the function call storage
will point to NULL and any access through storage
will lead to undefined behavior. dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > | mpiPatternP2P, |
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const size_type | numVectors, | ||
const ValueType | initVal = utils::Types<ValueType>::zero |
||
) |
Constructor for a distributed MultiVector based on an input MPIPatternP2P.
[in] | mpiPatternP2P | A shared_ptr to const MPIPatternP2P based on which the distributed MultiVector will be created. |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
[in] | numVectors | number of vectors in the MultiVector |
[in] | initVal | value with which the MultiVector shoud be initialized |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > | mpiPatternP2P, |
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const size_type | numVectors, | ||
const ValueType | min, | ||
const ValueType | max | ||
) |
Constructor for a distributed random MultiVector based on an input MPIPatternP2P.
[in] | mpiPatternP2P | A shared_ptr to const MPIPatternP2P based on which the distributed MultiVector will be created. |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
[in] | numVectors | number of vectors in the MultiVector |
[in] | min,max | value between for the random numbers |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | std::unique_ptr< typename MultiVector< ValueType, memorySpace >::Storage > & | storage, |
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > | mpiPatternP2P, | ||
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const size_type | numVectors | ||
) |
Constructor for a distributed MultiVector with a predefined MultiVector::Storage (i.e., utils::MemoryStorage) and MPIPatternP2P. This constructor transfers the ownership of the input Storage to the MultiVector. This is useful when one does not want to allocate new memory and instead use memory allocated in the input MultiVector::Storage (i.e., utils::MemoryStorage).
[in] | storage | unique_ptr to MultiVector::Storage whose ownership is to be transfered to the MultiVector |
[in] | mpiPatternP2P | A shared_ptr to const MPIPatternP2P based on which the distributed MultiVector will be created. |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
[in] | numVectors | number of vectors in the MultiVector |
storage
to the internal data member of the MultiVector. Thus, after the function call storage
will point to NULL and any access through storage
will lead to undefined behavior. dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | const std::pair< global_size_type, global_size_type > | locallyOwnedRange, |
const std::vector< global_size_type > & | ghostIndices, | ||
const utils::mpi::MPIComm & | mpiComm, | ||
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const size_type | numVectors, | ||
ValueType | initVal = utils::Types<ValueType>::zero |
||
) |
Constructor for a \distributed MultiVector based on locally owned and ghost indices.
[in] | locallyOwnedRange | a pair \((a,b)\) which defines a range of indices (continuous) that are owned by the current processor. |
[in] | ghostIndices | vector containing an ordered set of ghost indices (ordered in increasing order and non-repeating) |
[in] | mpiComm | utils::mpi::MPIComm object associated with the group of processors across which the MultiVector is to be distributed |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
[in] | numVectors | number of vectors in the MultiVector |
[in] | initVal | value with which the MultiVector shoud be initialized |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | const std::pair< global_size_type, global_size_type > | locallyOwnedRange, |
const utils::mpi::MPIComm & | mpiComm, | ||
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const size_type | numVectors, | ||
const ValueType | initVal = utils::Types<ValueType>::zero |
||
) |
Constructor for a special case of distributed MultiVector where none none of the processors have any ghost indices.
[in] | locallyOwnedRange | a pair \((a,b)\) which defines a range of indices (continuous) that are owned by the current processor. |
[in] | mpiComm | utils::mpi::MPIComm object associated with the group of processors across which the MultiVector is to be distributed |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
[in] | numVectors | number of vectors in the MultiVector |
[in] | initVal | value with which the MultiVector shoud be initialized |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | const global_size_type | globalSize, |
const utils::mpi::MPIComm & | mpiComm, | ||
std::shared_ptr< LinAlgOpContext< memorySpace > > | linAlgOpContext, | ||
const size_type | numVectors, | ||
const ValueType | initVal = utils::Types<ValueType>::zero |
||
) |
Constructor for a distributed MultiVector based on total number of global indices. The resulting MultiVector will not contain any ghost indices on any of the processors. Internally, the vector is divided to ensure as much equitable distribution across all the processors much as possible.
[in] | globalSize | Total number of global indices that is distributed over the processors. |
[in] | mpiComm | utils::mpi::MPIComm object associated with the group of processors across which the MultiVector is to be distributed |
[in] | linAlgOpContext | shared pointer to LinAlgOpContext object |
[in] | numVectors | number of vectors in the MultiVector |
[in] | initVal | value with which the MultiVector shoud be initialized |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | const MultiVector< ValueType, memorySpace > & | u | ) |
Copy constructor.
[in] | u | MultiVector object to copy from |
dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::MultiVector | ( | const MultiVector< ValueType, memorySpace > & | u, |
const ValueType | initVal = utils::Types<ValueType>::zero |
||
) |
Copy constructor with reinitialisation.
[in] | u | MultiVector object to copy from |
[in] | initVal | Initial value of the MultiVector |
|
noexcept |
Move constructor.
[in] | u | MultiVector object to move from |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::accumulateAddLocallyOwned | ( | const size_type | communicationChannel = 0 | ) |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::accumulateAddLocallyOwnedBegin | ( | const size_type | communicationChannel = 0 | ) |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::accumulateAddLocallyOwnedEnd |
MultiVector< ValueType, memorySpace >::iterator dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::begin |
Return iterator pointing to the beginning of MultiVector data.
MultiVector< ValueType, memorySpace >::const_iterator dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::begin |
Return iterator pointing to the beginning of MultiVector data.
ValueType * dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::data |
Return the raw pointer to the MultiVector data.
const ValueType * dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::data |
Return the constant raw pointer to the MultiVector data.
MultiVector< ValueType, memorySpace >::iterator dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::end |
Return iterator pointing to the end of MultiVector data.
MultiVector< ValueType, memorySpace >::const_iterator dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::end |
Return iterator pointing to the end of MultiVector data.
std::shared_ptr< LinAlgOpContext< memorySpace > > dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::getLinAlgOpContext |
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::getMPIPatternP2P |
size_type dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::getNumberComponents |
Returns the nunber of vectors in this multi-vector.
size_type dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::ghostSize |
global_size_type dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::globalSize |
bool dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::isCompatible | ( | const MultiVector< ValueType, memorySpace > & | rhs | ) | const |
std::vector< double > dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::l2Norms |
Returns \( l_2 \) norms of all the \(N\) vectors in the MultiVector.
std::vector< double > dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::lInfNorms |
Returns \( l_{\inf} \) norms of all the \(N\) vectors in the MultiVector.
size_type dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::locallyOwnedSize |
size_type dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::localSize |
size_type dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::numVectors |
MultiVector< ValueType, memorySpace > & dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::operator= | ( | const MultiVector< ValueType, memorySpace > & | u | ) |
Copy assignment operator.
[in] | u | const reference to MultiVector object to copy from |
MultiVector< ValueType, memorySpace > & dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::operator= | ( | MultiVector< ValueType, memorySpace > && | u | ) |
Move assignment operator.
[in] | u | const reference to MultiVector object to move from |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::setValue | ( | const ValueType | val | ) |
Set all entries of the MultiVector to a given value.
[in] | val | The value to which the entries are to be set |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::updateGhostValues | ( | const size_type | communicationChannel = 0 | ) |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::updateGhostValuesBegin | ( | const size_type | communicationChannel = 0 | ) |
void dftefe::linearAlgebra::MultiVector< ValueType, memorySpace >::updateGhostValuesEnd |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |