diff --git a/src/coupledtimestepper.cc b/src/coupledtimestepper.cc index 1dd286ffc91e1a88f0c07675581b8e91bf15f2ac..6df0982860b548efafb9ed75cd116a3e56dbdeb2 100644 --- a/src/coupledtimestepper.cc +++ b/src/coupledtimestepper.cc @@ -3,7 +3,6 @@ #endif #include "coupledtimestepper.hh" -#include "fixedpointiterator.hh" template <class Factory, class StateUpdater, class VelocityUpdater, class ErrorNorm> @@ -26,7 +25,8 @@ CoupledTimeStepper<Factory, StateUpdater, VelocityUpdater, ErrorNorm>:: template <class Factory, class StateUpdater, class VelocityUpdater, class ErrorNorm> -int CoupledTimeStepper<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::step( +FixedPointIterationCounter +CoupledTimeStepper<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::step( double relativeTime, double relativeTau) { stateUpdater_->nextTimeStep(); velocityUpdater_->nextTimeStep(); diff --git a/src/coupledtimestepper.hh b/src/coupledtimestepper.hh index f8122e6227bb9235bf245bd0e3567e76d9d5f009..a039829932757ed6d7abcd91dc84fb309a459eb9 100644 --- a/src/coupledtimestepper.hh +++ b/src/coupledtimestepper.hh @@ -5,6 +5,7 @@ #include <memory> #include <dune/common/parametertree.hh> +#include "fixedpointiterator.hh" template <class Factory, class StateUpdater, class VelocityUpdater, class ErrorNorm> @@ -23,7 +24,7 @@ class CoupledTimeStepper { ErrorNorm const &errorNorm, std::function<void(double, Vector &)> externalForces); - int step(double relativeTime, double relativeTau); + FixedPointIterationCounter step(double relativeTime, double relativeTau); private: double finalTime_; diff --git a/src/fixedpointiterator.cc b/src/fixedpointiterator.cc index 23569d9fd12df0cdb030de4836f075250f3f49b9..8a73ba48e2a9e1fe7bcabe16ae70501f7e1b3dd4 100644 --- a/src/fixedpointiterator.cc +++ b/src/fixedpointiterator.cc @@ -32,7 +32,8 @@ FixedPointIterator<Factory, StateUpdater, VelocityUpdater, ErrorNorm>:: template <class Factory, class StateUpdater, class VelocityUpdater, class ErrorNorm> -int FixedPointIterator<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::run( +FixedPointIterationCounter +FixedPointIterator<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::run( std::shared_ptr<StateUpdater> stateUpdater, std::shared_ptr<VelocityUpdater> velocityUpdater, Matrix const &velocityMatrix, Vector const &velocityRHS, @@ -45,6 +46,7 @@ int FixedPointIterator<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::run( verbosity_, false); // absolute error size_t fixedPointIteration; + size_t multigridIterations = 0; ScalarVector alpha; stateUpdater->extractAlpha(alpha); for (fixedPointIteration = 0; fixedPointIteration < fixedPointMaxIterations_; @@ -58,6 +60,8 @@ int FixedPointIterator<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::run( velocityProblemSolver.preprocess(); velocityProblemSolver.solve(); + multigridIterations += velocityProblemSolver.getResult().iterations; + Vector v_m; velocityUpdater->extractOldVelocity(v_m); v_m *= 1.0 - lambda_; @@ -79,7 +83,13 @@ int FixedPointIterator<Factory, StateUpdater, VelocityUpdater, ErrorNorm>::run( velocityUpdater->postProcess(velocityIterate); - return fixedPointIteration; + return { fixedPointIteration, multigridIterations }; +} + +std::ostream &operator<<(std::ostream &stream, + FixedPointIterationCounter const &fpic) { + return stream << "(" << fpic.iterations << "," << fpic.multigridIterations + << ")"; } #include "fixedpointiterator_tmpl.cc" diff --git a/src/fixedpointiterator.hh b/src/fixedpointiterator.hh index 34a7d42fe9021f05a4d101ea8df557cf49c80da7..f7c8ccec5d1c286d7e4d8a00e2508da96cc07acf 100644 --- a/src/fixedpointiterator.hh +++ b/src/fixedpointiterator.hh @@ -8,6 +8,14 @@ #include <dune/solvers/norms/norm.hh> #include <dune/solvers/solvers/solver.hh> +struct FixedPointIterationCounter { + size_t iterations; + size_t multigridIterations; +}; + +std::ostream &operator<<(std::ostream &stream, + FixedPointIterationCounter const &fpic); + template <class Factory, class StateUpdater, class VelocityUpdater, class ErrorNorm> class FixedPointIterator { @@ -23,10 +31,11 @@ class FixedPointIterator { std::shared_ptr<Nonlinearity> globalFriction, ErrorNorm const &errorNorm_); - int run(std::shared_ptr<StateUpdater> stateUpdater, - std::shared_ptr<VelocityUpdater> velocityUpdater, - Matrix const &velocityMatrix, Vector const &velocityRHS, - Vector &velocityIterate); + FixedPointIterationCounter run( + std::shared_ptr<StateUpdater> stateUpdater, + std::shared_ptr<VelocityUpdater> velocityUpdater, + Matrix const &velocityMatrix, Vector const &velocityRHS, + Vector &velocityIterate); private: Factory &factory_;