From: Bruno Turcksin Date: Tue, 13 Aug 2013 17:30:01 +0000 (+0000) Subject: Add TrilinosWrappers::PreconditionIdentity, i.e., identity preconditioner for Trilinos. X-Git-Tag: v8.1.0~1072 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=609569f2c72db8f3b344e6b05f19e48223e48313;p=dealii.git Add TrilinosWrappers::PreconditionIdentity, i.e., identity preconditioner for Trilinos. git-svn-id: https://svn.dealii.org/trunk@30302 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/trilinos_precondition.h b/deal.II/include/deal.II/lac/trilinos_precondition.h index 34a6017f4f..3936118d50 100644 --- a/deal.II/include/deal.II/lac/trilinos_precondition.h +++ b/deal.II/include/deal.II/lac/trilinos_precondition.h @@ -121,13 +121,13 @@ namespace TrilinosWrappers /** * Apply the preconditioner. */ - void vmult (VectorBase &dst, - const VectorBase &src) const; + virtual void vmult (VectorBase &dst, + const VectorBase &src) const; /** * Apply the transpose preconditioner. */ - void Tvmult (VectorBase &dst, + virtual void Tvmult (VectorBase &dst, const VectorBase &src) const; /** @@ -137,8 +137,8 @@ namespace TrilinosWrappers * in the Trilinos wrapper * class. */ - void vmult (dealii::Vector &dst, - const dealii::Vector &src) const; + virtual void vmult (dealii::Vector &dst, + const dealii::Vector &src) const; /** * Apply the transpose preconditioner on @@ -147,8 +147,8 @@ namespace TrilinosWrappers * in the Trilinos wrapper * class. */ - void Tvmult (dealii::Vector &dst, - const dealii::Vector &src) const; + virtual void Tvmult (dealii::Vector &dst, + const dealii::Vector &src) const; /** * Apply the preconditioner on deal.II @@ -156,8 +156,8 @@ namespace TrilinosWrappers * the ones provided in the Trilinos * wrapper class. */ - void vmult (dealii::parallel::distributed::Vector &dst, - const dealii::parallel::distributed::Vector &src) const; + virtual void vmult (dealii::parallel::distributed::Vector &dst, + const dealii::parallel::distributed::Vector &src) const; /** * Apply the transpose preconditioner on deal.II @@ -165,8 +165,8 @@ namespace TrilinosWrappers * the ones provided in the Trilinos * wrapper class. */ - void Tvmult (dealii::parallel::distributed::Vector &dst, - const dealii::parallel::distributed::Vector &src) const; + virtual void Tvmult (dealii::parallel::distributed::Vector &dst, + const dealii::parallel::distributed::Vector &src) const; /** * Exception. @@ -1508,6 +1508,64 @@ namespace TrilinosWrappers + /** + * A wrapper class for an identity preconditioner for Trilinos matrices. + * + * @ingroup TrilinosWrappers + * @ingroup Preconditioners + * @author Bruno Turcksin, 2013 + */ + class PreconditionIdentity : public PreconditionBase + { + public: + + /** + * Apply the preconditioner, i.e., dst = src. + */ + void vmult (VectorBase &dst, + const VectorBase &src) const; + + /** + * Apply the transport conditioner, i.e., dst = src. + */ + void Tvmult (VectorBase &dst, + const VectorBase &src) const; + + /** + * Apply the preconditioner on deal.II data structures + * instead of the ones provided in the Trilinos wrapper class, + * i.e., dst = src. + */ + void vmult (dealii::Vector &dst, + const dealii::Vector &src) const; + + /** + * Apply the transpose preconditioner on deal.II data structures + * instead of the ones provided in the Trilinos wrapper class, + * i.e. dst = src. + */ + void Tvmult (dealii::Vector &dst, + const dealii::Vector &src) const; + + /** + * Apply the preconditioner on deal.II parallel data structures + * instead of the ones provided in the Trilinos wrapper class, + * i.e., dst = src. + */ + void vmult (parallel::distributed::Vector &dst, + const dealii::parallel::distributed::Vector &src) const; + + /** + * Apply the transpose preconditioner on deal.II parallel data structures + * instead of the ones provided in the Trilinos wrapper class, + * i.e., dst = src. + */ + void Tvmult (parallel::distributed::Vector &dst, + const dealii::parallel::distributed::Vector &src) const; + }; + + + // -------------------------- inline and template functions ---------------------- diff --git a/deal.II/source/lac/trilinos_precondition.cc b/deal.II/source/lac/trilinos_precondition.cc index d8342f04d2..a014bdd2f3 100644 --- a/deal.II/source/lac/trilinos_precondition.cc +++ b/deal.II/source/lac/trilinos_precondition.cc @@ -745,6 +745,52 @@ namespace TrilinosWrappers const AdditionalData &, const double, const ::dealii::SparsityPattern *); + + + + /* -------------------------- PreconditionAMG -------------------------- */ + + void + PreconditionIdentity::vmult(VectorBase &dst, + const VectorBase &src) const + { + dst = src; + } + + void + PreconditionIdentity::Tvmult(VectorBase &dst, + const VectorBase &src) const + { + dst = src; + } + + void + PreconditionIdentity::vmult(dealii::Vector &dst, + const dealii::Vector &src) const + { + dst = src; + } + + void + PreconditionIdentity::Tvmult(dealii::Vector &dst, + const dealii::Vector &src) const + { + dst = src; + } + + void + PreconditionIdentity::vmult(parallel::distributed::Vector &dst, + const parallel::distributed::Vector &src) const + { + dst = src; + } + + void + PreconditionIdentity::Tvmult(parallel::distributed::Vector &dst, + const parallel::distributed::Vector &src) const + { + dst = src; + } } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/lac/trilinos_solver.cc b/deal.II/source/lac/trilinos_solver.cc index f04ca39f85..896d5d8499 100644 --- a/deal.II/source/lac/trilinos_solver.cc +++ b/deal.II/source/lac/trilinos_solver.cc @@ -208,11 +208,14 @@ namespace TrilinosWrappers Assert (false, ExcNotImplemented()); } - // Introduce the - // preconditioner, ... - ierr = solver.SetPrecOperator (const_cast - (preconditioner.preconditioner.get())); - AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + // Introduce the preconditioner, + // if not the identity preconditioner ... + if (preconditioner.preconditioner.use_count()!=0) + { + ierr = solver.SetPrecOperator (const_cast + (preconditioner.preconditioner.get())); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + } // ... set some options, ... solver.SetAztecOption (AZ_output, additional_data.output_solver_details ?