MTL4Solver.h 2.64 KB
Newer Older
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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==                                                                        ==
// ==  Institut für Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

#ifndef MTL4SOLVER_H
#define MTL4SOLVER_H

#include "OEMSolver.h"
#include "MatrixStreams.h"
#include <iostream>

namespace AMDiS {
  template< typename MTLMatrix, typename MTLVector, typename Worker >
  class MTL4Solver : public OEMSolver {

    protected:

      Worker worker;

      template< typename Matrix, typename Vector, typename Mapper >
      int solve(const Matrix& A, Vector& x, Vector& b, Mapper& mapper) 
      {
	 MTLMatrix matrix(mapper.nRow(), mapper.nCol());
	 set_to_zero(matrix);
	 MatMap< const Matrix, Mapper > matMap(A,mapper);
	 matrix << matMap;

         MTLVector mtl_x(mapper.nRow());
	 set_to_zero(mtl_x);
	 VecMap< Vector, Mapper > xVecMap(x, mapper);
	 mtl_x << xVecMap;

	 MTLVector mtl_b(mapper.nRow());
	 set_to_zero(mtl_b);
	 VecMap< Vector, Mapper> bVecMap(b, mapper);
	 mtl_b << bVecMap;

	 error = worker.solve(matrix, mtl_x, mtl_b);

	 mtl_x >> xVecMap;
	 return error;
      }

    public:
      MTL4Solver(std::string n):
	OEMSolver(n),
        worker(this)
      {
	FUNCNAME("MTL4Solver()");

      }

      virtual int solveSystem(const SolverMatrix<Matrix<DOFMatrix*> >& A,
			    SystemVector& x, 
			    SystemVector& b,
			    VectorialMapper& m)
      {
	return solve(A,x,b,m);
      }

      
  };
}
#endif