#include <LinearSystem.hpp>
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 |
Definition at line 45 of file LinearSystem.hpp.
LinearSystem::LinearSystem | ( | PetscInt | lhsVectorSize, | |
MatType | matType = (MatType) MATMPIAIJ | |||
) |
Linear System implementation.
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.
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.
Definition at line 106 of file LinearSystem.cpp.
References mOwnershipRangeHi, and mOwnershipRangeLo.
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 |
) |
Definition at line 485 of file LinearSystem.cpp.
References GenericEventHandler< 11, HeartEventHandler >::BeginEvent(), and GenericEventHandler< 11, HeartEventHandler >::EndEvent().
Referenced by AbstractLinearAssembler< DIM, DIM, 1, false, MonodomainRhsMatrixAssembler< DIM > >::StaticSolve().
Vec & LinearSystem::rGetRhsVector | ( | ) |
Get access to the rhs vector directly. Shouldn't generally need to be called.
Definition at line 406 of file LinearSystem.cpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::ApplyDirichletConditions(), BoundaryConditionsContainer< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::ApplyDirichletToLinearProblem(), and AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, MonodomainRhsMatrixAssembler< DIM > >::AssembleSystem().
Mat & LinearSystem::rGetLhsMatrix | ( | ) |
Get access to the lhs matrix directly. Shouldn't generally need to be called.
Definition at line 414 of file LinearSystem.cpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::ApplyDirichletConditions(), BoundaryConditionsContainer< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::ApplyDirichletToLinearProblem(), AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, NON_HEART, MonodomainRhsMatrixAssembler< DIM > >::AssembleSystem(), MonodomainRhsMatrixAssembler< DIM >::GetMatrix(), BidomainWithBathRhsMatrixAssembler< DIM >::GetMatrix(), and BidomainRhsMatrixAssembler< DIM >::GetMatrix().
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.
PetscInt LinearSystem::mOwnershipRangeLo [private] |
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().
bool LinearSystem::mDestroyMatAndVec [private] |
Whether we need to destroy the Petsc matrix and vector in our destructor
Definition at line 63 of file LinearSystem.hpp.
Vec LinearSystem::mDirichletBoundaryConditionsVector [private] |
Storage for efficient application of Dirichlet BCs, see boundary conditions container
Definition at line 74 of file LinearSystem.hpp.
Referenced by rGetDirichletBoundaryConditionsVector().