#include <PetscTools.hpp>
Static Public Member Functions | |
static void | ResetCache () |
static bool | IsSequential () |
static unsigned | NumProcs () |
static unsigned | GetMyRank () |
static bool | AmMaster () |
static void | Barrier () |
static Vec | CreateVec (int size) |
static Vec | CreateVec (int size, double value) |
static Vec | CreateVec (std::vector< double > data) |
static void | SetupMat (Mat &rMat, int numRows, int numColumns, MatType matType=(MatType) MATMPIAIJ, int numLocalRows=PETSC_DECIDE, int numLocalColumns=PETSC_DECIDE, int maxColsPerRow=54) |
static void | ReplicateException (bool flag) |
static void | DumpPetscObject (Mat &rMat, const std::string &rOutputFileFullPath) |
static void | DumpPetscObject (Vec &rVec, const std::string &rOutputFileFullPath) |
static void | ReadPetscObject (Mat &rMat, const std::string &rOutputFileFullPath) |
static void | ReadPetscObject (Vec &rVec, const std::string &rOutputFileFullPath) |
Static Public Attributes | |
static const unsigned | MASTER_RANK = 0 |
Static Private Attributes | |
static bool | mPetscIsInitialised = false |
static unsigned | mNumProcessors = 0 |
static unsigned | mRank = 0 |
Definition at line 54 of file PetscTools.hpp.
void PetscTools::ResetCache | ( | ) | [static] |
Reset our cached values: whether PETSc is initialised, how many processors there are, and which one we are.
Definition at line 35 of file PetscTools.cpp.
References mNumProcessors, mPetscIsInitialised, and mRank.
Referenced by AmMaster(), Barrier(), GetMyRank(), IsSequential(), and NumProcs().
bool PetscTools::IsSequential | ( | ) | [static] |
Just returns whether there is one process or not.
Definition at line 70 of file PetscTools.cpp.
References mNumProcessors, and ResetCache().
Referenced by GenericEventHandler< 9, CancerEventHandler >::Headings(), and GenericEventHandler< 9, CancerEventHandler >::Report().
unsigned PetscTools::NumProcs | ( | ) | [static] |
Returns total number of processors
Definition at line 79 of file PetscTools.cpp.
References mNumProcessors, and ResetCache().
Referenced by AbstractCardiacPde< SPACE_DIM >::AbstractCardiacPde(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ComputeMeshPartitioning(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, MonodomainRhsMatrixAssembler< DIM > >::PrepareForSolve(), and GenericEventHandler< 9, CancerEventHandler >::Report().
unsigned PetscTools::GetMyRank | ( | ) | [static] |
Return our rank.
If PETSc has not been initialized, returns 0.
Definition at line 88 of file PetscTools.cpp.
References mNumProcessors, mRank, and ResetCache().
Referenced by AbstractCardiacPde< SPACE_DIM >::AbstractCardiacPde(), AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, MonodomainRhsMatrixAssembler< DIM > >::PrepareForSolve(), and GenericEventHandler< 9, CancerEventHandler >::Report().
bool PetscTools::AmMaster | ( | ) | [static] |
Just returns whether it is the master process or not.
If not running in parallel, always returns true.
Definition at line 97 of file PetscTools.cpp.
References MASTER_RANK, mNumProcessors, mRank, and ResetCache().
Referenced by AbstractCardiacProblem< SPACE_DIM, PROBLEM_DIM >::CloseFilesAndPostProcess(), Hdf5ToMeshalyzerConverter::Hdf5ToMeshalyzerConverter(), GenericEventHandler< 9, CancerEventHandler >::Headings(), OutputFileHandler::OutputFileHandler(), GenericEventHandler< 9, CancerEventHandler >::Report(), and Hdf5ToMeshalyzerConverter::Write().
void PetscTools::Barrier | ( | ) | [static] |
If MPI is set up, perform a barrier synchronisation. If not, it's a noop.
Definition at line 110 of file PetscTools.cpp.
References mNumProcessors, mPetscIsInitialised, and ResetCache().
Referenced by GenericEventHandler< 9, CancerEventHandler >::Headings(), HoneycombMeshGenerator::Make2dPeriodicCryptMesh(), and GenericEventHandler< 9, CancerEventHandler >::Report().
Vec PetscTools::CreateVec | ( | int | size | ) | [static] |
Create a vector of the specified size. SetFromOptions is called.
size |
Definition at line 144 of file PetscTools.cpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::CreateConstantInitialGuess(), and CreateVec().
Vec PetscTools::CreateVec | ( | int | size, | |
double | value | |||
) | [static] |
Create a vector of the specified size with all values set to be the given constant. SetFromOptions is called.
size | ||
value |
Definition at line 154 of file PetscTools.cpp.
References CreateVec().
Vec PetscTools::CreateVec | ( | std::vector< double > | data | ) | [static] |
Create a Vec from the given data.
data |
Definition at line 170 of file PetscTools.cpp.
References CreateVec().
void PetscTools::SetupMat | ( | Mat & | rMat, | |
int | numRows, | |||
int | numColumns, | |||
MatType | matType = (MatType) MATMPIAIJ , |
|||
int | numLocalRows = PETSC_DECIDE , |
|||
int | numLocalColumns = PETSC_DECIDE , |
|||
int | maxColsPerRow = 54 | |||
) | [static] |
Set up a matrix - set the size using the given parameters, the type (default MATMPIAIJ). The number of local rows and columns is by default PETSC_DECIDE. SetFromOptions is called.
rMat | the matrix | |
numRows | the number of rows in the matrix | |
numColumns | the number of columns in the matrix | |
matType | the matrix type (defaults to MATMPIAIJ) | |
numLocalRows | the number of local rows (detaults to PETSC_DECIDE) | |
numLocalColumns | the number of local columns (detaults to PETSC_DECIDE) | |
maxColsPerRow | The maximum number of non zeros per row. This value is problem dependent. An upper bound is (3^ELEMENT_DIM) * PROBLEM_DIM. The default value (3D bidomain problem) should be big enough for any of the problems being solved. |
Definition at line 192 of file PetscTools.cpp.
Referenced by LinearSystem::LinearSystem(), SimplePetscNonlinearSolver::Solve(), and AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::VerifyJacobian().
void PetscTools::ReplicateException | ( | bool | flag | ) | [static] |
Ensure exceptions are handled cleanly in parallel code, by causing all processes to throw if any one does.
flag | is set to true if this process has thrown. |
Definition at line 124 of file PetscTools.cpp.
Referenced by AbstractCardiacProblem< SPACE_DIM, PROBLEM_DIM >::Solve(), and AbstractCardiacPde< SPACE_DIM >::SolveCellSystems().
void PetscTools::DumpPetscObject | ( | Mat & | rMat, | |
const std::string & | rOutputFileFullPath | |||
) | [static] |
Another helper method to get a single value from a vector in 1 line than Petsc's usual 4 or 5. DOES NOT check that the requested component is local, DOES do bound-checking.
rMat | a matrix | |
rOutputFileFullPath | where to dump the matrix to disk |
Definition at line 218 of file PetscTools.cpp.
void PetscTools::DumpPetscObject | ( | Vec & | rVec, | |
const std::string & | rOutputFileFullPath | |||
) | [static] |
Dumps a given Petsc object to disk.
rVec | a vector | |
rOutputFileFullPath | where to dump the vector to disk |
Definition at line 233 of file PetscTools.cpp.
void PetscTools::ReadPetscObject | ( | Mat & | rMat, | |
const std::string & | rOutputFileFullPath | |||
) | [static] |
Read a previously dumped Petsc object from disk.
rMat | a matrix | |
rOutputFileFullPath | where to read the matrix from |
Definition at line 248 of file PetscTools.cpp.
void PetscTools::ReadPetscObject | ( | Vec & | rVec, | |
const std::string & | rOutputFileFullPath | |||
) | [static] |
Read a previously dumped Petsc object from disk.
rVec | a vector | |
rOutputFileFullPath | where to read the matrix from |
Definition at line 263 of file PetscTools.cpp.
bool PetscTools::mPetscIsInitialised = false [static, private] |
Whether PETSc has been initialised.
Definition at line 58 of file PetscTools.hpp.
Referenced by Barrier(), and ResetCache().
unsigned PetscTools::mNumProcessors = 0 [static, private] |
The total number of processors.
Definition at line 61 of file PetscTools.hpp.
Referenced by AmMaster(), Barrier(), GetMyRank(), IsSequential(), NumProcs(), and ResetCache().
unsigned PetscTools::mRank = 0 [static, private] |
Which processors we are.
Definition at line 64 of file PetscTools.hpp.
Referenced by AmMaster(), GetMyRank(), and ResetCache().
const unsigned PetscTools::MASTER_RANK = 0 [static] |
As a convention, we consider processor 0 the master process
Definition at line 71 of file PetscTools.hpp.
Referenced by AmMaster().