From: oliver Date: Mon, 26 Jul 2004 14:42:04 +0000 (+0000) Subject: Added a preconditioner class for the LU decomposition provided by PetSC. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b0289aa3281797c8f067ece41ef12b47d064533;p=dealii-svn.git Added a preconditioner class for the LU decomposition provided by PetSC. Works only for single processor machines. git-svn-id: https://svn.dealii.org/trunk@9519 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/petsc_precondition.h b/deal.II/lac/include/lac/petsc_precondition.h index 447191e0a8..510fad9603 100644 --- a/deal.II/lac/include/lac/petsc_precondition.h +++ b/deal.II/lac/include/lac/petsc_precondition.h @@ -511,8 +511,67 @@ namespace PETScWrappers virtual void set_preconditioner_type (PC &pc) const; }; + + +/** + * A class that implements the interface to use the PETSc LU + * preconditioner. The LU decomposition is only implemented for single + * processor machines. It should provide a convenient interface to + * another direct solver. + * + * @ingroup PETScWrappers + * @author Oliver Kayser-Herold, 2004 + */ + class PreconditionLU : public PreconditionerBase + { + public: + /** + * Standardized data struct to + * pipe additional flags to the + * preconditioner. + */ + struct AdditionalData + { + /** + * Constructor. + */ + AdditionalData (); + }; + + /** + * Constructor. Take the matrix which + * is used to form the preconditioner, + * and additional flags if there are + * any. + * + * We specify the (default) value to + * the constructor call in the default + * argument because otherwise gcc 2.95 + * generates a compiler fault. + */ + PreconditionLU (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; + }; + } + #endif // DEAL_II_USE_PETSC /*---------------------------- petsc_precondition.h ---------------------------*/ diff --git a/deal.II/lac/source/petsc_precondition.cc b/deal.II/lac/source/petsc_precondition.cc index 7fedb96742..836d439622 100644 --- a/deal.II/lac/source/petsc_precondition.cc +++ b/deal.II/lac/source/petsc_precondition.cc @@ -256,6 +256,33 @@ namespace PETScWrappers } +/* ----------------- PreconditionLU -------------------- */ + + PreconditionLU::AdditionalData:: + AdditionalData () + {} + + + + PreconditionLU::PreconditionLU (const MatrixBase &matrix, + const AdditionalData &additional_data) + : + PreconditionerBase (matrix), + additional_data (additional_data) + {} + + + void + PreconditionLU::set_preconditioner_type (PC &pc) const + { + // set the right type for the + // preconditioner + int ierr; + ierr = PCSetType (pc, const_cast(PCLU)); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + } + + } #else