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 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


Detailed Description

A helper class of static methods.

Definition at line 48 of file PetscTools.hpp.


Member Function Documentation

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]

unsigned PetscTools::GetNumProcs (  )  [static]

unsigned PetscTools::GetMyRank (  )  [static]

bool PetscTools::AmMaster (  )  [static]

void PetscTools::Barrier (  )  [static]

Vec PetscTools::CreateVec ( int  size  )  [static]

Create a vector of the specified size. SetFromOptions is called.

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

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

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

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

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

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 208 of file PetscTools.cpp.

void PetscTools::DumpPetscObject ( const 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 223 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 238 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 253 of file PetscTools.cpp.


Member Data Documentation

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


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

Generated on Tue Aug 4 16:11:37 2009 for Chaste by  doxygen 1.5.5