From 72d4266b8c78b24bfd047da311ffa262f23cd383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org> Date: Wed, 29 Oct 2014 20:06:35 +0100 Subject: [PATCH] [cleanup] Simplify addCriterion() methods Now there's only one addCriterion method taking a Criterion and one forwarding a variadic argument list to the Criterion constructor for convenince. The latter is just syntactic candy. --- dune/solvers/solvers/loopsolver.hh | 47 +++++++++--------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/dune/solvers/solvers/loopsolver.hh b/dune/solvers/solvers/loopsolver.hh index 7484bf09..d1b1800c 100644 --- a/dune/solvers/solvers/loopsolver.hh +++ b/dune/solvers/solvers/loopsolver.hh @@ -69,43 +69,24 @@ public: /** * \brief Add a convergence criterion * - * \param f The criterion functor - * \param header The header string - * - * This is a short cut for - * \code{.cpp} - * loopSolver.addCriterion(Criterion(f,header)); - * \endcode - * For the possible choices for return values of - * the functor refer to the documentation of Criterion. - */ - template<class F> - void addCriterion(F&& f, const std::string& header) - { - monitors_.push_back(Dune::Solvers::Criterion(std::forward<F>(f), header)); - } - - /** - * \brief Add a convergence monitor + * All criteria are checked after each loop. The solver loop will + * terminate once any of the supplied criteria evaluates to true. + * If you want to terminate only if several criteria are true + * you can combine criteria using the overloaded bitwise + * logical operations. * - * \param f The monitor functor - * \param format A printf format string used to print the result of f - * \param header The header string + * Besides checking the criterion the LoopSolver will + * print the diagnostic string returned by the criterion + * in a column with the criterions header string on top. * - * This is a short cut for - * \code{.cpp} - * loopSolver.addCriterion(Criterion(f,format,header)); - * \endcode - * This will add an always-false Criterion only for - * diagnostic. The result of the function will be - * formated according to the format string and - * printed in a column with the criterions header - * string on top. + * This is a convenience method that just forwards all + * arguments to the constructor of Dune::Solvers::Criterion. + * Refer to the documentation of the latter for details. */ - template<class F> - void addMonitor(F&& f, const std::string& format, const std::string& header) + template<class... Args> + void addCriterion(const Args&... args) { - monitors_.push_back(Criterion(std::forward<F>(f), format, header)); + monitors_.push_back(Dune::Solvers::Criterion(args...)); } /** -- GitLab