aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@ff385933-4943-42dc-877b-ffc776028de6>2013-01-14 17:40:55 +0000
committereschnett <eschnett@ff385933-4943-42dc-877b-ffc776028de6>2013-01-14 17:40:55 +0000
commit59b159bdb44d7a42d122aefc079775b9fbea86ae (patch)
treee1c4a3f424e61575dddd6535511c27c73b9a8d16
parentd3f1a47c862c49ef1e399fa71c35e8884d189c98 (diff)
Support array padding (take cctk_ash into account)
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/NaNChecker/trunk@113 ff385933-4943-42dc-877b-ffc776028de6
-rw-r--r--src/NaNCheck.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/NaNCheck.cc b/src/NaNCheck.cc
index 3203cab..cc98b2c 100644
--- a/src/NaNCheck.cc
+++ b/src/NaNCheck.cc
@@ -174,7 +174,7 @@ void NaNChecker_NaNCheck_Prepare (CCTK_ARGUMENTS)
/* zero out the NaN mask */
for (i = 0, nelems = 1; i < cctk_dim; i++)
{
- nelems *= cctk_lsh[i];
+ nelems *= cctk_ash[i];
}
memset (info.NaNmask, 0, nelems * sizeof (CCTK_INT));
}
@@ -632,12 +632,12 @@ void PrintWarning (const char *error_type,
coord_buf << ", ";
}
}
- index_buf << /* "%d" */ (amended_index % gdata->lsh[i]) + gdata->lbnd[i] + 1;
+ index_buf << (amended_index % gdata->ash[i]) + gdata->lbnd[i] + 1;
if (coords)
{
coord_buf << /* "%5.3e" */ coords[i][linear_index];
}
- amended_index /= gdata->lsh[i];
+ amended_index /= gdata->ash[i];
}
if (coords)
@@ -685,7 +685,14 @@ CHECK_DATA(const cctk_type *_data, int nelems, const CCTK_REAL *CarpetWeights,
#pragma omp parallel for schedule(dynamic)
for (int _i = 0; _i < nelems; _i++)
{
- if (!CarpetWeights || CarpetWeights[_i] > 0.0)
+ bool is_inside = true;
+ int amended_index = _i;
+ for (int d=0; d<gdata.dim; ++d) {
+ int dir_index = amended_index % gdata.ash[d];
+ is_inside &= dir_index < gdata.lsh[d];
+ amended_index /= gdata.ash[d];
+ }
+ if (is_inside && (!CarpetWeights || CarpetWeights[_i] > 0.0))
{
/* We call the C wrapper functions instead of the autoconfigured
@@ -1088,7 +1095,7 @@ void SetToNaN (int vindex, const char *optstring, void *_info)
CCTK_GroupDynamicData (info->GH, gindex, &gdata);
for (i = 0; i < gdata.dim; i++)
{
- nelems *= gdata.lsh[i];
+ nelems *= gdata.ash[i];
}
}