From 989dcd93ed2fb2bcc44a1f829a4b31e185b293d8 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 1 Apr 2004 17:00:41 +0000 Subject: [PATCH] Implement block jacobi, simple version. git-svn-id: https://svn.dealii.org/trunk@8947 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/petsc_precondition.h | 45 ++++++++++++++++++++ deal.II/lac/source/petsc_precondition.cc | 23 ++++++++++ 2 files changed, 68 insertions(+) diff --git a/deal.II/lac/include/lac/petsc_precondition.h b/deal.II/lac/include/lac/petsc_precondition.h index 939ae226a2..b39f97448c 100644 --- a/deal.II/lac/include/lac/petsc_precondition.h +++ b/deal.II/lac/include/lac/petsc_precondition.h @@ -143,6 +143,51 @@ namespace PETScWrappers +/** + * A class that implements the interface to use the PETSc Block Jacobi + * preconditioner. + * + * @author Wolfgang Bangerth, 2004 + */ + class PreconditionBlockJacobi : public PreconditionerBase + { + public: + /** + * Standardized data struct to + * pipe additional flags to the + * preconditioner. + */ + struct AdditionalData + {}; + + /** + * Constructor. Take the matrix which + * is used to form the preconditioner, + * and additional flags if there are + * any. + */ + PreconditionBlockJacobi (const MatrixBase &matrix, + const AdditionalData &additional_data = AdditionalData()); + + protected: + /** + * Store a copy of the flags for this + * particular preconditioner. + */ + const AdditionalData additional_data; + + /** + * Function that takes a Krylov + * Subspace Preconditioner context + * object, and sets the type of + * preconditioner that is appropriate + * for the present class. + */ + virtual void set_preconditioner_type (PC &pc) const; + }; + + + /** * A class that implements the interface to use the PETSc SOR * preconditioner. diff --git a/deal.II/lac/source/petsc_precondition.cc b/deal.II/lac/source/petsc_precondition.cc index 90fe59203e..a060c7e20b 100644 --- a/deal.II/lac/source/petsc_precondition.cc +++ b/deal.II/lac/source/petsc_precondition.cc @@ -63,6 +63,29 @@ namespace PETScWrappers } +/* ----------------- PreconditionJacobi -------------------- */ + + + PreconditionBlockJacobi:: + PreconditionBlockJacobi (const MatrixBase &matrix, + const AdditionalData &additional_data) + : + PreconditionerBase (matrix), + additional_data (additional_data) + {} + + + void + PreconditionBlockJacobi::set_preconditioner_type (PC &pc) const + { + // set the right type for the + // preconditioner + int ierr; + ierr = PCSetType (pc, const_cast(PCBJACOBI)); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + } + + /* ----------------- PreconditionSOR -------------------- */ PreconditionSOR::AdditionalData:: -- 2.39.5