aboutsummaryrefslogtreecommitdiff
path: root/ports/hypre/fix-macro-to-template.patch
blob: 22994f96a8e28347534ee533c337208be4a7d36b (plain)
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
--- a/struct_ls/pfmg3_setup_rap.c	Thu Jun 09 15:56:18 2016
+++ b/struct_ls/pfmg3_setup_rap.c	Thu Dec 22 17:45:20 2016
@@ -19,13 +19,28 @@
  * allow for coarsening to be done in the x- and y-directions also.
  *--------------------------------------------------------------------------*/
 
-#define MapIndex(in_index, cdir, out_index)                     \
-   hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 2);   \
-   cdir = (cdir + 1) % 3;                                       \
-   hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 0);   \
-   cdir = (cdir + 1) % 3;                                       \
-   hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 1);   \
-   cdir = (cdir + 1) % 3;
+//#define MapIndex(in_index, cdir, out_index)                     \
+//   hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 2);   \
+//   cdir = (cdir + 1) % 3;                                       \
+//   hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 0);   \
+//   cdir = (cdir + 1) % 3;                                       \
+//   hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 1);   \
+//   cdir = (cdir + 1) % 3;
+
+template<typename T, typename U, typename V>
+void MapIndex(T& in_index, U& cdir, V& out_index)
+{
+	if(cdir > 3) cdir = cdir - (cdir / 3) * 3;
+	hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 2);
+	if(cdir == 3) cdir = 1;
+	else ++cdir;
+	hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 0);
+	if(cdir == 3) cdir = 1;
+	else ++cdir;
+	hypre_IndexD(out_index, cdir) = hypre_IndexD(in_index, 1);
+	if(cdir == 3) cdir = 1;
+	else ++cdir;
+}
  
 /*--------------------------------------------------------------------------
  *  Sets up new coarse grid operator stucture.