aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <>2003-10-14 14:39:00 +0000
committerschnetter <>2003-10-14 14:39:00 +0000
commitfad00e54fbb8c02501d69318ad9a273bd426297a (patch)
treedec086d7cdf464cbb379c5488b7668c8f9b385f8
parent4aa9136c5d2e909262f1d8ff84e32e936be97a28 (diff)
Make gf and data objects store a Cactus variable index that this
Make gf and data objects store a Cactus variable index that this object is associated with. This can be used to access various kinds of information, e.g. variable names. darcs-hash:20031014143916-07bb3-678d114393008db7790b5ed72d6462673414c06a.gz
-rw-r--r--Carpet/Carpet/src/Storage.cc16
-rw-r--r--Carpet/CarpetIOASCII/src/ioascii.cc4
-rw-r--r--Carpet/CarpetInterp/src/interp.cc8
-rw-r--r--Carpet/CarpetLib/src/data.cc29
-rw-r--r--Carpet/CarpetLib/src/data.hh8
-rw-r--r--Carpet/CarpetLib/src/gdata.cc11
-rw-r--r--Carpet/CarpetLib/src/gdata.hh10
-rw-r--r--Carpet/CarpetLib/src/gf.cc10
-rw-r--r--Carpet/CarpetLib/src/gf.hh6
-rw-r--r--Carpet/CarpetLib/src/ggf.cc6
-rw-r--r--Carpet/CarpetLib/src/ggf.hh8
-rw-r--r--Carpet/CarpetSlab/src/slab.cc8
-rw-r--r--CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc4
13 files changed, 66 insertions, 62 deletions
diff --git a/Carpet/Carpet/src/Storage.cc b/Carpet/Carpet/src/Storage.cc
index 344be658a..e2d05efd4 100644
--- a/Carpet/Carpet/src/Storage.cc
+++ b/Carpet/Carpet/src/Storage.cc
@@ -10,7 +10,7 @@
#include "carpet.hh"
extern "C" {
- static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Storage.cc,v 1.27 2003/09/19 16:08:37 schnetter Exp $";
+ static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Storage.cc,v 1.28 2003/10/14 16:39:16 schnetter Exp $";
CCTK_FILEVERSION(Carpet_Carpet_Storage_cc);
}
@@ -100,13 +100,13 @@ namespace Carpet {
for (int var=0; var<(int)arrdata[group].data.size(); ++var) {
const int n = n0 + var;
switch (CCTK_VarTypeI(n)) {
-#define TYPECASE(N,T) \
- case N: \
- assert (! arrdata[group].data[var]); \
- /* VGF */ \
- arrdata[group].data[var] = new gf<T,dim> \
- (CCTK_VarName(n), *arrdata[group].tt, *arrdata[group].dd, \
- tmin, tmax, my_prolongation_order_time); \
+#define TYPECASE(N,T) \
+ case N: \
+ assert (! arrdata[group].data[var]); \
+ /* VGF */ \
+ arrdata[group].data[var] = new gf<T,dim> \
+ (n, *arrdata[group].tt, *arrdata[group].dd, \
+ tmin, tmax, my_prolongation_order_time); \
break;
#include "typecase"
#undef TYPECASE
diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc
index e5ff80eed..896fcce42 100644
--- a/Carpet/CarpetIOASCII/src/ioascii.cc
+++ b/Carpet/CarpetIOASCII/src/ioascii.cc
@@ -30,7 +30,7 @@
#include "ioascii.hh"
extern "C" {
- static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.52 2003/08/08 14:35:48 tradke Exp $";
+ static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.53 2003/10/14 16:39:16 schnetter Exp $";
CCTK_FILEVERSION(Carpet_CarpetIOASCII_ioascii_cc);
}
@@ -827,7 +827,7 @@ namespace CarpetIOASCII {
} else {
// copy to processor 0 and output there
- gdata<D>* const tmp = gfdata->make_typed();
+ gdata<D>* const tmp = gfdata->make_typed(vi);
tmp->allocate(gfdata->extent(), 0);
tmp->copy_from (gfdata, gfdata->extent());
WriteASCII (os, tmp, gfext, vi, time, org, dirs, tl, rl, c, ml,
diff --git a/Carpet/CarpetInterp/src/interp.cc b/Carpet/CarpetInterp/src/interp.cc
index dd8e3c5d7..75ae5675d 100644
--- a/Carpet/CarpetInterp/src/interp.cc
+++ b/Carpet/CarpetInterp/src/interp.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.12 2003/08/15 11:42:25 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.13 2003/10/14 16:39:16 schnetter Exp $
#include <assert.h>
#include <math.h>
@@ -19,7 +19,7 @@
#include "interp.hh"
extern "C" {
- static char const * const rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.12 2003/08/15 11:42:25 schnetter Exp $";
+ static char const * const rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.13 2003/10/14 16:39:16 schnetter Exp $";
CCTK_FILEVERSION(Carpet_CarpetInterp_interp_cc);
}
@@ -211,7 +211,7 @@ namespace CarpetInterp {
// Create coordinate patches
- vector<data<CCTK_REAL,dim> > allcoords (nprocs * (maxrl-minrl) * maxncomps);
+ vector<data<CCTK_REAL,dim> > allcoords (nprocs * (maxrl-minrl) * maxncomps, -1);
for (int p=0; p<nprocs; ++p) {
for (int rl=minrl; rl<maxrl; ++rl) {
for (int c=0; c<hh->components(rl); ++c) {
@@ -262,7 +262,7 @@ namespace CarpetInterp {
// Create output patches
- vector<data<CCTK_REAL,dim> > alloutputs (nprocs * (maxrl-minrl) * maxncomps);
+ vector<data<CCTK_REAL,dim> > alloutputs (nprocs * (maxrl-minrl) * maxncomps, -1);
for (int p=0; p<nprocs; ++p) {
for (int rl=minrl; rl<maxrl; ++rl) {
for (int c=0; c<hh->components(rl); ++c) {
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc
index 315a83361..da9b54b2b 100644
--- a/Carpet/CarpetLib/src/data.cc
+++ b/Carpet/CarpetLib/src/data.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.29 2003/08/28 21:27:03 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.30 2003/10/14 16:39:16 schnetter Exp $
#include <assert.h>
#include <limits.h>
@@ -23,15 +23,17 @@ using namespace std;
// Constructors
template<class T, int D>
-data<T,D>::data ()
- : _storage(0)
+data<T,D>::data (const int varindex_)
+ : gdata<D>(varindex_),
+ _storage(0)
{ }
template<class T, int D>
-data<T,D>::data (const ibbox& extent, const int proc)
- : _storage(0)
+data<T,D>::data (const int varindex_, const ibbox& extent_, const int proc_)
+ : gdata<D>(varindex_),
+ _storage(0)
{
- allocate(extent, proc);
+ allocate(extent_, proc_);
}
// Destructors
@@ -42,20 +44,20 @@ data<T,D>::~data () {
// Pseudo constructors
template<class T, int D>
-data<T,D>* data<T,D>::make_typed () const {
- return new data();
+data<T,D>* data<T,D>::make_typed (const int varindex_) const {
+ return new data(varindex_);
}
// Storage management
template<class T, int D>
-void data<T,D>::allocate (const ibbox& extent, const int proc,
+void data<T,D>::allocate (const ibbox& extent_, const int proc_,
void* const mem) {
assert (!this->_has_storage);
this->_has_storage = true;
// data
- this->_extent = extent;
+ this->_extent = extent_;
this->_shape = max(ivect(0), this->_extent.shape() / this->_extent.stride());
this->_size = 1;
for (int d=0; d<D; ++d) {
@@ -63,7 +65,7 @@ void data<T,D>::allocate (const ibbox& extent, const int proc,
assert (this->_shape[d]==0 || this->_size <= INT_MAX / this->_shape[d]);
this->_size *= this->_shape[d];
}
- this->_proc = proc;
+ this->_proc = proc_;
int rank;
MPI_Comm_rank (dist::comm, &rank);
if (rank==this->_proc) {
@@ -90,7 +92,7 @@ void data<T,D>::transfer_from (gdata<D>* gsrc) {
data* src = (data*)gsrc;
assert (!_storage);
*this = *src;
- *src = data();
+ *src = data(varindex);
}
@@ -580,9 +582,6 @@ void data<CCTK_REAL8,3>
// Output
template<class T,int D>
ostream& data<T,D>::output (ostream& os) const {
- // The IBM C++ compiler has a bug: when "this->size()" is changed to
- // "size()", it wants to use size(vect) instead, and complains about
- // the missing argument.
T Tdummy;
os << "data<" << typestring(Tdummy) << "," << D << ">:"
<< "extent=" << this->extent() << ","
diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh
index e395ebe06..f126c6c47 100644
--- a/Carpet/CarpetLib/src/data.hh
+++ b/Carpet/CarpetLib/src/data.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.hh,v 1.13 2003/08/28 21:27:03 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.hh,v 1.14 2003/10/14 16:39:16 schnetter Exp $
#ifndef DATA_HH
#define DATA_HH
@@ -34,14 +34,14 @@ class data: public gdata<D> {
public:
// Constructors
- data ();
- data (const ibbox& extent, const int proc);
+ data (const int varindex);
+ data (const int varindex, const ibbox& extent, const int proc);
// Destructors
virtual ~data ();
// Pseudo constructors
- virtual data* make_typed () const;
+ virtual data* make_typed (const int varindex) const;
// Storage management
virtual void allocate (const ibbox& extent, const int proc,
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc
index f17534838..e438a3147 100644
--- a/Carpet/CarpetLib/src/gdata.cc
+++ b/Carpet/CarpetLib/src/gdata.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.22 2003/02/25 22:57:00 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.23 2003/10/14 16:39:16 schnetter Exp $
#include <assert.h>
@@ -19,8 +19,9 @@ using namespace std;
// Constructors
template<int D>
-gdata<D>::gdata ()
- : _has_storage(false)
+gdata<D>::gdata (const int varindex_)
+ : varindex(varindex_),
+ _has_storage(false)
{ }
// Destructors
@@ -57,7 +58,7 @@ void gdata<D>::copy_from (const gdata* src, const ibbox& box)
} else {
// copy to different processor
- gdata* const tmp = make_typed();
+ gdata* const tmp = make_typed(varindex);
tmp->allocate (box, src->proc());
tmp->copy_from (src, box);
tmp->change_processor (proc());
@@ -105,7 +106,7 @@ void gdata<D>
} else {
// interpolate from other processor
- gdata* const tmp = make_typed();
+ gdata* const tmp = make_typed(varindex);
tmp->allocate (box, srcs[0]->proc());
tmp->interpolate_from (srcs, times, box, time, order_space, order_time);
tmp->change_processor (proc());
diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh
index 169a85757..75b12319e 100644
--- a/Carpet/CarpetLib/src/gdata.hh
+++ b/Carpet/CarpetLib/src/gdata.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.17 2003/05/02 15:59:18 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.18 2003/10/14 16:39:16 schnetter Exp $
#ifndef GDATA_HH
#define GDATA_HH
@@ -31,6 +31,8 @@ class gdata {
protected: // should be readonly
// Fields
+ int varindex; // Cactus variable index, or -1
+
bool _has_storage; // has storage associated (on some processor)
bool _owns_storage; // owns the storage
// (only valid if there is storage on this processor; it means that
@@ -42,17 +44,17 @@ protected: // should be readonly
ivect _shape, _stride; // shape and index order
ibbox _extent; // bbox for all data
-
+
public:
// Constructors
- gdata ();
+ gdata (const int varindex);
// Destructors
virtual ~gdata ();
// Pseudo constructors
- virtual gdata<D>* make_typed () const = 0;
+ virtual gdata<D>* make_typed (const int varindex) const = 0;
// Processor management
virtual void change_processor (const int newproc, void* const mem=0) = 0;
diff --git a/Carpet/CarpetLib/src/gf.cc b/Carpet/CarpetLib/src/gf.cc
index 5824bbcac..8de652672 100644
--- a/Carpet/CarpetLib/src/gf.cc
+++ b/Carpet/CarpetLib/src/gf.cc
@@ -1,7 +1,9 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.cc,v 1.12 2003/09/19 16:06:41 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.cc,v 1.13 2003/10/14 16:39:16 schnetter Exp $
#include <assert.h>
+#include "cctk.h"
+
#include "defs.hh"
#include "gf.hh"
@@ -13,9 +15,9 @@ using namespace std;
// Constructors
// VGF
template<class T,int D>
-gf<T,D>::gf (const string name, th<D>& t, dh<D>& d,
+gf<T,D>::gf (const int varindex, th<D>& t, dh<D>& d,
const int tmin, const int tmax, const int prolongation_order_time)
- : ggf<D>(name, t, d, tmin, tmax, prolongation_order_time)
+ : ggf<D>(varindex, t, d, tmin, tmax, prolongation_order_time)
{
// VGF
this->recompose();
@@ -53,7 +55,7 @@ template<class T,int D>
ostream& gf<T,D>::output (ostream& os) const {
T Tdummy;
os << "gf<" << typestring(Tdummy) << "," << D << ">:"
- << "\"" << this->name << "\","
+ << this->varindex << "[" << CCTK_VarName(this->varindex) << "],"
<< "dt=[" << this->tmin << ":" << this->tmax<< "]";
return os;
}
diff --git a/Carpet/CarpetLib/src/gf.hh b/Carpet/CarpetLib/src/gf.hh
index 20c84ceb6..f8242528b 100644
--- a/Carpet/CarpetLib/src/gf.hh
+++ b/Carpet/CarpetLib/src/gf.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.hh,v 1.8 2003/09/19 16:06:41 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.hh,v 1.9 2003/10/14 16:39:16 schnetter Exp $
#ifndef GF_HH
#define GF_HH
@@ -43,7 +43,7 @@ public:
// Constructors
// VGF
- gf (const string name, th<D>& t, dh<D>& d,
+ gf (const int varindex, th<D>& t, dh<D>& d,
const int tmin, const int tmax, const int prolongation_order_time);
// Destructors
@@ -55,7 +55,7 @@ public:
protected:
- virtual gdata<D>* typed_data() { return new data<T,D>; }
+ virtual gdata<D>* typed_data() { return new data<T,D>(varindex); }
diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc
index eacf99a10..a096ce0fb 100644
--- a/Carpet/CarpetLib/src/ggf.cc
+++ b/Carpet/CarpetLib/src/ggf.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.27 2003/09/19 16:06:41 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.28 2003/10/14 16:39:16 schnetter Exp $
#include <assert.h>
#include <stdlib.h>
@@ -20,10 +20,10 @@ using namespace std;
// Constructors
template<int D>
-ggf<D>::ggf (const string name, th<D>& t, dh<D>& d,
+ggf<D>::ggf (const int varindex, th<D>& t, dh<D>& d,
const int tmin, const int tmax,
const int prolongation_order_time)
- : name(name), t(t),
+ : varindex(varindex), t(t),
tmin(tmin), tmax(tmax),
prolongation_order_time(prolongation_order_time),
h(d.h), d(d),
diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh
index 8d3c90b3b..98c556800 100644
--- a/Carpet/CarpetLib/src/ggf.hh
+++ b/Carpet/CarpetLib/src/ggf.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.hh,v 1.15 2003/09/19 16:06:41 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.hh,v 1.16 2003/10/14 16:39:16 schnetter Exp $
#ifndef GGF_HH
#define GGF_HH
@@ -51,8 +51,8 @@ class ggf {
public: // should be readonly
// Fields
- string name;
-
+ int varindex; // Cactus variable index
+
th<D> &t; // time hierarchy
int tmin, tmax; // timelevels
int prolongation_order_time; // order of temporal prolongation operator
@@ -66,7 +66,7 @@ protected:
public:
// Constructors
- ggf (const string name, th<D>& t, dh<D>& d,
+ ggf (const int varindex, th<D>& t, dh<D>& d,
const int tmin, const int tmax,
const int prolongation_order_time);
diff --git a/Carpet/CarpetSlab/src/slab.cc b/Carpet/CarpetSlab/src/slab.cc
index a390a522c..f6d613441 100644
--- a/Carpet/CarpetSlab/src/slab.cc
+++ b/Carpet/CarpetSlab/src/slab.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/slab.cc,v 1.11 2003/09/20 13:53:18 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/slab.cc,v 1.12 2003/10/14 16:39:17 schnetter Exp $
#include <assert.h>
#include <stdlib.h>
@@ -21,7 +21,7 @@
#include "slab.hh"
extern "C" {
- static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/slab.cc,v 1.11 2003/09/20 13:53:18 schnetter Exp $";
+ static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetSlab/src/slab.cc,v 1.12 2003/10/14 16:39:17 schnetter Exp $";
CCTK_FILEVERSION(Carpet_CarpetSlab_slab_cc);
}
@@ -170,7 +170,7 @@ namespace CarpetSlab {
// Create collector data object
void* myhdata = rank==collect_proc ? hdata : 0;
- gdata<dim>* const alldata = mydata->make_typed();
+ gdata<dim>* const alldata = mydata->make_typed(-1);
alldata->allocate (hextent, collect_proc, myhdata);
// Done with the temporary stuff
@@ -208,7 +208,7 @@ namespace CarpetSlab {
if (proc != collect_proc) {
void* myhdata = rank==proc ? hdata : 0;
- gdata<dim>* const tmpdata = mydata->make_typed();
+ gdata<dim>* const tmpdata = mydata->make_typed(-1);
tmpdata->allocate (alldata->extent(), proc, myhdata);
tmpdata->copy_from (alldata, alldata->extent());
delete tmpdata;
diff --git a/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc b/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc
index a4964f0ed..7456091de 100644
--- a/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc
+++ b/CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc
@@ -303,7 +303,7 @@ namespace CarpetIOFlexIO {
ext = bbox<int,dim>(lo,hi,str);
- gdata<dim>* const tmp = data->make_typed ();
+ gdata<dim>* const tmp = data->make_typed (n);
tmp->allocate (ext, 0);
tmp->copy_from (data, ext);
@@ -591,7 +591,7 @@ namespace CarpetIOFlexIO {
const vect<int,dim> ub
= lb + (vect<int,dim>(amr_dims) - 1) * str;
const bbox<int,dim> ext(lb,ub,str);
- gdata<dim>* const tmp = data->make_typed ();
+ gdata<dim>* const tmp = data->make_typed (n);
if (CCTK_MyProc(cgh)==0) {
tmp->allocate (ext, 0, amrgrid->data);