#include <PetscTools.hpp>

Static Public Member Functions | |
| static void | ResetCache () |
| static bool | IsSequential () |
| static unsigned | GetNumProcs () |
| static unsigned | GetMyRank () |
| static bool | AmMaster () |
| static bool | AmTopMost () |
| static void | Barrier (const std::string callerId="") |
| 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) |
| static bool | ReplicateBool (bool flag) |
| 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 void | SetMaxNumNonzerosIfMatMpiAij (unsigned maxColsPerRowIfMatMpiAij) |
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 | mMaxNumNonzerosIfMatMpiAij = 54 |
| static unsigned | mRank = 0 |
A helper class of static methods.
Definition at line 54 of file PetscTools.hpp.
| 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 98 of file PetscTools.cpp.
References CheckCache(), MASTER_RANK, and mRank.
Referenced by AbstractHdf5Converter< ELEMENT_DIM, SPACE_DIM >::AbstractHdf5Converter(), ParallelColumnDataWriter::AdvanceAlongUnlimitedDimension(), ArchiveOpener< Archive, Stream >::ArchiveOpener(), ParallelColumnDataWriter::Close(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructCuboid(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructLinearMesh(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructRectangularMesh(), AbstractConvergenceTester< CELL, CARDIAC_PROBLEM, DIM, PROBLEM_DIM >::Converge(), CellMLToSharedLibraryConverter::ConvertCellmlToSo(), OutputDirectoryFifoQueue::CreateNextDir(), ParallelColumnDataWriter::EndDefineMode(), StreeterFibreGenerator< SPACE_DIM >::GenerateOrthotropicFibreOrientation(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::GetNextElement(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::GetNextNode(), Hdf5ToVtkConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToVtkConverter(), GenericEventHandler< 13, HeartEventHandler >::Headings(), HoneycombMeshGenerator::Make2dPeriodicCryptMesh(), OutputFileHandler::MakeFoldersAndReturnFullPath(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisLibraryNodePartitioning(), OutputFileHandler::OutputFileHandler(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodesWithMetisBinaries(), ProgressReporter::PrintFinalising(), ProgressReporter::PrintInitialising(), ProgressReporter::ProgressReporter(), Hdf5DataWriter::PutUnlimitedVariable(), ParallelColumnDataWriter::PutVariable(), ParallelColumnDataWriter::PutVector(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), GenericEventHandler< 13, HeartEventHandler >::Report(), QuadraticMesh< DIM >::RunMesherAndReadMesh(), HeartConfig::save(), CardiacSimulationArchiver< PROBLEM_CLASS >::Save(), ProgressReporter::Update(), HeartConfig::Write(), Hdf5ToMeshalyzerConverter< ELEMENT_DIM, SPACE_DIM >::Write(), Hdf5ToCmguiConverter< ELEMENT_DIM, SPACE_DIM >::Write(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh(), AbstractMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMeshReader(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingParallelMesh(), PostProcessingWriter< ELEMENT_DIM, SPACE_DIM >::WriteGenericFile(), MonodomainProblem< ELEMENT_DIM, SPACE_DIM >::WriteInfo(), BidomainProblem< DIM >::WriteInfo(), HeartGeometryInformation< SPACE_DIM >::WriteLayerForEachNode(), PseudoEcgCalculator< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::WritePseudoEcg(), OdeSolution::WriteToFile(), and ProgressReporter::~ProgressReporter().
| bool PetscTools::AmTopMost | ( | ) | [static] |
Just returns whether it is the right-most process or not.
If not running in parallel, always returns true.
Definition at line 104 of file PetscTools.cpp.
References CheckCache(), mNumProcessors, and mRank.
Referenced by DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader().
| void PetscTools::Barrier | ( | const std::string | callerId = "" |
) | [static] |
If MPI is set up, perform a barrier synchronisation. If not, it's a noop.
| callerId | only used in debug mode; printed before & after the barrier call |
Definition at line 114 of file PetscTools.cpp.
References CheckCache(), GetMyRank(), and mPetscIsInitialised.
Referenced by ParallelColumnDataWriter::AdvanceAlongUnlimitedDimension(), ParallelColumnDataWriter::Close(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), OutputDirectoryFifoQueue::CreateNextDir(), StreeterFibreGenerator< SPACE_DIM >::GenerateOrthotropicFibreOrientation(), Hdf5ToCmguiConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToCmguiConverter(), Hdf5ToMeshalyzerConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToMeshalyzerConverter(), GenericEventHandler< 13, HeartEventHandler >::Headings(), HoneycombMeshGenerator::Make2dPeriodicCryptMesh(), OutputFileHandler::MakeFoldersAndReturnFullPath(), OutputFileHandler::OutputFileHandler(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::PermuteNodesWithMetisBinaries(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), GenericEventHandler< 13, HeartEventHandler >::Report(), QuadraticMesh< DIM >::RunMesherAndReadMesh(), AbstractTetrahedralMesh< SPACE_DIM, SPACE_DIM >::save(), HeartConfig::save(), CardiacSimulationArchiver< PROBLEM_CLASS >::Save(), CardiacElectroMechanicsProblem< DIM >::Solve(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingParallelMesh(), PostProcessingWriter< ELEMENT_DIM, SPACE_DIM >::WriteGenericFile(), and HeartGeometryInformation< SPACE_DIM >::WriteLayerForEachNode().
| 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 75 of file PetscTools.hpp.
References mNumProcessors, and ResetCache().
Referenced by AmMaster(), AmTopMost(), Barrier(), GetMyRank(), GetNumProcs(), and IsSequential().
Create a Vec from the given data.
| data | some data |
Definition at line 183 of file PetscTools.cpp.
References CreateVec().
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 167 of file PetscTools.cpp.
References CreateVec().
| 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 157 of file PetscTools.cpp.
Referenced by PseudoEcgCalculator< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::ComputePseudoEcgAtOneTimeStep(), AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::CreateConstantInitialGuess(), CreateVec(), PCBlockDiagonal::PCBlockDiagonalCreate(), and PCLDUFactorisation::PCLDUFactorisationCreate().
| 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 245 of file PetscTools.cpp.
| void PetscTools::DumpPetscObject | ( | const Mat & | rMat, | |
| const std::string & | rOutputFileFullPath | |||
| ) | [static] |
Dumps a given Petsc object to disk.
| rMat | a matrix | |
| rOutputFileFullPath | where to dump the matrix to disk |
Definition at line 230 of file PetscTools.cpp.
| unsigned PetscTools::GetMyRank | ( | ) | [static] |
Return our rank.
If PETSc has not been initialized, returns 0.
Definition at line 92 of file PetscTools.cpp.
References CheckCache(), and mRank.
Referenced by ArchiveOpener< Archive, Stream >::ArchiveOpener(), NonlinearElasticityAssembler< DIM >::AssembleSystem(), Barrier(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetAnyNode(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisLibraryNodePartitioning(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ParMetisLibraryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ReadNodesPerProcessorFile(), GenericEventHandler< 13, HeartEventHandler >::Report(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SolveBoundaryElementMapping(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SolveElementMapping(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SolveNodeMapping(), AbstractNonlinearElasticityAssembler< DIM >::TakeNewtonStep(), DistanceMapCalculator< ELEMENT_DIM, SPACE_DIM >::UpdateQueueFromRemote(), and PostProcessingWriter< ELEMENT_DIM, SPACE_DIM >::WriteGenericFile().
| unsigned PetscTools::GetNumProcs | ( | ) | [static] |
Returns total number of processors
Definition at line 86 of file PetscTools.cpp.
References CheckCache(), and mNumProcessors.
Referenced by NonlinearElasticityAssembler< DIM >::AllocateMatrixMemory(), DistanceMapCalculator< ELEMENT_DIM, SPACE_DIM >::ComputeDistanceMap(), DistanceMapCalculator< ELEMENT_DIM, SPACE_DIM >::DistanceMapCalculator(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisLibraryNodePartitioning(), CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ParMetisLibraryNodePartitioning(), TetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ReadNodesPerProcessorFile(), GenericEventHandler< 13, HeartEventHandler >::Report(), CardiacSimulationArchiver< PROBLEM_CLASS >::Save(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::SetDistributedVectorFactory(), DistanceMapCalculator< ELEMENT_DIM, SPACE_DIM >::UpdateQueueFromRemote(), and PostProcessingWriter< ELEMENT_DIM, SPACE_DIM >::WriteGenericFile().
| bool PetscTools::IsSequential | ( | ) | [static] |
Just returns whether there is one process or not.
Definition at line 80 of file PetscTools.cpp.
References CheckCache(), and mNumProcessors.
Referenced by DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ComputeMeshPartitioning(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), DistanceMapCalculator< ELEMENT_DIM, SPACE_DIM >::DistanceMapCalculator(), GenericEventHandler< 13, HeartEventHandler >::Headings(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::MetisLibraryNodePartitioning(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ParMetisLibraryNodePartitioning(), MutableMesh< ELEMENT_DIM, SPACE_DIM >::ReMesh(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ReorderNodes(), and GenericEventHandler< 13, HeartEventHandler >::Report().
| 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 275 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 260 of file PetscTools.cpp.
Boolean AND of a flags between processes
| flag | is set to true on this process. |
Definition at line 131 of file PetscTools.cpp.
Referenced by AbstractBoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::HasDirichletBoundaryConditions(), ReplicateException(), CardiacSimulationArchiver< PROBLEM_CLASS >::Save(), and DistanceMapCalculator< ELEMENT_DIM, SPACE_DIM >::UpdateQueueFromRemote().
| 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 139 of file PetscTools.cpp.
References ReplicateBool().
Referenced by DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), CellMLToSharedLibraryConverter::ConvertCellmlToSo(), BidomainPde< SPACE_DIM >::CreateExtracellularConductivityTensors(), AbstractCardiacPde< ELEMENT_DIM, SPACE_DIM >::CreateIntracellularConductivityTensor(), ReplicatableVector::Resize(), AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), and AbstractCardiacPde< ELEMENT_DIM, SPACE_DIM >::SolveCellSystems().
| 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 45 of file PetscTools.cpp.
References mNumProcessors, mPetscIsInitialised, and mRank.
Referenced by CheckCache().
| void PetscTools::SetMaxNumNonzerosIfMatMpiAij | ( | unsigned | maxColsPerRowIfMatMpiAij | ) | [static] |
Set the number of nonzeros per row that PETSc will preallocate memory for.
| 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 290 of file PetscTools.cpp.
References mMaxNumNonzerosIfMatMpiAij.
| void PetscTools::SetupMat | ( | Mat & | rMat, | |
| int | numRows, | |||
| int | numColumns, | |||
| MatType | matType = (MatType) MATMPIAIJ, |
|||
| int | numLocalRows = PETSC_DECIDE, |
|||
| int | numLocalColumns = PETSC_DECIDE | |||
| ) | [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) |
Definition at line 205 of file PetscTools.cpp.
References mMaxNumNonzerosIfMatMpiAij.
Referenced by LinearSystem::LinearSystem(), LinearSystem::SetupVectorAndMatrix(), SimplePetscNonlinearSolver::Solve(), and AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::VerifyJacobian().
const unsigned PetscTools::MASTER_RANK = 0 [static] |
As a convention, we consider processor 0 the master process
Definition at line 88 of file PetscTools.hpp.
Referenced by AmMaster().
unsigned PetscTools::mMaxNumNonzerosIfMatMpiAij = 54 [static, private] |
The number of nonzeros per row that PETSc preallocates
Definition at line 64 of file PetscTools.hpp.
Referenced by SetMaxNumNonzerosIfMatMpiAij(), and SetupMat().
unsigned PetscTools::mNumProcessors = 0 [static, private] |
The total number of processors.
Definition at line 61 of file PetscTools.hpp.
Referenced by AmTopMost(), CheckCache(), GetNumProcs(), IsSequential(), and ResetCache().
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::mRank = 0 [static, private] |
Which processors we are.
Definition at line 72 of file PetscTools.hpp.
Referenced by AmMaster(), AmTopMost(), GetMyRank(), and ResetCache().
1.6.2