#include <ReplicatableVector.hpp>
Public Member Functions | |
ReplicatableVector () | |
ReplicatableVector (Vec vec) | |
ReplicatableVector (unsigned size) | |
~ReplicatableVector () | |
unsigned | size () |
void | resize (unsigned size) |
double & | operator[] (unsigned index) |
void | Replicate (unsigned lo, unsigned hi) |
void | ReplicatePetscVector (Vec vec) |
Private Member Functions | |
void | RemovePetscContext () |
Private Attributes | |
std::vector< double > | mData |
VecScatter | mToAll |
Vec | mReplicated |
Vec | mDistributed |
Definition at line 39 of file ReplicatableVector.hpp.
ReplicatableVector::ReplicatableVector | ( | ) |
Default constructor. Note that the vector will need to be resized before it can be used.
Definition at line 59 of file ReplicatableVector.cpp.
ReplicatableVector::ReplicatableVector | ( | Vec | vec | ) |
Constructor taking in Petsc vector, which is immediately replicated into the internal data
vec | a Petsc vector |
Definition at line 66 of file ReplicatableVector.cpp.
References ReplicatePetscVector().
ReplicatableVector::ReplicatableVector | ( | unsigned | size | ) |
Constructor to make a vector of given size.
size | the size of the vector |
Definition at line 74 of file ReplicatableVector.cpp.
References resize().
ReplicatableVector::~ReplicatableVector | ( | ) |
Default destructor. Remove PETSc context.
Definition at line 82 of file ReplicatableVector.cpp.
References RemovePetscContext().
void ReplicatableVector::RemovePetscContext | ( | ) | [private] |
Clear data. Used in resize method and destructor.
Definition at line 36 of file ReplicatableVector.cpp.
References mDistributed, mReplicated, and mToAll.
Referenced by resize(), and ~ReplicatableVector().
unsigned ReplicatableVector::size | ( | ) |
Return the size of the vector.
Definition at line 90 of file ReplicatableVector.cpp.
References mData.
Referenced by AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, CONCRETE >::AssembleOnElement(), AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, CONCRETE >::AssembleSystem(), AbstractFunctionalCalculator< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Calculate(), Replicate(), ReplicatePetscVector(), and Hdf5ToMeshalyzerConverter::Write().
void ReplicatableVector::resize | ( | unsigned | size | ) |
Resize the vector.
size | The number of elements to allocate memory for. |
Definition at line 95 of file ReplicatableVector.cpp.
References mData, and RemovePetscContext().
Referenced by AbstractCardiacPde< ELEM_DIM, SPACE_DIM >::AbstractCardiacPde(), BidomainPde< SPACE_DIM >::BidomainPde(), ReplicatableVector(), and ReplicatePetscVector().
double & ReplicatableVector::operator[] | ( | unsigned | index | ) |
Access the vector.
index | the index of the vector to return |
Definition at line 102 of file ReplicatableVector.cpp.
References mData.
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.
lo | The start of our ownership range | |
hi | One past the end of our ownership range |
Definition at line 111 of file ReplicatableVector.cpp.
References mData, mDistributed, ReplicatePetscVector(), and size().
Referenced by AbstractCardiacPde< ELEM_DIM, SPACE_DIM >::ReplicateCaches().
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.
vec | The PETSc vector to replicate. |
Definition at line 132 of file ReplicatableVector.cpp.
References mData, mReplicated, mToAll, resize(), and size().
Referenced by AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, CONCRETE >::AssembleSystem(), AbstractFunctionalCalculator< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Calculate(), ReplicatableVector(), Replicate(), MonodomainProblem< ELEM_DIM, SPACE_DIM >::WriteInfo(), and BidomainProblem< DIM >::WriteInfo().
std::vector<double> ReplicatableVector::mData [private] |
The wrapped vector.
Definition at line 46 of file ReplicatableVector.hpp.
Referenced by operator[](), Replicate(), ReplicatePetscVector(), resize(), and size().
VecScatter ReplicatableVector::mToAll [private] |
Variable holding information for replicating a PETSc vector.
Definition at line 48 of file ReplicatableVector.hpp.
Referenced by RemovePetscContext(), and ReplicatePetscVector().
Vec ReplicatableVector::mReplicated [private] |
Vector to hold concentrated copy of replicated vector.
Definition at line 49 of file ReplicatableVector.hpp.
Referenced by RemovePetscContext(), and ReplicatePetscVector().
Vec ReplicatableVector::mDistributed [private] |
Vector to hold data before replication.
Definition at line 50 of file ReplicatableVector.hpp.
Referenced by RemovePetscContext(), and Replicate().