source: src/solver/solver.hpp@ 66f24d

Last change on this file since 66f24d was 48b662, checked in by Olaf Lenz <olenz@…>, 14 years ago

Moved files in scafacos_fcs one level up.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@847 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.7 KB
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 "base/discretization.hpp"
14#include "base/object.hpp"
15#include "base/stencil.hpp"
16#include "comm/comm.hpp"
17#include "grid/grid.hpp"
18#include "mg.hpp"
19
20namespace VMGTests
21{
22class SolverTestSuite;
23}
24
25namespace VMG
26{
27
28class Solver : public Object
29{
30public:
31 friend class VMGTests::SolverTestSuite;
32
33 Solver()
34 {
35 max_size = 0;
36 vec_size = 0;
37 b = NULL;
38 x = NULL;
39 A = NULL;
40 }
41
42 virtual ~Solver()
43 {
44 delete [] b;
45 delete [] x;
46 for (int i=0; i<max_size; i++)
47 delete [] A[i];
48 delete [] A;
49 }
50
51 void Run(Grid& sol, Grid& rhs)
52 {
53#ifdef DEBUG
54 sol.IsConsistent();
55 rhs.IsConsistent();
56 sol.IsCompatible(rhs);
57#endif
58
59 Grid *rhsGlobal = MG::GetComm()->CommMergeGrids(rhs);
60
61 this->Realloc(*rhsGlobal);
62 this->AssembleMatrix(*rhsGlobal);
63 this->Compute();
64 this->ExportSol(sol, rhs);
65 }
66
67private:
68
69 virtual void Compute() = 0; ///< Solves the system of equations
70 virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors.
71 virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh.
72
73 vmg_float **A, *b, *x;
74 int max_size, vec_size;
75
76protected:
77 void Realloc(int n);
78 void Realloc(Grid& x);
79
80 vmg_float& Mat(int i, int j)
81 {
82 return A[i][j];
83 }
84
85 vmg_float& Rhs(int i)
86 {
87 return b[i];
88 }
89
90 vmg_float& Sol(int i)
91 {
92 return x[i];
93 }
94
95 const int& Size() const {return vec_size;}
96 const int& MemSize() const {return max_size;}
97};
98
99}
100
101#endif
Note: See TracBrowser for help on using the repository browser.