Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
AMGSystemSolver Class Reference

The class AMGSystemSolver is derived form SystemSolver and it allows to solve the linear system using PETSc GAMG preconditioner. Only non-block matrices can be solved using GAMG. More...

Inheritance diagram for AMGSystemSolver:
Inheritance graph
[legend]
Collaboration diagram for AMGSystemSolver:
Collaboration graph
[legend]

Public Member Functions

 AMGSystemSolver (bool transpose, bool multigrid, bool debug)
 
- Public Member Functions inherited from bitpit::SystemSolver
 SystemSolver (bool debug=false)
 
 SystemSolver (bool flatten, bool transpose, bool debug)
 
 SystemSolver (bool transpose, bool debug)
 
 SystemSolver (const std::string &prefix, bool debug=false)
 
 SystemSolver (const std::string &prefix, bool flatten, bool transpose, bool debug)
 
 SystemSolver (const std::string &prefix, bool transpose, bool debug)
 
virtual ~SystemSolver ()
 
void assembly (const Assembler &assembler)
 
void assembly (const Assembler &assembler, const SystemMatrixOrdering &reordering)
 
void assembly (const SparseMatrix &matrix)
 
void assembly (const SparseMatrix &matrix, const SystemMatrixOrdering &reordering)
 
virtual void clear ()
 
virtual void clearWorkspace ()
 
void dumpSystem (const std::string &header, const std::string &directory, const std::string &prefix="") const
 
void enableForceConsistency (bool enable)
 
virtual void exportMatrix (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const
 
virtual void exportRHS (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const
 
virtual void exportSolution (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const
 
virtual int getBlockSize () const
 
long getColCount () const
 
long getColElementCount () const
 
long getColGlobalCount () const
 
long getColGlobalElementCount () const
 
KSPOptionsgetKSPOptions ()
 
const KSPOptionsgetKSPOptions () const
 
const KSPStatusgetKSPStatus () const
 
double * getRHSRawPtr ()
 
const double * getRHSRawPtr () const
 
const double * getRHSRawReadPtr () const
 
long getRowCount () const
 
long getRowElementCount () const
 
long getRowGlobalCount () const
 
long getRowGlobalElementCount () const
 
double * getSolutionRawPtr ()
 
const double * getSolutionRawPtr () const
 
const double * getSolutionRawReadPtr () const
 
bool getTranspose () const
 
virtual void importMatrix (const std::string &filePath)
 
virtual void importRHS (const std::string &filePath)
 
virtual void importSolution (const std::string &filePath)
 
bool isAssembled () const
 
bool isForceConsistencyEnabled () const
 
bool isPartitioned () const
 
bool isSetUp () const
 
void restoreRHSRawPtr (double *raw_rhs)
 
void restoreRHSRawReadPtr (const double *raw_rhs) const
 
void restoreSolutionRawPtr (double *raw_solution)
 
void restoreSolutionRawReadPtr (const double *raw_solution) const
 
void restoreSystem (MPI_Comm communicator, bool redistribute, const std::string &directory, const std::string &prefix="")
 
virtual void setNullSpace ()
 
void setTranspose (bool transpose)
 
void setUp ()
 
void solve ()
 
void solve (const std::vector< double > &rhs, std::vector< double > *solution)
 
void unsetNullSpace ()
 
void update (const Assembler &assembler)
 
void update (const SparseMatrix &elements)
 
void update (long nRows, const long *rows, const Assembler &assembler)
 
void update (long nRows, const long *rows, const SparseMatrix &elements)
 

Protected Member Functions

void setupPreconditioner (PC pc, const KSPOptions &options) const override
 
- Protected Member Functions inherited from bitpit::SystemSolver
template<typename DerivedSystemSolver >
void assembly (const typename DerivedSystemSolver::Assembler &assembler, const SystemMatrixOrdering &reordering)
 
void clearReordering ()
 
virtual void createKSP ()
 
void createMatrix (int rowBlockSize, int colBlockSize, int nNestRows, int nNestCols, Mat *subMatrices, Mat *matrix) const
 
void createMatrix (int rowBlockSize, int colBlockSize, Mat *matrix) const
 
void createVector (int blockSize, int nestSize, Vec *subVectors, Vec *vector) const
 
void createVector (int blockSize, Vec *vector) const
 
virtual void destroyKSP ()
 
virtual void destroyKSPOptions ()
 
virtual void destroyKSPStatus ()
 
void destroyMatrix (Mat *matrix) const
 
void destroyVector (Vec *vector) const
 
virtual void dumpInfo (std::ostream &stream) const
 
void dumpMatrix (Mat matrix, const std::string &directory, const std::string &name) const
 
void dumpVector (Vec vector, const std::string &directory, const std::string &name) const
 
void dumpVector (Vec vector, VectorSide side, const std::string &directory, const std::string &name) const
 
void exportMatrix (Mat matrix, const std::string &filePath, FileFormat fileFormat) const
 
void exportVector (Vec vector, const std::string &filePath, FileFormat fileFormat) const
 
void exportVector (Vec vector, std::vector< double > *data) const
 
virtual void fillKSPStatus ()
 
virtual void fillKSPStatus (KSP ksp, KSPStatus *status) const
 
void fillMatrix (Mat matrix, const std::string &filePath) const
 
void fillVector (Vec vector, const std::string &filePath) const
 
void fillVector (Vec vector, const std::vector< double > &data) const
 
virtual void finalizeKSP ()
 
const MPI_Comm & getCommunicator () const
 
std::string getDataFilePath (const std::string &directory, const std::string &name) const
 
virtual int getDumpVersion () const
 
std::string getFilePath (const std::string &directory, const std::string &name) const
 
std::string getInfoFilePath (const std::string &directory, const std::string &name) const
 
virtual void initializeKSPOptions ()
 
virtual void initializeKSPStatus ()
 
void matrixAssembly (const Assembler &assembler)
 
virtual void matrixDestroy ()
 
virtual void matrixDump (std::ostream &systemStream, const std::string &directory, const std::string &prefix) const
 
virtual void matrixFill (const std::string &filePath)
 
virtual void matrixRestore (std::istream &systemStream, const std::string &directory, const std::string &prefix, bool redistribute)
 
void matrixUpdate (long nRows, const long *rows, const Assembler &assembler)
 
virtual void postKrylovSetupActions ()
 
virtual void postKSPSolveActions ()
 
virtual void postPreconditionerSetupActions ()
 
virtual void preKrylovSetupActions ()
 
virtual void preKSPSolveActions ()
 
virtual void prepareKSP ()
 
virtual void prePreconditionerSetupActions ()
 
void reorderVector (Vec vector, IS permutations, bool invert) const
 
virtual void resetKSPOptions (KSPOptions *options) const
 
virtual void resetKSPStatus ()
 
virtual void resetKSPStatus (KSPStatus *status) const
 
virtual void restoreInfo (std::istream &stream)
 
void restoreMatrix (const std::string &directory, const std::string &name, bool redistribute, Mat *matrix) const
 
void restoreVector (const std::string &directory, const std::string &name, bool redistribute, Vec *vector) const
 
void restoreVector (const std::string &directory, const std::string &name, Mat matrix, VectorSide side, Vec *vector) const
 
void restoreVector (const std::string &directory, const std::string &name, std::size_t localSize, std::size_t globalSize, Vec *vector) const
 
void setReordering (long nRows, long nCols, const SystemMatrixOrdering &reordering)
 
virtual void setupKrylov ()
 
virtual void setupKrylov (KSP ksp, const KSPOptions &options) const
 
virtual void setupPreconditioner ()
 
virtual void solveKSP ()
 
template<typename DerivedSystemSolver >
void update (long nRows, const long *rows, const typename DerivedSystemSolver::Assembler &assembler)
 
virtual void vectorsCreate ()
 
virtual void vectorsDestroy ()
 
virtual void vectorsDump (std::ostream &systemStream, const std::string &directory, const std::string &prefix) const
 
virtual void vectorsFill (const std::string &rhsFilePath, const std::string &solutionFilePath)
 
virtual void vectorsFill (const std::vector< double > &rhs, const std::vector< double > &solution)
 
virtual void vectorsReorder (bool invert)
 
virtual void vectorsRestore (std::istream &systemStream, const std::string &directory, const std::string &prefix)
 

Protected Attributes

bool m_multigrid
 
- Protected Attributes inherited from bitpit::SystemSolver
Mat m_A
 
IS m_colReordering
 
bool m_convergenceMonitorEnabled
 
bool m_flatten
 
KSP m_KSP
 
bool m_KSPDirty
 
KSPOptions m_KSPOptions
 
KSPStatus m_KSPStatus
 
Vec m_rhs
 
IS m_rowReordering
 
Vec m_solution
 
bool m_transpose
 

Static Protected Attributes

static const PetscInt GAMG_MAX_LEVELS = 10
 
static const PetscReal GAMG_THRESHOLD = 0.02
 
static const PetscReal GAMG_THRESHOLD_SCALE = 1.0
 

Additional Inherited Members

- Public Types inherited from bitpit::SystemSolver
typedef SystemMatrixAssembler Assembler
 
enum  FileFormat { FILE_BINARY , FILE_ASCII }
 
- Protected Types inherited from bitpit::SystemSolver
enum  VectorSide { VECTOR_SIDE_RIGHT , VECTOR_SIDE_LEFT }
 

Detailed Description

The class AMGSystemSolver is derived form SystemSolver and it allows to solve the linear system using PETSc GAMG preconditioner. Only non-block matrices can be solved using GAMG.

Examples
LA_example_00001.cpp.

Definition at line 73 of file LA_example_00001.cpp.

Constructor & Destructor Documentation

◆ AMGSystemSolver()

AMGSystemSolver::AMGSystemSolver ( bool transpose,
bool multigrid,
bool debug )
inline

Constructor.

Parameters
transposeif true the solver solves the transposed linear system.
multigridif true the solver uses algebraic multigrid as preconditioner.
debugif true PETSc monitors on residual, reason and singular values are turned on.
Examples
LA_example_00001.cpp.

Definition at line 83 of file LA_example_00001.cpp.

Member Function Documentation

◆ setupPreconditioner()

void AMGSystemSolver::setupPreconditioner ( PC pc,
const KSPOptions & options ) const
inlineoverrideprotectedvirtual

Set up the specified preconditioner using the given options.

Parameters
pcis the preconditioner to set up
optionsare the options that will be used to set up the preconditioner

Reimplemented from bitpit::SystemSolver.

Definition at line 102 of file LA_example_00001.cpp.

Member Data Documentation

◆ GAMG_MAX_LEVELS

const PetscInt AMGSystemSolver::GAMG_MAX_LEVELS = 10
staticprotected

Definition at line 90 of file LA_example_00001.cpp.

◆ GAMG_THRESHOLD

const PetscReal AMGSystemSolver::GAMG_THRESHOLD = 0.02
staticprotected

Definition at line 91 of file LA_example_00001.cpp.

◆ GAMG_THRESHOLD_SCALE

const PetscReal AMGSystemSolver::GAMG_THRESHOLD_SCALE = 1.0
staticprotected

Definition at line 92 of file LA_example_00001.cpp.

◆ m_multigrid

bool AMGSystemSolver::m_multigrid
protected

Definition at line 94 of file LA_example_00001.cpp.


The documentation for this class was generated from the following file:
--- layout: doxygen_footer ---