aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/Carpet/src/carpet.cc389
-rw-r--r--Carpet/Carpet/src/carpet.hh25
-rw-r--r--Carpet/CarpetIOASCII/src/ioascii.cc284
-rw-r--r--Carpet/CarpetLib/src/bbox.cc5
-rw-r--r--Carpet/CarpetLib/src/bboxset.cc6
-rw-r--r--Carpet/CarpetLib/src/data.cc4
-rw-r--r--Carpet/CarpetLib/src/defs.cc16
-rw-r--r--Carpet/CarpetLib/src/dggf.hh10
-rw-r--r--Carpet/CarpetLib/src/dh.cc4
-rw-r--r--Carpet/CarpetLib/src/gdata.cc40
-rw-r--r--Carpet/CarpetLib/src/gf.cc4
-rw-r--r--Carpet/CarpetLib/src/ggf.cc8
-rw-r--r--Carpet/CarpetLib/src/ggf.hh8
-rw-r--r--Carpet/CarpetLib/src/gh.cc6
-rw-r--r--Carpet/CarpetLib/src/make.code.defn19
-rw-r--r--Carpet/CarpetLib/src/vect.cc5
-rw-r--r--Carpet/CarpetSlab/src/carpetslab.cc218
17 files changed, 764 insertions, 287 deletions
diff --git a/Carpet/Carpet/src/carpet.cc b/Carpet/Carpet/src/carpet.cc
index a7e5afe87..3969e83a0 100644
--- a/Carpet/Carpet/src/carpet.cc
+++ b/Carpet/Carpet/src/carpet.cc
@@ -32,7 +32,7 @@
#include "carpet.hh"
-static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.27 2001/06/12 15:14:16 schnetter Exp $";
+static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.28 2001/07/02 13:22:09 schnetter Exp $";
@@ -101,10 +101,10 @@ namespace Carpet {
vector<arrdesc> arrdata; // [group]
// The grid hierarchy
- gh<dim>* hh;
+ gh<gfdim>* hh;
th* tt;
- dh<dim>* dd;
- int gfsize[dim];
+ dh<gfdim>* dd;
+ int gfsize[gfdim];
// Data for grid functions
vector<gfdesc> gfdata; // [group]
@@ -147,7 +147,8 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- assert (cgh->cctk_dim == dim);
+ assert (maxdim>0 && gfdim>0 && gfdim <= maxdim);
+ assert (cgh->cctk_dim == gfdim);
// Not sure what to do with that
assert (convLevel==0);
@@ -161,40 +162,41 @@ namespace Carpet {
= (int)floor(pow((double)refinement_factor, maxreflevels-1) + 0.5);
// Ghost zones
- vect<int,dim> lghosts, ughosts;
+ assert (gfdim == 3);
+ vect<int,gfdim> lghosts, ughosts;
if (ghost_size == -1) {
- lghosts = vect<int,dim>(ghost_size_x, ghost_size_y, ghost_size_z);
- ughosts = vect<int,dim>(ghost_size_x, ghost_size_y, ghost_size_z);
+ lghosts = vect<int,gfdim>(ghost_size_x, ghost_size_y, ghost_size_z);
+ ughosts = vect<int,gfdim>(ghost_size_x, ghost_size_y, ghost_size_z);
} else {
- lghosts = vect<int,dim>(ghost_size, ghost_size, ghost_size);
- ughosts = vect<int,dim>(ghost_size, ghost_size, ghost_size);
+ lghosts = vect<int,gfdim>(ghost_size, ghost_size, ghost_size);
+ ughosts = vect<int,gfdim>(ghost_size, ghost_size, ghost_size);
}
// Grid size
const int stride = maxreflevelfact;
- vect<int,dim> npoints;
+ vect<int,gfdim> npoints;
if (global_nsize == -1) {
- npoints = vect<int,dim>(global_nx, global_ny, global_nz);
+ npoints = vect<int,gfdim>(global_nx, global_ny, global_nz);
} else {
- npoints = vect<int,dim>(global_nsize, global_nsize, global_nsize);
+ npoints = vect<int,gfdim>(global_nsize, global_nsize, global_nsize);
}
- const vect<int,dim> str(stride);
- const vect<int,dim> lb(lghosts * str);
- const vect<int,dim> ub = (npoints - ughosts - 1) * str;
+ const vect<int,gfdim> str(stride);
+ const vect<int,gfdim> lb(lghosts * str);
+ const vect<int,gfdim> ub = (npoints - ughosts - 1) * str;
- const bbox<int,dim> baseext(lb, ub, str);
+ const bbox<int,gfdim> baseext(lb, ub, str);
// Allocate grid hierarchy
- hh = new gh<dim>(refinement_factor, vertex_centered,
- multigrid_factor, vertex_centered,
- baseext);
+ hh = new gh<gfdim>(refinement_factor, vertex_centered,
+ multigrid_factor, vertex_centered,
+ baseext);
// Allocate time hierarchy
tt = new th(hh, maxreflevelfact);
// Allocate data hierarchy
- dd = new dh<dim>(*hh, lghosts, ughosts, prolongation_order_space);
+ dd = new dh<gfdim>(*hh, lghosts, ughosts, prolongation_order_space);
if (max_refinement_levels > 1) {
const int prolongation_stencil_size = dd->prolongation_stencil_size();
@@ -238,47 +240,81 @@ namespace Carpet {
cGroup gp;
CCTK_GroupData (group, &gp);
- // TODO
- assert (CCTK_GroupDimI(group) == dim);
+ assert (gp.dim>=1 || gp.dim<=maxdim);
// TODO
// assert (gp.disttype == CCTK_DISTRIB_CONSTANT);
assert (gp.disttype == CCTK_DISTRIB_DEFAULT);
- vect<int,dim> alb, aub;
- for (int d=0; d<dim; ++d) {
- alb[d] = 0;
- aub[d] = (*CCTK_GroupSizesI(group))[d];
- }
- const bbox<int,dim> arrext(alb, aub-str, str);
-
- arrdata[group].hh = new gh<dim>
- (refinement_factor, vertex_centered,
- multigrid_factor, vertex_centered,
- arrext);
-
- arrdata[group].tt = new th (arrdata[group].hh, maxreflevelfact);
- vect<int,dim> alghosts, aughosts;
- for (int d=0; d<dim; ++d) {
- alghosts[d] = (*CCTK_GroupGhostsizesI(group))[d];
- aughosts[d] = (*CCTK_GroupGhostsizesI(group))[d];
+ switch (gp.dim) {
+
+#define CODE \
+ do { \
+ vect<int,dim> alb, aub, astr; \
+ for (int d=0; d<dim; ++d) { \
+ alb[d] = 0; \
+ aub[d] = (*CCTK_GroupSizesI(group))[d]; \
+ astr[d] = stride; \
+ } \
+ const bbox<int,dim> arrext(alb, aub-astr, astr); \
+ \
+ arrdata[group].hh = new gh<dim> \
+ (refinement_factor, vertex_centered, \
+ multigrid_factor, vertex_centered, \
+ arrext); \
+ \
+ arrdata[group].tt = new th (arrdata[group].hh, maxreflevelfact); \
+ \
+ vect<int,dim> alghosts, aughosts; \
+ for (int d=0; d<dim; ++d) { \
+ alghosts[d] = (*CCTK_GroupGhostsizesI(group))[d]; \
+ aughosts[d] = (*CCTK_GroupGhostsizesI(group))[d]; \
+ } \
+ \
+ arrdata[group].dd \
+ = new dh<dim>(*(gh<dim>*)arrdata[group].hh, \
+ alghosts, aughosts, \
+ prolongation_order_space); \
+ \
+ if (max_refinement_levels > 1) { \
+ const int prolongation_stencil_size \
+ = arrdata[group].dd->prolongation_stencil_size(); \
+ const int min_nghosts \
+ = ((prolongation_stencil_size + refinement_factor - 2) \
+ / (refinement_factor-1)); \
+ if (any(min(alghosts,aughosts) < min_nghosts)) { \
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, \
+ "There are not enough ghost zones for the desired spatial prolongation order for the grid function group \"%s\". With Carpet::prolongation_order_space=%d, you need at least %d ghost zones.", \
+ CCTK_GroupName(group), \
+ prolongation_order_space, min_nghosts); \
+ } \
+ } \
+ \
+ } while (0)
+
+ case 1: {
+ const int dim = 1;
+ CODE;
+ break;
}
-
- arrdata[group].dd = new dh<dim>(*arrdata[group].hh, alghosts, aughosts,
- prolongation_order_space);
-
- if (max_refinement_levels > 1) {
- const int prolongation_stencil_size
- = arrdata[group].dd->prolongation_stencil_size();
- const int min_nghosts
- = ((prolongation_stencil_size + refinement_factor - 2)
- / (refinement_factor-1));
- if (any(min(alghosts,aughosts) < min_nghosts)) {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "There are not enough ghost zones for the desired spatial prolongation order for the grid function group \"%s\". With Carpet::prolongation_order_space=%d, you need at least %d ghost zones.",
- CCTK_GroupName(group),
- prolongation_order_space, min_nghosts);
- }
+
+ case 2: {
+ const int dim = 2;
+ CODE;
+ break;
+ }
+
+ case 3: {
+ const int dim = 3;
+ CODE;
+ break;
+ }
+
+ default:
+ abort();
+
+#undef CODE
+
}
arrdata[group].data.resize(CCTK_NumVarsInGroupI(group));
@@ -289,8 +325,7 @@ namespace Carpet {
}
case CCTK_GF: {
- /* TODO */
- assert (CCTK_GroupDimI(group) == dim);
+ assert (CCTK_GroupDimI(group) == gfdim);
gfdata[group].data.resize(CCTK_NumVarsInGroupI(group));
for (int var=0; var<(int)scdata[group].data.size(); ++var) {
@@ -305,7 +340,7 @@ namespace Carpet {
}
// Initialise cgh
- for (int d=0; d<dim; ++d) {
+ for (int d=0; d<gfdim; ++d) {
cgh->cctk_nghostzones[d] = dd->lghosts[d];
}
@@ -748,17 +783,56 @@ namespace Carpet {
|| arrdata[group].data[0] == 0);
for (int var=0; var<(int)arrdata[group].data.size(); ++var) {
const int n = n0 + var;
- switch (CCTK_VarTypeI(n)) {
+ switch (CCTK_GroupDimI(group)) {
+ case 1: {
+ const int dim=1;
+ switch (CCTK_VarTypeI(n)) {
#define TYPECASE(N,T) \
- case N: \
- arrdata[group].data[var] = new gf<T,dim> \
- (CCTK_VarName(n), *arrdata[group].tt, *arrdata[group].dd, \
- tmin, tmax); \
+ case N: \
+ arrdata[group].data[var] = new gf<T,dim> \
+ (CCTK_VarName(n), *arrdata[group].tt, *(dh<dim>*)arrdata[group].dd, \
+ tmin, tmax); \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
break;
+ }
+ case 2: {
+ const int dim=2;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ arrdata[group].data[var] = new gf<T,dim> \
+ (CCTK_VarName(n), *arrdata[group].tt, *(dh<dim>*)arrdata[group].dd, \
+ tmin, tmax); \
+ break;
#include "typecase"
#undef TYPECASE
- default:
- UnsupportedVarType(n);
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ case 3: {
+ const int dim=3;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ arrdata[group].data[var] = new gf<T,dim> \
+ (CCTK_VarName(n), *arrdata[group].tt, *(dh<dim>*)arrdata[group].dd, \
+ tmin, tmax); \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ default: abort();
}
}
break;
@@ -768,16 +842,53 @@ namespace Carpet {
|| gfdata[group].data[0] == 0);
for (int var=0; var<(int)gfdata[group].data.size(); ++var) {
const int n = n0 + var;
- switch (CCTK_VarTypeI(n)) {
+ switch (CCTK_GroupDimI(group)) {
+ case 1: {
+ const int dim=1;
+ switch (CCTK_VarTypeI(n)) {
#define TYPECASE(N,T) \
- case N: \
- gfdata[group].data[var] = new gf<T,dim> \
- (CCTK_VarName(n), *tt, *dd, tmin, tmax); \
+ case N: \
+ gfdata[group].data[var] = new gf<T,dim> \
+ (CCTK_VarName(n), *tt, *(dh<dim>*)dd, tmin, tmax); \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
break;
+ }
+ case 2: {
+ const int dim=2;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ gfdata[group].data[var] = new gf<T,dim> \
+ (CCTK_VarName(n), *tt, *(dh<dim>*)dd, tmin, tmax); \
+ break;
#include "typecase"
#undef TYPECASE
- default:
- UnsupportedVarType(n);
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ case 3: {
+ const int dim=3;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ gfdata[group].data[var] = new gf<T,dim> \
+ (CCTK_VarName(n), *tt, *(dh<dim>*)dd, tmin, tmax); \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ default: abort();
}
}
break;
@@ -851,15 +962,50 @@ namespace Carpet {
}
for (int var=0; var<(int)arrdata[group].data.size(); ++var) {
const int n = CCTK_FirstVarIndexI(group) + var;
- switch (CCTK_VarTypeI(n)) {
-#define TYPECASE(N,T) \
- case N: \
- delete (gf<T,dim>*)arrdata[group].data[var]; \
+ switch (CCTK_GroupDimI(group)) {
+ case 1: {
+ const int dim=1;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ delete (gf<T,dim>*)arrdata[group].data[var]; \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
break;
+ }
+ case 2: {
+ const int dim=2;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ delete (gf<T,dim>*)arrdata[group].data[var]; \
+ break;
#include "typecase"
#undef TYPECASE
- default:
- UnsupportedVarType(n);
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ case 3: {
+ const int dim=3;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ delete (gf<T,dim>*)arrdata[group].data[var]; \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ default: abort();
}
arrdata[group].data[var] = 0;
}
@@ -873,15 +1019,50 @@ namespace Carpet {
}
for (int var=0; var<(int)gfdata[group].data.size(); ++var) {
const int n = CCTK_FirstVarIndexI(group) + var;
- switch (CCTK_VarTypeI(n)) {
+ switch (CCTK_GroupDimI(group)) {
+ case 1: {
+ const int dim=1;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ delete (gf<T,dim>*)gfdata[group].data[var]; \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ case 2: {
+ const int dim=2;
+ switch (CCTK_VarTypeI(n)) {
#define TYPECASE(N,T) \
- case N: \
- delete (gf<T,dim>*)gfdata[group].data[var]; \
+ case N: \
+ delete (gf<T,dim>*)gfdata[group].data[var]; \
+ break;
+#include "typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(n);
+ }
break;
+ }
+ case 3: {
+ const int dim=3;
+ switch (CCTK_VarTypeI(n)) {
+#define TYPECASE(N,T) \
+ case N: \
+ delete (gf<T,dim>*)gfdata[group].data[var]; \
+ break;
#include "typecase"
#undef TYPECASE
- default:
- UnsupportedVarType(n);
+ default:
+ UnsupportedVarType(n);
+ }
+ break;
+ }
+ default: abort();
}
gfdata[group].data[var] = 0;
}
@@ -921,6 +1102,7 @@ namespace Carpet {
assert (component == -1);
Checkpoint ("%*sRecompose", 2*reflevel, "");
+ const int dim = gfdim;
const int nprocs = CCTK_nProcs(cgh);
const int reflevels = max_refinement_levels; // arbitrary value
const int mglevels = 1; // arbitrary value
@@ -1141,6 +1323,8 @@ namespace Carpet {
}
assert (group>=0 && group<CCTK_NumGroups());
+ const int dim = CCTK_GroupDimI(group);
+
assert (dir>=0 && dir<dim);
if (CCTK_QueryGroupStorageI(cgh, group)) {
@@ -1273,6 +1457,7 @@ namespace Carpet {
case CCTK_GF: {
BEGIN_COMPONENT_LOOP(cgh) {
if (hh->is_local(reflevel,component)) {
+ const int dim = CCTK_GroupDimI(group);
int np = 1;
for (int d=0; d<dim; ++d) {
np *= *CCTK_ArrayGroupSizeI(cgh, d, group);
@@ -1345,6 +1530,7 @@ namespace Carpet {
case CCTK_GF: {
BEGIN_COMPONENT_LOOP(cgh) {
if (hh->is_local(reflevel,component)) {
+ const int dim = CCTK_GroupDimI(group);
int size[dim];
for (int d=0; d<dim; ++d) {
size[d] = *CCTK_ArrayGroupSizeI(cgh, d, group);
@@ -1485,6 +1671,7 @@ namespace Carpet {
case CCTK_GF: {
BEGIN_COMPONENT_LOOP(cgh) {
if (hh->is_local(reflevel,component)) {
+ const int dim = CCTK_GroupDimI(group);
int np = 1;
for (int d=0; d<dim; ++d) {
np *= *CCTK_ArrayGroupSizeI(cgh, d, group);
@@ -1566,6 +1753,7 @@ namespace Carpet {
BEGIN_COMPONENT_LOOP(cgh) {
if (checksums[n][reflevel][tl][component].valid) {
if (hh->is_local(reflevel,component)) {
+ const int dim = CCTK_GroupDimI(group);
int np = 1;
for (int d=0; d<dim; ++d) {
np *= *CCTK_ArrayGroupSizeI(cgh, d, group);
@@ -1685,6 +1873,7 @@ namespace Carpet {
// Change
reflevel = rl;
+ const int dim = gfdim;
const bbox<int,dim>& base = hh->baseextent;
reflevelfact = (int)floor(pow((double)hh->reffact, reflevel)+0.5);
cgh->cctk_delta_time = base_delta_time / reflevelfact;
@@ -1712,6 +1901,8 @@ namespace Carpet {
{
assert (c==-1 || (c>=0 && c<hh->components(reflevel)));
component = c;
+
+ const int dim = gfdim;
if (component == -1) {
// Global mode -- no component is active
@@ -1836,11 +2027,33 @@ namespace Carpet {
case CCTK_SCALAR:
break;
case CCTK_ARRAY: {
- const bbox<int,dim> ext =
- arrdata[group].dd->
- boxes[reflevel][component][mglevel].exterior;
- for (int d=0; d<dim; ++d) {
- arrdata[group].size[d] = ext.shape()[d] / ext.stride()[d];
+ switch (CCTK_GroupDimI(group)) {
+#define CODE \
+ do { \
+ const bbox<int,dim> ext = \
+ ((dh<dim>*)arrdata[group].dd)-> \
+ boxes[reflevel][component][mglevel].exterior; \
+ for (int d=0; d<dim; ++d) { \
+ arrdata[group].size[d] = ext.shape()[d] / ext.stride()[d]; \
+ } \
+ } while(0)
+ case 1: {
+ const int dim = 1;
+ CODE;
+ break;
+ }
+ case 2: {
+ const int dim = 1;
+ CODE;
+ break;
+ }
+ case 3: {
+ const int dim = 1;
+ CODE;
+ break;
+ }
+ default: abort();
+#undef CODE
}
break;
}
diff --git a/Carpet/Carpet/src/carpet.hh b/Carpet/Carpet/src/carpet.hh
index cca0ade8f..a221b300c 100644
--- a/Carpet/Carpet/src/carpet.hh
+++ b/Carpet/Carpet/src/carpet.hh
@@ -1,10 +1,13 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet.hh,v 1.9 2001/06/12 14:56:56 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet.hh,v 1.10 2001/07/02 13:22:10 schnetter Exp $
#include <vector>
#include "cctk.h"
#include "cctk_Schedule.h"
+#include "Carpet/CarpetLib/src/dgdh.hh"
+#include "Carpet/CarpetLib/src/dggf.hh"
+#include "Carpet/CarpetLib/src/dggh.hh"
#include "Carpet/CarpetLib/src/dh.hh"
#include "Carpet/CarpetLib/src/ggf.hh"
#include "Carpet/CarpetLib/src/gh.hh"
@@ -14,7 +17,8 @@ namespace Carpet {
- const int dim = 3;
+ const int maxdim = 3;
+ const int gfdim = 3;
@@ -51,24 +55,25 @@ namespace Carpet {
// Data for arrays
struct arrdesc {
- gh<dim>* hh;
+ int dim;
+ dimgeneric_gh* hh;
th* tt;
- dh<dim>* dd;
- vector<generic_gf<dim>* > data; // [var]
- int size[dim];
+ dimgeneric_dh* dd;
+ vector<dimgeneric_gf* > data; // [var]
+ int size[maxdim];
};
extern vector<arrdesc> arrdata; // [group]
// Data for grid functions
// The grid hierarchy
- extern gh<dim>* hh;
+ extern gh<gfdim>* hh;
extern th* tt;
- extern dh<dim>* dd;
- extern int gfsize[dim];
+ extern dh<gfdim>* dd;
+ extern int gfsize[gfdim];
struct gfdesc {
- vector<generic_gf<dim>* > data; // [var]
+ vector<dimgeneric_gf* > data; // [var]
};
extern vector<gfdesc> gfdata; // [group]
diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc
index 9957b7620..674bf9361 100644
--- a/Carpet/CarpetIOASCII/src/ioascii.cc
+++ b/Carpet/CarpetIOASCII/src/ioascii.cc
@@ -24,7 +24,7 @@
#include "ioascii.hh"
-static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.12 2001/04/23 08:10:13 schnetter Exp $";
+static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.13 2001/07/02 13:22:10 schnetter Exp $";
@@ -253,103 +253,229 @@ int CarpetIOASCII<outdim>
}
}
- // Find the output offset
- vect<int,dim> offset(0);
- switch (outdim) {
- case 1:
- switch (dirs[0]) {
- case 0:
- offset[1] = GetGridOffset (cgh, 2,
- "out%dD_xline_yi", "out_xline_yi",
- "out%dD_xline_y", "out_xline_y",
- out_xline_y);
- offset[2] = GetGridOffset (cgh, 3,
- "out%dD_xline_zi", "out_xline_zi",
- "out%dD_xline_z", "out_xline_z",
- out_xline_z);
- break;
+ switch (CCTK_GroupDimI(group)) {
+
+ case 1: {
+ const int dim=1;
+
+ // Find the output offset
+ vect<int,dim> offset(0);
+ switch (outdim) {
case 1:
- offset[0] = GetGridOffset (cgh, 1,
- "out%dD_yline_xi", "out_yline_xi",
- "out%dD_yline_x", "out_yline_x",
- out_yline_x);
- offset[2] = GetGridOffset (cgh, 3,
- "out%dD_yline_zi", "out_yline_zi",
- "out%dD_yline_z", "out_yline_z",
- out_yline_z);
- break;
- case 2:
- offset[0] = GetGridOffset (cgh, 1,
- "out%dD_zline_xi", "out_zline_xi",
- "out%dD_zline_x", "out_zline_x",
- out_zline_x);
- offset[1] = GetGridOffset (cgh, 2,
- "out%dD_zline_yi", "out_zline_yi",
- "out%dD_zline_y", "out_zline_y",
- out_zline_y);
+ // The offset doesn't matter in this case
break;
default:
abort();
}
+
+ // Traverse all components on this refinement and
+ // multigrid level
+ BEGIN_COMPONENT_LOOP(cgh) {
+
+ generic_gf<dim>* ff = 0;
+
+ switch (CCTK_GroupTypeI(group)) {
+
+ case CCTK_ARRAY:
+ assert (var < (int)arrdata[group].data.size());
+ ff = (generic_gf<dim>*)arrdata[group].data[var];
+ break;
+
+ case CCTK_GF:
+ assert (var < (int)gfdata[group].data.size());
+ ff = (generic_gf<dim>*)gfdata[group].data[var];
+ break;
+
+ default:
+ abort();
+ }
+
+ const generic_data<dim>* const data
+ = (*ff) (tl, reflevel, component, mglevel);
+ const bbox<int,dim> ext = data->extent();
+ const vect<int,dim> offset1 = offset * ext.stride();
+
+ data->write_ascii (filename, cgh->cctk_iteration, offset1, dirs,
+ tl, reflevel, component, mglevel);
+
+ } END_COMPONENT_LOOP(cgh);
break;
- case 2:
- if (dirs[0]==0 && dirs[1]==1) {
- offset[2] = GetGridOffset (cgh, 3,
- "out%dD_xyplane_zi", "out_xyplane_zi",
- "out%dD_xyplane_z", "out_xyplane_z",
- out_xyplane_z);
- } else if (dirs[0]==0 && dirs[1]==2) {
- offset[1] = GetGridOffset (cgh, 2,
- "out%dD_xzplane_yi", "out_xzplane_yi",
- "out%dD_xzplane_y", "out_xzplane_y",
- out_xzplane_y);
- } else if (dirs[0]==1 && dirs[1]==2) {
- offset[0] = GetGridOffset (cgh, 1,
- "out%dD_yzplane_xi", "out_yzplane_xi",
- "out%dD_yzplane_x", "out_yzplane_x",
- out_yzplane_x);
- } else {
+ }
+
+ case 2: {
+ const int dim=2;
+
+ // Find the output offset
+ vect<int,dim> offset(0);
+ switch (outdim) {
+ case 1:
+ switch (dirs[0]) {
+ case 0:
+ offset[1] = GetGridOffset (cgh, 2,
+ "out%dD_xline_yi", "out_xline_yi",
+ "out%dD_xline_y", "out_xline_y",
+ out_xline_y);
+ break;
+ case 1:
+ offset[0] = GetGridOffset (cgh, 1,
+ "out%dD_yline_xi", "out_yline_xi",
+ "out%dD_yline_x", "out_yline_x",
+ out_yline_x);
+ break;
+ default:
+ abort();
+ }
+ break;
+ case 2:
+ // The offset doesn't matter in this case
+ break;
+ default:
abort();
}
+
+ // Traverse all components on this refinement and
+ // multigrid level
+ BEGIN_COMPONENT_LOOP(cgh) {
+
+ generic_gf<dim>* ff = 0;
+
+ switch (CCTK_GroupTypeI(group)) {
+
+ case CCTK_ARRAY:
+ assert (var < (int)arrdata[group].data.size());
+ ff = (generic_gf<dim>*)arrdata[group].data[var];
+ break;
+
+ case CCTK_GF:
+ assert (var < (int)gfdata[group].data.size());
+ ff = (generic_gf<dim>*)gfdata[group].data[var];
+ break;
+
+ default:
+ abort();
+ }
+
+ const generic_data<dim>* const data
+ = (*ff) (tl, reflevel, component, mglevel);
+ const bbox<int,dim> ext = data->extent();
+ const vect<int,dim> offset1 = offset * ext.stride();
+
+ data->write_ascii (filename, cgh->cctk_iteration, offset1, dirs,
+ tl, reflevel, component, mglevel);
+
+ } END_COMPONENT_LOOP(cgh);
break;
- case 3:
- // The offset doesn't matter in this case
- break;
- default:
- abort();
}
-
- // Traverse all components on this refinement and multigrid
- // level
- BEGIN_COMPONENT_LOOP(cgh) {
- generic_gf<dim>* ff = 0;
+ case 3: {
+ const int dim=3;
- switch (CCTK_GroupTypeI(group)) {
-
- case CCTK_ARRAY:
- assert (var < (int)arrdata[group].data.size());
- ff = arrdata[group].data[var];
+ // Find the output offset
+ vect<int,dim> offset(0);
+ switch (outdim) {
+ case 1:
+ switch (dirs[0]) {
+ case 0:
+ offset[1] = GetGridOffset (cgh, 2,
+ "out%dD_xline_yi", "out_xline_yi",
+ "out%dD_xline_y", "out_xline_y",
+ out_xline_y);
+ offset[2] = GetGridOffset (cgh, 3,
+ "out%dD_xline_zi", "out_xline_zi",
+ "out%dD_xline_z", "out_xline_z",
+ out_xline_z);
+ break;
+ case 1:
+ offset[0] = GetGridOffset (cgh, 1,
+ "out%dD_yline_xi", "out_yline_xi",
+ "out%dD_yline_x", "out_yline_x",
+ out_yline_x);
+ offset[2] = GetGridOffset (cgh, 3,
+ "out%dD_yline_zi", "out_yline_zi",
+ "out%dD_yline_z", "out_yline_z",
+ out_yline_z);
+ break;
+ case 2:
+ offset[0] = GetGridOffset (cgh, 1,
+ "out%dD_zline_xi", "out_zline_xi",
+ "out%dD_zline_x", "out_zline_x",
+ out_zline_x);
+ offset[1] = GetGridOffset (cgh, 2,
+ "out%dD_zline_yi", "out_zline_yi",
+ "out%dD_zline_y", "out_zline_y",
+ out_zline_y);
+ break;
+ default:
+ abort();
+ }
break;
-
- case CCTK_GF:
- assert (var < (int)gfdata[group].data.size());
- ff = gfdata[group].data[var];
+ case 2:
+ if (dirs[0]==0 && dirs[1]==1) {
+ offset[2] = GetGridOffset
+ (cgh, 3,
+ "out%dD_xyplane_zi", "out_xyplane_zi",
+ "out%dD_xyplane_z", "out_xyplane_z",
+ out_xyplane_z);
+ } else if (dirs[0]==0 && dirs[1]==2) {
+ offset[1] = GetGridOffset
+ (cgh, 2,
+ "out%dD_xzplane_yi", "out_xzplane_yi",
+ "out%dD_xzplane_y", "out_xzplane_y",
+ out_xzplane_y);
+ } else if (dirs[0]==1 && dirs[1]==2) {
+ offset[0] = GetGridOffset
+ (cgh, 1,
+ "out%dD_yzplane_xi", "out_yzplane_xi",
+ "out%dD_yzplane_x", "out_yzplane_x",
+ out_yzplane_x);
+ } else {
+ abort();
+ }
+ break;
+ case 3:
+ // The offset doesn't matter in this case
break;
-
default:
abort();
}
- const generic_data<dim>* const data
- = (*ff) (tl, reflevel, component, mglevel);
- const bbox<int,dim> ext = data->extent();
- const vect<int,dim> offset1 = offset * ext.stride();
+ // Traverse all components on this refinement and
+ // multigrid level
+ BEGIN_COMPONENT_LOOP(cgh) {
+
+ generic_gf<dim>* ff = 0;
+
+ switch (CCTK_GroupTypeI(group)) {
+
+ case CCTK_ARRAY:
+ assert (var < (int)arrdata[group].data.size());
+ ff = (generic_gf<dim>*)arrdata[group].data[var];
+ break;
+
+ case CCTK_GF:
+ assert (var < (int)gfdata[group].data.size());
+ ff = (generic_gf<dim>*)gfdata[group].data[var];
+ break;
+
+ default:
+ abort();
+ }
+
+ const generic_data<dim>* const data
+ = (*ff) (tl, reflevel, component, mglevel);
+ const bbox<int,dim> ext = data->extent();
+ const vect<int,dim> offset1 = offset * ext.stride();
+
+ data->write_ascii (filename, cgh->cctk_iteration, offset1, dirs,
+ tl, reflevel, component, mglevel);
+
+ } END_COMPONENT_LOOP(cgh);
+ break;
+ }
- data->write_ascii (filename, cgh->cctk_iteration, offset1, dirs,
- tl, reflevel, component, mglevel);
+ default: abort();
- } END_COMPONENT_LOOP(cgh);
+ } // switch (CCTK_GroupDimI(group))
// Append EOL after every complete set of components
if (CCTK_MyProc(cgh)==0) {
@@ -367,7 +493,7 @@ int CarpetIOASCII<outdim>
// Next direction combination
for (int d=0; d<outdim; ++d) {
++dirs[d];
- if (dirs[d]<dim) goto notyetdone;
+ if (dirs[d]<CCTK_GroupDimI(group)) goto notyetdone;
dirs[d] = 0;
}
break;
diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc
index 78227a3b8..337857826 100644
--- a/Carpet/CarpetLib/src/bbox.cc
+++ b/Carpet/CarpetLib/src/bbox.cc
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.6 2001/03/27 22:26:31 eschnett Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.7 2001/07/02 13:22:11 schnetter Exp $
***************************************************************************/
@@ -234,7 +234,10 @@ void bbox<T,D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
+
+// Note: We need all dimensions all the time.
template class bbox<int,1>;
template class bbox<int,2>;
template class bbox<int,3>;
+
#endif
diff --git a/Carpet/CarpetLib/src/bboxset.cc b/Carpet/CarpetLib/src/bboxset.cc
index 3976dfb2c..835a46e96 100644
--- a/Carpet/CarpetLib/src/bboxset.cc
+++ b/Carpet/CarpetLib/src/bboxset.cc
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.cc,v 1.6 2001/03/27 22:26:31 eschnett Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.cc,v 1.7 2001/07/02 13:22:12 schnetter Exp $
***************************************************************************/
@@ -302,5 +302,9 @@ void bboxset<T,D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
+
+template class bboxset<int,1>;
+template class bboxset<int,2>;
template class bboxset<int,3>;
+
#endif
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc
index bbc925d91..d95f0dd6f 100644
--- a/Carpet/CarpetLib/src/data.cc
+++ b/Carpet/CarpetLib/src/data.cc
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.11 2001/03/30 00:50:20 eschnett Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.12 2001/07/02 13:22:12 schnetter Exp $
***************************************************************************/
@@ -586,6 +586,8 @@ ostream& data<T,D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
#define INSTANTIATE(T) \
+template class data<T,1>; \
+template class data<T,2>; \
template class data<T,3>;
#include "instantiate"
diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc
index b73796e54..d2fed76b5 100644
--- a/Carpet/CarpetLib/src/defs.cc
+++ b/Carpet/CarpetLib/src/defs.cc
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.5 2001/03/27 22:26:31 eschnett Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.6 2001/07/02 13:22:12 schnetter Exp $
***************************************************************************/
@@ -76,6 +76,20 @@ ostream& output (ostream& os, const vector<T>& v) {
#include "bbox.hh"
#include "bboxset.hh"
+template ostream& output (ostream& os, const list<bbox<int,1> >& l);
+template ostream& output (ostream& os, const set<bbox<int,1> >& s);
+template ostream& output (ostream& os, const set<bboxset<int,1> >& s);
+template ostream& output (ostream& os, const vector<list<bbox<int,1> > >& v);
+template ostream& output (ostream& os, const vector<vector<bbox<int,1> > >& v);
+template ostream& output (ostream& os, const vector<vector<vector<bbox<int,1> > > >& v);
+
+template ostream& output (ostream& os, const list<bbox<int,2> >& l);
+template ostream& output (ostream& os, const set<bbox<int,2> >& s);
+template ostream& output (ostream& os, const set<bboxset<int,2> >& s);
+template ostream& output (ostream& os, const vector<list<bbox<int,2> > >& v);
+template ostream& output (ostream& os, const vector<vector<bbox<int,2> > >& v);
+template ostream& output (ostream& os, const vector<vector<vector<bbox<int,2> > > >& v);
+
template ostream& output (ostream& os, const list<bbox<int,3> >& l);
template ostream& output (ostream& os, const set<bbox<int,3> >& s);
template ostream& output (ostream& os, const set<bboxset<int,3> >& s);
diff --git a/Carpet/CarpetLib/src/dggf.hh b/Carpet/CarpetLib/src/dggf.hh
index 31a2cc1fc..76727afee 100644
--- a/Carpet/CarpetLib/src/dggf.hh
+++ b/Carpet/CarpetLib/src/dggf.hh
@@ -6,7 +6,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dggf.hh,v 1.1 2001/06/12 14:56:58 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dggf.hh,v 1.2 2001/07/02 13:22:13 schnetter Exp $
***************************************************************************/
@@ -76,6 +76,8 @@ public:
+ // TODO:
+
// are these necessary in dimgeneric_gf, or is it sufficient to have
// them in generic_gf<D>?
@@ -84,7 +86,6 @@ public:
// i likely also have to make a dimgeneric_data class.
-#if 0
// The grid boundaries have to be updated after calling mg_restrict,
// mg_prolongate, ref_restrict, or ref_prolongate.
@@ -116,15 +117,14 @@ public:
// Prolongate a refinement level
virtual void ref_prolongate (int tl, int rl, int c, int ml,
int order_space=1) = 0;
-#endif
// Access to the data
virtual const dimgeneric_data* operator() (int tl, int rl, int c, int ml)
- const;
+ const = 0;
- virtual dimgeneric_data* operator() (int tl, int rl, int c, int ml);
+ virtual dimgeneric_data* operator() (int tl, int rl, int c, int ml) = 0;
diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc
index 366f525a2..a22240ea8 100644
--- a/Carpet/CarpetLib/src/dh.cc
+++ b/Carpet/CarpetLib/src/dh.cc
@@ -6,7 +6,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.14 2001/06/12 14:56:59 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.15 2001/07/02 13:22:13 schnetter Exp $
***************************************************************************/
@@ -360,5 +360,7 @@ void dh<D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
+template class dh<1>;
+template class dh<2>;
template class dh<3>;
#endif
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc
index 84691b475..de80207c0 100644
--- a/Carpet/CarpetLib/src/gdata.cc
+++ b/Carpet/CarpetLib/src/gdata.cc
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.12 2001/06/12 14:56:59 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.13 2001/07/02 13:22:13 schnetter Exp $
***************************************************************************/
@@ -141,6 +141,8 @@ void generic_data<D>::write_ascii (const string name, const int time,
assert (_has_storage);
CHECKPOINT;
+ assert (DD<=D);
+
if (proc()==0) {
// output on processor 0
@@ -213,6 +215,41 @@ void generic_data<D>::write_ascii (const string name, const int time,
#if defined(TMPL_EXPLICIT)
+
+template class generic_data<1>;
+
+template void generic_data<1>
+::write_ascii (const string name, const int time,
+ const vect<int,1>& org, const vect<int,1>& dirs,
+ const int tl, const int rl, const int c, const int ml) const;
+template void generic_data<1>
+::write_ascii (const string name, const int time,
+ const vect<int,1>& org, const vect<int,2>& dirs,
+ const int tl, const int rl, const int c, const int ml) const;
+template void generic_data<1>
+::write_ascii (const string name, const int time,
+ const vect<int,1>& org, const vect<int,3>& dirs,
+ const int tl, const int rl, const int c, const int ml) const;
+
+
+
+template class generic_data<2>;
+
+template void generic_data<2>
+::write_ascii (const string name, const int time,
+ const vect<int,2>& org, const vect<int,1>& dirs,
+ const int tl, const int rl, const int c, const int ml) const;
+template void generic_data<2>
+::write_ascii (const string name, const int time,
+ const vect<int,2>& org, const vect<int,2>& dirs,
+ const int tl, const int rl, const int c, const int ml) const;
+template void generic_data<2>
+::write_ascii (const string name, const int time,
+ const vect<int,2>& org, const vect<int,3>& dirs,
+ const int tl, const int rl, const int c, const int ml) const;
+
+
+
template class generic_data<3>;
template void generic_data<3>
@@ -227,4 +264,5 @@ template void generic_data<3>
::write_ascii (const string name, const int time,
const vect<int,3>& org, const vect<int,3>& dirs,
const int tl, const int rl, const int c, const int ml) const;
+
#endif
diff --git a/Carpet/CarpetLib/src/gf.cc b/Carpet/CarpetLib/src/gf.cc
index d7b183cd8..42743ff29 100644
--- a/Carpet/CarpetLib/src/gf.cc
+++ b/Carpet/CarpetLib/src/gf.cc
@@ -6,7 +6,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.cc,v 1.5 2001/06/12 14:56:59 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.cc,v 1.6 2001/07/02 13:22:14 schnetter Exp $
***************************************************************************/
@@ -80,6 +80,8 @@ ostream& gf<T,D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
#define INSTANTIATE(T) \
+template class gf<T,1>; \
+template class gf<T,2>; \
template class gf<T,3>;
#include "instantiate"
diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc
index b1af8103a..4afe6983b 100644
--- a/Carpet/CarpetLib/src/ggf.cc
+++ b/Carpet/CarpetLib/src/ggf.cc
@@ -6,7 +6,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.10 2001/06/12 14:56:59 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.11 2001/07/02 13:22:14 schnetter Exp $
***************************************************************************/
@@ -41,11 +41,11 @@ using namespace std;
template<int D>
generic_gf<D>::generic_gf (const string name, th& t, dh<D>& d,
const int tmin, const int tmax)
- : name(name), h(d.h), t(t), d(d), tmin(tmin), tmax(tmax),
+ : dimgeneric_gf(name, t, tmin, tmax),
+ h(d.h), d(d),
storage(tmax-tmin+1)
{
assert (t.h == &d.h);
- assert (tmin<=tmax+1);
d.add(this);
@@ -465,5 +465,7 @@ void generic_gf<D>::ref_prolongate (int tl, int rl, int c, int ml,
#if defined(TMPL_EXPLICIT)
+template class generic_gf<1>;
+template class generic_gf<2>;
template class generic_gf<3>;
#endif
diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh
index 44ea800f0..15d817b1b 100644
--- a/Carpet/CarpetLib/src/ggf.hh
+++ b/Carpet/CarpetLib/src/ggf.hh
@@ -6,7 +6,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.hh,v 1.6 2001/06/12 14:56:59 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.hh,v 1.7 2001/07/02 13:22:14 schnetter Exp $
***************************************************************************/
@@ -29,6 +29,7 @@
#include <vector>
#include "defs.hh"
+#include "dggf.hh"
#include "dh.hh"
#include "gdata.hh"
#include "gh.hh"
@@ -49,7 +50,7 @@ ostream& operator<< (ostream& os, const generic_gf<D>& f);
// A generic grid function without type information
template<int D>
-class generic_gf {
+class generic_gf: public dimgeneric_gf {
// Types
@@ -68,12 +69,9 @@ class generic_gf {
public: // should be readonly
// Fields
- string name;
gh<D> &h; // grid hierarchy
- th &t; // time hierarchy
dh<D> &d; // data hierarchy
- int tmin, tmax; // timelevels
protected:
fdata storage; // storage
diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc
index ed2235f98..52f225e61 100644
--- a/Carpet/CarpetLib/src/gh.cc
+++ b/Carpet/CarpetLib/src/gh.cc
@@ -7,7 +7,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.7 2001/06/12 14:57:00 schnetter Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.8 2001/07/02 13:22:14 schnetter Exp $
***************************************************************************/
@@ -235,5 +235,9 @@ ostream& gh<D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
+
+template class gh<1>;
+template class gh<2>;
template class gh<3>;
+
#endif
diff --git a/Carpet/CarpetLib/src/make.code.defn b/Carpet/CarpetLib/src/make.code.defn
index f2c5d3cfc..b4f538fc2 100644
--- a/Carpet/CarpetLib/src/make.code.defn
+++ b/Carpet/CarpetLib/src/make.code.defn
@@ -1,8 +1,23 @@
# Main make.code.defn file for thorn CarpetLib -*-Makefile-*-
-# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/make.code.defn,v 1.5 2001/06/12 14:57:00 schnetter Exp $
+# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/make.code.defn,v 1.6 2001/07/02 13:22:14 schnetter Exp $
# Source files in this directory
-SRCS = bbox.cc bboxset.cc data.cc defs.cc dgdata.cc dgdh.cc dggh.cc dh.cc dist.cc gdata.cc gf.cc ggf.cc gh.cc th.cc vect.cc \
+SRCS = bbox.cc \
+ bboxset.cc \
+ data.cc \
+ defs.cc \
+ dgdata.cc \
+ dgdh.cc \
+ dggf.cc \
+ dggh.cc \
+ dh.cc \
+ dist.cc \
+ gdata.cc \
+ gf.cc \
+ ggf.cc \
+ gh.cc \
+ th.cc \
+ vect.cc \
copy_3d_real8.F77 \
prolongate_3d_real8.F77 \
prolongate_3d_real8_o3.F77 \
diff --git a/Carpet/CarpetLib/src/vect.cc b/Carpet/CarpetLib/src/vect.cc
index 1016151d8..9441e6676 100644
--- a/Carpet/CarpetLib/src/vect.cc
+++ b/Carpet/CarpetLib/src/vect.cc
@@ -5,7 +5,7 @@
copyright : (C) 2000 by Erik Schnetter
email : schnetter@astro.psu.edu
- $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.cc,v 1.4 2001/03/27 22:26:31 eschnett Exp $
+ $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.cc,v 1.5 2001/07/02 13:22:14 schnetter Exp $
***************************************************************************/
@@ -46,7 +46,10 @@ void vect<T,D>::output (ostream& os) const {
#if defined(TMPL_EXPLICIT)
+
+// Note: We need all dimensions all the time.
template class vect<int,1>;
template class vect<int,2>;
template class vect<int,3>;
+
#endif
diff --git a/Carpet/CarpetSlab/src/carpetslab.cc b/Carpet/CarpetSlab/src/carpetslab.cc
index 828cd7157..41cac072a 100644
--- a/Carpet/CarpetSlab/src/carpetslab.cc
+++ b/Carpet/CarpetSlab/src/carpetslab.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/Attic/carpetslab.cc,v 1.8 2001/05/16 14:29:47 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/Attic/carpetslab.cc,v 1.9 2001/07/02 13:22:15 schnetter Exp $
#include <alloca.h>
#include <assert.h>
@@ -18,7 +18,7 @@
#include "carpetslab.hh"
-static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/Attic/carpetslab.cc,v 1.8 2001/05/16 14:29:47 schnetter Exp $";
+static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/Attic/carpetslab.cc,v 1.9 2001/07/02 13:22:15 schnetter Exp $";
@@ -52,9 +52,6 @@ namespace CarpetSlab {
// Check destination processor
assert (dest_proc>=-1 && dest_proc<CCTK_nProcs(cgh));
- // Check dimension
- assert (hdim>=0 && hdim<=dim);
-
// Check variable index
assert (n>=0 && n<CCTK_NumVars());
@@ -69,11 +66,16 @@ namespace CarpetSlab {
// Get info about group
cGroup gp;
CCTK_GroupData (group, &gp);
- assert (gp.dim==dim);
+ assert (gp.dim<=maxdim);
assert (CCTK_QueryGroupStorageI(cgh, group));
const int typesize = CCTK_VarTypeSize(gp.vartype);
assert (typesize>0);
+ const int dim = gp.dim;
+
+ // Check dimension
+ assert (hdim>=0 && hdim<=gp.dim);
+
// Check timelevel
const int num_tl = gp.numtimelevels;
assert (ti>=0 && ti<num_tl);
@@ -105,9 +107,9 @@ namespace CarpetSlab {
// }
// Get insider information about variable
- const gh<dim>* myhh;
- const dh<dim>* mydd;
- const generic_gf<dim>* myff;
+ const dimgeneric_gh* myhh;
+ const dimgeneric_dh* mydd;
+ const dimgeneric_gf* myff;
switch (gp.grouptype) {
case CCTK_SCALAR:
abort();
@@ -120,7 +122,7 @@ namespace CarpetSlab {
break;
case CCTK_GF:
myhh = hh;
- mydd = Carpet::dd; // necessary for pre-ANSI C++ compilers
+ mydd = Carpet::dd; // dd is int dd above for old C++ compilers
assert (group < (int)gfdata.size());
assert (var < (int)gfdata[group].data.size());
myff = gfdata[group].data[var];
@@ -153,88 +155,129 @@ namespace CarpetSlab {
if (hh->components(reflevel) > 0) {
- // Only temporarily
- component = 0;
-
- // Get sample data
- const generic_data<dim>* mydata;
- mydata = (*myff)(tl, reflevel, component, mglevel);
-
- // Stride of data in memory
- const vect<int,dim> str = mydata->extent().stride();
-
- // Stride of collected data
- vect<int,dim> hstr = str;
- for (int dd=0; dd<hdim; ++dd) {
- hstr[dirs[dd]-1] *= stride[dd];
- }
-
- // Lower bound of collected data
- vect<int,dim> hlb;
- for (int d=0; d<dim; ++d) {
- hlb[d] = origin[d] * str[d];
+ switch (CCTK_GroupDimI(group)) {
+
+#define CODE \
+ do { \
+ \
+ /* convert types */ \
+ const gh<dim>* myhh1 = dynamic_cast<const gh<dim>*>(myhh); \
+ const dh<dim>* mydd1 = dynamic_cast<const dh<dim>*>(mydd); \
+ const generic_gf<dim>* myff1 \
+ = dynamic_cast<const generic_gf<dim>*>(myff); \
+ \
+ /* Only temporarily */ \
+ component = 0; \
+ \
+ /* Get sample data */ \
+ const generic_data<dim>* mydata; \
+ mydata = (*myff1)(tl, reflevel, component, mglevel); \
+ \
+ /* Stride of data in memory */ \
+ const vect<int,dim> str = mydata->extent().stride(); \
+ \
+ /* Stride of collected data */ \
+ vect<int,dim> hstr = str; \
+ for (int dd=0; dd<hdim; ++dd) { \
+ hstr[dirs[dd]-1] *= stride[dd]; \
+ } \
+ \
+ /* Lower bound of collected data */ \
+ vect<int,dim> hlb; \
+ for (int d=0; d<dim; ++d) { \
+ hlb[d] = origin[d] * str[d]; \
+ } \
+ \
+ /* Upper bound of collected data */ \
+ vect<int,dim> hub = hlb; \
+ for (int dd=0; dd<hdim; ++dd) { \
+ hub[dirs[dd]-1] += (length[dd]-1) * hstr[dirs[dd]-1]; \
+ } \
+ \
+ /* Calculate extent to collect */ \
+ const bbox<int,dim> hextent (hlb, hub, hstr); \
+ assert (hextent.num_points() == totalsize); \
+ \
+ /* Create collector data object */ \
+ void* myhdata = rank==collect_proc ? hdata : 0; \
+ generic_data<dim>* const alldata = mydata->make_typed(); \
+ alldata->allocate (hextent, collect_proc, myhdata); \
+ \
+ /* Done with the temporary stuff */ \
+ mydata = 0; \
+ component = -1; \
+ \
+ /* Loop over all components, copying data from them */ \
+ assert (component == -1); \
+ for (component=0; \
+ component<hh->components(reflevel); \
+ ++component) { \
+ \
+ /* Get data object */ \
+ mydata = (*myff1)(tl, reflevel, component, mglevel); \
+ \
+ /* Calculate overlapping extents */ \
+ const bboxset<int,dim> myextents \
+ = ((mydd1->boxes[reflevel][component][mglevel].sync_not \
+ | mydd1->boxes[reflevel][component][mglevel].interior) \
+ & hextent); \
+ \
+ /* Loop over overlapping extents */ \
+ for (bboxset<int,dim>::const_iterator \
+ ext_iter = myextents.begin(); \
+ ext_iter != myextents.end(); \
+ ++ext_iter) { \
+ \
+ /* Copy data */ \
+ alldata->copy_from (mydata, *ext_iter); \
+ \
+ } \
+ \
+ } /* Loop over components */ \
+ component = -1; \
+ \
+ /* Copy result to all processors */ \
+ if (dest_proc == -1) { \
+ for (int proc=0; proc<CCTK_nProcs(cgh); ++proc) { \
+ if (proc != collect_proc) { \
+ \
+ void* myhdata = rank==proc ? hdata : 0; \
+ generic_data<dim>* const tmpdata = mydata->make_typed(); \
+ tmpdata->allocate (alldata->extent(), proc, myhdata); \
+ tmpdata->copy_from (alldata, alldata->extent()); \
+ delete tmpdata; \
+ \
+ } \
+ } \
+ } /* Copy result */ \
+ \
+ delete alldata; \
+ \
+ } while(0)
+
+ case 1: {
+ const int dim=1;
+ CODE;
+ break;
}
-
- // Upper bound of collected data
- vect<int,dim> hub = hlb;
- for (int dd=0; dd<hdim; ++dd) {
- hub[dirs[dd]-1] += (length[dd]-1) * hstr[dirs[dd]-1];
+
+ case 2: {
+ const int dim=2;
+ CODE;
+ break;
}
-
- // Calculate extent to collect
- const bbox<int,dim> hextent (hlb, hub, hstr);
- assert (hextent.num_points() == totalsize);
-
- // Create collector data object
- void* myhdata = rank==collect_proc ? hdata : 0;
- generic_data<dim>* const alldata = mydata->make_typed();
- alldata->allocate (hextent, collect_proc, myhdata);
-
- // Done with the temporary stuff
- mydata = 0;
- component = -1;
-
- // Loop over all components, copying data from them
- assert (component == -1);
- for (component=0; component<hh->components(reflevel); ++component) {
- // Get data object
- mydata = (*myff)(tl, reflevel, component, mglevel);
+ case 3: {
+ const int dim=3;
+ CODE;
+ break;
+ }
- // Calculate overlapping extents
- const bboxset<int,dim> myextents
- = ((mydd->boxes[reflevel][component][mglevel].sync_not
- | mydd->boxes[reflevel][component][mglevel].interior)
- & hextent);
+ default: abort();
- // Loop over overlapping extents
- for (bboxset<int,dim>::const_iterator ext_iter = myextents.begin();
- ext_iter != myextents.end(); ++ext_iter) {
-
- // Copy data
- alldata->copy_from (mydata, *ext_iter);
-
- }
+#undef CODE
- } // Loop over components
- component = -1;
-
- // Copy result to all processors
- if (dest_proc == -1) {
- for (int proc=0; proc<CCTK_nProcs(cgh); ++proc) {
- if (proc != collect_proc) {
-
- void* myhdata = rank==proc ? hdata : 0;
- generic_data<dim>* const tmpdata = mydata->make_typed();
- tmpdata->allocate (alldata->extent(), proc, myhdata);
- tmpdata->copy_from (alldata, alldata->extent());
- delete tmpdata;
-
- }
- }
- } // Copy result
-
- delete alldata;
+ } // switch
} // if components>0
@@ -259,6 +302,9 @@ namespace CarpetSlab {
void** const hdata,
int hsize [/*hdim*/])
{
+ const int dim = CCTK_GroupDimFromVarI(vindex);
+ assert (dim>=1 && dim<=maxdim);
+
// Check some arguments
assert (hdim>=0 && hdim<=dim);