| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @file solver.hpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 13:11:14 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief VMG::Solver
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #ifndef SOLVER_HPP_
|
|---|
| 11 | #define SOLVER_HPP_
|
|---|
| 12 |
|
|---|
| 13 | #include <vector>
|
|---|
| 14 |
|
|---|
| 15 | #include "base/discretization.hpp"
|
|---|
| 16 | #include "base/object.hpp"
|
|---|
| 17 | #include "base/stencil.hpp"
|
|---|
| 18 | #include "comm/comm.hpp"
|
|---|
| 19 | #include "grid/grid.hpp"
|
|---|
| 20 | #include "mg.hpp"
|
|---|
| 21 |
|
|---|
| 22 | namespace VMGTests
|
|---|
| 23 | {
|
|---|
| 24 | class SolverTestSuite;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | namespace VMG
|
|---|
| 28 | {
|
|---|
| 29 |
|
|---|
| 30 | class Solver : public Object
|
|---|
| 31 | {
|
|---|
| 32 | public:
|
|---|
| 33 | friend class VMGTests::SolverTestSuite;
|
|---|
| 34 |
|
|---|
| 35 | Solver()
|
|---|
| 36 | {
|
|---|
| 37 | size = 0;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | virtual ~Solver()
|
|---|
| 41 | {
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | void Run(Grid& sol, Grid& rhs);
|
|---|
| 45 |
|
|---|
| 46 | private:
|
|---|
| 47 |
|
|---|
| 48 | virtual void Compute() = 0; ///< Solves the system of equations
|
|---|
| 49 | virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors.
|
|---|
| 50 | virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh.
|
|---|
| 51 |
|
|---|
| 52 | std::vector<vmg_float> A, b, x;
|
|---|
| 53 | int size;
|
|---|
| 54 |
|
|---|
| 55 | protected:
|
|---|
| 56 | void Realloc(int n);
|
|---|
| 57 | void Realloc(Grid& x);
|
|---|
| 58 |
|
|---|
| 59 | vmg_float& Mat(int i, int j)
|
|---|
| 60 | {
|
|---|
| 61 | return A[j+size*i];
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | vmg_float& Rhs(int i)
|
|---|
| 65 | {
|
|---|
| 66 | return b[i];
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | vmg_float& Sol(int i)
|
|---|
| 70 | {
|
|---|
| 71 | return x[i];
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | const int& Size() const {return size;}
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.