From 6181c149bb25230fb8a3511a406e6820fe603a47 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Tue, 17 Oct 2017 11:19:56 +0200 Subject: [PATCH] [params] Use getParam method for LinearSolver group --- dumux/common/parameters.hh | 5 ++++ dumux/linear/linearsolverproperties.hh | 7 +++++ dumux/linear/seqsolverbackend.hh | 40 ++++++++++++-------------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/dumux/common/parameters.hh b/dumux/common/parameters.hh index 34b996bb17..942b45c4f3 100644 --- a/dumux/common/parameters.hh +++ b/dumux/common/parameters.hh @@ -313,6 +313,11 @@ private: params["Implicit.UpwindWeight"] = "1.0"; // parameters in the linear solver group + params["LinearSolver.GMResRestart"] = "10"; + params["LinearSolver.MaxIterations"] = "250"; + params["LinearSolver.PreconditionerIterations"] = "1"; + params["LinearSolver.PreconditionerRelaxation"] = "1.0"; + params["LinearSolver.ResidualReduction"] = "1e-6"; params["LinearSolver.Verbosity"] = "0"; // parameters in the problem group diff --git a/dumux/linear/linearsolverproperties.hh b/dumux/linear/linearsolverproperties.hh index 59efb4c44b..6c094ed106 100644 --- a/dumux/linear/linearsolverproperties.hh +++ b/dumux/linear/linearsolverproperties.hh @@ -40,15 +40,19 @@ NEW_TYPE_TAG(LinearSolverTypeTag); NEW_PROP_TAG(LinearSolver); //! target reduction of the initial residual +// TODO: remove this once the sequential models don't use the tag anymore NEW_PROP_TAG(LinearSolverResidualReduction); //! maximum number of iterations of solver +// TODO: remove this once the sequential models don't use the tag anymore NEW_PROP_TAG(LinearSolverMaxIterations); //! relaxation parameter for the preconditioner +// TODO: remove this once the sequential models don't use the tag anymore NEW_PROP_TAG(LinearSolverPreconditionerRelaxation); //! number of preconditioner iterations per solver iteration +// TODO: remove this once the sequential models don't use the tag anymore NEW_PROP_TAG(LinearSolverPreconditionerIterations); //! Block level depth for the preconditioner @@ -69,15 +73,18 @@ NEW_PROP_TAG(LinearSolverGMResRestart); NEW_PROP_TAG(LinearSolverBlockSize); //! set the preconditioner relaxation parameter to 1.0 by default +// TODO: remove this once the sequential models don't use the tag anymore SET_SCALAR_PROP(LinearSolverTypeTag, LinearSolverPreconditionerRelaxation, 1.0); //! set the preconditioner iterations to 1 by default +// TODO: remove this once the sequential models don't use the tag anymore SET_INT_PROP(LinearSolverTypeTag, LinearSolverPreconditionerIterations, 1); //! set the block level to 1, suitable for e.g. a simple Dune::BCRSMatrix. SET_INT_PROP(LinearSolverTypeTag, LinearSolverPreconditionerBlockLevel, 1); //! set the GMRes restart parameter to 10 by default +// TODO: remove this once the sequential models don't use the tag anymore SET_INT_PROP(LinearSolverTypeTag, LinearSolverGMResRestart, 10); } // namespace Properties diff --git a/dumux/linear/seqsolverbackend.hh b/dumux/linear/seqsolverbackend.hh index 351b49ca1f..c5675ffc46 100644 --- a/dumux/linear/seqsolverbackend.hh +++ b/dumux/linear/seqsolverbackend.hh @@ -63,15 +63,14 @@ public: template<class Preconditioner, class Solver, class Matrix, class Vector> bool solve(const Matrix& A, Vector& x, const Vector& b) { - const int verbosity = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.Verbosity");; - const int maxIter = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, MaxIterations); - const double residReduction = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, ResidualReduction); + const int verbosity = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.Verbosity"); + const int maxIter = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.MaxIterations"); + const double residReduction = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.ResidualReduction"); + const double relaxation = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.PreconditionerRelaxation"); + const int precondIter = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolverPreconditionerIterations"); Vector bTmp(b); - const double relaxation = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, PreconditionerRelaxation); - const int precondIter = GET_PARAM_FROM_GROUP(TypeTag, int, LinearSolver, PreconditionerIterations); - Preconditioner precond(A, precondIter, relaxation); typedef Dune::MatrixAdapter<Matrix, Vector, Vector> MatrixAdapter; @@ -89,14 +88,13 @@ public: bool solve(const Matrix& A, Vector& x, const Vector& b, const int restartGMRes) { const int verbosity = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.Verbosity"); - const int maxIter = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, MaxIterations); - const double residReduction = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, ResidualReduction); + const int maxIter = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.MaxIterations"); + const double residReduction = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.ResidualReduction"); + const double relaxation = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.PreconditionerRelaxation"); + const int precondIter = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolverPreconditionerIterations"); Vector bTmp(b); - const double relaxation = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, PreconditionerRelaxation); - const int precondIter = GET_PARAM_FROM_GROUP(TypeTag, int, LinearSolver, PreconditionerIterations); - Preconditioner precond(A, precondIter, relaxation); typedef Dune::MatrixAdapter<Matrix, Vector, Vector> MatrixAdapter; @@ -557,7 +555,7 @@ public: { typedef Dune::SeqSSOR<Matrix, Vector, Vector, blockLevel> Preconditioner; typedef Dune::RestartedGMResSolver<Vector> Solver; - const int restart = GET_PARAM_FROM_GROUP(TypeTag, int, LinearSolver, GMResRestart); + const int restart = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.GMResRestart"); return ParentType::template solve<Preconditioner, Solver>(A, x, b, restart); } @@ -588,13 +586,12 @@ public: bool solve(const Matrix& A, Vector& x, const Vector& b) { const int verbosity = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.Verbosity"); - const int maxIter = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, MaxIterations); - const double residReduction = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, ResidualReduction); + const int maxIter = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.MaxIterations"); + const double residReduction = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.ResidualReduction"); + const double relaxation = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.PreconditionerRelaxation"); Vector bTmp(b); - const double relaxation = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, PreconditionerRelaxation); - Preconditioner precond(A, relaxation); typedef Dune::MatrixAdapter<Matrix, Vector, Vector> MatrixAdapter; @@ -612,13 +609,12 @@ public: bool solve(const Matrix& A, Vector& x, const Vector& b, const int restartGMRes) { const int verbosity = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.Verbosity"); - const int maxIter = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, MaxIterations); - const double residReduction = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, ResidualReduction); + const int maxIter = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.MaxIterations"); + const double residReduction = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.ResidualReduction"); + const double relaxation = getParamFromGroup<double>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.PreconditionerRelaxation"); Vector bTmp(b); - const double relaxation = GET_PARAM_FROM_GROUP(TypeTag, double, LinearSolver, PreconditionerRelaxation); - Preconditioner precond(A, relaxation); typedef Dune::MatrixAdapter<Matrix, Vector, Vector> MatrixAdapter; @@ -754,7 +750,7 @@ public: { typedef Dune::SeqILU0<Matrix, Vector, Vector, blockLevel> Preconditioner; typedef Dune::RestartedGMResSolver<Vector> Solver; - const int restart = GET_PARAM_FROM_GROUP(TypeTag, int, LinearSolver, GMResRestart); + const int restart = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.GMResRestart"); return ParentType::template solve<Preconditioner, Solver>(A, x, b, restart); } @@ -793,7 +789,7 @@ public: { typedef Dune::SeqILUn<Matrix, Vector, Vector, blockLevel> Preconditioner; typedef Dune::RestartedGMResSolver<Vector> Solver; - const int restart = GET_PARAM_FROM_GROUP(TypeTag, int, LinearSolver, GMResRestart); + const int restart = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "LinearSolver.GMResRestart"); return ParentType::template solve<Preconditioner, Solver>(A, x, b, restart); } -- GitLab