From 7aae1d25599b741711cf4f5d2ae0566156547723 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Tue, 18 Nov 2008 13:56:27 +0000 Subject: [PATCH] It is now possible to define the number of smoother sweeps in the AMG preconditioner setup. git-svn-id: https://svn.dealii.org/trunk@17627 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-32/step-32.cc | 10 ++++-- .../lac/include/lac/trilinos_precondition.h | 33 +++++++++++++++---- deal.II/lac/source/trilinos_precondition.cc | 7 +++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/deal.II/examples/step-32/step-32.cc b/deal.II/examples/step-32/step-32.cc index 61d9629c11..47dab02c45 100644 --- a/deal.II/examples/step-32/step-32.cc +++ b/deal.II/examples/step-32/step-32.cc @@ -801,7 +801,7 @@ BoussinesqFlowProblem::build_stokes_preconditioner () Amg_preconditioner->initialize(stokes_preconditioner_matrix.block(0,0), TrilinosWrappers::PreconditionAMG::AdditionalData - (true, true, 5e-2, null_space, 0, false)); + (true, true, 5e-2, null_space, 3, 0, false)); Mp_preconditioner = boost::shared_ptr (new TrilinosWrappers::PreconditionIC()); @@ -1258,8 +1258,12 @@ void BoussinesqFlowProblem::solve () 1e-8*temperature_rhs.l2_norm()); SolverCG cg (solver_control); - TrilinosWrappers::PreconditionSSOR preconditioner; - preconditioner.initialize (temperature_matrix, 1.2); + TrilinosWrappers::PreconditionChebyshev preconditioner; + TrilinosWrappers::PreconditionChebyshev::AdditionalData data; + data.degree=3; + data.eigenvalue_ratio = 3; + data.max_eigenvalue = 2; + preconditioner.initialize (temperature_matrix, 3); cg.solve (temperature_matrix, temperature_solution, temperature_rhs, preconditioner); diff --git a/deal.II/lac/include/lac/trilinos_precondition.h b/deal.II/lac/include/lac/trilinos_precondition.h index db81826c6a..04101161ad 100755 --- a/deal.II/lac/include/lac/trilinos_precondition.h +++ b/deal.II/lac/include/lac/trilinos_precondition.h @@ -1088,13 +1088,14 @@ namespace TrilinosWrappers * fact that some of the entries in the preconditioner matrix are zero * and hence can be neglected. * - * The implementation is able to distinguish between matrices from - * elliptic problems and convection dominated problems. We use the - * standard options provided by Trilinos ML for elliptic problems, - * except that we use a Chebyshev smoother instead of a symmetric - * Gauss-Seidel smoother. For most elliptic problems, Chebyshev - * provides a better damping of high frequencies (in the algebraic - * sense) than Gauss-Seidel (SSOR). + * The implementation is able to distinguish between matrices from elliptic + * problems and convection dominated problems. We use the standard options + * provided by Trilinos ML for elliptic problems, except that we use a + * Chebyshev smoother instead of a symmetric Gauss-Seidel smoother. For + * most elliptic problems, Chebyshev provides a better damping of high + * frequencies (in the algebraic sense) than Gauss-Seidel (SSOR), and is + * faster (Chebyshev requires only some matrix-vector products, whereas SSOR + * requires substitutions which are more expensive). * * @ingroup TrilinosWrappers * @ingroup Preconditioners @@ -1117,6 +1118,7 @@ namespace TrilinosWrappers const bool higher_order_elements = false, const double aggregation_threshold = 1e-4, const std::vector > &constant_modes = std::vector > (1), + const unsigned int smoother_sweeps = 3, const unsigned int smoother_overlap = 0, const bool output_details = false); @@ -1176,6 +1178,23 @@ namespace TrilinosWrappers */ std::vector > constant_modes; + /** + * Determines how many sweeps of the + * smoother should be performed. When + * the flag elliptic is set + * to true, i.e., for + * elliptic or almost elliptic + * problems, the polynomial degree of + * the Chebyshev smoother is set to + * smoother_sweeps. In the + * non-elliptic case, + * smoother_sweeps sets the + * number of SSOR relaxation sweeps + * for post-smoothing to be + * performed. + */ + unsigned int smoother_sweeps; + /** * Determines the overlap in * the SSOR/Chebyshev error diff --git a/deal.II/lac/source/trilinos_precondition.cc b/deal.II/lac/source/trilinos_precondition.cc index 6c4a54a4d1..ffc68d79b2 100755 --- a/deal.II/lac/source/trilinos_precondition.cc +++ b/deal.II/lac/source/trilinos_precondition.cc @@ -480,6 +480,7 @@ namespace TrilinosWrappers const bool higher_order_elements, const double aggregation_threshold, const std::vector > &constant_modes, + const unsigned int smoother_sweeps, const unsigned int smoother_overlap, const bool output_details) : @@ -487,6 +488,7 @@ namespace TrilinosWrappers higher_order_elements (higher_order_elements), aggregation_threshold (aggregation_threshold), constant_modes (constant_modes), + smoother_sweeps (smoother_sweeps), smoother_overlap (smoother_overlap), output_details (output_details) {} @@ -511,13 +513,16 @@ namespace TrilinosWrappers { ML_Epetra::SetDefaults("SA",parameter_list); parameter_list.set("smoother: type", "Chebyshev"); - parameter_list.set("smoother: sweeps", 4); + parameter_list.set("smoother: sweeps", + (int)additional_data.smoother_sweeps); } else { ML_Epetra::SetDefaults("NSSA",parameter_list); parameter_list.set("aggregation: type", "Uncoupled"); parameter_list.set("aggregation: block scaling", true); + parameter_list.set("smoother: sweeps", + (int)additional_data.smoother_sweeps); } parameter_list.set("smoother: ifpack overlap", -- 2.39.5