Skip to content
Snippets Groups Projects
Commit 72d4266b authored by Carsten Gräser's avatar Carsten Gräser
Browse files

[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.
parent 4242e71f
Branches
No related tags found
1 merge request!4Feature/flexible loopsolver monitoring
...@@ -69,43 +69,24 @@ public: ...@@ -69,43 +69,24 @@ public:
/** /**
* \brief Add a convergence criterion * \brief Add a convergence criterion
* *
* \param f The criterion functor * All criteria are checked after each loop. The solver loop will
* \param header The header string * terminate once any of the supplied criteria evaluates to true.
* * If you want to terminate only if several criteria are true
* This is a short cut for * you can combine criteria using the overloaded bitwise
* \code{.cpp} * logical operations.
* 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
* *
* \param f The monitor functor * Besides checking the criterion the LoopSolver will
* \param format A printf format string used to print the result of f * print the diagnostic string returned by the criterion
* \param header The header string * in a column with the criterions header string on top.
* *
* This is a short cut for * This is a convenience method that just forwards all
* \code{.cpp} * arguments to the constructor of Dune::Solvers::Criterion.
* loopSolver.addCriterion(Criterion(f,format,header)); * Refer to the documentation of the latter for details.
* \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.
*/ */
template<class F> template<class... Args>
void addMonitor(F&& f, const std::string& format, const std::string& header) void addCriterion(const Args&... args)
{ {
monitors_.push_back(Criterion(std::forward<F>(f), format, header)); monitors_.push_back(Dune::Solvers::Criterion(args...));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment