#include <DistributedVectorFactory.hpp>
Factory for creating PETSc vectors distributed across processes.
Replacement for the vector creation portions of DistributedVector (which was implemented using static methods and data), the factory class allows several patterns of PETSc vector length (and distributions among processes) to co-exist.
All vectors created by a factory instance will have the same base size and parallelisation pattern.
Definition at line 50 of file DistributedVectorFactory.hpp.
DistributedVectorFactory::DistributedVectorFactory | ( | Vec | vec | ) |
Set the problem with an existing PETSc vector -- must have stride=1.
vec | is a PETSc vector which we want to use as the pattern for future vectors produced by this factory |
Definition at line 73 of file DistributedVectorFactory.cpp.
References CalculateOwnership().
DistributedVectorFactory::DistributedVectorFactory | ( | unsigned | size, | |
PetscInt | local = PETSC_DECIDE | |||
) |
Set the problem size specifying distribution over local processor.
size | the problem size | |
local | defaults to PETSc's default |
Definition at line 80 of file DistributedVectorFactory.cpp.
References CalculateOwnership(), CheckForPetsc(), and CreateVec().
DistributedVectorFactory::DistributedVectorFactory | ( | DistributedVectorFactory * | pOriginalFactory | ) |
Constructor for use in archiving. Note that this constructor is only called when the number of processes is different from the original. Therefore, the orignal local node ownership cannot be used, and a new even partition will be applied.
pOriginalFactory | see mpOriginalFactory |
Definition at line 92 of file DistributedVectorFactory.cpp.
References CalculateOwnership(), CreateVec(), GetProblemSize(), and mpOriginalFactory.
DistributedVectorFactory::DistributedVectorFactory | ( | unsigned | lo, | |
unsigned | hi, | |||
unsigned | size, | |||
unsigned | numProcs = PetscTools::GetNumProcs() | |||
) |
Constructor intended for use in archiving. Allows complete manual specification of the factory.
lo | first index owned by this process | |
hi | one beyond last index owned by this process | |
size | total size of vectors | |
numProcs | the number of processes expected (defaults to the current number) |
Definition at line 108 of file DistributedVectorFactory.cpp.
References CheckForPetsc().
DistributedVectorFactory::~DistributedVectorFactory | ( | ) |
Destructor deletes mpOriginalFactory if it exists.
Definition at line 121 of file DistributedVectorFactory.cpp.
References mpOriginalFactory.
void DistributedVectorFactory::CalculateOwnership | ( | Vec | vec | ) | [private] |
Helper method for the constructors.
vec | the sample PETSc vector from which to calculate ownerships |
Definition at line 36 of file DistributedVectorFactory.cpp.
References CheckForPetsc(), GetNumProcs(), mGlobalLows, mHi, mLo, mNumProcs, mPetscStatusKnown, and mProblemSize.
Referenced by DistributedVectorFactory().
void DistributedVectorFactory::CheckForPetsc | ( | ) | [private] |
Double check (in debug code) that PETSc has been initialised properly.
Definition at line 126 of file DistributedVectorFactory.cpp.
References mPetscStatusKnown.
Referenced by CalculateOwnership(), and DistributedVectorFactory().
static bool DistributedVectorFactory::CheckNumberOfProcessesOnLoad | ( | ) | [inline, static] |
Determine whether, when loading an instance from an archive, to check that the current number of processes matches that used in creating the archive.
Definition at line 237 of file DistributedVectorFactory.hpp.
References msCheckNumberOfProcessesOnLoad.
DistributedVector DistributedVectorFactory::CreateDistributedVector | ( | Vec | vec | ) |
Create a distributed vector which wraps a given petsc vector.
vec | is the vector |
Definition at line 159 of file DistributedVectorFactory.cpp.
Referenced by BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::ApplyDirichletToNonlinearResidual(), ExtendedBidomainProblem< DIM >::CreateInitialCondition(), AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::CreateInitialCondition(), AbstractExtendedBidomainSolver< ELEMENT_DIM, SPACE_DIM >::GenerateNullBasis(), AbstractBidomainSolver< ELEMENT_DIM, SPACE_DIM >::GenerateNullBasis(), ParallelColumnDataWriter::PutVectorStripe(), OperatorSplittingMonodomainSolver< ELEMENT_DIM, SPACE_DIM >::SetupLinearSystem(), MonodomainSolver< ELEMENT_DIM, SPACE_DIM >::SetupLinearSystem(), ExtendedBidomainSolver< ELEM_DIM, SPACE_DIM >::SetupLinearSystem(), BidomainSolver< ELEMENT_DIM, SPACE_DIM >::SetupLinearSystem(), ExtendedBidomainTissue< SPACE_DIM >::SolveCellSystems(), and AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::SolveCellSystems().
Create a striped PETSc vector of size: stride * problem size.
stride |
Definition at line 152 of file DistributedVectorFactory.cpp.
References mHi, mLo, and mProblemSize.
Vec DistributedVectorFactory::CreateVec | ( | ) |
Create a PETSc vector of the problem size.
Definition at line 146 of file DistributedVectorFactory.cpp.
References mHi, mLo, and mProblemSize.
Referenced by ExtendedBidomainProblem< DIM >::CreateInitialCondition(), AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::CreateInitialCondition(), DistributedVectorFactory(), AbstractExtendedBidomainSolver< ELEMENT_DIM, SPACE_DIM >::GenerateNullBasis(), AbstractBidomainSolver< ELEMENT_DIM, SPACE_DIM >::GenerateNullBasis(), Hdf5ToTxtConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToTxtConverter(), Hdf5ToVtkConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToVtkConverter(), ParallelColumnDataWriter::PutVectorStripe(), Hdf5ToMeshalyzerConverter< ELEMENT_DIM, SPACE_DIM >::Write(), and Hdf5ToCmguiConverter< ELEMENT_DIM, SPACE_DIM >::Write().
unsigned DistributedVectorFactory::GetHigh | ( | ) | const [inline] |
Definition at line 193 of file DistributedVectorFactory.hpp.
References mHi.
Referenced by AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::AbstractCardiacTissue(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructCuboid(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructLinearMesh(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructRectangularMesh(), CardiacSimulation::CreateAndRun(), Hdf5DataWriter::DefineFixedDimension(), DistributedVector::DistributedVector(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::DumbNodePartitioning(), ExtendedBidomainTissue< SPACE_DIM >::ExtendedBidomainTissue(), StreeterFibreGenerator< SPACE_DIM >::GetAveragedThicknessLocalNode(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetCardiacCell(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetPurkinjeCell(), ExtendedBidomainTissue< SPACE_DIM >::ReplicateAdditionalCaches(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::ReplicateCaches(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SetElementOwnerships(), SetFromFactory(), and CardiacElectroMechanicsProblem< DIM >::Solve().
unsigned DistributedVectorFactory::GetLocalOwnership | ( | ) | const [inline] |
Definition at line 185 of file DistributedVectorFactory.hpp.
Referenced by AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::AbstractCardiacTissue(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructCuboid(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructLinearMesh(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructRectangularMesh(), ExtendedBidomainTissue< SPACE_DIM >::CreateGGapConductivities(), Hdf5DataWriter::DefineFixedDimension(), ExtendedBidomainTissue< SPACE_DIM >::ExtendedBidomainTissue(), Hdf5DataWriter::Hdf5DataWriter(), AbstractCardiacTissue< SPACE_DIM >::load(), AbstractCardiacTissue< SPACE_DIM >::LoadCardiacCells(), and AbstractCardiacTissue< SPACE_DIM >::save().
unsigned DistributedVectorFactory::GetLow | ( | ) | const [inline] |
Definition at line 201 of file DistributedVectorFactory.hpp.
References mLo.
Referenced by AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::AbstractCardiacTissue(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructCuboid(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructLinearMesh(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructRectangularMesh(), CardiacSimulation::CreateAndRun(), ExtendedBidomainTissue< SPACE_DIM >::CreateGGapConductivities(), Hdf5DataWriter::DefineFixedDimension(), DistributedVector::DistributedVector(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::DumbNodePartitioning(), ExtendedBidomainTissue< SPACE_DIM >::ExtendedBidomainTissue(), StreeterFibreGenerator< SPACE_DIM >::GetAveragedThicknessLocalNode(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetCardiacCell(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetCardiacCellOrHaloCell(), ExtendedBidomainTissue< SPACE_DIM >::GetCardiacSecondCell(), ExtendedBidomainTissue< SPACE_DIM >::GetExtracellularStimulus(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetPurkinjeCell(), AbstractCardiacTissue< SPACE_DIM >::load(), AbstractCardiacTissue< SPACE_DIM >::LoadCardiacCells(), ExtendedBidomainTissue< SPACE_DIM >::ReplicateAdditionalCaches(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::ReplicateCaches(), AbstractCardiacTissue< SPACE_DIM >::save(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::SetElementOwnerships(), SetFromFactory(), CardiacElectroMechanicsProblem< DIM >::Solve(), and AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::SolveCellSystems().
unsigned DistributedVectorFactory::GetNumProcs | ( | ) | const [inline] |
Definition at line 217 of file DistributedVectorFactory.hpp.
References mNumProcs.
Referenced by CalculateOwnership(), AbstractTetrahedralMesh< SPACE_DIM, SPACE_DIM >::load(), CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate(), rGetGlobalLows(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::SetDistributedVectorFactory(), and SetFromFactory().
DistributedVectorFactory* DistributedVectorFactory::GetOriginalFactory | ( | ) | [inline] |
If msCheckNumberOfProcessesOnLoad is not set, and this factory was loaded from an archive, then return a factory with the settings from the archive, which may not be the same as ours - if running on a different number of processes from the original, we will have used PETSC_DECIDE to set the local ownership on load.
Definition at line 248 of file DistributedVectorFactory.hpp.
References mpOriginalFactory.
Referenced by AbstractTetrahedralMesh< SPACE_DIM, SPACE_DIM >::load(), and CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate().
unsigned DistributedVectorFactory::GetProblemSize | ( | ) | const [inline] |
Definition at line 209 of file DistributedVectorFactory.hpp.
References mProblemSize.
Referenced by AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::AbstractCardiacTissue(), DistributedVector::DistributedVector(), DistributedVectorFactory(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::DumbNodePartitioning(), ExtendedBidomainTissue< SPACE_DIM >::ExtendedBidomainTissue(), AbstractCardiacTissue< SPACE_DIM >::load(), and SetFromFactory().
Test if the given global index is owned by the current process, i.e. is local to it.
globalIndex | a global index |
Definition at line 141 of file DistributedVectorFactory.cpp.
Referenced by HeartGeometryInformation< SPACE_DIM >::CalculateBoundingBoxOfSurface(), ElectrodesStimulusFactory< DIM >::CheckForElectrodesIntersection(), HeartConfigRelatedCellFactory< SPACE_DIM >::FillInCellularTransmuralAreas(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetCardiacCellOrHaloCell(), and AbstractCardiacTissue< SPACE_DIM >::LoadCardiacCells().
std::vector< unsigned > & DistributedVectorFactory::rGetGlobalLows | ( | ) |
Definition at line 165 of file DistributedVectorFactory.cpp.
References PetscTools::GetNumProcs(), GetNumProcs(), mGlobalLows, and mLo.
Referenced by AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::CalculateNodeExchange().
void DistributedVectorFactory::serialize | ( | Archive & | archive, | |
const unsigned int | version | |||
) | [inline, private] |
Archive the member variables.
archive | the archive | |
version | the current version of this class |
Definition at line 108 of file DistributedVectorFactory.hpp.
static void DistributedVectorFactory::SetCheckNumberOfProcessesOnLoad | ( | bool | checkNumberOfProcessesOnLoad = true |
) | [inline, static] |
Set whether, when loading an instance from an archive, to check that the current number of processes matches that used in creating the archive.
checkNumberOfProcessesOnLoad |
Definition at line 228 of file DistributedVectorFactory.hpp.
References msCheckNumberOfProcessesOnLoad.
Referenced by CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate().
void DistributedVectorFactory::SetFromFactory | ( | DistributedVectorFactory * | pFactory | ) |
Set mLo and mHi from another vector factory. Used by archiving.
pFactory | the factory to set from. |
Definition at line 58 of file DistributedVectorFactory.cpp.
References EXCEPTION, GetHigh(), GetLow(), GetNumProcs(), GetProblemSize(), mGlobalLows, mHi, mLo, mNumProcs, and mProblemSize.
Referenced by AbstractTetrahedralMesh< SPACE_DIM, SPACE_DIM >::load().
void DistributedVectorFactory::SetOriginalFactory | ( | DistributedVectorFactory * | pOriginalFactory | ) | [inline] |
Set method for mpOriginalFactory, used by archiving (load_construct_data).
pOriginalFactory | see mpOriginalFactory |
Definition at line 257 of file DistributedVectorFactory.hpp.
References mpOriginalFactory.
friend class boost::serialization::access [friend] |
Needed for serialization.
Definition at line 99 of file DistributedVectorFactory.hpp.
std::vector<unsigned> DistributedVectorFactory::mGlobalLows [private] |
A cached vector of mLo values from each process.
Definition at line 72 of file DistributedVectorFactory.hpp.
Referenced by CalculateOwnership(), rGetGlobalLows(), and SetFromFactory().
unsigned DistributedVectorFactory::mHi [private] |
One above the last entry owned by the current processor.
Definition at line 60 of file DistributedVectorFactory.hpp.
Referenced by CalculateOwnership(), CreateVec(), GetHigh(), GetLocalOwnership(), IsGlobalIndexLocal(), and SetFromFactory().
unsigned DistributedVectorFactory::mLo [private] |
The first entry owned by the current processor.
Definition at line 57 of file DistributedVectorFactory.hpp.
Referenced by CalculateOwnership(), CreateVec(), GetLocalOwnership(), GetLow(), IsGlobalIndexLocal(), rGetGlobalLows(), and SetFromFactory().
unsigned DistributedVectorFactory::mNumProcs [private] |
How many processes this factory is expecting.
Definition at line 66 of file DistributedVectorFactory.hpp.
Referenced by CalculateOwnership(), GetNumProcs(), and SetFromFactory().
Whether we've checked that PETSc is initialised.
Definition at line 69 of file DistributedVectorFactory.hpp.
Referenced by CalculateOwnership(), and CheckForPetsc().
If this instance was loaded from an archive, this points to a factory with the settings from the archive, which may not be the same as this instance.
Definition at line 84 of file DistributedVectorFactory.hpp.
Referenced by DistributedVectorFactory(), GetOriginalFactory(), SetOriginalFactory(), and ~DistributedVectorFactory().
The problem size, i.e. the number of nodes in the mesh (the number of unknowns may be larger in a Stripe).
Definition at line 63 of file DistributedVectorFactory.hpp.
Referenced by CalculateOwnership(), CreateVec(), GetProblemSize(), and SetFromFactory().
bool DistributedVectorFactory::msCheckNumberOfProcessesOnLoad = true [static, private] |
Whether, when loading an instance from an archive, to check that the current number of processes matches that used in creating the archive.
Definition at line 78 of file DistributedVectorFactory.hpp.
Referenced by CheckNumberOfProcessesOnLoad(), and SetCheckNumberOfProcessesOnLoad().