From 7656351860db1965f22c2f2cb62be36da771e4ea Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Wed, 29 Jan 2020 17:04:07 +0100 Subject: [PATCH] [params] Move global defaults for linear solver to local defaults in the solver class --- CHANGELOG.md | 2 ++ dumux/linear/istlsolverfactorybackend.hh | 21 ++++++++++++++++++--- dumux/linear/solver.hh | 10 +++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a36b953e7..fc0be3f2c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Differences Between DuMuX 3.2 and DuMuX 3.1 - __Van Genuchten__: Corrected VanGenuchten-Mualem exponent in the non-wetting saturation formula (`1/3` instead of `1/2` (or `l`, see above)) - __Van Genuchten__: Corrected VanGenuchten-Mualem implementation of `dkrn/dSw` - __AMGBackend__: The internal structure of the AMGBackend and the ParallelISTLHelper has been overhauled, as only used by the AMG, we did not make the changes backwards-compatible +- The global default parameters for linear solvers have been removed and moved to the class `LinearSolver`. +This only affects users that directly obtain this parameter via `getParam` somewhere in the code. - __Change matrix block arrangement for staggered models__: The matrix block structure has been adapted such that it complies with the literature standard, i.e., having the velocity block (C) on `M[0][0]` rather than on `M[1][1]`. This also requires re-arranging the submodels and properties in dumux-multidomain such that the face-related classes and vector entries now appear before the cell-centered ones. diff --git a/dumux/linear/istlsolverfactorybackend.hh b/dumux/linear/istlsolverfactorybackend.hh index ec261f841a..3c5d9706d3 100644 --- a/dumux/linear/istlsolverfactorybackend.hh +++ b/dumux/linear/istlsolverfactorybackend.hh @@ -80,7 +80,9 @@ public: { if (Dune::MPIHelper::getCollectiveCommunication().size() > 1) DUNE_THROW(Dune::InvalidStateException, "Using sequential constructor for parallel run. Use signature with gridView and dofMapper!"); - convertParameterTree(paramGroup); + + resetDefaultParameters(); + convertParameterTree_(paramGroup); } /*! @@ -96,7 +98,8 @@ public: : phelper_(std::make_shared<ParallelISTLHelper<GridView, AMGTraits>>(gridView, dofMapper)) , firstCall_(true) { - convertParameterTree(paramGroup); + resetDefaultParameters(); + convertParameterTree_(paramGroup); } /*! @@ -146,9 +149,21 @@ public: firstCall_ = false; return result_.converged; } + + //! reset some defaults for the solver parameters + void resetDefaultParameters() + { + params_["restart"] = "10"; + params_["maxit"] = "250"; + params_["reduction"] = "1e-13"; + params_["verbose"] = "0"; + params_["preconditioner.iterations"] = "1"; + params_["preconditioner.relaxation"] = "1.0"; + } + private: - void convertParameterTree(const std::string& paramGroup="") + void convertParameterTree_(const std::string& paramGroup="") { const auto& loggingTree = Parameters::getTree(); auto matchingGroups = loggingTree.getSubGroups("LinearSolver", paramGroup); diff --git a/dumux/linear/solver.hh b/dumux/linear/solver.hh index 328e9604e2..822dee897c 100644 --- a/dumux/linear/solver.hh +++ b/dumux/linear/solver.hh @@ -52,11 +52,11 @@ public: LinearSolver(const std::string& paramGroup = "") : paramGroup_(paramGroup) { - verbosity_ = getParamFromGroup<int>(paramGroup, "LinearSolver.Verbosity"); - maxIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.MaxIterations"); - residReduction_ = getParamFromGroup<double>(paramGroup, "LinearSolver.ResidualReduction"); - relaxation_ = getParamFromGroup<double>(paramGroup, "LinearSolver.PreconditionerRelaxation"); - precondIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.PreconditionerIterations"); + verbosity_ = getParamFromGroup<int>(paramGroup, "LinearSolver.Verbosity", 0); + maxIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.MaxIterations", 250); + residReduction_ = getParamFromGroup<double>(paramGroup, "LinearSolver.ResidualReduction", 1e-13); + relaxation_ = getParamFromGroup<double>(paramGroup, "LinearSolver.PreconditionerRelaxation", 1); + precondIter_ = getParamFromGroup<int>(paramGroup, "LinearSolver.PreconditionerIterations", 1); } /*! -- GitLab