#include <PetscTools.hpp>

Static Public Member Functions | |
| static void | ResetCache () |
| static bool | IsSequential () |
| static unsigned | GetNumProcs () |
| 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 maxColsPerRowIfMatMpiAij=54) |
| static void | ReplicateException (bool flag) |
| static void | DumpPetscObject (const Mat &rMat, const std::string &rOutputFileFullPath) |
| static void | DumpPetscObject (const 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 Member Functions | |
| static void | CheckCache () |
Static Private Attributes | |
| static bool | mPetscIsInitialised = false |
| static unsigned | mNumProcessors = 0 |
| static unsigned | mRank = 0 |
Definition at line 48 of file PetscTools.hpp.
| static void PetscTools::CheckCache | ( | ) | [inline, static, private] |
Private method makes sure that (if this is the first use within a test) then PETSc has been probed
Definition at line 61 of file PetscTools.hpp.
References mNumProcessors, and ResetCache().
Referenced by AmMaster(), Barrier(), GetMyRank(), GetNumProcs(), and IsSequential().
| 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 40 of file PetscTools.cpp.
References mNumProcessors, mPetscIsInitialised, and mRank.
Referenced by CheckCache().
| bool PetscTools::IsSequential | ( | ) | [static] |
Just returns whether there is one process or not.
Definition at line 75 of file PetscTools.cpp.
References CheckCache(), and mNumProcessors.
Referenced by GenericEventHandler< 9, CancerEventHandler >::Headings(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), and GenericEventHandler< 9, CancerEventHandler >::Report().
| unsigned PetscTools::GetNumProcs | ( | ) | [static] |
Returns total number of processors
Definition at line 81 of file PetscTools.cpp.
References CheckCache(), and mNumProcessors.
Referenced by BidomainDg0Assembler< ELEMENT_DIM, SPACE_DIM >::CheckCompatibilityCondition(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ComputeMeshPartitioning(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisBinaryNodePartitioning(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisLibraryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ReadNodesPerProcessorFile(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ReorderNodes(), and GenericEventHandler< 9, CancerEventHandler >::Report().
| unsigned PetscTools::GetMyRank | ( | ) | [static] |
Return our rank.
If PETSc has not been initialized, returns 0.
Definition at line 87 of file PetscTools.cpp.
References CheckCache(), and mRank.
Referenced by ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), ArchiveLocationInfo::GetProcessUniqueFilePath(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisBinaryNodePartitioning(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisLibraryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ReadNodesPerProcessorFile(), GenericEventHandler< 9, CancerEventHandler >::Report(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SolveBoundaryElementMapping(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SolveElementMapping(), and ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SolveNodeMapping().
| 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 93 of file PetscTools.cpp.
References CheckCache(), MASTER_RANK, and mRank.
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::CloseFilesAndPostProcess(), Hdf5ToMeshalyzerConverter::Hdf5ToMeshalyzerConverter(), GenericEventHandler< 9, CancerEventHandler >::Headings(), OutputFileHandler::OutputFileHandler(), Hdf5DataWriter::PutUnlimitedVariable(), GenericEventHandler< 9, CancerEventHandler >::Report(), CardiacElectroMechanicsProblem< DIM >::Solve(), Hdf5ToMeshalyzerConverter::Write(), PostProcessingWriter::WriteApdMapFile(), PostProcessingWriter::WriteConductionVelocityMap(), HeartGeometryInformation< SPACE_DIM >::WriteLayerForEachNode(), PostProcessingWriter::WriteMaxUpstrokeVelocityMap(), and PostProcessingWriter::WriteUpstrokeTimeMap().
| void PetscTools::Barrier | ( | ) | [static] |
If MPI is set up, perform a barrier synchronisation. If not, it's a noop.
Definition at line 103 of file PetscTools.cpp.
References CheckCache(), and mPetscIsInitialised.
Referenced by CuboidMeshConstructor< DIM >::Construct(), GenericEventHandler< 9, CancerEventHandler >::Headings(), HoneycombMeshGenerator::Make2dPeriodicCryptMesh(), ParallelTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisBinaryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodesWithMetisBinaries(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), GenericEventHandler< 9, CancerEventHandler >::Report(), and HeartGeometryInformation< SPACE_DIM >::WriteLayerForEachNode().
| Vec PetscTools::CreateVec | ( | int | size | ) | [static] |
Create a vector of the specified size. SetFromOptions is called.
| size | the size of the vector |
Definition at line 134 of file PetscTools.cpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::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 | the size of the vector | |
| value | the value to set each entry |
Definition at line 144 of file PetscTools.cpp.
References CreateVec().
| Vec PetscTools::CreateVec | ( | std::vector< double > | data | ) | [static] |
Create a Vec from the given data.
| data | some data |
Definition at line 160 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 | maxColsPerRowIfMatMpiAij = 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) | |
| maxColsPerRowIfMatMpiAij | The maximum number of non zeros per row. This value is problem dependent. Since the call to set this depends on the matrix-type (eg MatMPIAIJSetPreallocation/MatSeqAIJSetPreallocation), preallocation using this value is done only if the matrix-type is MATMPIAIJ (the default). WITH OTHER TYPES OF MATRIX NO PREALLOCATION IS DONE AND YOU MUST PREALLOCATE MANUALLY (by calling the appropriate method)! |
Definition at line 182 of file PetscTools.cpp.
Referenced by LinearSystem::LinearSystem(), LinearSystem::SetupVectorAndMatrix(), SimplePetscNonlinearSolver::Solve(), and AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::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 114 of file PetscTools.cpp.
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), and AbstractCardiacPde< ELEM_DIM, SPACE_DIM >::SolveCellSystems().
| void PetscTools::DumpPetscObject | ( | const 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 208 of file PetscTools.cpp.
| void PetscTools::DumpPetscObject | ( | const 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 223 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 238 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 253 of file PetscTools.cpp.
bool PetscTools::mPetscIsInitialised = false [static, private] |
Whether PETSc has been initialised.
Definition at line 52 of file PetscTools.hpp.
Referenced by Barrier(), and ResetCache().
unsigned PetscTools::mNumProcessors = 0 [static, private] |
The total number of processors.
Definition at line 55 of file PetscTools.hpp.
Referenced by CheckCache(), GetNumProcs(), IsSequential(), and ResetCache().
unsigned PetscTools::mRank = 0 [static, private] |
Which processors we are.
Definition at line 58 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 74 of file PetscTools.hpp.
Referenced by AmMaster().
1.5.5