36 #include "ReplicatableVector.hpp"
117 catch(std::bad_alloc &badAlloc)
119 #define COVERAGE_IGNORE
120 std::cout <<
"Failed to allocate a ReplicatableVector of size " << size << std::endl;
123 #undef COVERAGE_IGNORE
130 assert(index <
mSize);
141 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 3) //PETSc 3.3 or later
143 VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, hi-lo, this->
GetSize(), &
mpData[lo], &distributed_vec);
145 VecCreateMPIWithArray(PETSC_COMM_WORLD, hi-lo, this->
GetSize(), &
mpData[lo], &distributed_vec);
147 #if (PETSC_VERSION_MAJOR == 3) //PETSc 3.x.x
148 VecSetOption(distributed_vec, VEC_IGNORE_OFF_PROC_ENTRIES, PETSC_TRUE);
150 VecSetOption(distributed_vec, VEC_IGNORE_OFF_PROC_ENTRIES);
163 VecGetSize(vec, &isize);
164 unsigned size = isize;
178 #if ( (PETSC_VERSION_MAJOR == 3) || (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 3 && PETSC_VERSION_SUBMINOR == 3)) //2.3.3 or 3.x.x
189 double* p_replicated;
191 for (
unsigned i=0; i<size; i++)
193 mpData[i] = p_replicated[i];
void Replicate(unsigned lo, unsigned hi)
double & operator[](unsigned index)
void RemovePetscContext()
void ReplicatePetscVector(Vec vec)
void Resize(unsigned size)