#include #include #include #include #include #include #include #include #include #include #include namespace Carpet { using namespace std; // The parameter where specifies which time levels should be // poisoned. what specifies what kind of grid variables should be // poisoned. void Poison (cGH const * const cctkGH, checktimes const where, int const what) { DECLARE_CCTK_PARAMETERS; assert (what == 0 or what == CCTK_GF or what == CCTK_ARRAY); if (not poison_new_timelevels) return; Timers::Timer timer("Poison"); timer.start(); for (int group=0; group=0 and group=0); int const sz = CCTK_VarTypeSize(CCTK_VarTypeI(n0)); assert (sz>0); int const table = CCTK_GroupTagsTableI (group); assert (table >= 0); bool persistent; char buf[100]; int const ilen = Util_TableGetString (table, sizeof buf, buf, "Persistent"); if (ilen > 0) { if (CCTK_EQUALS(buf, "yes")) { persistent = true; } else if (CCTK_EQUALS(buf, "no")) { persistent = false; } else { assert (0); } } else if (ilen == UTIL_ERROR_TABLE_NO_SUCH_KEY) { // default persistent = true; } else { assert (0); } int const num_tl = CCTK_ActiveTimeLevelsVI(cctkGH, n0); assert (num_tl>0); int const min_tl = min_timelevel(where, num_tl, persistent); int const max_tl = max_timelevel(where, num_tl, persistent); if (min_tl <= max_tl) { { char * const groupname = CCTK_GroupName(group); Checkpoint ("PoisonGroup \"%s\"", groupname); free (groupname); } CCTK_INT const poison_value = get_poison_value(); int const grouptype = CCTK_GroupTypeI(group); BEGIN_LOCAL_MAP_LOOP(cctkGH, grouptype) { BEGIN_LOCAL_COMPONENT_LOOP(cctkGH, grouptype) { ivect size(1); int const gpdim = groupdata.AT(group).info.dim; for (int d=0; ddata[n][tl], poison_value, np*sz); } // for tl } // for var } END_LOCAL_COMPONENT_LOOP; } END_LOCAL_MAP_LOOP; } // if tl } void PoisonCheck (cGH const * const cctkGH, checktimes const where) { DECLARE_CCTK_PARAMETERS; if (not check_for_poison) return; Checkpoint ("PoisonCheck"); Timers::Timer timer("PoisonCheck"); timer.start(); for (int group=0; group 0 and CCTK_QueryGroupStorageI(cctkGH, group)) { int const grouptype = CCTK_GroupTypeI(group); int const n0 = CCTK_FirstVarIndexI(group); assert (n0>=0); int const tp = CCTK_VarTypeI(n0); int const gpdim = groupdata.AT(group).info.dim; int const table = CCTK_GroupTagsTableI (group); assert (table >= 0); bool persistent; char buf[100]; int const ilen = Util_TableGetString (table, sizeof buf, buf, "Persistent"); if (ilen > 0) { if (CCTK_EQUALS(buf, "yes")) { persistent = true; } else if (CCTK_EQUALS(buf, "no")) { persistent = false; } else { assert (0); } } else if (ilen == UTIL_ERROR_TABLE_NO_SUCH_KEY) { // default persistent = true; } else { assert (0); } CCTK_INT const poison_value = get_poison_value(); int const num_tl = CCTK_ActiveTimeLevelsVI(cctkGH, n0); assert (num_tl>0); int const min_tl = min_timelevel(where, num_tl, persistent); int const max_tl = max_timelevel(where, num_tl, persistent); BEGIN_LOCAL_MAP_LOOP(cctkGH, grouptype) { BEGIN_LOCAL_COMPONENT_LOOP(cctkGH, grouptype) { ivect size(1), asize(1); for (int d=0; ddata[n][tl]; int numpoison=0; for (int k=0; kcctk_iteration, tl, component, map, reflevel, fullname, i,j,k); free (fullname); } } // if poisoned } // for i } // for j } // for k if (max_poison_locations!=-1 and numpoison>max_poison_locations) { char* fullname = CCTK_FullName(n); CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "At iteration %d: timelevel %d, component %d, map %d, refinement level %d of the variable \"%s\" contains poison at %d of %d locations; not all locations were printed", cctkGH->cctk_iteration, tl, component, map, reflevel, fullname, numpoison, np); free (fullname); } else if (numpoison>0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Found poison at %d of %d locations", numpoison, np); } } // for tl } // for var } END_LOCAL_COMPONENT_LOOP; } END_LOCAL_MAP_LOOP; } // if has storage } // for group timer.stop(); } } // namespace Carpet