aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8>2003-03-02 13:16:04 +0000
committerschnetter <schnetter@2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8>2003-03-02 13:16:04 +0000
commitbb2c73195c19312597c7b7620646f653a63f263f (patch)
tree3223922f5f5c0d077212e7849894317374b8ad0d
parent9d9320a8584fd999fb7f44af7ec2fa21d03cc7b1 (diff)
Choose the correct destination regions.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Slab/trunk@17 2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8
-rw-r--r--src/slab.c78
1 files changed, 69 insertions, 9 deletions
diff --git a/src/slab.c b/src/slab.c
index ee45b77..5a4f8c4 100644
--- a/src/slab.c
+++ b/src/slab.c
@@ -40,6 +40,10 @@ CCTK_FILEVERSION(TAT_Slab_slab_c);
/* Perform expensive self-checks? */
#undef CHECK
+/* Byte value for poison checks: use 255 for nan, or e.g. 113 for a
+ large value */
+#define POISON_VALUE 254
+
#ifdef DEBUG
@@ -613,10 +617,59 @@ int Slab_Transfer (cGH * restrict const cctkGH,
struct bbox const fake_bbox = { 0, 1, 1 };
struct arrays const fake_arrays
= { fake_bbox, fake_bbox, fake_bbox, fake_bbox };
+
+ bbox_check (&fake_bbox);
+
info[d].src = fake_arrays;
+ assert (bbox_iscontained (&info[d].src.active, &info[d].src.local));
+ assert (bbox_iscontained (&info[d].src.local, &info[d].src.global));
+
info[d].dst = fake_arrays;
+ assert (bbox_iscontained (&info[d].dst.active, &info[d].dst.local));
+ assert (bbox_iscontained (&info[d].dst.local, &info[d].dst.global));
+
info[d].xpose = d;
+ assert (info[d].xpose >= 0 && info[d].xpose < SLAB_MAXDIM);
info[d].flip = 0;
+ assert (info[d].flip == 0 || info[d].flip == 1);
+ }
+
+ ifcheck {
+ ifdebug printf ("srcinfo:\n");
+ for (d=0; d<SLAB_MAXDIM; ++d) {
+ printf (" src.global d=%d ", d);
+ bbox_print (&info[d].src.global);
+ printf ("\n");
+ printf (" src.local d=%d ", d);
+ bbox_print (&info[d].src.local);
+ printf ("\n");
+ printf (" src.active d=%d ", d);
+ bbox_print (&info[d].src.active);
+ printf ("\n");
+ printf (" src.slab d=%d ", d);
+ bbox_print (&info[d].src.slab);
+ printf ("\n");
+ }
+ ifdebug printf ("dstinfo:\n");
+ for (d=0; d<SLAB_MAXDIM; ++d) {
+ printf (" dst.global d=%d ", d);
+ bbox_print (&info[d].dst.global);
+ printf ("\n");
+ printf (" dst.local d=%d ", d);
+ bbox_print (&info[d].dst.local);
+ printf ("\n");
+ printf (" dst.active d=%d ", d);
+ bbox_print (&info[d].dst.active);
+ printf ("\n");
+ printf (" dst.slab d=%d ", d);
+ bbox_print (&info[d].dst.slab);
+ printf ("\n");
+ }
+ ifdebug printf ("info:\n");
+ for (d=0; d<SLAB_MAXDIM; ++d) {
+ printf (" xpose d=%d %d\n", d, info[d].xpose);
+ printf (" flip d=%d %d\n", d, info[d].flip);
+ }
}
{
@@ -643,6 +696,7 @@ int Slab_Transfer (cGH * restrict const cctkGH,
dstlentot *= info[d].dst.local.len;
}
+ /* Check arguments (continued) */
if (srclentot > 0) assert (srcptr);
if (dstlentot > 0) assert (dstptr);
@@ -702,6 +756,8 @@ int Slab_Transfer (cGH * restrict const cctkGH,
(allinfo[n*SLAB_MAXDIM+d].src.active.str == info[d].src.active.str);
assert
(allinfo[n*SLAB_MAXDIM+d].dst.active.str == info[d].dst.active.str);
+ /* 2003-03-01 schnetter: I don't know why the following two
+ should be necessary */
assert
(allinfo[n*SLAB_MAXDIM+d].src.slab.str == info[d].src.slab.str);
assert
@@ -719,7 +775,7 @@ int Slab_Transfer (cGH * restrict const cctkGH,
ifdebug printf ("srcdetail n=%d:\n", n);
for (d=0; d<SLAB_MAXDIM; ++d) {
srcdetail[n*SLAB_MAXDIM+d] = allinfo[n*SLAB_MAXDIM+d].src.slab;
- ifdebug printf (" src.slab d=%d ", d);
+ ifdebug printf (" src.slab d=%d ", d);
ifdebug bbox_print (&srcdetail[n*SLAB_MAXDIM+d]);
ifdebug printf ("\n");
bbox_clip (&srcdetail[n*SLAB_MAXDIM+d], &info[d].src.active);
@@ -773,7 +829,7 @@ int Slab_Transfer (cGH * restrict const cctkGH,
if (srctype == CCTK_VARIABLE_REAL) {
CCTK_REAL * restrict const srcdataptr = srcdata;
CCTK_REAL marker;
- memset (&marker, -1, sizeof marker);
+ memset (&marker, POISON_VALUE, sizeof marker);
for (i = 0; i < srcoffset[size]; ++i) {
memcpy (&srcdataptr[i], &marker, sizeof marker);
}
@@ -785,9 +841,8 @@ int Slab_Transfer (cGH * restrict const cctkGH,
for (n = 0; n < size; ++n) {
ifdebug printf ("dstdetail n=%d:\n", n);
for (d=0; d<SLAB_MAXDIM; ++d) {
- struct bbox wherefrom;
- struct bbox whereto;
- dstdetail[n*SLAB_MAXDIM+d] = allinfo[n*SLAB_MAXDIM+d].dst.slab;
+/* dstdetail[n*SLAB_MAXDIM+d] = allinfo[n*SLAB_MAXDIM+d].dst.slab; */
+ dstdetail[n*SLAB_MAXDIM+d] = info[d].dst.slab;
ifdebug printf (" dst.slab d=%d ", d);
ifdebug bbox_print (&dstdetail[n*SLAB_MAXDIM+d]);
ifdebug printf ("\n");
@@ -795,7 +850,12 @@ int Slab_Transfer (cGH * restrict const cctkGH,
ifdebug printf (" clipped with dst.active d=%d ", d);
ifdebug bbox_print (&dstdetail[n*SLAB_MAXDIM+d]);
ifdebug printf ("\n");
- wherefrom = allinfo[n*SLAB_MAXDIM+info[d].xpose].src.slab;
+ }
+ for (d=0; d<SLAB_MAXDIM; ++d) {
+ struct bbox wherefrom;
+ struct bbox whereto;
+/* wherefrom = allinfo[n*SLAB_MAXDIM+info[d].xpose].src.slab; */
+ wherefrom = info[info[d].xpose].src.slab;
ifdebug printf (" src.slab d=%d ", d);
ifdebug bbox_print (&dstdetail[n*SLAB_MAXDIM+d]);
ifdebug printf ("\n");
@@ -838,7 +898,7 @@ int Slab_Transfer (cGH * restrict const cctkGH,
if (dsttype == CCTK_VARIABLE_REAL) {
CCTK_REAL * restrict const dstdataptr = dstdata;
CCTK_REAL marker;
- memset (&marker, -1, sizeof marker);
+ memset (&marker, POISON_VALUE, sizeof marker);
for (i = 0; i < dstoffset[size]; ++i) {
memcpy (&dstdataptr[i], &marker, sizeof marker);
}
@@ -915,7 +975,7 @@ int Slab_Transfer (cGH * restrict const cctkGH,
if (srctype == CCTK_VARIABLE_REAL) {
const CCTK_REAL * restrict const srcdataptr = srcdata;
CCTK_REAL marker;
- memset (&marker, -1, sizeof marker);
+ memset (&marker, POISON_VALUE, sizeof marker);
for (i = 0; i < srcoffset[size]; ++i) {
assert (memcmp(&srcdataptr[i], &marker, sizeof marker) != 0);
}
@@ -931,7 +991,7 @@ int Slab_Transfer (cGH * restrict const cctkGH,
if (dsttype == CCTK_VARIABLE_REAL) {
const CCTK_REAL * restrict const dstdataptr = dstdata;
CCTK_REAL marker;
- memset (&marker, -1, sizeof marker);
+ memset (&marker, POISON_VALUE, sizeof marker);
for (i = 0; i < dstoffset[size]; ++i) {
assert (memcmp(&dstdataptr[i], &marker, sizeof marker) != 0);
}