Skip to content
Snippets Groups Projects
Commit ba4a6f45 authored by Elias Pipping's avatar Elias Pipping
Browse files

[Cleanup] Construct EnergyNorm where it's needed

parent 840e63e3
Branches
No related tags found
No related merge requests found
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#include "config.h" #include "config.h"
#endif #endif
#include <dune/solvers/norms/energynorm.hh>
#include "coupledtimestepper.hh" #include "coupledtimestepper.hh"
#include "fixedpointiterator.hh" #include "fixedpointiterator.hh"
...@@ -40,13 +38,11 @@ int CoupledTimeStepper<Factory, StateUpdater, VelocityUpdater>::step( ...@@ -40,13 +38,11 @@ int CoupledTimeStepper<Factory, StateUpdater, VelocityUpdater>::step(
stateUpdater_->setup(tau); stateUpdater_->setup(tau);
velocityUpdater_->setup(ell, tau, newRelativeTime, velocityRHS, velocityUpdater_->setup(ell, tau, newRelativeTime, velocityRHS,
velocityIterate, velocityMatrix); velocityIterate, velocityMatrix);
EnergyNorm<Matrix, Vector> const velocityMatrixNorm(velocityMatrix);
FixedPointIterator<Factory, StateUpdater, VelocityUpdater> fixedPointIterator( FixedPointIterator<Factory, StateUpdater, VelocityUpdater> fixedPointIterator(
factory_, parset_, globalFriction_); factory_, parset_, globalFriction_);
auto const iterations = auto const iterations =
fixedPointIterator.run(stateUpdater_, velocityUpdater_, velocityMatrix, fixedPointIterator.run(stateUpdater_, velocityUpdater_, velocityMatrix,
velocityMatrixNorm, velocityRHS, velocityIterate); velocityRHS, velocityIterate);
return iterations; return iterations;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <dune/common/exceptions.hh> #include <dune/common/exceptions.hh>
#include <dune/solvers/common/arithmetic.hh> #include <dune/solvers/common/arithmetic.hh>
#include <dune/solvers/norms/energynorm.hh>
#include <dune/solvers/solvers/loopsolver.hh> #include <dune/solvers/solvers/loopsolver.hh>
#include "enums.hh" #include "enums.hh"
...@@ -30,14 +31,14 @@ template <class Factory, class StateUpdater, class VelocityUpdater> ...@@ -30,14 +31,14 @@ template <class Factory, class StateUpdater, class VelocityUpdater>
int FixedPointIterator<Factory, StateUpdater, VelocityUpdater>::run( int FixedPointIterator<Factory, StateUpdater, VelocityUpdater>::run(
std::shared_ptr<StateUpdater> stateUpdater, std::shared_ptr<StateUpdater> stateUpdater,
std::shared_ptr<VelocityUpdater> velocityUpdater, std::shared_ptr<VelocityUpdater> velocityUpdater,
Matrix const &velocityMatrix, Norm<Vector> const &velocityMatrixNorm, Matrix const &velocityMatrix, Vector const &velocityRHS,
Vector const &velocityRHS, Vector &velocityIterate) { Vector &velocityIterate) {
auto multigridStep = factory_.getSolver(); auto multigridStep = factory_.getSolver();
EnergyNorm<Matrix, Vector> energyNorm(velocityMatrix);
LoopSolver<Vector> velocityProblemSolver( LoopSolver<Vector> velocityProblemSolver(
multigridStep, velocityMaxIterations_, velocityTolerance_, multigridStep, velocityMaxIterations_, velocityTolerance_, &energyNorm,
&velocityMatrixNorm, verbosity_, false); // absolute error verbosity_, false); // absolute error
Vector previousVelocityIterate = velocityIterate; Vector previousVelocityIterate = velocityIterate;
size_t fixedPointIteration; size_t fixedPointIteration;
...@@ -62,7 +63,7 @@ int FixedPointIterator<Factory, StateUpdater, VelocityUpdater>::run( ...@@ -62,7 +63,7 @@ int FixedPointIterator<Factory, StateUpdater, VelocityUpdater>::run(
velocityProblemSolver.preprocess(); velocityProblemSolver.preprocess();
velocityProblemSolver.solve(); velocityProblemSolver.solve();
if (velocityMatrixNorm.diff(previousVelocityIterate, velocityIterate) < if (energyNorm.diff(previousVelocityIterate, velocityIterate) <
fixedPointTolerance_) { fixedPointTolerance_) {
fixedPointIteration++; fixedPointIteration++;
break; break;
......
...@@ -23,8 +23,8 @@ class FixedPointIterator { ...@@ -23,8 +23,8 @@ class FixedPointIterator {
int run(std::shared_ptr<StateUpdater> stateUpdater, int run(std::shared_ptr<StateUpdater> stateUpdater,
std::shared_ptr<VelocityUpdater> velocityUpdater, std::shared_ptr<VelocityUpdater> velocityUpdater,
Matrix const &velocityMatrix, Norm<Vector> const &velocityMatrixNorm, Matrix const &velocityMatrix, Vector const &velocityRHS,
Vector const &velocityRHS, Vector &velocityIterate); Vector &velocityIterate);
private: private:
Factory &factory_; Factory &factory_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment