LinearSystem Class Reference

#include <LinearSystem.hpp>

Collaboration diagram for LinearSystem:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 LinearSystem (PetscInt lhsVectorSize, MatType matType=(MatType) MATMPIAIJ)
 LinearSystem (Vec templateVector)
 LinearSystem (Vec residualVector, Mat jacobianMatrix)
void SetMatrixElement (PetscInt row, PetscInt col, double value)
void AddToMatrixElement (PetscInt row, PetscInt col, double value)
void AssembleFinalLinearSystem ()
void AssembleIntermediateLinearSystem ()
void AssembleFinalLhsMatrix ()
void AssembleIntermediateLhsMatrix ()
void AssembleRhsVector ()
void SetMatrixIsSymmetric ()
void SetMatrixIsConstant (bool matrixIsConstant)
void SetRelativeTolerance (double relativeTolerance)
void SetAbsoluteTolerance (double absoluteTolerance)
void SetKspType (const char *)
void SetPcType (const char *)
void DisplayMatrix ()
void DisplayRhs ()
void SetMatrixRow (PetscInt row, double value)
void ZeroMatrixRow (PetscInt row)
void ZeroMatrixColumn (PetscInt col)
void ZeroLhsMatrix ()
void ZeroRhsVector ()
void ZeroLinearSystem ()
Vec Solve (Vec lhsGuess=NULL)
void SetRhsVectorElement (PetscInt row, double value)
void AddToRhsVectorElement (PetscInt row, double value)
unsigned GetSize ()
void SetNullBasis (Vec nullbasis[], unsigned numberOfBases)
Vec & rGetRhsVector ()
Mat & rGetLhsMatrix ()
Vec & rGetDirichletBoundaryConditionsVector ()
void GetOwnershipRange (PetscInt &lo, PetscInt &hi)
double GetMatrixElement (PetscInt row, PetscInt col)
double GetRhsVectorElement (PetscInt row)
template<size_t MATRIX_SIZE>
void AddLhsMultipleValues (unsigned *matrixRowAndColIndices, c_matrix< double, MATRIX_SIZE, MATRIX_SIZE > &smallMatrix)
template<size_t VECTOR_SIZE>
void AddRhsMultipleValues (unsigned *VectorIndices, c_vector< double, VECTOR_SIZE > &smallVector)

Private Attributes

Mat mLhsMatrix
Vec mRhsVector
PetscInt mSize
PetscInt mOwnershipRangeLo
PetscInt mOwnershipRangeHi
MatNullSpace mMatNullSpace
bool mDestroyMatAndVec
KSP mKspSolver
bool mKspIsSetup
double mNonZerosUsed
bool mMatrixIsConstant
double mTolerance
bool mUseAbsoluteTolerance
char mKspType [30]
char mPcType [30]
Vec mDirichletBoundaryConditionsVector

Friends

class TestLinearSystem


Detailed Description

Linear System class. Stores and solves a linear equation of the form Ax=b, where A is a square matrix and x and b are column vectors. The class uses PETSc.

Definition at line 45 of file LinearSystem.hpp.


Constructor & Destructor Documentation

LinearSystem::LinearSystem ( PetscInt  lhsVectorSize,
MatType  matType = (MatType) MATMPIAIJ 
)

Linear System implementation.

Todo:
: if we create a linear system object outside a cardiac assembler, these are gonna be the default solver and preconditioner. Not consitent with ChasteDefaults.xml though...

Definition at line 44 of file LinearSystem.cpp.

References mOwnershipRangeHi, mOwnershipRangeLo, and PetscTools::SetupMat().

LinearSystem::LinearSystem ( Vec  templateVector  ) 

Create a linear system, where the size is based on the size of a given PETSc vec. The LHS & RHS vectors will be created by duplicating this vector's settings. This should avoid problems with using VecScatter on bidomain simulation results.

Todo:
: if we create a linear system object outside a cardiac assembler, these are gonna be the default solver and preconditioner. Not consitent with ChasteDefaults.xml though...

Definition at line 76 of file LinearSystem.cpp.

References mOwnershipRangeHi, mOwnershipRangeLo, and PetscTools::SetupMat().

LinearSystem::LinearSystem ( Vec  residualVector,
Mat  jacobianMatrix 
)

Create a linear system which wraps the provided PETSc objects so we can access them using our API. Either of the objects may be NULL, but at least one of them must not be.

Useful for storing residuals and jacobians when solving nonlinear PDEs.

Todo:
: if we create a linear system object outside a cardiac assembler, these are gonna be the default solver and preconditioner. Not consitent with ChasteDefaults.xml though...

Definition at line 106 of file LinearSystem.cpp.

References mOwnershipRangeHi, and mOwnershipRangeLo.


Member Function Documentation

void LinearSystem::SetMatrixIsSymmetric (  ) 

Force PETSc to treat the matrix in this linear system as symmetric from now on

Definition at line 431 of file LinearSystem.cpp.

void LinearSystem::ZeroMatrixColumn ( PetscInt  col  ) 

Zero the column of a matrix. Unfortunately there is no equivalent method in Petsc, so this has to be done carefully to ensure that the sparsity structure of the matrix is not broken. Only owned entries which are non-zero are zeroed.

Definition at line 283 of file LinearSystem.cpp.

References GetMatrixElement(), mOwnershipRangeHi, and mOwnershipRangeLo.

Referenced by BoundaryConditionsContainer< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::ApplyDirichletToLinearProblem().

Vec LinearSystem::Solve ( Vec  lhsGuess = NULL  ) 

Vec & LinearSystem::rGetRhsVector (  ) 

Mat & LinearSystem::rGetLhsMatrix (  ) 

Vec & LinearSystem::rGetDirichletBoundaryConditionsVector (  ) 

Gets access to the dirichlet boundary conditions vector.

Should only be used by the BoundaryConditionsContainer.

Definition at line 424 of file LinearSystem.cpp.

References mDirichletBoundaryConditionsVector.

Referenced by BoundaryConditionsContainer< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::ApplyDirichletToLinearProblem().

void LinearSystem::GetOwnershipRange ( PetscInt &  lo,
PetscInt &  hi 
)

Get this process' ownership range of the contents of the system

Definition at line 361 of file LinearSystem.cpp.

References mOwnershipRangeHi, and mOwnershipRangeLo.

double LinearSystem::GetMatrixElement ( PetscInt  row,
PetscInt  col 
)

Return an element of the matrix. May only be called for elements you own.

Definition at line 371 of file LinearSystem.cpp.

References mOwnershipRangeHi, and mOwnershipRangeLo.

Referenced by ZeroMatrixColumn().

double LinearSystem::GetRhsVectorElement ( PetscInt  row  ) 

Return an element of the RHS vector. May only be called for elements you own.

Definition at line 390 of file LinearSystem.cpp.

References mOwnershipRangeHi, and mOwnershipRangeLo.


Member Data Documentation

PetscInt LinearSystem::mOwnershipRangeLo [private]

Todo:
Verify claim that ownership range for Vec and Mat is same. This should only matter for efficiency if the claim is false.
For parallel code. Stores lowest index of vectors and lowest row of matrix

Definition at line 57 of file LinearSystem.hpp.

Referenced by GetMatrixElement(), GetOwnershipRange(), GetRhsVectorElement(), LinearSystem(), and ZeroMatrixColumn().

PetscInt LinearSystem::mOwnershipRangeHi [private]

Stores one more than the highest index stored locally

Definition at line 58 of file LinearSystem.hpp.

Referenced by GetMatrixElement(), GetOwnershipRange(), GetRhsVectorElement(), LinearSystem(), and ZeroMatrixColumn().

Whether we need to destroy the Petsc matrix and vector in our destructor

Definition at line 63 of file LinearSystem.hpp.

Storage for efficient application of Dirichlet BCs, see boundary conditions container

Definition at line 74 of file LinearSystem.hpp.

Referenced by rGetDirichletBoundaryConditionsVector().


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

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