PetscTools Class Reference

#include <PetscTools.hpp>

Collaboration diagram for PetscTools:

Collaboration graph
[legend]

List of all members.

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


Detailed Description

A helper class of static methods.

Definition at line 54 of file PetscTools.hpp.


Member Function Documentation

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]

unsigned PetscTools::GetMyRank (  )  [static]

bool PetscTools::AmMaster (  )  [static]

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Todo:
Think if there is an efficient compromise between this method and the full weight of ReplicatableVector (broadcast single values to all processors). How do you know who has the value?
Dumps a given Petsc object to disk.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
rVec a vector
rOutputFileFullPath where to read the matrix from

Definition at line 263 of file PetscTools.cpp.


Member Data Documentation

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().


The documentation for this class was generated from the following files:

Generated on Wed Mar 18 12:52:47 2009 for Chaste by  doxygen 1.5.5