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

The class AMGSplitSystemSolver is derived form SplitSystemSolver 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 AMGSplitSystemSolver:
Inheritance graph
[legend]
Collaboration diagram for AMGSplitSystemSolver:
Collaboration graph
[legend]

Public Member Functions

 AMGSplitSystemSolver (bool transpose, bool multigrid, bool debug)
 
- Public Member Functions inherited from bitpit::SplitSystemSolver
 SplitSystemSolver (bool debug=false)
 
 SplitSystemSolver (bool flatten, bool transpose, bool debug)
 
 SplitSystemSolver (bool transpose, bool debug)
 
 SplitSystemSolver (const std::string &prefix, bool debug=false)
 
 SplitSystemSolver (const std::string &prefix, bool flatten, bool transpose, bool debug)
 
 SplitSystemSolver (const std::string &prefix, bool transpose, bool debug)
 
void assembly (const Assembler &assembler)
 
void assembly (const Assembler &assembler, const SystemMatrixOrdering &reordering)
 
void assembly (const SparseMatrix &matrix, SystemSplitStrategy splitStrategy, const std::vector< int > &splitSizes)
 
void assembly (const SparseMatrix &matrix, SystemSplitStrategy splitStrategy, const std::vector< int > &splitSizes, const SystemMatrixOrdering &reordering)
 
void exportMatrix (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const override
 
int getBlockSize () const override
 
int getSplitCount () const
 
KSPOptionsgetSplitKSPOptions (int split)
 
const KSPOptionsgetSplitKSPOptions (int split) const
 
const KSPStatusgetSplitKSPStatus (int split) const
 
std::vector< int > getSplitOffsets () const
 
std::vector< int > getSplitSizes () const
 
SystemSplitStrategy getSplitStrategy () const
 
 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)
 
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)
 
- 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 exportRHS (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const
 
virtual void exportSolution (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) 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::SplitSystemSolver
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)
 
template<typename DerivedSystemSolver >
void assembly (const typename DerivedSystemSolver::Assembler &assembler, const SystemMatrixOrdering &reordering)
 
void destroyKSPOptions () override
 
void destroyKSPStatus () override
 
virtual void destroySplitKSPOptions ()
 
virtual void destroySplitKSPStatuses ()
 
void dumpInfo (std::ostream &systemStream) const override
 
virtual void exportMatrix (const std::string &filePath, FileFormat exportFormat=FILE_BINARY) const
 
void exportMatrix (Mat matrix, const std::string &filePath, FileFormat fileFormat) const
 
virtual void fillKSPStatus ()
 
void fillKSPStatus () override
 
virtual void fillKSPStatus (KSP ksp, KSPStatus *status) const
 
virtual void fillSplitKSPStatuses ()
 
void generateSplitIndexes (int split, long nItems, std::vector< std::size_t > *indexes) const
 
std::string generateSplitPath (const std::string &path, const std::string &index) const
 
std::string generateSplitPath (const std::string &path, int i) const
 
std::string generateSplitPath (const std::string &path, int i, int j) const
 
void generateSplitPermutation (long nItems, long itemGlobalOffset, IS *splitReordering) const
 
void initializeKSPOptions () override
 
void initializeKSPStatus () override
 
virtual void initializeSplitKSPOptions ()
 
virtual void initializeSplitKSPStatuses ()
 
void matrixAssembly (const Assembler &assembler)
 
void matrixDestroy () override
 
void matrixDump (std::ostream &systemStream, const std::string &directory, const std::string &prefix) const override
 
void matrixFill (const std::string &filePath) override
 
void matrixRestore (std::istream &systemStream, const std::string &directory, const std::string &prefix, bool redistribute) override
 
void matrixUpdate (long nRows, const long *rows, const Assembler &assembler)
 
void postKSPSolveActions () override
 
void preKrylovSetupActions () override
 
virtual void resetKSPOptions (KSPOptions *options) const
 
virtual void resetKSPStatus ()
 
void resetKSPStatus () override
 
virtual void resetKSPStatus (KSPStatus *status) const
 
virtual void resetSplitKSPStatuses ()
 
void restoreInfo (std::istream &systemStream) override
 
virtual void setupKrylov ()
 
void setupKrylov () override
 
virtual void setupKrylov (KSP ksp, const KSPOptions &options) const
 
virtual void setupPreconditioner ()
 
void setupPreconditioner () override
 
virtual void setupPreconditioner (PC pc, const KSPOptions &options) const
 
virtual void setupSplitKrylovs ()
 
virtual void setupSplitPreconditioners ()
 
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)
 
template<typename DerivedSystemSolver >
void update (long nRows, const long *rows, const typename DerivedSystemSolver::Assembler &assembler)
 
void vectorsCreate () override
 
void vectorsCreateSplitPermutations ()
 
void vectorsDestroy () override
 
void vectorsReorder (bool invert) override
 
void vectorsRestore (std::istream &systemStream, const std::string &directory, const std::string &prefix) 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 ()
 
void destroyMatrix (Mat *matrix) const
 
void destroyVector (Vec *vector) 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
 
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
 
void matrixAssembly (const Assembler &assembler)
 
void matrixUpdate (long nRows, const long *rows, const Assembler &assembler)
 
virtual void postKrylovSetupActions ()
 
virtual void postPreconditionerSetupActions ()
 
virtual void preKSPSolveActions ()
 
virtual void prepareKSP ()
 
virtual void prePreconditionerSetupActions ()
 
void reorderVector (Vec vector, IS permutations, bool invert) const
 
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 solveKSP ()
 
template<typename DerivedSystemSolver >
void update (long nRows, const long *rows, const typename DerivedSystemSolver::Assembler &assembler)
 
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)
 

Protected Attributes

bool m_multigrid
 
- Protected Attributes inherited from bitpit::SplitSystemSolver
std::vector< Mat > m_splitAs
 
std::vector< KSPOptionsm_splitKSPOptions
 
std::vector< KSPStatusm_splitKSPStatuses
 
SystemSplitStrategy m_splitStrategy
 
- 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::SplitSystemSolver
typedef SplitSystemMatrixAssembler Assembler
 
typedef SystemSplitStrategy splitStrategy
 
- 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 AMGSplitSystemSolver is derived form SplitSystemSolver and it allows to solve the linear system using PETSc GAMG preconditioner. Only non-block matrices can be solved using GAMG.

Definition at line 77 of file LA_example_00002.cpp.

Constructor & Destructor Documentation

◆ AMGSplitSystemSolver()

AMGSplitSystemSolver::AMGSplitSystemSolver ( 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.

Definition at line 87 of file LA_example_00002.cpp.

Member Function Documentation

◆ setupPreconditioner()

void AMGSplitSystemSolver::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 106 of file LA_example_00002.cpp.

Member Data Documentation

◆ GAMG_MAX_LEVELS

const PetscInt AMGSplitSystemSolver::GAMG_MAX_LEVELS = 10
staticprotected

Definition at line 94 of file LA_example_00002.cpp.

◆ GAMG_THRESHOLD

const PetscReal AMGSplitSystemSolver::GAMG_THRESHOLD = 0.02
staticprotected

Definition at line 95 of file LA_example_00002.cpp.

◆ GAMG_THRESHOLD_SCALE

const PetscReal AMGSplitSystemSolver::GAMG_THRESHOLD_SCALE = 1.0
staticprotected

Definition at line 96 of file LA_example_00002.cpp.

◆ m_multigrid

bool AMGSplitSystemSolver::m_multigrid
protected

Definition at line 98 of file LA_example_00002.cpp.


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