36 #include "ReplicatableVector.hpp" 118 catch(std::bad_alloc &badAlloc)
120 std::cout <<
"Failed to allocate a ReplicatableVector of size " << size << std::endl;
131 assert(index <
mSize);
142 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 3) //PETSc 3.3 or later 144 VecCreateMPIWithArray(PETSC_COMM_WORLD, 1, hi-lo, this->
GetSize(), &
mpData[lo], &distributed_vec);
146 VecCreateMPIWithArray(PETSC_COMM_WORLD, hi-lo, this->
GetSize(), &
mpData[lo], &distributed_vec);
148 #if (PETSC_VERSION_MAJOR == 3) //PETSc 3.x.x 149 VecSetOption(distributed_vec, VEC_IGNORE_OFF_PROC_ENTRIES, PETSC_TRUE);
151 VecSetOption(distributed_vec, VEC_IGNORE_OFF_PROC_ENTRIES);
164 VecGetSize(vec, &isize);
165 unsigned size = isize;
179 #if ((PETSC_VERSION_MAJOR == 3) || (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 3 && PETSC_VERSION_SUBMINOR == 3)) //2.3.3 or 3.x.x 190 double* p_replicated;
192 for (
unsigned i=0; i<size; i++)
194 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)