From fad00e54fbb8c02501d69318ad9a273bd426297a Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Tue, 14 Oct 2003 14:39:00 +0000 Subject: 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 --- Carpet/Carpet/src/Storage.cc | 16 ++++++++-------- Carpet/CarpetIOASCII/src/ioascii.cc | 4 ++-- Carpet/CarpetInterp/src/interp.cc | 8 ++++---- Carpet/CarpetLib/src/data.cc | 29 ++++++++++++++--------------- Carpet/CarpetLib/src/data.hh | 8 ++++---- Carpet/CarpetLib/src/gdata.cc | 11 ++++++----- Carpet/CarpetLib/src/gdata.hh | 10 ++++++---- Carpet/CarpetLib/src/gf.cc | 10 ++++++---- Carpet/CarpetLib/src/gf.hh | 6 +++--- Carpet/CarpetLib/src/ggf.cc | 6 +++--- Carpet/CarpetLib/src/ggf.hh | 8 ++++---- Carpet/CarpetSlab/src/slab.cc | 8 ++++---- CarpetAttic/CarpetIOFlexIO/src/ioflexio.cc | 4 ++-- 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 \ - (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 \ + (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* const tmp = gfdata->make_typed(); + gdata* 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 #include @@ -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 > allcoords (nprocs * (maxrl-minrl) * maxncomps); + vector > allcoords (nprocs * (maxrl-minrl) * maxncomps, -1); for (int p=0; pcomponents(rl); ++c) { @@ -262,7 +262,7 @@ namespace CarpetInterp { // Create output patches - vector > alloutputs (nprocs * (maxrl-minrl) * maxncomps); + vector > alloutputs (nprocs * (maxrl-minrl) * maxncomps, -1); for (int p=0; pcomponents(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 #include @@ -23,15 +23,17 @@ using namespace std; // Constructors template -data::data () - : _storage(0) +data::data (const int varindex_) + : gdata(varindex_), + _storage(0) { } template -data::data (const ibbox& extent, const int proc) - : _storage(0) +data::data (const int varindex_, const ibbox& extent_, const int proc_) + : gdata(varindex_), + _storage(0) { - allocate(extent, proc); + allocate(extent_, proc_); } // Destructors @@ -42,20 +44,20 @@ data::~data () { // Pseudo constructors template -data* data::make_typed () const { - return new data(); +data* data::make_typed (const int varindex_) const { + return new data(varindex_); } // Storage management template -void data::allocate (const ibbox& extent, const int proc, +void data::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::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::transfer_from (gdata* gsrc) { data* src = (data*)gsrc; assert (!_storage); *this = *src; - *src = data(); + *src = data(varindex); } @@ -580,9 +582,6 @@ void data // Output template ostream& data::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 { 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 @@ -19,8 +19,9 @@ using namespace std; // Constructors template -gdata::gdata () - : _has_storage(false) +gdata::gdata (const int varindex_) + : varindex(varindex_), + _has_storage(false) { } // Destructors @@ -57,7 +58,7 @@ void gdata::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 } 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* make_typed () const = 0; + virtual gdata* 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 +#include "cctk.h" + #include "defs.hh" #include "gf.hh" @@ -13,9 +15,9 @@ using namespace std; // Constructors // VGF template -gf::gf (const string name, th& t, dh& d, +gf::gf (const int varindex, th& t, dh& d, const int tmin, const int tmax, const int prolongation_order_time) - : ggf(name, t, d, tmin, tmax, prolongation_order_time) + : ggf(varindex, t, d, tmin, tmax, prolongation_order_time) { // VGF this->recompose(); @@ -53,7 +55,7 @@ template ostream& gf::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& t, dh& d, + gf (const int varindex, th& t, dh& d, const int tmin, const int tmax, const int prolongation_order_time); // Destructors @@ -55,7 +55,7 @@ public: protected: - virtual gdata* typed_data() { return new data; } + virtual gdata* typed_data() { return new data(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 #include @@ -20,10 +20,10 @@ using namespace std; // Constructors template -ggf::ggf (const string name, th& t, dh& d, +ggf::ggf (const int varindex, th& t, dh& 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 &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& t, dh& d, + ggf (const int varindex, th& t, dh& 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 #include @@ -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* const alldata = mydata->make_typed(); + gdata* 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* const tmpdata = mydata->make_typed(); + gdata* 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(lo,hi,str); - gdata* const tmp = data->make_typed (); + gdata* const tmp = data->make_typed (n); tmp->allocate (ext, 0); tmp->copy_from (data, ext); @@ -591,7 +591,7 @@ namespace CarpetIOFlexIO { const vect ub = lb + (vect(amr_dims) - 1) * str; const bbox ext(lb,ub,str); - gdata* const tmp = data->make_typed (); + gdata* const tmp = data->make_typed (n); if (CCTK_MyProc(cgh)==0) { tmp->allocate (ext, 0, amrgrid->data); -- cgit v1.2.3