Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
DistributedVector Class Reference

#include <DistributedVector.hpp>

+ Collaboration diagram for DistributedVector:

Classes

class  Chunk
 
class  Iterator
 
class  Stripe
 

Public Member Functions

bool IsGlobalIndexLocal (unsigned globalIndex)
 
 DistributedVector (Vec vec, DistributedVectorFactory *pFactory, bool readOnly=false)
 
unsigned GetHigh () const
 
unsigned GetLow () const
 
DistributedVectorFactoryGetFactory ()
 
doubleoperator[] (unsigned globalIndex)
 
void Restore ()
 
Iterator Begin ()
 
Iterator End ()
 
doubleoperator[] (Iterator index)
 

Private Attributes

unsigned mLo
 
unsigned mHi
 
unsigned mProblemSize
 
unsigned mSizeMultiplier
 
Vec mVec
 
doublempVec
 
DistributedVectorFactorympFactory
 
bool mReadOnly
 

Friends

class TestDistributedVector
 

Detailed Description

Gives access to the local portion of a PETSc vector via an iterator.

It also provides two nested classes for accessing vectors with particular memory layouts: striped and chunked.

Definition at line 55 of file DistributedVector.hpp.

Constructor & Destructor Documentation

◆ DistributedVector()

DistributedVector::DistributedVector ( Vec  vec,
DistributedVectorFactory pFactory,
bool  readOnly = false 
)

Constructor. This class represents the portion of a distributed PETSc vector on this process.

Note that this class does NOT take over responsibility for destroying the Vec.

Parameters
vecPETSc vector of which this class shall be a portion
readOnlyA suggestion to PETSc that we are not going to change the content of the Vec (Note that it may still be possible to alter the content of the vector in an inconsistent way – the user is responsible for ensuring that this doesn't happen.) *
pFactorypointer to the DistributedVectorFactory used to create this vector

Definition at line 44 of file DistributedVector.cpp.

References DistributedVectorFactory::GetHigh(), DistributedVectorFactory::GetLow(), DistributedVectorFactory::GetProblemSize(), mHi, mLo, mProblemSize, mpVec, mReadOnly, and mSizeMultiplier.

Member Function Documentation

◆ Begin()

◆ End()

◆ GetFactory()

DistributedVectorFactory * DistributedVector::GetFactory ( )
inline
Returns
the factory used to create this vector.

Definition at line 139 of file DistributedVector.hpp.

References mpFactory.

Referenced by DistributedVector::Stripe::Stripe().

◆ GetHigh()

unsigned DistributedVector::GetHigh ( ) const
inline
Returns
mHi - The next index above the top one owned by the process.

Definition at line 123 of file DistributedVector.hpp.

References mHi.

Referenced by DistributedVector::Chunk::Chunk(), and DistributedVector::Stripe::Stripe().

◆ GetLow()

unsigned DistributedVector::GetLow ( ) const
inline
Returns
mLo - The lowest index owned by the process.

Definition at line 131 of file DistributedVector.hpp.

References mLo.

Referenced by DistributedVector::Chunk::Chunk(), and DistributedVector::Stripe::Stripe().

◆ IsGlobalIndexLocal()

bool DistributedVector::IsGlobalIndexLocal ( unsigned  globalIndex)

Test if the given global index is owned by the current process, i.e. is local to it.

Parameters
globalIndex
Returns
true if the global index can be accessed by this process

Definition at line 39 of file DistributedVector.cpp.

References mHi, and mLo.

Referenced by BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::ApplyDirichletToNonlinearResidual().

◆ operator[]() [1/2]

double & DistributedVector::operator[] ( Iterator  index)
Parameters
index
Returns
value of distributed vector pointed to by index. Do not use if stride>1.

Definition at line 88 of file DistributedVector.cpp.

References mpVec, and mSizeMultiplier.

◆ operator[]() [2/2]

double & DistributedVector::operator[] ( unsigned  globalIndex)
Parameters
globalIndex
Returns
value of distributed vector at globalIndex Do not use if stride>1. For use in tests. Will throw a DistributedVectorException if the specified element is not on this process.

Definition at line 78 of file DistributedVector.cpp.

References mHi, mLo, mpVec, and mSizeMultiplier.

◆ Restore()

Friends And Related Symbol Documentation

◆ TestDistributedVector

friend class TestDistributedVector
friend

Definition at line 58 of file DistributedVector.hpp.

Member Data Documentation

◆ mHi

unsigned DistributedVector::mHi
private

One above the last entry owned by the current processor.

Definition at line 66 of file DistributedVector.hpp.

Referenced by DistributedVector(), End(), GetHigh(), IsGlobalIndexLocal(), and operator[]().

◆ mLo

unsigned DistributedVector::mLo
private

The first entry owned by the current processor.

Definition at line 63 of file DistributedVector.hpp.

Referenced by DistributedVector(), Begin(), End(), GetLow(), IsGlobalIndexLocal(), and operator[]().

◆ mpFactory

DistributedVectorFactory* DistributedVector::mpFactory
private

Pointer to the factory that created this DistributedVector. Gives access to local and global sizes

Definition at line 86 of file DistributedVector.hpp.

Referenced by GetFactory().

◆ mProblemSize

unsigned DistributedVector::mProblemSize
private

The problem size, i.e. the length of the vector of unknowns.

Definition at line 69 of file DistributedVector.hpp.

Referenced by DistributedVector().

◆ mpVec

double* DistributedVector::mpVec
private

The local part of the underlying PETSc vector.

Definition at line 80 of file DistributedVector.hpp.

Referenced by DistributedVector::Chunk::Chunk(), DistributedVector(), DistributedVector::Stripe::Stripe(), operator[](), operator[](), and Restore().

◆ mReadOnly

bool DistributedVector::mReadOnly
private

A hint to PETSc that we only want to read from the vector (and never write). Note that it may still be possible to alter the content of the vector in an inconsistent way – the user is responsible for ensuring that this doesn't happen. The only makes sense with PETSc 3.2 and above.

Definition at line 93 of file DistributedVector.hpp.

Referenced by DistributedVector(), and Restore().

◆ mSizeMultiplier

unsigned DistributedVector::mSizeMultiplier
private

How much bigger this vector is than the problem size.

Definition at line 74 of file DistributedVector.hpp.

Referenced by DistributedVector::Chunk::Chunk(), DistributedVector(), DistributedVector::Stripe::Stripe(), operator[](), and operator[]().

◆ mVec

Vec DistributedVector::mVec
private

The underlying PETSc vector.

Definition at line 77 of file DistributedVector.hpp.

Referenced by Restore().


The documentation for this class was generated from the following files: