3HPNY5XHNPWR6RVX4LYEVDFJQWSB2CMS7J6XPAKATQ2UPFTXD33QC
J3SP5HQRWGMM6EM4ZIWPNUIY5HYFRJA4SH2X4OWGESSK7AWA3RNQC
A7ETPFXEHA2RM4LINSBVMJJ3G62NF7Q5ZQOKJPNJK3YOQ5WS5HKAC
KCIWCVZOHG44WBOLKI2XK33WPHPRI5FWCETF4AOGTPZISKCW3CLQC
BVR7DVINVPQG7PA6Z7QYVYNQ43YZL7XCC6AOMSMWMGAAB2Q43STAC
BSMJ4V7GV3EOGY4KCSTOJQUOFE2OOCIKQETE4WC2WRNLWBQIBW3QC
GECUITHDXKCWB7HBCM7EA5Q56JDDWUVUWHMW2K6OM7UW36DFAZ3QC
LHPZHX4FMRYBM7NI22QTP3VZDBYFRSNTY3L6BEEFPPF5KWCFFIHQC
T3TZRPPAIA24I3YL3JFB4XEAYCWU3HJAJUCF7NNIFMP4I5X4SM5QC
R5ZPKCVY742K4RWVAJ4O6OGMIYH563GNCSVVSVF2Y66ILIUH7B4AC
DHFIRBK6SZI7R5QBVGMX2M5ADXIVQWNLCVBE6MKVPGHZ4USEC3VQC
M5R6KQLXLGYSVKHVAX5AJKD6NYE6IM5Z6WVTR3BTKPJDNNKF3ARAC
IV3MLV677VWS7GLESBQZ4HRFNW5TBFBIGIBWXTCHAER3FQ7VG3GQC
UEZKNPXXK5WU6B5LYRKGGYGBZ6T6TAZI26CWTJFUBUW2SJJOMV2AC
JN2TPHENEBIY2OE5FRCQ2E6QCL6FPVHJHUCP4UODD6DITRVV2LIQC
atomic<bool> found_nan{false};
size_t nan_count{0};
array<int, 3> nan_imin, nan_imax;
array<CCTK_REAL, 3> nan_xmin, nan_xmax;
for (int d = 0; d < 3; ++d) {
nan_imin[d] = numeric_limits<int>::max();
nan_imax[d] = numeric_limits<int>::min();
nan_xmin[d] = +1.0 / 0.0;
nan_xmax[d] = -1.0 / 0.0;
}
const auto nan_update{
[&](const GridDescBase &grid, const Loop::PointDesc &p) {
#pragma omp critical
{
++nan_count;
nan_imin[0] = min(nan_imin[0], grid.lbnd[0] + p.i);
nan_imin[1] = min(nan_imin[1], grid.lbnd[1] + p.j);
nan_imin[2] = min(nan_imin[2], grid.lbnd[2] + p.k);
nan_imax[0] = max(nan_imax[0], grid.lbnd[0] + p.i);
nan_imax[1] = max(nan_imax[1], grid.lbnd[1] + p.j);
nan_imax[2] = max(nan_imax[2], grid.lbnd[2] + p.k);
nan_xmin[0] = fmin(nan_xmin[0], p.x);
nan_xmin[1] = fmin(nan_xmin[1], p.y);
nan_xmin[2] = fmin(nan_xmin[2], p.z);
nan_xmax[0] = fmax(nan_xmax[0], p.x);
nan_xmax[1] = fmax(nan_xmax[1], p.y);
nan_xmax[2] = fmax(nan_xmax[2], p.z);
}
}};
const auto nan_check{[&](const GridDescBase &grid,
const GF3D1<const CCTK_REAL> &ptr_,
const Loop::PointDesc &p) {
if (CCTK_BUILTIN_EXPECT(CCTK_isnan(ptr_(p.I)), false))
nan_update(grid, p);
}};
grid.loop_idx(where_t::everywhere, groupdata.indextype,
groupdata.nghostzones, [&](const Loop::PointDesc &p) {
if (CCTK_BUILTIN_EXPECT(CCTK_isnan(ptr_(p.I)), false))
found_nan = true;
});
grid.loop_idx(
where_t::everywhere, groupdata.indextype, groupdata.nghostzones,
[&](const Loop::PointDesc &p) { nan_check(grid, ptr_, p); });
grid.loop_idx(where_t::interior, groupdata.indextype,
groupdata.nghostzones, [&](const Loop::PointDesc &p) {
if (CCTK_BUILTIN_EXPECT(CCTK_isnan(ptr_(p.I)), false))
found_nan = true;
});
grid.loop_idx(
where_t::interior, groupdata.indextype, groupdata.nghostzones,
[&](const Loop::PointDesc &p) { nan_check(grid, ptr_, p); });
grid.loop_idx(where_t::boundary, groupdata.indextype,
groupdata.nghostzones, [&](const Loop::PointDesc &p) {
if (CCTK_BUILTIN_EXPECT(CCTK_isnan(ptr_(p.I)), false))
found_nan = true;
});
grid.loop_idx(
where_t::boundary, groupdata.indextype, groupdata.nghostzones,
[&](const Loop::PointDesc &p) { nan_check(grid, ptr_, p); });
grid.loop_idx(where_t::ghosts, groupdata.indextype,
groupdata.nghostzones, [&](const Loop::PointDesc &p) {
if (CCTK_BUILTIN_EXPECT(CCTK_isnan(ptr_(p.I)), false))
found_nan = true;
});
grid.loop_idx(
where_t::ghosts, groupdata.indextype, groupdata.nghostzones,
[&](const Loop::PointDesc &p) { nan_check(grid, ptr_, p); });
if (CCTK_BUILTIN_EXPECT(found_nan, false)) {
CCTK_VINFO("%s: Grid function \"%s\" has nans on refinement level %d, time "
"level %d; expected valid %s",
if (CCTK_BUILTIN_EXPECT(nan_count > 0, false)) {
CCTK_VINFO(
"%s: Grid function \"%s\" has %td nans on refinement level %d, time "
"level %d, in box [%d,%d,%d]:[%d,%d,%d] (%g,%g,%g):(%g,%g,%g); "
"expected valid %s",
leveldata.level, tl,
size_t(nan_count), leveldata.level, tl, nan_imin[0], nan_imin[1],
nan_imin[2], nan_imax[0], nan_imax[1], nan_imax[2], double(nan_xmin[0]),
double(nan_xmin[1]), double(nan_xmin[2]), double(nan_xmax[0]),
double(nan_xmax[1]), double(nan_xmax[2]),
if (CCTK_BUILTIN_EXPECT(found_nan, false))
CCTK_VERROR(
"%s: Grid Scalar \"%s\" has nans on time level %d; expected valid %s",
msg().c_str(), CCTK_FullVarName(scalargroupdata.firstvarindex + vi), tl,
if (CCTK_BUILTIN_EXPECT(nan_count > 0, false))
CCTK_VERROR("%s: Grid Scalar \"%s\" has %td nans on time level %d; "
"expected valid %s",
msg().c_str(),
CCTK_FullVarName(scalargroupdata.firstvarindex + vi),
size_t(nan_count), tl,