DirectRunner.hpp 1.52 KB
 Praetorius, Simon committed Sep 23, 2018 1 2 3 4 5 6 #pragma once #include #include #include  Praetorius, Simon committed Feb 28, 2019 7 8 #include #include  Praetorius, Simon committed Sep 23, 2018 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  namespace AMDiS { /** * \ingroup Solver * \class AMDiS::DirectRunner * \brief \implements RunnerInterface for the (external) direct solvers */ template class DirectRunner : public RunnerInterface { protected: using Super = RunnerInterface; using BaseSolver = Dune::InverseOperator; public: /// Constructor.  Praetorius, Simon committed Oct 23, 2018 27  DirectRunner(std::string const& prefix)  Praetorius, Simon committed Sep 23, 2018 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63  : solverCreator_(prefix) {} /// Implementes \ref RunnerInterface::init() virtual void init(Matrix const& A) override { solver_ = solverCreator_.create(A); } /// Implementes \ref RunnerInterface::exit() virtual void exit() override { solver_.reset(); } /// Implementes \ref RunnerInterface::solve() virtual int solve(Matrix const& A, VectorX& x, VectorB const& b, SolverInfo& solverInfo) override { // storing some statistics Dune::InverseOperatorResult statistics; // solve the linear system VectorB _b = b; solver_->apply(x, _b, statistics); solverInfo.setRelResidual(statistics.reduction); return 0; } private: ISTLSolverCreator solverCreator_; std::shared_ptr solver_; }; }