From 49c77c1c08093f6d3d76d3bf4f1f0d9ebf9e8218 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 5 Nov 2012 00:52:50 +0000 Subject: [PATCH] Partial merge from the parallel_mg branch: Introduce Tvmult for Trilinos preconditioners. git-svn-id: https://svn.dealii.org/trunk@27379 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 ++ .../deal.II/lac/trilinos_precondition.h | 82 +++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 0a6fcfc76b..db2c26e5a2 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -154,6 +154,12 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. New: The TrilinosWrappers::PreconditionBase class now has +a function TrilinosWrappers::PreconditionBase::Tvmult that +allows applying the transpose preconditioner. +
    +(Guido Kanschat, 2012/11/04) +
  2. New: The parallel::distributed::Triangulation::n_global_levels() function returns the maximal refinement level over all involved processors. diff --git a/deal.II/include/deal.II/lac/trilinos_precondition.h b/deal.II/include/deal.II/lac/trilinos_precondition.h index aed66aaded..025817f8be 100644 --- a/deal.II/include/deal.II/lac/trilinos_precondition.h +++ b/deal.II/include/deal.II/lac/trilinos_precondition.h @@ -113,6 +113,12 @@ namespace TrilinosWrappers * Apply the preconditioner. */ void vmult (VectorBase &dst, + const VectorBase &src) const; + + /** + * Apply transpose the preconditioner. + */ + void Tvmult (VectorBase &dst, const VectorBase &src) const; /** @@ -123,6 +129,16 @@ namespace TrilinosWrappers * class. */ 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. + */ + void Tvmult (dealii::Vector &dst, const dealii::Vector &src) const; /** @@ -132,6 +148,15 @@ namespace TrilinosWrappers * wrapper class. */ void vmult (dealii::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. + */ + void Tvmult (dealii::parallel::distributed::Vector &dst, const dealii::parallel::distributed::Vector &src) const; /** @@ -1488,6 +1513,23 @@ namespace TrilinosWrappers AssertThrow (ierr == 0, ExcTrilinosError(ierr)); } + inline + void + PreconditionBase::Tvmult (VectorBase &dst, + const VectorBase &src) const + { + Assert (dst.vector_partitioner().SameAs(preconditioner->OperatorRangeMap()), + ExcNonMatchingMaps("dst")); + Assert (src.vector_partitioner().SameAs(preconditioner->OperatorDomainMap()), + ExcNonMatchingMaps("src")); + + preconditioner->SetUseTranspose(true); + const int ierr = preconditioner->ApplyInverse (src.trilinos_vector(), + dst.trilinos_vector()); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + preconditioner->SetUseTranspose(false); + } + // For the implementation of // the vmult @@ -1531,6 +1573,26 @@ namespace TrilinosWrappers } + inline + void PreconditionBase::Tvmult (dealii::Vector &dst, + const dealii::Vector &src) const + { + AssertDimension (static_cast(dst.size()), + preconditioner->OperatorDomainMap().NumMyElements()); + AssertDimension (static_cast(src.size()), + preconditioner->OperatorRangeMap().NumMyElements()); + Epetra_Vector tril_dst (View, preconditioner->OperatorDomainMap(), + dst.begin()); + Epetra_Vector tril_src (View, preconditioner->OperatorRangeMap(), + const_cast(src.begin())); + + preconditioner->SetUseTranspose(true); + const int ierr = preconditioner->ApplyInverse (tril_src, tril_dst); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + preconditioner->SetUseTranspose(false); + } + + inline void @@ -1550,6 +1612,26 @@ namespace TrilinosWrappers AssertThrow (ierr == 0, ExcTrilinosError(ierr)); } + inline + void + PreconditionBase::Tvmult (parallel::distributed::Vector &dst, + const parallel::distributed::Vector &src) const + { + AssertDimension (static_cast(dst.local_size()), + preconditioner->OperatorDomainMap().NumMyElements()); + AssertDimension (static_cast(src.local_size()), + preconditioner->OperatorRangeMap().NumMyElements()); + Epetra_Vector tril_dst (View, preconditioner->OperatorDomainMap(), + dst.begin()); + Epetra_Vector tril_src (View, preconditioner->OperatorRangeMap(), + const_cast(src.begin())); + + preconditioner->SetUseTranspose(true); + const int ierr = preconditioner->ApplyInverse (tril_src, tril_dst); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + preconditioner->SetUseTranspose(false); + } + #endif } -- 2.39.5