Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
PetscTools.hpp File Reference
#include <string>
#include <vector>
#include <cstdlib>
#include <petsc.h>
#include <petscvec.h>
#include <petscmat.h>
#include <petscsys.h>
+ Include dependency graph for PetscTools.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PetscTools
 

Macros

#define EXIT_IF_PARALLEL   if(PetscTools::IsParallel()){TS_TRACE("This test does not pass in parallel yet.");return;}
 
#define EXIT_IF_SEQUENTIAL   if(PetscTools::IsSequential()){TS_TRACE("This test is not meant to be executed in sequential.");return;}
 
#define CHASTE_PETSC_NULLPTR   PETSC_NULL
 A macro to define PETSc null pointer based on the PETSc version.
 
#define PETSC_DESTROY_PARAM(x)   x
 
#define TRY_IF_MASTER(method)
 

Typedefs

typedef PetscTruth PetscBool
 

Detailed Description

Contains the PetscTools class.

Definition in file PetscTools.hpp.

Macro Definition Documentation

◆ CHASTE_PETSC_NULLPTR

#define CHASTE_PETSC_NULLPTR   PETSC_NULL

A macro to define PETSc null pointer based on the PETSc version.

This macro is defined to handle the change in PETSc's null pointer definition between versions. For PETSc version 3.19.0 and later, it uses PETSC_NULLPTR. For older versions, it uses PETSC_NULL. See https://github.com/Chaste/Chaste/issues/263.

Definition at line 69 of file PetscTools.hpp.

◆ EXIT_IF_PARALLEL

#define EXIT_IF_PARALLEL   if(PetscTools::IsParallel()){TS_TRACE("This test does not pass in parallel yet.");return;}

For use in tests that do not work when run in parallel.

Definition at line 54 of file PetscTools.hpp.

◆ EXIT_IF_SEQUENTIAL

#define EXIT_IF_SEQUENTIAL   if(PetscTools::IsSequential()){TS_TRACE("This test is not meant to be executed in sequential.");return;}

For use in tests that should ONLY be run in parallel.

Definition at line 56 of file PetscTools.hpp.

◆ PETSC_DESTROY_PARAM

#define PETSC_DESTROY_PARAM (   x)    x

This macro is for converting a pre-PETSc3.2 "Destroy" function call (which involves an object, such as PetscViewerDestroy(VecView view) ) to a PETSc3.2 destroy via pointer call. Note that we only use this macro for calls which appear rarely in the code. Please destroy Vec and Mat objects via the overloaded PetscTools::Destroy methods.

Parameters
xThe object to destroy

Definition at line 84 of file PetscTools.hpp.

◆ TRY_IF_MASTER

#define TRY_IF_MASTER (   method)
Value:
{ \
{ try { \
method; \
} catch (Exception& e) { \
PetscTools::ReplicateException(true);\
throw(e); \
} } \
PetscTools::ReplicateException(false); \
}
static bool AmMaster()

A macro to allow code to be attempted by just the master process, but to replicate any exceptions that occur to other processes. Useful for file access.

Note
MUST be called collectively, as it contains a barrier.
Parameters
methoda command or block of code to run if master process

Definition at line 105 of file PetscTools.hpp.

Typedef Documentation

◆ PetscBool

typedef PetscTruth PetscBool

Older versions of PETSc used PetscTruth in place of PetscBool, so we define an alias for those installations.

Definition at line 76 of file PetscTools.hpp.