From 932074d09d9bb230869f4b4246f1cd2933f7c433 Mon Sep 17 00:00:00 2001 From: eschnett Date: Tue, 19 Mar 2013 02:54:09 +0000 Subject: Use cctk_ash to index grid functions git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@313 6a38eb6e-646e-4a02-a296-d141613ad6c4 --- src/CopyBoundary.c | 9 +++++---- src/FlatBoundary.c | 10 ++++++---- src/RobinBoundary.c | 4 ++-- src/ScalarBoundary.c | 8 +++++--- src/StaticBoundary.c | 13 +++++++------ 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/CopyBoundary.c b/src/CopyBoundary.c index 171577c..0a46f02 100644 --- a/src/CopyBoundary.c +++ b/src/CopyBoundary.c @@ -959,7 +959,7 @@ void CCTK_FCALL CCTK_FNAME (BndCopyVN) #define MAXDIM 3 /* macro to compute the linear index of a 3D point */ -#define INDEX_3D(lsh, i, j, k) ((i) + (lsh)[0]*((j) + (lsh)[1]*(k))) +#define INDEX_3D(ash, i, j, k) ((i) + (ash)[0]*((j) + (ash)[1]*(k))) /*@@ @routine COPY_BOUNDARY @@ -1000,8 +1000,7 @@ void CCTK_FCALL CCTK_FNAME (BndCopyVN) { \ int _index; \ \ - \ - _index = INDEX_3D (lsh, ii, jj, kk) * vtypesize; \ + _index = INDEX_3D (ash, ii, jj, kk) * vtypesize; \ memcpy ((char *) GH->data[var_to][timelvl_to] + _index, \ (char *) GH->data[var_from][timelvl_from] + _index, \ vtypesize); \ @@ -1094,7 +1093,7 @@ static int ApplyBndCopy (const cGH *GH, int timelvl_to, timelvl_from; int gindex, gdim; int var_to, var_from, vtypesize; - int doBC[2*MAXDIM], lsh[MAXDIM]; + int doBC[2*MAXDIM], ash[MAXDIM], lsh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; CCTK_INT symtable; CCTK_INT symbnd[2*MAXDIM]; @@ -1147,6 +1146,7 @@ static int ApplyBndCopy (const cGH *GH, so that we can use the INDEX_3D macro later on */ for (i = gdim; i < MAXDIM; i++) { + ash[i] = 0; lsh[i] = 0; } @@ -1180,6 +1180,7 @@ static int ApplyBndCopy (const cGH *GH, } for (i = 0; i < gdim; i++) { + ash[i] = GH->cctk_ash[i]; lsh[i] = GH->cctk_lsh[i]; doBC[i*2] &= GH->cctk_lsh[i] > widths[i*2] && GH->cctk_bbox[i*2]; doBC[i*2+1] &= GH->cctk_lsh[i] > widths[i*2+1] && GH->cctk_bbox[i*2+1]; diff --git a/src/FlatBoundary.c b/src/FlatBoundary.c index 8d18023..7d09cf1 100644 --- a/src/FlatBoundary.c +++ b/src/FlatBoundary.c @@ -789,7 +789,7 @@ void CCTK_FCALL CCTK_FNAME (BndFlatVN) #define MAXDIM 3 /* macro to compute the linear index of a 3D point */ -#define INDEX_3D(lsh, i, j, k) ((i) + (lsh)[0]*((j) + (lsh)[1]*(k))) +#define INDEX_3D(ash, i, j, k) ((i) + (ash)[0]*((j) + (ash)[1]*(k))) /*@@ @routine FLAT_BOUNDARY @@ -836,8 +836,8 @@ void CCTK_FCALL CCTK_FNAME (BndFlatVN) { \ int _index_to, _index_from; \ \ - _index_to = INDEX_3D (lsh, ii_to, jj_to, kk_to) * vtypesize; \ - _index_from = INDEX_3D (lsh, ii_from, jj_from, kk_from) * vtypesize;\ + _index_to = INDEX_3D (ash, ii_to, jj_to, kk_to) * vtypesize; \ + _index_from = INDEX_3D (ash, ii_from, jj_from, kk_from) * vtypesize;\ memcpy ((char *) GH->data[var][timelvl] + _index_to, \ (char *) GH->data[var][timelvl] + _index_from, \ vtypesize); \ @@ -922,7 +922,7 @@ static int ApplyBndFlat (const cGH *GH, { int i, j, k; int var, vtypesize, gindex, gdim, timelvl; - int doBC[2*MAXDIM], lsh[MAXDIM]; + int doBC[2*MAXDIM], ash[MAXDIM], lsh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; CCTK_INT symtable; CCTK_INT symbnd[2*MAXDIM]; @@ -975,6 +975,7 @@ static int ApplyBndFlat (const cGH *GH, so that we can use the INDEX_3D macro later on */ for (i = gdim; i < MAXDIM; i++) { + ash[i] = 0; lsh[i] = 0; } @@ -1005,6 +1006,7 @@ static int ApplyBndFlat (const cGH *GH, } for (i = 0; i < gdim; i++) { + ash[i] = GH->cctk_ash[i]; lsh[i] = GH->cctk_lsh[i]; doBC[i*2] &= GH->cctk_lsh[i] > widths[i*2] && GH->cctk_bbox[i*2]; doBC[i*2+1] &= GH->cctk_lsh[i] > widths[i*2+1] && GH->cctk_bbox[i*2+1]; diff --git a/src/RobinBoundary.c b/src/RobinBoundary.c index 1e36aa2..46c08d5 100644 --- a/src/RobinBoundary.c +++ b/src/RobinBoundary.c @@ -588,8 +588,8 @@ void CCTK_FCALL CCTK_FNAME (BndRobinVN) #define SET_LINEAR_INDICES(i) \ { \ dst = CCTK_GFINDEX3D (GH, i, j, k); \ - src = CCTK_GFINDEX3D (GH, i+dx, j+dy, k+dz); \ - distance = dist[abs(dx) + 2*abs (dy) + 4*abs (dz)]; \ + src = CCTK_GFINDEX3D (GH, (i)+dx, j+dy, k+dz); \ + distance = dist[abs (dx) + 2*abs (dy) + 4*abs (dz)]; \ } diff --git a/src/ScalarBoundary.c b/src/ScalarBoundary.c index c943367..3fa9703 100644 --- a/src/ScalarBoundary.c +++ b/src/ScalarBoundary.c @@ -870,7 +870,7 @@ void CCTK_FCALL CCTK_FNAME (BndScalarVN) #define MAXDIM 3 /* macro to compute the linear index of a 3D point */ -#define INDEX_3D(lsh, i, j, k) ((i) + (lsh)[0]*((j) + (lsh)[1]*(k))) +#define INDEX_3D(ash, i, j, k) ((i) + (ash)[0]*((j) + (ash)[1]*(k))) /* an empty macro */ #define NOTHING @@ -922,7 +922,7 @@ void CCTK_FCALL CCTK_FNAME (BndScalarVN) int _index; \ \ \ - _index = INDEX_3D (lsh, ii, jj, kk); \ + _index = INDEX_3D (ash, ii, jj, kk); \ ((left_cctk_type *) GH->data[var][timelvl])[_index] = \ (right_cctk_type) scalar; \ } \ @@ -1062,7 +1062,7 @@ static int ApplyBndScalar (const cGH *GH, int i, j, k; int gindex, gdim; int var, timelvl; - int doBC[2*MAXDIM], lsh[MAXDIM]; + int doBC[2*MAXDIM], ash[MAXDIM], lsh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; CCTK_INT symtable; CCTK_INT symbnd[2*MAXDIM]; @@ -1111,6 +1111,7 @@ static int ApplyBndScalar (const cGH *GH, so that we can use the INDEX_3D macro later on */ for (i = gdim; i < MAXDIM; i++) { + ash[i] = 0; lsh[i] = 0; } @@ -1141,6 +1142,7 @@ static int ApplyBndScalar (const cGH *GH, } for (i = 0; i < gdim; i++) { + ash[i] = GH->cctk_ash[i]; lsh[i] = GH->cctk_lsh[i]; doBC[i*2] &= GH->cctk_lsh[i] > widths[i*2] && GH->cctk_bbox[i*2]; doBC[i*2+1] &= GH->cctk_lsh[i] > widths[i*2+1] && GH->cctk_bbox[i*2+1]; diff --git a/src/StaticBoundary.c b/src/StaticBoundary.c index 74372e5..e942531 100644 --- a/src/StaticBoundary.c +++ b/src/StaticBoundary.c @@ -804,7 +804,7 @@ void CCTK_FCALL CCTK_FNAME (BndStaticVN) #define MAXDIM 3 /* macro to compute the linear index of a 3D point */ -#define INDEX_3D(lsh, i, j, k) ((i) + (lsh)[0]*((j) + (lsh)[1]*(k))) +#define INDEX_3D(ash, i, j, k) ((i) + (ash)[0]*((j) + (ash)[1]*(k))) /*@@ @routine STATIC_BOUNDARY @@ -845,10 +845,9 @@ void CCTK_FCALL CCTK_FNAME (BndStaticVN) { \ int _index; \ \ - \ - _index = INDEX_3D (lsh, ii, jj, kk) * vtypesize; \ - memcpy ((char *) GH->data[var][timelvl_to] + _index, \ - (char *) GH->data[var][timelvl_from] + _index, \ + _index = INDEX_3D (ash, ii, jj, kk) * vtypesize; \ + memcpy ((char *) GH->data[var][timelvl_to] + _index, \ + (char *) GH->data[var][timelvl_from] + _index, \ vtypesize); \ } \ } \ @@ -935,7 +934,7 @@ static int ApplyBndStatic (const cGH *GH, int timelvl_to, timelvl_from; int gindex, gdim; int var, vtypesize; - int doBC[2*MAXDIM], lsh[MAXDIM]; + int doBC[2*MAXDIM], ash[MAXDIM], lsh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; CCTK_INT symtable; CCTK_INT symbnd[2*MAXDIM]; @@ -992,6 +991,7 @@ static int ApplyBndStatic (const cGH *GH, so that we can use the INDEX_3D macro later on */ for (i = gdim; i < MAXDIM; i++) { + ash[i] = 0; lsh[i] = 0; } @@ -1031,6 +1031,7 @@ static int ApplyBndStatic (const cGH *GH, } for (i = 0; i < gdim; i++) { + ash[i] = GH->cctk_ash[i]; lsh[i] = GH->cctk_lsh[i]; doBC[i*2] &= GH->cctk_lsh[i] > widths[i*2] && GH->cctk_bbox[i*2]; doBC[i*2+1] &= GH->cctk_lsh[i] > widths[i*2+1] && GH->cctk_bbox[i*2+1]; -- cgit v1.2.3