aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <>2001-03-19 20:29:00 +0000
committereschnett <>2001-03-19 20:29:00 +0000
commit6c21319d35e66a4fd110c615f063b2e850a03a44 (patch)
tree2188f7149824b9a5ab52e796f0a6dd426a423b0a
parent43e277c27525008595b7a549dda442394d886628 (diff)
Fixed bug; variables types were not recognised.
darcs-hash:20010319202959-f6438-d34c229495ae54d323eb18af5e9f53505790d805.gz
-rw-r--r--Carpet/Carpet/src/carpet.cc21
-rw-r--r--Carpet/Carpet/src/typecase136
2 files changed, 144 insertions, 13 deletions
diff --git a/Carpet/Carpet/src/carpet.cc b/Carpet/Carpet/src/carpet.cc
index c74c72933..a317a7dfb 100644
--- a/Carpet/Carpet/src/carpet.cc
+++ b/Carpet/Carpet/src/carpet.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.15 2001/03/18 05:20:20 eschnett Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.16 2001/03/19 21:29:59 eschnett Exp $
// It is assumed that the number of components of all arrays is equal
// to the number of components of the grid functions, and that their
@@ -36,7 +36,7 @@
#include "carpet.hh"
-static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.15 2001/03/18 05:20:20 eschnett Exp $";
+static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.16 2001/03/19 21:29:59 eschnett Exp $";
@@ -884,25 +884,28 @@ namespace Carpet {
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);
switch (CCTK_GroupTypeFromVarI(n)) {
case CCTK_SCALAR: {
assert (group<(int)scdata.size());
assert (var<(int)scdata[group].size());
- const int sz = CCTK_VarTypeSize(CCTK_VarTypeI(n));
- for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n)-1; ++ti) {
+ void* tmpdata = scdata[group][var][0];
+ for (int ti=0; ti<num_tl-1; ++ti) {
// TODO: Which refinement level to use?
- memcpy (scdata[group][var][ti], scdata[group][var][ti+1], sz);
+ scdata[group][var][ti] = scdata[group][var][ti+1];
}
+ scdata[group][var][num_tl-1] = tmpdata;
+ tmpdata = 0;
break;
}
case CCTK_ARRAY: {
assert (group<(int)arrdata.size());
assert (var<(int)arrdata[group].data.size());
for (int c=0; c<arrdata[group].hh->components(reflevel); ++c) {
- for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n)-1; ++ti) {
- const int tmin = min(0, 2 - CCTK_NumTimeLevelsFromVarI(n));
- const int tl = tmin + ti;
- arrdata[group].data[var]->copy(tl, reflevel, c, mglevel);
+ for (int ti=0; ti<num_tl-1; ++ti) {
+ const int tmin = min(0, 2 - num_tl);
+ const int tl = tmin + ti;
+ arrdata[group].data[var]->copy(tl, reflevel, c, mglevel);
}
}
break;
diff --git a/Carpet/Carpet/src/typecase b/Carpet/Carpet/src/typecase
index 67d115a1d..f964d3300 100644
--- a/Carpet/Carpet/src/typecase
+++ b/Carpet/Carpet/src/typecase
@@ -1,32 +1,160 @@
// Instantiate type cases for all available types -*-C++-*-
// (C) 2001 Erik Schnetter <schnetter@uni-tuebingen.de>
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/typecase,v 1.1 2001/03/01 13:40:10 eschnett Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/typecase,v 1.2 2001/03/19 21:30:00 eschnett Exp $
// Usage:
// Define the macro TYPECASE(N,T) to be a typecase for the type T with name N,
// then include this file,
// then undefine the macro TYPECASE.
+
+
+// Decide which types to typecase
+
+#ifdef CARPET_ALL
+# undef CARPET_BYTE
+# undef CARPET_INT
+# undef CARPET_REAL
+# undef CARPET_COMPLEX
+# define CARPET_BYTE
+# define CARPET_INT
+# define CARPET_REAL
+# define CARPET_COMPLEX
+#endif
+
+#ifdef CARPET_ALL_INT
+# undef CARPET_INT2
+# undef CARPET_INT4
+# undef CARPET_INT8
+# define CARPET_INT2
+# define CARPET_INT4
+# define CARPET_INT8
+#endif
+
+#ifdef CARPET_ALL_REAL
+# undef CARPET_REAL4
+# undef CARPET_REAL8
+# undef CARPET_REAL16
+# define CARPET_REAL4
+# define CARPET_REAL8
+# define CARPET_REAL16
+#endif
+
+#ifdef CARPET_ALL_COMPLEX
+# undef CARPET_COMPLEX8
+# undef CARPET_COMPLEX16
+# undef CARPET_COMPLEX32
+# define CARPET_COMPLEX8
+# define CARPET_COMPLEX16
+# define CARPET_COMPLEX32
+#endif
+
+#if !defined(CARPET_BYTE) && !defined(CARPET_INT2) && !defined(CARPET_INT4) && !defined(CARPET_INT8) && !defined(CARPET_REAL4) && !defined(CARPET_REAL8) && !defined(CARPET_REAL16) && !defined(CARPET_COMPLEX8) && !defined(CARPET_COMPLEX16) && !defined(CARPET_COMPLEX32)
+// Assume the user just wants REAL
+# undef CARPET_REAL
+# define CARPET_REAL
+#endif
+
+#ifdef CARPET_INT
+# ifdef CCTK_INTEGER_PRECISION_2
+# undef CARPET_INT2
+# define CARPET_INT2
+# endif
+# ifdef CCTK_INTEGER_PRECISION_4
+# undef CARPET_INT4
+# define CARPET_INT4
+# endif
+# ifdef CCTK_INTEGER_PRECISION_8
+# undef CARPET_INT8
+# define CARPET_INT8
+# endif
+#endif
+#ifdef CARPET_REAL
+# ifdef CCTK_REAL_PRECISION_4
+# undef CARPET_REAL4
+# define CARPET_REAL4
+# endif
+# ifdef CCTK_REAL_PRECISION_8
+# undef CARPET_REAL8
+# define CARPET_REAL8
+# endif
+# ifdef CCTK_REAL_PRECISION_16
+# undef CARPET_REAL16
+# define CARPET_REAL16
+# endif
+#endif
+#ifdef CARPET_COMPLEX
+# ifdef CCTK_REAL_PRECISION_4
+# undef CARPET_COMPLEX8
+# define CARPET_COMPLEX8
+# endif
+# ifdef CCTK_REAL_PRECISION_8
+# undef CARPET_COMPLEX16
+# define CARPET_COMPLEX16
+# endif
+# ifdef CCTK_REAL_PRECISION_16
+# undef CARPET_COMPLEX32
+# define CARPET_COMPLEX32
+# endif
+#endif
+
+
+
+// // Check
+// #if !defined(CARPET_BYTE) && !defined(CARPET_INT2) && !defined(CARPET_INT4) && !defined(CARPET_INT8) && !defined(CARPET_REAL4) && !defined(CARPET_REAL8) && !defined(CARPET_REAL16) && !defined(CARPET_COMPLEX8) && !defined(CARPET_COMPLEX16) && !defined(CARPET_COMPLEX32)
+// # error "You have not defined which grid function types to instantiate."
+// #endif
+
+
+
+// Typecase the desired types
+
+#ifdef CARPET_BYTE
TYPECASE(CCTK_VARIABLE_BYTE, CCTK_BYTE)
+#endif
+#ifdef CARPET_INT
TYPECASE(CCTK_VARIABLE_INT, CCTK_INT)
+#endif
+#ifdef CARPET_INT2
TYPECASE(CCTK_VARIABLE_INT2, CCTK_INT2)
+#endif
+#ifdef CARPET_INT4
TYPECASE(CCTK_VARIABLE_INT4, CCTK_INT4)
-#ifdef CCTK_INT8
+#endif
+#ifdef CARPET_INT4
+# ifdef CCTK_INT8
TYPECASE(CCTK_VARIABLE_INT8, CCTK_INT8)
+# endif
#endif
+#ifdef CARPET_REAL
TYPECASE(CCTK_VARIABLE_REAL, CCTK_REAL)
+#endif
+#ifdef CARPET_REAL4
TYPECASE(CCTK_VARIABLE_REAL4, CCTK_REAL4)
+#endif
+#ifdef CARPET_REAL8
TYPECASE(CCTK_VARIABLE_REAL8, CCTK_REAL8)
-#ifdef CCTK_REAL16
+#endif
+#ifdef CARPET_REAL16
+# ifdef CCTK_REAL16
TYPECASE(CCTK_VARIABLE_REAL16, CCTK_REAL16)
+# endif
#endif
+#ifdef CARPET_COMPLEX
TYPECASE(CCTK_VARIABLE_COMPLEX, complex<CCTK_REAL>)
+#endif
+#ifdef CARPET_COMPLEX8
TYPECASE(CCTK_VARIABLE_COMPLEX8, complex<CCTK_REAL4>)
+#endif
+#ifdef CARPET_COMPLEX16
TYPECASE(CCTK_VARIABLE_COMPLEX16, complex<CCTK_REAL8>)
-#ifdef CCTK_REAL16
+#endif
+#ifdef CARPET_COMPLEX32
+# ifdef CCTK_REAL16
TYPECASE(CCTK_VARIABLE_COMPLEX32, complex<CCTK_REAL16>)
+# endif
#endif