ParallelMapper.h 1.39 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
#ifndef PARALLEL_MAPPER_H
#define PARALLEL_MAPPER_H

#include "parallel/MeshDistributor.h"
namespace AMDiS {
	//todo: request from a problem -> distributor mapper?
	template< typename size_type > 
	class ParallelMapper_base {
		MeshDistributor& md;
		/// the current row in the problem system
		size_type r;
		/// the current column in the problem system
		size_type c;
		int nComponents;

		public:

		ParallelMapper_base(MeshDistributor& md, int nComponents):
			md(md),r(0),c(0),nComponents(nComponents) 
		{
			TEST_EXIT_DBG(nComponents > 0)("the system must have at least one component");
		}
		size_type row(size_type r_) 
		{
Naumann, Andreas's avatar
Naumann, Andreas committed
25
26
			size_type ret = md.mapLocalToGlobal(r_)*nComponents+r;
			//size_type ret = md.mapLocalToGlobal(r_)+r*md.getNumberOverallDofs() ;
27
28
29
30
			return ret;
		}
		size_type col(size_type c_) 
		{
Naumann, Andreas's avatar
Naumann, Andreas committed
31
32
			size_type ret = md.mapLocalToGlobal(c_)*nComponents+c;
			//size_type ret = md.mapLocalToGlobal(c_)+c*md.getNumberOverallDofs() ;
33
34
35
			return ret ;
		}

Naumann, Andreas's avatar
Naumann, Andreas committed
36
37
38
		inline MeshDistributor& meshDistributor() { return md; }
		inline int getNumComponents() { return nComponents; }

39
40
		inline void setRow(size_type r_) { r = r_ ;}
		inline void setCol(size_type c_) { c = c_; }
Naumann, Andreas's avatar
Naumann, Andreas committed
41
42
		inline size_type getNumRows() { return md.getNumberOverallDofs() * nComponents; }
		inline size_type getNumCols() { return md.getNumberOverallDofs() * nComponents; }
43
44
45
46
47
	};

	typedef ParallelMapper_base< unsigned int > ParallelMapper;
}
#endif