From bf39a0d6a199ddb258263132f9045a46a318d8f0 Mon Sep 17 00:00:00 2001 From: Laura Prieto Saavedra <40216050+lpsaavedra@users.noreply.github.com> Date: Tue, 27 Aug 2024 09:27:23 -0600 Subject: [PATCH] Specify GMRES parameters whent iterating intermediate GMG levels (#1264) Description In PR #1211 a new parameter was introduced that allow to iterate intermediate GMG levels. This allows to choose a level as coarse grid and used there a GMRES iterative solver preconditioned by a MG. So far, only one parameter was present: mg int level, however, the parameters for the number of iterations and tolerances were being hardcoded. This PR changes that by using already existing GMRES parameters.. Testing I have tested this in the flow around a sphere case and seems to work just fine. Documentation The documentation was updated by adding a note that specifies the use of these parameters for this purpose as well. --- .../parameters/cfd/linear_solver_control.rst | 2 +- source/solvers/fluid_dynamics_matrix_free.cc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/source/parameters/cfd/linear_solver_control.rst b/doc/source/parameters/cfd/linear_solver_control.rst index 16b915cdba..5d72c1dbe1 100644 --- a/doc/source/parameters/cfd/linear_solver_control.rst +++ b/doc/source/parameters/cfd/linear_solver_control.rst @@ -264,7 +264,7 @@ Different parameters for the main components of the two geometric multigrid algo Evaluating terms involving the hessian is expensive. Therefore, one can turn on or off those terms in the mg level operators to improve performance by setting ``mg enable hessians in jacobian`` to ``false``. This is useful for certain problems and must be used carefully. .. tip:: - The ``mg int level`` option only works for ``gcmg`` preconditioner. It allows to choose an intermediate level as coarse grid solver and to perform several multigrid v-cycles there. + The ``mg int level`` option only works for the ``gcmg`` preconditioner. It allows to choose an intermediate level as coarse grid solver where a GMRES preconditioned by several multigrid v-cycles is used. The following parameters: ``set mg gmres max iterations``, ``set mg gmres tolerance`` and ``set mg gmres reduce`` can be used to set the desired number of maximum iterations, the absolute tolerance and the relative tolerance. In addition, Lethe supports `p-multigrid` through the ``gcmg`` preconditioner. It can be used by specifying two additional parameters: diff --git a/source/solvers/fluid_dynamics_matrix_free.cc b/source/solvers/fluid_dynamics_matrix_free.cc index 29e0cefc25..e1fe2036cb 100644 --- a/source/solvers/fluid_dynamics_matrix_free.cc +++ b/source/solvers/fluid_dynamics_matrix_free.cc @@ -1647,9 +1647,19 @@ MFNavierStokesPreconditionGMG::initialize( std::make_shared>( this->dof_handler, *this->mg_intermediate, *this->mg_transfer_gc); - // TODO: introduce parameters + const int max_iterations = this->simulation_parameters.linear_solver + .at(PhysicsID::fluid_dynamics) + .mg_gmres_max_iterations; + const double tolerance = this->simulation_parameters.linear_solver + .at(PhysicsID::fluid_dynamics) + .mg_gmres_tolerance; + const double reduce = this->simulation_parameters.linear_solver + .at(PhysicsID::fluid_dynamics) + .mg_gmres_reduce; + this->coarse_grid_solver_control_intermediate = - std::make_shared(1000, 1e-20, 1e-2, false, false); + std::make_shared( + max_iterations, tolerance, reduce, false, false); this->coarse_grid_solver_intermediate = std::make_shared>(