diff --git a/dumux/common/parameters.hh b/dumux/common/parameters.hh index 34b996bb171fdf202fa4d8d4b73a0cba853fc2ff..942b45c4f3e9aea1664a7fce72e508570749c8aa 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 59efb4c44b5ee6ec565e6173b82c8168c020590f..6c094ed106da34831455b8a0025368d05c882355 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 351b49ca1f540dde6ab2f3e557f52107a2ff1d62..c5675ffc46156e6651eb50ea1da7c363a0a47eb1 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); }