aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <>2001-03-29 16:21:00 +0000
committereschnett <>2001-03-29 16:21:00 +0000
commitfbca5b644901f1cdf8b8e2380901322f6ac2c11f (patch)
tree8bff80cc6e896899aa8054ebeb48295d90ecd1b9
parent6c82b2c1b778cf77f77d5f7446fc9ed1f641c53e (diff)
Added facility to poison new time levels. Thus you can make sure that
Added facility to poison new time levels. Thus you can make sure that every grid point is defined. darcs-hash:20010329162125-f6438-982adcd3731d7c417b1a509699575909b7c144ae.gz
-rw-r--r--Carpet/Carpet/param.ccl23
-rw-r--r--Carpet/Carpet/src/carpet.cc184
-rw-r--r--CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par5
3 files changed, 209 insertions, 3 deletions
diff --git a/Carpet/Carpet/param.ccl b/Carpet/Carpet/param.ccl
index 59ee423d4..4f17ae400 100644
--- a/Carpet/Carpet/param.ccl
+++ b/Carpet/Carpet/param.ccl
@@ -1,5 +1,5 @@
# Parameter definitions for thorn Carpet
-# $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/param.ccl,v 1.6 2001/03/24 22:38:42 eschnett Exp $
+# $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/param.ccl,v 1.7 2001/03/29 18:21:25 eschnett Exp $
shares: Cactus
@@ -86,6 +86,27 @@ CCTK_INT prolongation_order_time "Order of prolongation operator in time"
+BOOLEAN poison_new_timelevels "Try to catch uninitialised grid elements by setting new timelevels to values that will catch your attention"
+{
+} "no"
+
+BOOLEAN check_for_poison "Explicitely check for the poison value after every time step"
+{
+} "no"
+
+CCTK_INT poison_value "Integer value (0..255) used to poison new timelevels (with memset)"
+{
+ 0:255 :: "Must fit into a byte"
+} 113
+
+
+
+BOOLEAN checksum_timelevels "Try to catched unintentionally changed timelevels by taking checksums and comparing against these"
+{
+} "no"
+
+
+
BOOLEAN verbose "Display info on the screen"
{
} "no"
diff --git a/Carpet/Carpet/src/carpet.cc b/Carpet/Carpet/src/carpet.cc
index b0a034ef2..5f2e86c4b 100644
--- a/Carpet/Carpet/src/carpet.cc
+++ b/Carpet/Carpet/src/carpet.cc
@@ -35,7 +35,7 @@
#include "carpet.hh"
-static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.19 2001/03/28 18:56:04 eschnett Exp $";
+static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.20 2001/03/29 18:21:29 eschnett Exp $";
@@ -47,6 +47,9 @@ namespace Carpet {
static void CycleTimeLevels (cGH* cgh);
static void Restrict (cGH* cgh);
+ static void Poison (cGH* cgh);
+ static void PoisonCheck (cGH* cgh);
+
// Debugging output
static void Checkpoint (const char* fmt, ...);
@@ -428,7 +431,9 @@ namespace Carpet {
if (cgh->cctk_iteration % (maxreflevelfact/reflevelfact) == 0) {
// Cycle time levels
+ PoisonCheck (cgh);
CycleTimeLevels (cgh);
+ Poison (cgh);
// Advance level times
tt->advance_time (reflevel, mglevel);
@@ -1161,6 +1166,183 @@ namespace Carpet {
+ void Poison (cGH* cgh)
+ {
+ DECLARE_CCTK_PARAMETERS;
+
+ if (! poison_new_timelevels) return;
+
+ Checkpoint ("%*sPoison", 2*reflevel, "");
+
+ BEGIN_COMPONENT_LOOP(cgh) {
+ if (hh->is_local(reflevel,component)) {
+
+ for (int group=0; group<CCTK_NumGroups(); ++group) {
+ if (CCTK_QueryGroupStorageI(cgh, group)) {
+ for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
+
+ const int n = CCTK_FirstVarIndexI(group) + var;
+ const int num_tl = CCTK_NumTimeLevelsFromVarI(n);
+ const int sz = CCTK_VarTypeSize(CCTK_VarTypeI(n));
+ assert (sz>0);
+
+ if (num_tl>1) {
+
+ switch (CCTK_GroupTypeFromVarI(n)) {
+ case CCTK_SCALAR: {
+ assert (group<(int)scdata.size());
+ assert (var<(int)scdata[group].size());
+ memset (cgh->data[n][num_tl-1], poison_value, sz);
+ break;
+ }
+ case CCTK_ARRAY: {
+ assert (group<(int)arrdata.size());
+ assert (var<(int)arrdata[group].data.size());
+ assert (arrdata[group].hh->is_local(reflevel,component));
+ int np = 1;
+ for (int d=0; d<dim; ++d) np *= arrdata[group].size[d];
+ memset (cgh->data[n][num_tl-1], poison_value, np*sz);
+ break;
+ }
+ case CCTK_GF: {
+ assert (group<(int)gfdata.size());
+ assert (var<(int)gfdata[group].data.size());
+ int np = 1;
+ for (int d=0; d<dim; ++d) np *= gfsize[d];
+ memset (cgh->data[n][num_tl-1], poison_value, np*sz);
+ break;
+ }
+ default:
+ abort();
+ }
+
+ } // if more than one timelevel
+
+ } // for var
+ } // if has storage
+ } // for group
+
+ }
+ } END_COMPONENT_LOOP(cgh);
+ }
+
+
+
+ void PoisonCheck (cGH* cgh)
+ {
+ DECLARE_CCTK_PARAMETERS;
+
+ if (! check_for_poison) return;
+
+ Checkpoint ("%*sPoisonCheck", 2*reflevel, "");
+
+ BEGIN_COMPONENT_LOOP(cgh) {
+ if (hh->is_local(reflevel,component)) {
+
+ for (int group=0; group<CCTK_NumGroups(); ++group) {
+ if (CCTK_QueryGroupStorageI(cgh, group)) {
+ for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
+
+ const int n = CCTK_FirstVarIndexI(group) + var;
+ const int num_tl = CCTK_NumTimeLevelsFromVarI(n);
+
+ if (num_tl>1) {
+
+ switch (CCTK_GroupTypeFromVarI(n)) {
+
+ case CCTK_SCALAR: {
+ bool poisoned=false;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: { \
+ T worm; \
+ memset (&worm, poison_value, sizeof(worm)); \
+ poisoned = *(const T*)cgh->data[n][num_tl-1] == worm; \
+ break; \
+ }
+#include "typecase"
+#undef TYPECASE
+ default:
+ CCTK_VWarn
+ (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Carpet does not support the type of the variable \"%s\".\n"
+ "Either enable support for this type, "
+ "or change the type of this variable.", CCTK_FullName(n));
+ }
+ if (poisoned) {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "The variable \"%s\" contains poison",
+ CCTK_VarName(n));
+ }
+ break;
+ }
+
+ case CCTK_ARRAY:
+ case CCTK_GF: {
+ int size[dim];
+ for (int d=0; d<dim; ++d) {
+ size[d] = *CCTK_ArrayGroupSizeI(cgh, d, group);
+ }
+ const int tp = CCTK_VarTypeI(n);
+ const void* const data = cgh->data[n][num_tl-1];
+ int numpoison=0;
+ for (int k=0; k<size[2]; ++k) {
+ for (int j=0; j<size[1]; ++j) {
+ for (int i=0; i<size[0]; ++i) {
+ const int idx = CCTK_GFINDEX3D(cgh,i,j,k);
+ bool poisoned=false;
+ switch (tp) {
+#define TYPECASE(N,T) \
+ case N: { \
+ T worm; \
+ memset (&worm, poison_value, sizeof(worm)); \
+ poisoned = ((const T*)data)[idx] == worm; \
+ break; \
+ }
+#include "typecase"
+#undef TYPECASE
+ default:
+ CCTK_VWarn
+ (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Carpet does not support the type of the variable \"%s\".\n"
+ "Either enable support for this type, "
+ "or change the type of this variable.", CCTK_FullName(n));
+ }
+ if (poisoned) {
+ ++numpoison;
+ if (numpoison<=10) {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "The variable \"%s\" contains poison at [%d,%d,%d]",
+ CCTK_VarName(n), i,j,k);
+ }
+ } // if poisoned
+ } // for i
+ } // for j
+ } // for k
+ if (numpoison>10) {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "The variable \"%s\" contains poison at alltogether %d locations",
+ CCTK_VarName(n), numpoison);
+ }
+ break;
+ }
+
+ default:
+ abort();
+ }
+
+ } // if more than one timelevel
+
+ } // for var
+ } // if has storage
+ } // for group
+
+ } // if is local
+ } END_COMPONENT_LOOP(cgh);
+ }
+
+
+
void Checkpoint (const char* fmt, ...)
{
DECLARE_CCTK_PARAMETERS;
diff --git a/CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par b/CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par
index 98f33031f..52915a06c 100644
--- a/CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par
+++ b/CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par
@@ -7,7 +7,7 @@
# @enddesc
# @@*/
#
-# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par,v 1.6 2001/03/28 18:56:09 eschnett Exp $
+# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/wavetoyf77_periodic_coarse_rl2.par,v 1.7 2001/03/29 18:21:29 eschnett Exp $
ActiveThorns = "Boundary IOBasic IOUtil Time Cart3d Carpet CarpetIOASCII CarpetIOFlexIO CarpetLib CarpetSlab IDScalarWave WaveToyF77"
@@ -25,6 +25,9 @@ Carpet::max_refinement_levels = 2
Carpet::prolongation_order_space= 3
Carpet::prolongation_order_time = 2
+Carpet::poison_new_timelevels = yes
+Carpet::check_for_poison = yes
+
grid::type = byrange
grid::xmin = -5.4
grid::ymin = -7.2