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;}
66#if PETSC_VERSION_GE(3, 19, 0)
67#define CHASTE_PETSC_NULLPTR PETSC_NULLPTR
69#define CHASTE_PETSC_NULLPTR PETSC_NULL
72#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR < 2 || PETSC_VERSION_MAJOR<3 )
76typedef PetscTruth PetscBool;
84#define PETSC_DESTROY_PARAM(x) x
93#define PETSC_DESTROY_PARAM(x) &x
105#define TRY_IF_MASTER(method) { \
106 if (PetscTools::AmMaster()) \
109 } catch (Exception& e) { \
110 PetscTools::ReplicateException(true);\
113 PetscTools::ReplicateException(false); \
215 static void Barrier(
const std::string callerId=
"");
257 static Vec CreateVec(
int size,
int localSize=PETSC_DECIDE,
bool ignoreOffProcEntries =
true);
295 static void SetupMat(
Mat& rMat,
int numRows,
int numColumns,
296 unsigned rowPreallocation,
297 int numLocalRows=PETSC_DECIDE,
298 int numLocalColumns=PETSC_DECIDE,
299 bool ignoreOffProcEntries=
true,
300 bool newAllocationError=
true);
341 static void ReadPetscObject(
Mat& rMat,
const std::string& rOutputFileFullPath,
Vec rParallelLayout=
nullptr);
350 static void ReadPetscObject(
Vec& rVec,
const std::string& rOutputFileFullPath,
Vec rParallelLayout=
nullptr);
368#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 2)
384#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 2)
398 static inline void SetOption(
const char* pOptionName,
const char* pOptionValue)
402 const std::string str_option_name(pOptionName);
403 if (str_option_name.find(
"log") != std::string::npos)
405#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR == 6)
407#elif (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 7)
408 PetscLogDefaultBegin();
412#if (PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 7)
413 PetscOptionsSetValue(NULL, pOptionName, pOptionValue);
415 PetscOptionsSetValue(pOptionName, pOptionValue);
419#if PETSC_VERSION_GE(3, 11, 2)
432 static PetscErrorCode ChasteMatCopy(Mat A, Mat B, MatStructure str);