38 #include "DistributedVectorFactory.hpp" 55 VecGetOwnershipRange(vec, &petsc_lo, &petsc_hi);
61 VecGetSize(vec, &size);
70 EXCEPTION(
"Cannot set from a factory for a different number of processes.");
74 EXCEPTION(
"Cannot set from a factory for a different problem size.");
137 PetscBool petsc_is_initialised;
138 PetscInitialized(&petsc_is_initialised);
145 assert(petsc_is_initialised);
151 return (
mLo<=globalIndex && globalIndex<
mHi);
163 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 3) //PETSc 3.3 or later 166 VecCreate(PETSC_COMM_WORLD, &vec);
167 VecSetBlockSize(vec, stride);
169 VecSetType(vec,VECMPI);
172 VecCreateMPI(PETSC_COMM_WORLD, stride*(
mHi-
mLo), stride*mProblemSize, &vec);
173 VecSetBlockSize(vec, stride);
175 #if (PETSC_VERSION_MAJOR == 3) //PETSc 3.x.x 176 VecSetOption(vec, VEC_IGNORE_OFF_PROC_ENTRIES, PETSC_TRUE);
178 VecSetOption(vec, VEC_IGNORE_OFF_PROC_ENTRIES);
197 MPI_Allgather( &
mLo, 1, MPI_UNSIGNED, &
mGlobalLows[0], 1, MPI_UNSIGNED, PETSC_COMM_WORLD);
std::vector< unsigned > & rGetGlobalLows()
std::vector< unsigned > mGlobalLows
~DistributedVectorFactory()
DistributedVector CreateDistributedVector(Vec vec, bool readOnly=false)
#define EXCEPTION(message)
bool IsGlobalIndexLocal(unsigned globalIndex)
static bool msCheckNumberOfProcessesOnLoad
DistributedVectorFactory(Vec vec)
unsigned GetProblemSize() const
void SetFromFactory(DistributedVectorFactory *pFactory)
DistributedVectorFactory * mpOriginalFactory
#define CHASTE_CLASS_EXPORT(T)
unsigned GetNumProcs() const
void CalculateOwnership(Vec vec)