DirectRunner.hpp 1.48 KB
 Praetorius, Simon committed Oct 03, 2018 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #pragma once #include #include #include #include #include namespace AMDiS { /** * \ingroup Solver * \class AMDiS::DirectRunner * \brief \implements RunnerInterface for the (external) direct solvers */ template class DirectRunner : public RunnerInterface { protected: using Super = RunnerInterface; public: /// Constructor. DirectRunner(std::string prefix) : solver_{} { SolverConfig::init(prefix, solver_); } /// Implementes \ref RunnerInterface::init() virtual void init(Matrix const& A) override { solver_.compute(A);  Praetorius, Simon committed Oct 05, 2018 36 37 38  test_exit(solver_.info() == Eigen::Success, "Error in solver.compute(matrix)");  Praetorius, Simon committed Oct 03, 2018 39 40  }  Praetorius, Simon committed Oct 05, 2018 41   Praetorius, Simon committed Oct 03, 2018 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64  /// Implementes \ref RunnerInterface::exit() virtual void exit() override {} /// Implementes \ref RunnerInterface::solve() virtual int solve(Matrix const& A, VectorX& x, VectorB const& b, SolverInfo& solverInfo) override { x = solver_.solve(b); auto r = VectorB(b); if (x.norm() != 0) r -= A * x; solverInfo.setAbsResidual(r.norm()); solverInfo.setError(solver_.info()); return solver_.info() == Eigen::Success ? 0 : 1; } private: LU solver_; }; }