/** * @file solver.hpp * @author Julian Iseringhausen * @date Mon Apr 18 13:11:14 2011 * * @brief VMG::Solver * */ #ifndef SOLVER_HPP_ #define SOLVER_HPP_ #include #include "base/discretization.hpp" #include "base/object.hpp" #include "base/stencil.hpp" #include "comm/comm.hpp" #include "grid/grid.hpp" #include "mg.hpp" namespace VMG { class Solver : public Object { public: Solver() { size = 0; } Solver(int size) : size(size) { this->Realloc(size); } virtual ~Solver() { } void Run(Grid& sol, Grid& rhs); void Realloc(int n); void Realloc(Grid& x); vmg_float& Mat(int i, int j) { return A[j+size*i]; } vmg_float& Rhs(int i) { return b[i]; } vmg_float& Sol(int i) { return x[i]; } const int& Size() const {return size;} protected: virtual void Compute() = 0; ///< Solves the system of equations private: virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors. virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh. std::vector A, b, x; int size; }; } #endif