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 )
62typedef PetscTruth PetscBool;
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)
370#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 2)
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)
393#elif (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 7)
394 PetscLogDefaultBegin();
398#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 7)
399 PetscOptionsSetValue(NULL, pOptionName, pOptionValue);
401 PetscOptionsSetValue(pOptionName, pOptionValue);
405#if PETSC_VERSION_GE(3, 11, 2)
418 static PetscErrorCode ChasteMatCopy(Mat A, Mat B, MatStructure str);