From: Martin Kronbichler Date: Tue, 19 May 2009 06:11:08 +0000 (+0000) Subject: Move PreconditionBase::vmult in h file. X-Git-Tag: v8.0.0~7670 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=327a4803524df5afa1d77234a008325707f0d2f6;p=dealii.git Move PreconditionBase::vmult in h file. git-svn-id: https://svn.dealii.org/trunk@18867 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/trilinos_precondition.h b/deal.II/lac/include/lac/trilinos_precondition.h index 26ab08b814..0e5ee7303f 100755 --- a/deal.II/lac/include/lac/trilinos_precondition.h +++ b/deal.II/lac/include/lac/trilinos_precondition.h @@ -16,9 +16,9 @@ #include #include - #include +#include #ifdef DEAL_II_USE_TRILINOS @@ -31,6 +31,7 @@ #include #include +#include // forward declarations class Ifpack_Preconditioner; @@ -53,8 +54,7 @@ template class Vector; namespace TrilinosWrappers { - - class VectorBase; + // forward declarations class SparseMatrix; class BlockSparseMatrix; class SolverBase; @@ -113,8 +113,9 @@ namespace TrilinosWrappers * in the Trilinos wrapper * class. */ - void vmult (dealii::Vector &dst, - const dealii::Vector &src) const; + template + void vmult (dealii::Vector &dst, + const dealii::Vector &src) const; /** * Exception. @@ -1465,8 +1466,73 @@ namespace TrilinosWrappers std_cxx1x::shared_ptr Matrix; }; + + +// -------------------------- inline and template functions ---------------------- + + +#ifndef DOXYGEN + + inline + void + PreconditionBase::vmult (VectorBase &dst, + const VectorBase &src) const + { + Assert (dst.vector_partitioner().SameAs(preconditioner->OperatorRangeMap()), + ExcNonMatchingMaps("dst")); + Assert (src.vector_partitioner().SameAs(preconditioner->OperatorDomainMap()), + ExcNonMatchingMaps("src")); + + const int ierr = preconditioner->ApplyInverse (src.trilinos_vector(), + dst.trilinos_vector()); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + } + + + // For the implementation of + // the vmult + // function with deal.II data + // structures we note that + // invoking a call of the + // Trilinos preconditioner + // requires us to use Epetra + // vectors as well. We do this + // by providing a view, i.e., + // feed Trilinos with a + // pointer to the data, so we + // avoid copying the content + // of the vectors during the + // iteration (this function is + // only useful when used in + // serial anyway). In the + // declaration of the right + // hand side, we need to cast + // the source vector (that is + // const in all + // deal.II calls) to + // non-constant value, as this + // is the way Trilinos wants + // to have them. + template + inline + void PreconditionBase::vmult (dealii::Vector &dst, + const dealii::Vector &src) const + { + + Epetra_Vector LHS (View, preconditioner->OperatorDomainMap(), + dst.begin()); + Epetra_Vector RHS (View, preconditioner->OperatorRangeMap(), + const_cast(src.begin())); + + const int ierr = preconditioner->ApplyInverse (RHS, LHS); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + } + +#endif + } + /*@}*/ diff --git a/deal.II/lac/source/trilinos_precondition.cc b/deal.II/lac/source/trilinos_precondition.cc index 659a444cec..646cb9f5da 100755 --- a/deal.II/lac/source/trilinos_precondition.cc +++ b/deal.II/lac/source/trilinos_precondition.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #ifdef DEAL_II_USE_TRILINOS @@ -23,9 +22,7 @@ #include #include #include -#include #include -#include #include #include @@ -63,60 +60,6 @@ namespace TrilinosWrappers - void - PreconditionBase::vmult (VectorBase &dst, - const VectorBase &src) const - { - Assert (dst.vector_partitioner().SameAs(preconditioner->OperatorRangeMap()), - ExcNonMatchingMaps("dst")); - Assert (src.vector_partitioner().SameAs(preconditioner->OperatorDomainMap()), - ExcNonMatchingMaps("src")); - - const int ierr = preconditioner->ApplyInverse (src.trilinos_vector(), - dst.trilinos_vector()); - AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - } - - - // For the implementation of - // the vmult - // function with deal.II data - // structures we note that - // invoking a call of the - // Trilinos preconditioner - // requires us to use Epetra - // vectors as well. We do this - // by providing a view, i.e., - // feed Trilinos with a - // pointer to the data, so we - // avoid copying the content - // of the vectors during the - // iteration (this function is - // only useful when used in - // serial anyway). In the - // declaration of the right - // hand side, we need to cast - // the source vector (that is - // const in all - // deal.II calls) to - // non-constant value, as this - // is the way Trilinos wants - // to have them. - void PreconditionBase::vmult (dealii::Vector &dst, - const dealii::Vector &src) const - { - - Epetra_Vector LHS (View, preconditioner->OperatorDomainMap(), - dst.begin()); - Epetra_Vector RHS (View, preconditioner->OperatorRangeMap(), - const_cast(src.begin())); - - const int ierr = preconditioner->ApplyInverse (RHS, LHS); - AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - } - - - /* -------------------------- PreconditionJacobi -------------------------- */ PreconditionJacobi::AdditionalData:: @@ -699,8 +642,7 @@ namespace TrilinosWrappers } - void PreconditionAMG:: - reinit () + void PreconditionAMG::reinit () { multilevel_operator->ReComputePreconditioner(); }