36 #ifndef PETSCTOOLS_HPP_
37 #define PETSCTOOLS_HPP_
54 #define EXIT_IF_PARALLEL if(PetscTools::IsParallel()){TS_TRACE("This test does not pass in parallel yet.");return;}
56 #define EXIT_IF_SEQUENTIAL if(PetscTools::IsSequential()){TS_TRACE("This test is not meant to be executed in sequential.");return;}
58 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR < 2 || PETSC_VERSION_MAJOR<3 ) // Before PETSc 3.2
70 #define PETSC_DESTROY_PARAM(x) x
79 #define PETSC_DESTROY_PARAM(x) &x
91 #define TRY_IF_MASTER(method) { \
92 if (PetscTools::AmMaster()) \
95 } catch (Exception& e) { \
96 PetscTools::ReplicateException(true);\
99 PetscTools::ReplicateException(false); \
201 static void Barrier(
const std::string callerId=
"");
243 static Vec CreateVec(
int size,
int localSize=PETSC_DECIDE,
bool ignoreOffProcEntries =
true);
281 static void SetupMat(
Mat& rMat,
int numRows,
int numColumns,
282 unsigned rowPreallocation,
283 int numLocalRows=PETSC_DECIDE,
284 int numLocalColumns=PETSC_DECIDE,
285 bool ignoreOffProcEntries=
true,
286 bool newAllocationError=
true);
327 static void ReadPetscObject(
Mat& rMat,
const std::string& rOutputFileFullPath,
Vec rParallelLayout=
nullptr);
336 static void ReadPetscObject(
Vec& rVec,
const std::string& rOutputFileFullPath,
Vec rParallelLayout=
nullptr);
354 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 2) //PETSc 3.2 or later
370 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 2) //PETSc 3.2 or later
384 static inline void SetOption(
const char* pOptionName,
const char* pOptionValue)
388 const std::string str_option_name(pOptionName);
389 if (str_option_name.find(
"log") != std::string::npos)
391 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 6) // PETSc 3.6
393 #elif (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 7) // PETSc 3.7 or later
394 PetscLogDefaultBegin();
398 #if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 7) // PETSc 3.7 or later
399 PetscOptionsSetValue(NULL, pOptionName, pOptionValue);
401 PetscOptionsSetValue(pOptionName, pOptionValue);