diff options
author | schnetter <schnetter@082bdb00-0f4f-0410-b49e-b1835e5f2039> | 2008-02-20 16:37:27 +0000 |
---|---|---|
committer | schnetter <schnetter@082bdb00-0f4f-0410-b49e-b1835e5f2039> | 2008-02-20 16:37:27 +0000 |
commit | 446827de87f13a982c4f3503be2d7ac4b3fb9568 (patch) | |
tree | 1baae67da0a0602c37b5be8790cd60f621009072 | |
parent | 2318af6e27cfe6298c73601e4b6da6d5ea62d218 (diff) |
Add more error checking.
Handle staggered upper boundaries (a very rare case) correctly.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/ReflectionSymmetry/trunk@22 082bdb00-0f4f-0410-b49e-b1835e5f2039
-rw-r--r-- | src/apply.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/apply.c b/src/apply.c index 918957e..d5223da 100644 --- a/src/apply.c +++ b/src/apply.c @@ -29,31 +29,34 @@ CCTK_FILEVERSION(AEIDevelopment_ReflectionSymmetry_apply_c); int const idir, int const jdir, int const kdir, \ int const parity) \ { \ - int i, j, k, iimin, jjmin, kkmin, iimax, jjmax, kkmax; \ + int i, j, k; \ \ - assert(imin>=0&&imax<=ni); \ - assert(jmin>=0&&jmax<=nj); \ - assert(kmin>=0&&kmax<=nk); \ - iimin = ioff + idir*imin; \ - jjmin = joff + jdir*jmin; \ - kkmin = koff + kdir*kmin; \ - iimax = ioff + idir*imax; \ - jjmax = joff + jdir*jmax; \ - kkmax = koff + kdir*kmax; \ - assert(iimin>=0&&iimax<=ni); \ - assert(jjmin>=0&&jjmax<=nj); \ - assert(kkmin>=0&&kkmax<=nk); \ - assert(iimax>=-1&&iimin<ni); \ - assert(jjmax>=-1&&jjmin<nj); \ - assert(kkmax>=-1&&kkmin<nk); \ + int const iioff = ioff + (1 - idir) * imin; \ + int const jjoff = joff + (1 - jdir) * jmin; \ + int const kkoff = koff + (1 - kdir) * kmin; \ + int const iimin = iioff + idir*imin; \ + int const jjmin = jjoff + jdir*jmin; \ + int const kkmin = kkoff + kdir*kmin; \ + int const iimax = iioff + idir*imax; \ + int const jjmax = jjoff + jdir*jmax; \ + int const kkmax = kkoff + kdir*kmax; \ + assert(imin>=0 && imax<=ni); \ + assert(jmin>=0 && jmax<=nj); \ + assert(kmin>=0 && kmax<=nk); \ + assert(iimin>=0 && iimax<=ni); \ + assert(jjmin>=0 && jjmax<=nj); \ + assert(kkmin>=0 && kkmax<=nk); \ + assert(iimax>=-1 && iimin<ni); \ + assert(jjmax>=-1 && jjmin<nj); \ + assert(kkmax>=-1 && kkmin<nk); \ \ for (k=kmin; k<kmax; ++k) { \ for (j=jmin; j<jmax; ++j) { \ for (i=imin; i<imax; ++i) { \ int const dstind = i + ni * (j + nj * k); \ - int const ii = ioff + idir * i; \ - int const jj = joff + jdir * j; \ - int const kk = koff + kdir * k; \ + int const ii = iioff + idir * i; \ + int const jj = jjoff + jdir * j; \ + int const kk = kkoff + kdir * k; \ int const srcind = ii + ni * (jj + nj * kk); \ REAL(dstvar[dstind] RE = parity * srcvar[srcind] RE;) \ IMAG(dstvar[dstind] IM = parity * srcvar[srcind] IM;) \ @@ -420,12 +423,12 @@ BndReflectVI (cGH const * restrict const cctkGH, if (face == 0) { imax[dir] = cctkGH->cctk_nghostzones[dir]; ioff[dir] = (+ 2*cctkGH->cctk_nghostzones[dir] - 1 - + (do_stagger[2*dir+face] ? 0 : 1)); + + (do_stagger[2*dir+face] ? 0 : 1)); idir[dir] = -1; } else { imin[dir] = cctkGH->cctk_lsh[dir] - cctkGH->cctk_nghostzones[dir]; - ioff[dir] = (- 2*cctkGH->cctk_nghostzones[dir] - - (do_stagger[2*dir+face] ? 0 : 1)); + ioff[dir] = (- 2*cctkGH->cctk_nghostzones[dir] + 1 + - (do_stagger[2*dir+face] ? 0 : 1)); idir[dir] = -1; } |