From: David Wells Date: Mon, 22 Feb 2016 04:23:43 +0000 (-0500) Subject: Prefer PreconditionerType to Preconditioner. X-Git-Tag: v8.5.0-rc1~1299^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2215%2Fhead;p=dealii.git Prefer PreconditionerType to Preconditioner. This commit updates the tutorials to use the same naming convention as the rest of the library. --- diff --git a/examples/step-22/step-22.cc b/examples/step-22/step-22.cc index b4ca614e5b..b5adc57a5a 100644 --- a/examples/step-22/step-22.cc +++ b/examples/step-22/step-22.cc @@ -264,26 +264,26 @@ namespace Step22 // InverseMatrix object is created. The member function // vmult is, as in step-20, a multiplication with a vector, // obtained by solving a linear system: - template + template class InverseMatrix : public Subscriptor { public: - InverseMatrix (const MatrixType &m, - const Preconditioner &preconditioner); + InverseMatrix (const MatrixType &m, + const PreconditionerType &preconditioner); void vmult (Vector &dst, const Vector &src) const; private: const SmartPointer matrix; - const SmartPointer preconditioner; + const SmartPointer preconditioner; }; - template - InverseMatrix::InverseMatrix - (const MatrixType &m, - const Preconditioner &preconditioner) + template + InverseMatrix::InverseMatrix + (const MatrixType &m, + const PreconditionerType &preconditioner) : matrix (&m), preconditioner (&preconditioner) @@ -300,9 +300,10 @@ namespace Step22 // inverse of the Laplace matrix – which is hence directly responsible // for the accuracy of the solution itself, so we can't choose a too large // tolerance, either. - template - void InverseMatrix::vmult (Vector &dst, - const Vector &src) const + template + void InverseMatrix::vmult + (Vector &dst, + const Vector &src) const { SolverControl solver_control (src.size(), 1e-6*src.l2_norm()); SolverCG<> cg (solver_control); @@ -317,35 +318,35 @@ namespace Step22 // This class implements the Schur complement discussed in the introduction. // It is in analogy to step-20. Though, we now call it with a template - // parameter Preconditioner in order to access that when + // parameter PreconditionerType in order to access that when // specifying the respective type of the inverse matrix class. As a // consequence of the definition above, the declaration // InverseMatrix now contains the second template parameter for // a preconditioner class as above, which affects the // SmartPointer object m_inverse as well. - template + template class SchurComplement : public Subscriptor { public: SchurComplement (const BlockSparseMatrix &system_matrix, - const InverseMatrix, Preconditioner> &A_inverse); + const InverseMatrix, PreconditionerType> &A_inverse); void vmult (Vector &dst, const Vector &src) const; private: const SmartPointer > system_matrix; - const SmartPointer, Preconditioner> > A_inverse; + const SmartPointer, PreconditionerType> > A_inverse; mutable Vector tmp1, tmp2; }; - template - SchurComplement:: - SchurComplement (const BlockSparseMatrix &system_matrix, - const InverseMatrix,Preconditioner> &A_inverse) + template + SchurComplement::SchurComplement + (const BlockSparseMatrix &system_matrix, + const InverseMatrix,PreconditionerType> &A_inverse) : system_matrix (&system_matrix), A_inverse (&A_inverse), @@ -354,9 +355,9 @@ namespace Step22 {} - template - void SchurComplement::vmult (Vector &dst, - const Vector &src) const + template + void SchurComplement::vmult (Vector &dst, + const Vector &src) const { system_matrix->block(0,1).vmult (tmp1, src); A_inverse->vmult (tmp2, tmp1); diff --git a/examples/step-31/step-31.cc b/examples/step-31/step-31.cc index 83453cea51..6a8935a3c6 100644 --- a/examples/step-31/step-31.cc +++ b/examples/step-31/step-31.cc @@ -237,7 +237,7 @@ namespace Step31 // way as the corresponding class in step-22: when the product of an // object of this class is requested, we solve a linear equation system // with that matrix using the CG method, accelerated by a preconditioner - // of (templated) class Preconditioner. + // of (templated) class PreconditionerType. // // In a minor deviation from the implementation of the same class in // step-22 (and step-20), we make the vmult function take any @@ -266,12 +266,12 @@ namespace Step31 // run-time exception into an assertion that fails and triggers a call to // abort(), allowing us to trace back in a debugger how we // got to the current place. - template + template class InverseMatrix : public Subscriptor { public: InverseMatrix (const MatrixType &m, - const Preconditioner &preconditioner); + const PreconditionerType &preconditioner); template @@ -280,14 +280,14 @@ namespace Step31 private: const SmartPointer matrix; - const Preconditioner &preconditioner; + const PreconditionerType &preconditioner; }; - template - InverseMatrix:: - InverseMatrix (const MatrixType &m, - const Preconditioner &preconditioner) + template + InverseMatrix::InverseMatrix + (const MatrixType &m, + const PreconditionerType &preconditioner) : matrix (&m), preconditioner (preconditioner) @@ -295,12 +295,12 @@ namespace Step31 - template + template template void - InverseMatrix:: - vmult (VectorType &dst, - const VectorType &src) const + InverseMatrix::vmult + (VectorType &dst, + const VectorType &src) const { SolverControl solver_control (src.size(), 1e-7*src.l2_norm()); SolverCG cg (solver_control); @@ -369,15 +369,15 @@ namespace Step31 // Schur complement in step-20, with the difference that we need some more // preconditioners in the constructor and that the matrices we use here // are built upon Trilinos: - template + template class BlockSchurPreconditioner : public Subscriptor { public: BlockSchurPreconditioner ( const TrilinosWrappers::BlockSparseMatrix &S, const InverseMatrix &Mpinv, - const PreconditionerA &Apreconditioner); + PreconditionerTypeMp> &Mpinv, + const PreconditionerTypeA &Apreconditioner); void vmult (TrilinosWrappers::MPI::BlockVector &dst, const TrilinosWrappers::MPI::BlockVector &src) const; @@ -385,8 +385,8 @@ namespace Step31 private: const SmartPointer stokes_matrix; const SmartPointer > m_inverse; - const PreconditionerA &a_preconditioner; + PreconditionerTypeMp > > m_inverse; + const PreconditionerTypeA &a_preconditioner; mutable TrilinosWrappers::MPI::Vector tmp; }; @@ -402,12 +402,12 @@ namespace Step31 // an IndexSet where every valid index is part of the set. Note that this // program can only be run sequentially and will throw an exception if used // in parallel. - template - BlockSchurPreconditioner:: - BlockSchurPreconditioner(const TrilinosWrappers::BlockSparseMatrix &S, + template + BlockSchurPreconditioner:: + BlockSchurPreconditioner(const TrilinosWrappers::BlockSparseMatrix &S, const InverseMatrix &Mpinv, - const PreconditionerA &Apreconditioner) + PreconditionerTypeMp> &Mpinv, + const PreconditionerTypeA &Apreconditioner) : stokes_matrix (&S), m_inverse (&Mpinv), @@ -431,11 +431,11 @@ namespace Step31 // vector and finally multiply by the inverse pressure mass matrix to get // the final pressure vector, completing our work on the Stokes // preconditioner: - template + template void - BlockSchurPreconditioner:: - vmult (TrilinosWrappers::MPI::BlockVector &dst, - const TrilinosWrappers::MPI::BlockVector &src) const + BlockSchurPreconditioner::vmult + (TrilinosWrappers::MPI::BlockVector &dst, + const TrilinosWrappers::MPI::BlockVector &src) const { a_preconditioner.vmult (dst.block(0), src.block(0)); stokes_matrix->block(1,0).residual(tmp, dst.block(0), src.block(1)); diff --git a/examples/step-32/step-32.cc b/examples/step-32/step-32.cc index 7acc4f3935..c650d850d0 100644 --- a/examples/step-32/step-32.cc +++ b/examples/step-32/step-32.cc @@ -232,15 +232,15 @@ namespace Step32 // discussion of composing solvers in step-20. namespace LinearSolvers { - template + template class BlockSchurPreconditioner : public Subscriptor { public: - BlockSchurPreconditioner (const TrilinosWrappers::BlockSparseMatrix &S, - const TrilinosWrappers::BlockSparseMatrix &Spre, - const PreconditionerMp &Mppreconditioner, - const PreconditionerA &Apreconditioner, - const bool do_solve_A) + BlockSchurPreconditioner (const TrilinosWrappers::BlockSparseMatrix &S, + const TrilinosWrappers::BlockSparseMatrix &Spre, + const PreconditionerTypeMp &Mppreconditioner, + const PreconditionerTypeA &Apreconditioner, + const bool do_solve_A) : stokes_matrix (&S), stokes_preconditioner_matrix (&Spre), @@ -286,8 +286,8 @@ namespace Step32 private: const SmartPointer stokes_matrix; const SmartPointer stokes_preconditioner_matrix; - const PreconditionerMp &mp_preconditioner; - const PreconditionerA &a_preconditioner; + const PreconditionerTypeMp &mp_preconditioner; + const PreconditionerTypeA &a_preconditioner; const bool do_solve_A; }; } diff --git a/examples/step-43/step-43.cc b/examples/step-43/step-43.cc index c7b4e198e0..8a69b6732b 100644 --- a/examples/step-43/step-43.cc +++ b/examples/step-43/step-43.cc @@ -361,12 +361,12 @@ namespace Step43 // darcy_matrix to match our problem. namespace LinearSolvers { - template + template class InverseMatrix : public Subscriptor { public: - InverseMatrix (const MatrixType &m, - const Preconditioner &preconditioner); + InverseMatrix (const MatrixType &m, + const PreconditionerType &preconditioner); template @@ -375,14 +375,14 @@ namespace Step43 private: const SmartPointer matrix; - const Preconditioner &preconditioner; + const PreconditionerType &preconditioner; }; - template - InverseMatrix:: - InverseMatrix (const MatrixType &m, - const Preconditioner &preconditioner) + template + InverseMatrix::InverseMatrix + (const MatrixType &m, + const PreconditionerType &preconditioner) : matrix (&m), preconditioner (preconditioner) @@ -390,12 +390,12 @@ namespace Step43 - template + template template void - InverseMatrix:: - vmult (VectorType &dst, - const VectorType &src) const + InverseMatrix::vmult + (VectorType &dst, + const VectorType &src) const { SolverControl solver_control (src.size(), 1e-7*src.l2_norm()); SolverCG cg (solver_control); @@ -412,15 +412,15 @@ namespace Step43 } } - template + template class BlockSchurPreconditioner : public Subscriptor { public: BlockSchurPreconditioner ( - const TrilinosWrappers::BlockSparseMatrix &S, + const TrilinosWrappers::BlockSparseMatrix &S, const InverseMatrix &Mpinv, - const PreconditionerA &Apreconditioner); + PreconditionerTypeMp> &Mpinv, + const PreconditionerTypeA &Apreconditioner); void vmult (TrilinosWrappers::MPI::BlockVector &dst, const TrilinosWrappers::MPI::BlockVector &src) const; @@ -428,20 +428,20 @@ namespace Step43 private: const SmartPointer darcy_matrix; const SmartPointer > m_inverse; - const PreconditionerA &a_preconditioner; + PreconditionerTypeMp > > m_inverse; + const PreconditionerTypeA &a_preconditioner; mutable TrilinosWrappers::MPI::Vector tmp; }; - template - BlockSchurPreconditioner:: - BlockSchurPreconditioner(const TrilinosWrappers::BlockSparseMatrix &S, + template + BlockSchurPreconditioner:: + BlockSchurPreconditioner(const TrilinosWrappers::BlockSparseMatrix &S, const InverseMatrix &Mpinv, - const PreconditionerA &Apreconditioner) + PreconditionerTypeMp> &Mpinv, + const PreconditionerTypeA &Apreconditioner) : darcy_matrix (&S), m_inverse (&Mpinv), @@ -450,8 +450,8 @@ namespace Step43 {} - template - void BlockSchurPreconditioner::vmult ( + template + void BlockSchurPreconditioner::vmult ( TrilinosWrappers::MPI::BlockVector &dst, const TrilinosWrappers::MPI::BlockVector &src) const { diff --git a/examples/step-45/step-45.cc b/examples/step-45/step-45.cc index fb8aae047a..abe241d45f 100644 --- a/examples/step-45/step-45.cc +++ b/examples/step-45/step-45.cc @@ -182,21 +182,21 @@ namespace Step45 - template + template class InverseMatrix : public Subscriptor { public: - InverseMatrix (const MatrixType &m, - const Preconditioner &preconditioner, - const IndexSet &locally_owned, - const MPI_Comm &mpi_communicator); + InverseMatrix (const MatrixType &m, + const PreconditionerType &preconditioner, + const IndexSet &locally_owned, + const MPI_Comm &mpi_communicator); void vmult (TrilinosWrappers::MPI::Vector &dst, const TrilinosWrappers::MPI::Vector &src) const; private: const SmartPointer matrix; - const SmartPointer preconditioner; + const SmartPointer preconditioner; const MPI_Comm *mpi_communicator; mutable TrilinosWrappers::MPI::Vector tmp; @@ -204,12 +204,12 @@ namespace Step45 - template - InverseMatrix::InverseMatrix - (const MatrixType &m, - const Preconditioner &preconditioner, - const IndexSet &locally_owned, - const MPI_Comm &mpi_communicator) + template + InverseMatrix::InverseMatrix + (const MatrixType &m, + const PreconditionerType &preconditioner, + const IndexSet &locally_owned, + const MPI_Comm &mpi_communicator) : matrix (&m), preconditioner (&preconditioner), @@ -219,8 +219,8 @@ namespace Step45 - template - void InverseMatrix::vmult + template + void InverseMatrix::vmult (TrilinosWrappers::MPI::Vector &dst, const TrilinosWrappers::MPI::Vector &src) const { @@ -235,15 +235,15 @@ namespace Step45 - template + template class SchurComplement : public TrilinosWrappers::SparseMatrix { public: - SchurComplement ( const TrilinosWrappers::BlockSparseMatrix &system_matrix, - const InverseMatrix &A_inverse, - const IndexSet &owned_pres, - const MPI_Comm &mpi_communicator); + SchurComplement (const TrilinosWrappers::BlockSparseMatrix &system_matrix, + const InverseMatrix &A_inverse, + const IndexSet &owned_pres, + const MPI_Comm &mpi_communicator); void vmult (TrilinosWrappers::MPI::Vector &dst, const TrilinosWrappers::MPI::Vector &src) const; @@ -251,19 +251,19 @@ namespace Step45 private: const SmartPointer system_matrix; const SmartPointer > A_inverse; + PreconditionerType> > A_inverse; mutable TrilinosWrappers::MPI::Vector tmp1, tmp2; }; - template - SchurComplement:: + template + SchurComplement:: SchurComplement (const TrilinosWrappers::BlockSparseMatrix &system_matrix, const InverseMatrix &A_inverse, - const IndexSet &owned_vel, - const MPI_Comm &mpi_communicator) + PreconditionerType> &A_inverse, + const IndexSet &owned_vel, + const MPI_Comm &mpi_communicator) : system_matrix (&system_matrix), A_inverse (&A_inverse), @@ -273,8 +273,8 @@ namespace Step45 - template - void SchurComplement::vmult + template + void SchurComplement::vmult (TrilinosWrappers::MPI::Vector &dst, const TrilinosWrappers::MPI::Vector &src) const {