summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2010-11-24 02:58:40 +0000
committereschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2010-11-24 02:58:40 +0000
commit232b81cc03dbdb548dffcf1f9b6e92659e2bd441 (patch)
tree30c700b12479072997f314e5625df78f964e82d7 /src
parentde4f1951d4d50293271482585e8fcc1cf273b72c (diff)
Add CCTK_VECTGFINDEX3D and friends
Add functions CCTK_VectGF1D, CCTK_VectGF2D etc. and the corresponding macros CCTK_VECTGFINDEX1D etc. that allow indexing into vector grid variables. Vector grid variables require an additional index, namely the vector index; these functions simplify using them. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4654 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r--src/include/cctk.h68
-rw-r--r--src/include/cctk_DebugDefines.h5
-rw-r--r--src/main/DebugDefines.c21
3 files changed, 86 insertions, 8 deletions
diff --git a/src/include/cctk.h b/src/include/cctk.h
index d4fed70e..75da0d53 100644
--- a/src/include/cctk.h
+++ b/src/include/cctk.h
@@ -202,7 +202,36 @@ static inline int CCTK_GFINDEX3D (const cGH *GH, int i, int j, int k)
static inline int CCTK_GFINDEX4D (const cGH *GH, int i, int j, int k, int l);
static inline int CCTK_GFINDEX4D (const cGH *GH, int i, int j, int k, int l)
{
- return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2] * l)));
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*l)));
+}
+
+static inline int CCTK_VECTGFINDEX1D (const cGH *GH, int i, int n);
+static inline int CCTK_VECTGFINDEX1D (const cGH *GH, int i, int n)
+{
+ return (i + GH->cctk_lsh[0]*n);
+}
+
+static inline int CCTK_VECTGFINDEX2D (const cGH *GH, int i, int j, int n);
+static inline int CCTK_VECTGFINDEX2D (const cGH *GH, int i, int j, int n)
+{
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*n));
+}
+
+static inline int CCTK_VECTGFINDEX3D (const cGH *GH,
+ int i, int j, int k, int n);
+static inline int CCTK_VECTGFINDEX3D (const cGH *GH,
+ int i, int j, int k, int n)
+{
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*n)));
+}
+
+static inline int CCTK_VECTGFINDEX4D (const cGH *GH,
+ int i, int j, int k, int l, int n);
+static inline int CCTK_VECTGFINDEX4D (const cGH *GH,
+ int i, int j, int k, int l, int n)
+{
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*
+ (l + GH->cctk_lsh[3]*n))));
}
#else /* ! defined(__cplusplus) && defined(inline) */
@@ -214,17 +243,40 @@ static inline int CCTK_GFINDEX4D (const cGH *GH, int i, int j, int k, int l)
#define CCTK_GFINDEX2D CCTK_GFIndex2D
#define CCTK_GFINDEX3D CCTK_GFIndex3D
#define CCTK_GFINDEX4D CCTK_GFIndex4D
+#define CCTK_VECTGFINDEX1D CCTK_VectGFIndex1D
+#define CCTK_VECTGFINDEX2D CCTK_VectGFIndex2D
+#define CCTK_VECTGFINDEX3D CCTK_VectGFIndex3D
+#define CCTK_VECTGFINDEX4D CCTK_VectGFIndex4D
#else /* ! defined(CCTK_DEBUG) */
/* The "inline" keyword is not supported, and we want to optimise */
-#define CCTK_GFINDEX1D(GH, i) (i)
-#define CCTK_GFINDEX2D(GH, i, j) ((i) + (GH)->cctk_lsh[0] * (j))
-#define CCTK_GFINDEX3D(GH, i, j, k) ((i) + (GH)->cctk_lsh[0] * \
- ((j) + (GH)->cctk_lsh[1] * (k)))
-#define CCTK_GFINDEX4D(GH, i, j, k, l) ((i) + (GH)->cctk_lsh[0] * \
- ((j) + (GH)->cctk_lsh[1] * \
- ((k) + (GH)->cctk_lsh[2] * (l))))
+#define CCTK_GFINDEX1D(GH, i) \
+ (i)
+#define CCTK_GFINDEX2D(GH, i, j) \
+ ((i) + (GH)->cctk_lsh[0] * (j))
+#define CCTK_GFINDEX3D(GH, i, j, k) \
+ ((i) + (GH)->cctk_lsh[0] * \
+ ((j) + (GH)->cctk_lsh[1] * (k)))
+#define CCTK_GFINDEX4D(GH, i, j, k, l) \
+ ((i) + (GH)->cctk_lsh[0] * \
+ ((j) + (GH)->cctk_lsh[1] * \
+ ((k) + (GH)->cctk_lsh[2] * (l))))
+
+#define CCTK_VECTGFINDEX1D(GH, i, n) \
+ ((i) + (GH)->cctk_lsh[0] * (n))
+#define CCTK_VECTGFINDEX2D(GH, i, j, n) \
+ ((i) + (GH)->cctk_lsh[0] * \
+ ((j) + (GH)->cctk_lsh[1] * (n)))
+#define CCTK_VECTGFINDEX3D(GH, i, j, k, n) \
+ ((i) + (GH)->cctk_lsh[0] * \
+ ((j) + (GH)->cctk_lsh[1] * \
+ ((k) + (GH)->cctk_lsh[2] * (n))))
+#define CCTK_VECTGFINDEX4D(GH, i, j, k, l, n) \
+ ((i) + (GH)->cctk_lsh[0] * \
+ ((j) + (GH)->cctk_lsh[1] * \
+ ((k) + (GH)->cctk_lsh[2] * \
+ ((l) + (GH)->cctk_lsh[3] * (n)))))
#endif /* ! defined(CCTK_DEBUG) */
diff --git a/src/include/cctk_DebugDefines.h b/src/include/cctk_DebugDefines.h
index b4b8c445..84926536 100644
--- a/src/include/cctk_DebugDefines.h
+++ b/src/include/cctk_DebugDefines.h
@@ -16,3 +16,8 @@ int CCTK_GFIndex1D (const cGH *GH, int i);
int CCTK_GFIndex2D (const cGH *GH, int i, int j);
int CCTK_GFIndex3D (const cGH *GH, int i, int j, int k);
int CCTK_GFIndex4D (const cGH *GH, int i, int j, int k, int l);
+
+int CCTK_VectGFIndex1D (const cGH *GH, int i, int n);
+int CCTK_VectGFIndex2D (const cGH *GH, int i, int j, int n);
+int CCTK_VectGFIndex3D (const cGH *GH, int i, int j, int k, int n);
+int CCTK_VectGFIndex4D (const cGH *GH, int i, int j, int k, int l, int n);
diff --git a/src/main/DebugDefines.c b/src/main/DebugDefines.c
index 43383489..76f70b2f 100644
--- a/src/main/DebugDefines.c
+++ b/src/main/DebugDefines.c
@@ -66,3 +66,24 @@ int CCTK_GFIndex4D (const cGH *GH, int i, int j, int k, int l)
{
return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2] * l)));
}
+
+int CCTK_VectGFIndex1D (const cGH *GH, int i, int n)
+{
+ return (i + GH->cctk_lsh[0]*n);
+}
+
+int CCTK_VectGFIndex2D (const cGH *GH, int i, int j, int n)
+{
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*n));
+}
+
+int CCTK_VectGFIndex3D (const cGH *GH, int i, int j, int k, int n)
+{
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*n)));
+}
+
+int CCTK_VectGFIndex4D (const cGH *GH, int i, int j, int k, int l, int n)
+{
+ return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*
+ (l + GH->cctk_lsh[3]*n))));
+}