Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
ReplicatableVector Class Reference

#include <ReplicatableVector.hpp>

+ Collaboration diagram for ReplicatableVector:

Public Member Functions

 ReplicatableVector ()
 
 ReplicatableVector (Vec vec)
 
 ReplicatableVector (unsigned size)
 
 ~ReplicatableVector ()
 
unsigned GetSize ()
 
void Resize (unsigned size)
 
doubleoperator[] (unsigned index)
 
void Replicate (unsigned lo, unsigned hi)
 
void ReplicatePetscVector (Vec vec)
 

Private Member Functions

void RemovePetscContext ()
 

Private Attributes

doublempData
 
unsigned mSize
 
VecScatter mToAll
 
Vec mReplicated
 

Detailed Description

Helper class for replicating a PETSc vector.

Definition at line 45 of file ReplicatableVector.hpp.

Constructor & Destructor Documentation

◆ ReplicatableVector() [1/3]

ReplicatableVector::ReplicatableVector ( )

Default constructor. Note that the vector will need to be resized before it can be used.

Definition at line 68 of file ReplicatableVector.cpp.

◆ ReplicatableVector() [2/3]

ReplicatableVector::ReplicatableVector ( Vec  vec)

Constructor taking in PETSc vector, which is immediately replicated into the internal data

Parameters
veca PETSc vector

Definition at line 76 of file ReplicatableVector.cpp.

References ReplicatePetscVector().

◆ ReplicatableVector() [3/3]

ReplicatableVector::ReplicatableVector ( unsigned  size)

Constructor to make a vector of given size.

Parameters
sizethe size of the vector

Definition at line 85 of file ReplicatableVector.cpp.

References Resize().

◆ ~ReplicatableVector()

ReplicatableVector::~ReplicatableVector ( )

Default destructor. Remove PETSc context.

Definition at line 94 of file ReplicatableVector.cpp.

References RemovePetscContext().

Member Function Documentation

◆ GetSize()

◆ operator[]()

double & ReplicatableVector::operator[] ( unsigned  index)

Access the vector.

Parameters
indexthe index of the vector to return
Returns
reference to component of the vector

Definition at line 129 of file ReplicatableVector.cpp.

References mpData, and mSize.

◆ RemovePetscContext()

void ReplicatableVector::RemovePetscContext ( )
private

Clear data. Used in resize method and destructor.

Definition at line 45 of file ReplicatableVector.cpp.

References PetscTools::Destroy(), mpData, mReplicated, mToAll, and PETSC_DESTROY_PARAM.

Referenced by ~ReplicatableVector(), and Resize().

◆ Replicate()

void ReplicatableVector::Replicate ( unsigned  lo,
unsigned  hi 
)

Replicate this vector over all processes.

Each process knows its local part of the vector. This method shares that knowledge across all the processes.

Parameters
loThe start of our ownership range
hiOne past the end of our ownership range

Definition at line 137 of file ReplicatableVector.cpp.

References PetscTools::Destroy(), GetSize(), mpData, and ReplicatePetscVector().

◆ ReplicatePetscVector()

void ReplicatableVector::ReplicatePetscVector ( Vec  vec)

Replicate the given PETSc vector over all processes.

Each process knows its local part of the vector. This method shares that knowledge across all the processes, storing it in this object.

Our data vector will automatically be resized to fit the whole PETSc vector.

Parameters
vecThe PETSc vector to replicate.

Definition at line 160 of file ReplicatableVector.cpp.

References GetSize(), mpData, mReplicated, mToAll, and Resize().

Referenced by Hdf5ToTxtConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToTxtConverter(), ReplicatableVector(), Replicate(), and Hdf5ToMeshalyzerConverter< ELEMENT_DIM, SPACE_DIM >::Write().

◆ Resize()

Member Data Documentation

◆ mpData

double* ReplicatableVector::mpData
private

The wrapped PeTSc vector.

Definition at line 49 of file ReplicatableVector.hpp.

Referenced by operator[](), RemovePetscContext(), Replicate(), ReplicatePetscVector(), and Resize().

◆ mReplicated

Vec ReplicatableVector::mReplicated
private

Vector to hold concentrated copy of replicated vector.

Definition at line 52 of file ReplicatableVector.hpp.

Referenced by RemovePetscContext(), and ReplicatePetscVector().

◆ mSize

unsigned ReplicatableVector::mSize
private

The length of the vector.

Definition at line 50 of file ReplicatableVector.hpp.

Referenced by GetSize(), operator[](), and Resize().

◆ mToAll

VecScatter ReplicatableVector::mToAll
private

Variable holding information for replicating a PETSc vector.

Definition at line 51 of file ReplicatableVector.hpp.

Referenced by RemovePetscContext(), and ReplicatePetscVector().


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