From fc2408a04ec4422b3617446f7de95369e6740d1e Mon Sep 17 00:00:00 2001 From: lanfer Date: Fri, 25 Aug 2000 12:23:10 +0000 Subject: bug fix: ghostzones not treated properly git-svn-id: http://svn.cactuscode.org/arrangements/CactusWave/WaveBinarySource/trunk@12 b9286e40-80fe-41ab-903a-d6b447012e1e --- src/CoordinateStuff.c | 49 ++++++++++++------------------------------------- src/WaveBinary.c | 49 ++++++++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 64 deletions(-) diff --git a/src/CoordinateStuff.c b/src/CoordinateStuff.c index de22af4..6173e0f 100644 --- a/src/CoordinateStuff.c +++ b/src/CoordinateStuff.c @@ -11,13 +11,11 @@ @author Gerd Lanfermann @desc For a given physical, global coordinate, IndexFloor returns - the closest lower grid index *locally* in the direction d, - which is owned by the grid path. (Ghostzone are not owned!) + the closest lower grid index *locally* in the direction d, + this includes ghostzones; + Other return values: -1 : gridindex not on this gridpatch - -3 : coordinate is outside global grid - - This routine and the Fortran wrapper are Fortran/C index aware. @enddesc @calls @calledby @@ -30,7 +28,7 @@ int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) { - int index_low,idummy,ugs,lgs; + int index_low,idummy; char *message; CCTK_REAL cmin,cmax; @@ -56,20 +54,10 @@ int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) idummy = floor((coord_value-cmin)/ GH->cctk_delta_space[d]); index_low = idummy-GH->cctk_lbnd[d]; - if (GH->cctk_bbox[2*d]==1) - lgs = 0; - else - lgs = GH->cctk_nghostzones[d]; - - if (GH->cctk_bbox[2*d+1]==1) - ugs = 0; - else - ugs = GH->cctk_nghostzones[d]; - - if (index_low=GH->cctk_lsh[d]-ugs) + if (index_low>=GH->cctk_lsh[d]) index_low = -1; return(index_low); @@ -82,13 +70,10 @@ int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) @author Gerd Lanfermann @desc For a given physical, global coordinate, IndexCeil returns - the closest upper grid index *locally* in the direction d, - which is owned by the grid path. (Ghostzone are not owned!) + the closest upper grid index *locally* in the direction d + including ghostzones. Other return values: -1 : grid index not on this gridpatch - -3 : coordinate is outside global grid - - This routine and the Fortran wrapper are Fortran/C index aware. @enddesc @calls @calledby @@ -101,7 +86,7 @@ int IndexFloorC(cGH *GH, CCTK_REAL coord_value, int d) int IndexCeilC(cGH *GH, CCTK_REAL coord_value, int d) { - int index_up,idummy,ugs,lgs; + int index_up,idummy; char *message; CCTK_REAL cmin,cmax; @@ -127,21 +112,11 @@ int IndexCeilC(cGH *GH, CCTK_REAL coord_value, int d) idummy = ceil((coord_value-cmin)/ GH->cctk_delta_space[d]); index_up = idummy-GH->cctk_lbnd[d]; - - if (GH->cctk_bbox[2*d]==1) - lgs = 0; - else - lgs = GH->cctk_nghostzones[d]; - - if (GH->cctk_bbox[2*d+1]==1) - ugs = 0; - else - ugs = GH->cctk_nghostzones[d]; - - if (index_up=GH->cctk_lsh[d]-ugs) + if (index_up>=GH->cctk_lsh[d]) index_up = -1; return(index_up); diff --git a/src/WaveBinary.c b/src/WaveBinary.c index bd2dcb1..68f1fe9 100644 --- a/src/WaveBinary.c +++ b/src/WaveBinary.c @@ -37,7 +37,7 @@ void WaveBinaryC(CCTK_ARGUMENTS) int mingp[3], maxgp[3]; /* some flags */ - int onthisproc, sign; + int onthisproc, xproc, sign; static int firstcall; CCTK_REAL xs,ys,zs,rad; @@ -107,34 +107,29 @@ void WaveBinaryC(CCTK_ARGUMENTS) Increase onthisproc : if equal to three, we have the source */ - if ((lbin[d]>=minc[d]) && (ubin[d]<=minc[d])) - { - lowerloc[d]=IndexFloorC(cctkGH, lbin[d],d); - upperloc[d]=IndexCeilC (cctkGH, ubin[d],d); - onthisproc += 1; - } - else if ((lbin[d]>=minc[d]) && (lbin[d]<=maxc[d])) - { - lowerloc[d]=IndexFloorC(cctkGH, lbin[d],d); - upperloc[d]=maxgp[d]; - onthisproc += 1; - } - else if ((ubin[d]>=minc[d]) && (ubin[d]<=maxc[d])) - { - lowerloc[d]=mingp[d]; - upperloc[d]=IndexCeilC (cctkGH, ubin[d],d); - onthisproc += 1; - } - else if ((ubin[d]>=maxc[d]) && (lbin[d]<=minc[d])) + + xproc = 0; + lowerloc[d]=mingp[d]; + upperloc[d]=maxgp[d]; + + if ((lbin[d]<=minc[d]) && (ubin[d]>=maxc[d])) + { + xproc = 1; + } + else { - lowerloc[d]=mingp[d]; - upperloc[d]=maxgp[d]; - onthisproc += 1; - } - else { - lowerloc[d] = -1; - upperloc[d] = -1; + if ((minc[d]<=lbin[d]) && (lbin[d]<=maxc[d])) + { + lowerloc[d]=IndexFloorC(cctkGH, lbin[d],d); + xproc = 1; + } + if ((minc[d]<=ubin[d]) && (ubin[d]<=maxc[d])) + { + upperloc[d]=IndexCeilC (cctkGH, ubin[d],d); + xproc = 1; + } } + onthisproc+=xproc; } /* Debugging debugging */ -- cgit v1.2.3