diff options
author | schnetter <> | 2001-06-12 12:56:00 +0000 |
---|---|---|
committer | schnetter <> | 2001-06-12 12:56:00 +0000 |
commit | 8867059a4180017e191773894b66fc36521168b9 (patch) | |
tree | 27cc2b6bbfdf277b797d883a5770679de6dcff05 /Carpet | |
parent | 2de5b11b0a7bfb67d2ac1be8b74edcd024698617 (diff) |
Introduced abstraction classes that have no <dim> parameter. This
Introduced abstraction classes that have no <dim> parameter. This
will make it easier to adapte the driver to support multiple
dimensions at once.
darcs-hash:20010612125655-07bb3-1cba35eb867eca1234b3a40bd7a5641b64776c50.gz
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/Carpet/options/carpet-lilypond-lf95 | 4 | ||||
-rw-r--r-- | Carpet/Carpet/src/carpet.cc | 23 | ||||
-rw-r--r-- | Carpet/Carpet/src/carpet.hh | 6 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dgdata.cc | 42 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dgdata.hh | 104 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dgdh.cc | 59 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dgdh.hh | 82 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dggf.cc | 61 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dggf.hh | 147 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dggh.cc | 66 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dggh.hh | 99 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dh.cc | 22 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dh.hh | 29 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.cc | 3 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.hh | 64 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gf.cc | 4 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gf.hh | 4 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.cc | 6 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.hh | 6 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.cc | 23 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.hh | 36 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/make.code.defn | 4 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/th.cc | 45 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/th.hh | 33 |
24 files changed, 766 insertions, 206 deletions
diff --git a/Carpet/Carpet/options/carpet-lilypond-lf95 b/Carpet/Carpet/options/carpet-lilypond-lf95 index c13e0dd41..6b4daeacf 100644 --- a/Carpet/Carpet/options/carpet-lilypond-lf95 +++ b/Carpet/Carpet/options/carpet-lilypond-lf95 @@ -1,4 +1,4 @@ -# $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/options/carpet-lilypond-lf95,v 1.1 2001/04/06 10:37:35 schnetter Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/options/carpet-lilypond-lf95,v 1.2 2001/06/12 14:56:55 schnetter Exp $ LAHEY = /usr/local/lf9560 @@ -29,7 +29,7 @@ F90_WARN_FLAGS = --warn F77_WARN_FLAGS = --warn SYS_INC_DIRS = /home/eschnett/proj/FlexIO -LIBDIRS = /home/eschnett/proj/FlexIO +LIBDIRS = /home/eschnett/proj/FlexIO /usr/local/lf9560/lib LIBS = AMR h5io hdfio hlio ieeeio hdf5 mfhdf df jpeg z crypt fj9i6 fj9f6 fj9e6 fccx86_6a m HDF5 = yes diff --git a/Carpet/Carpet/src/carpet.cc b/Carpet/Carpet/src/carpet.cc index e70e6d661..25633ff7f 100644 --- a/Carpet/Carpet/src/carpet.cc +++ b/Carpet/Carpet/src/carpet.cc @@ -3,9 +3,6 @@ // distribution onto the processors is the same, and that all // processors own the same number of components. -// Scalar variables currently exist in one single incarnation for all -// components. - #include <assert.h> #include <math.h> #include <stdarg.h> @@ -35,7 +32,7 @@ #include "carpet.hh" -static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.25 2001/05/16 14:29:45 schnetter Exp $"; +static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.26 2001/06/12 14:56:56 schnetter Exp $"; @@ -105,7 +102,7 @@ namespace Carpet { // The grid hierarchy gh<dim>* hh; - th<dim>* tt; + th* tt; dh<dim>* dd; int gfsize[dim]; @@ -194,7 +191,7 @@ namespace Carpet { baseext); // Allocate time hierarchy - tt = new th<dim>(*hh, maxreflevelfact); + tt = new th(hh, maxreflevelfact); // Allocate data hierarchy dd = new dh<dim>(*hh, lghosts, ughosts, prolongation_order_space); @@ -236,6 +233,15 @@ namespace Carpet { } case CCTK_ARRAY: { + cGroup gp; + CCTK_GroupData (group, &gp); + + // TODO + assert (CCTK_GroupDimI(group) == dim); + + // 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; @@ -248,7 +254,7 @@ namespace Carpet { multigrid_factor, vertex_centered, arrext); - arrdata[group].tt = new th<dim> (*arrdata[group].hh, maxreflevelfact); + arrdata[group].tt = new th (arrdata[group].hh, maxreflevelfact); vect<int,dim> alghosts, aughosts; for (int d=0; d<dim; ++d) { @@ -279,6 +285,9 @@ namespace Carpet { } case CCTK_GF: { + /* TODO */ + assert (CCTK_GroupDimI(group) == dim); + gfdata[group].data.resize(CCTK_NumVarsInGroupI(group)); for (int var=0; var<(int)scdata[group].data.size(); ++var) { gfdata[group].data[var] = 0; diff --git a/Carpet/Carpet/src/carpet.hh b/Carpet/Carpet/src/carpet.hh index 6b14c1589..cca0ade8f 100644 --- a/Carpet/Carpet/src/carpet.hh +++ b/Carpet/Carpet/src/carpet.hh @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet.hh,v 1.8 2001/04/23 08:10:13 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet.hh,v 1.9 2001/06/12 14:56:56 schnetter Exp $ #include <vector> @@ -52,7 +52,7 @@ namespace Carpet { // Data for arrays struct arrdesc { gh<dim>* hh; - th<dim>* tt; + th* tt; dh<dim>* dd; vector<generic_gf<dim>* > data; // [var] int size[dim]; @@ -63,7 +63,7 @@ namespace Carpet { // The grid hierarchy extern gh<dim>* hh; - extern th<dim>* tt; + extern th* tt; extern dh<dim>* dd; extern int gfsize[dim]; diff --git a/Carpet/CarpetLib/src/dgdata.cc b/Carpet/CarpetLib/src/dgdata.cc new file mode 100644 index 000000000..36771e8de --- /dev/null +++ b/Carpet/CarpetLib/src/dgdata.cc @@ -0,0 +1,42 @@ +/*************************************************************************** + dgdata.cc - description + ------------------- + begin : Wed Jul 19 2000 + copyright : (C) 2000 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dgdata.cc,v 1.1 2001/06/12 14:56:57 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <assert.h> + +#if !defined(TMPL_IMPLICIT) || !defined(GDATA_HH) +# include "dgdata.hh" +#endif + +using namespace std; + + + +// Constructors +dimgeneric_data::dimgeneric_data () + : _has_storage(false) +{ } + +// Destructors +dimgeneric_data::~dimgeneric_data () { } + + + +#if defined(TMPL_EXPLICIT) +#endif diff --git a/Carpet/CarpetLib/src/dgdata.hh b/Carpet/CarpetLib/src/dgdata.hh new file mode 100644 index 000000000..ae5cd89cc --- /dev/null +++ b/Carpet/CarpetLib/src/dgdata.hh @@ -0,0 +1,104 @@ +/*************************************************************************** + dgdata.hh - description + ------------------- + begin : Wed Jul 19 2000 + copyright : (C) 2000 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dgdata.hh,v 1.1 2001/06/12 14:56:57 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DGDATA_HH +#define DGDATA_HH + +#include <assert.h> + +#include <iostream> + +#include "defs.hh" + +using namespace std; + + + +// Forward declaration +class dimgeneric_data; + +// Output +ostream& operator<< (ostream& os, const dimgeneric_data& d); + + + +// A generic data storage without type information +class dimgeneric_data { + +protected: // should be readonly + + // Fields + bool _has_storage; // has storage associated (on some processor) + bool _owns_storage; // owns the storage + int _size; // size + + int _proc; // stored on processor + +public: + + // Constructors + dimgeneric_data (); + + // Destructors + virtual ~dimgeneric_data (); + + // Processor management + virtual void change_processor (const int newproc, void* const mem=0) = 0; + + // Accessors + bool has_storage () const { + return _has_storage; + } + bool owns_storage () const { + assert (_has_storage); + return _owns_storage; + } + + virtual const void* storage () const = 0; + + virtual void* storage () = 0; + + int size () const { + assert (_has_storage); + return _size; + } + + int proc () const { + assert (_has_storage); + return _proc; + } + + // Output + virtual ostream& output (ostream& os) const = 0; +}; + + + +inline ostream& operator<< (ostream& os, const dimgeneric_data& d) { + return d.output(os); +} + + + +#if defined(TMPL_IMPLICIT) +# include "dgdata.cc" +#endif + +#endif // DGDATA_HH diff --git a/Carpet/CarpetLib/src/dgdh.cc b/Carpet/CarpetLib/src/dgdh.cc new file mode 100644 index 000000000..188ca8885 --- /dev/null +++ b/Carpet/CarpetLib/src/dgdh.cc @@ -0,0 +1,59 @@ +/*************************************************************************** + dgdh.cc - Dimension Generic Data Hierarchy + A grid hierarchy plus ghost zones + ------------------- + begin : Sun Jun 11 2000 + copyright : (C) 2000 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dgdh.cc,v 1.1 2001/06/12 14:56:57 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <assert.h> + +#include "defs.hh" +#include "dist.hh" +#include "ggf.hh" + +#if !defined(TMPL_IMPLICIT) || !defined(DH_HH) +# include "dgdh.hh" +#endif + +#undef DEBUG_OUTPUT + +using namespace std; + + + +// Constructors +dimgeneric_dh::dimgeneric_dh (int prolongation_order) + : prolongation_order(prolongation_order) +{ + assert (prolongation_order>=0); +} + +// Destructors +dimgeneric_dh::~dimgeneric_dh () +{ +} + +// Helpers +int dimgeneric_dh::prolongation_stencil_size () const { + assert (prolongation_order>=0); + return prolongation_order/2; +} + + + +#if defined(TMPL_EXPLICIT) +#endif diff --git a/Carpet/CarpetLib/src/dgdh.hh b/Carpet/CarpetLib/src/dgdh.hh new file mode 100644 index 000000000..ff7ed8b1e --- /dev/null +++ b/Carpet/CarpetLib/src/dgdh.hh @@ -0,0 +1,82 @@ +/*************************************************************************** + dgdh.hh - Dimension Generic Data Hierarchy + A grid hierarchy plus ghost zones + ------------------- + begin : Sun Jun 11 2000 + copyright : (C) 2000 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dgdh.hh,v 1.1 2001/06/12 14:56:58 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DGDH_HH +#define DGDH_HH + +#include <assert.h> + +#include <iostream> +#include <list> + +#include "defs.hh" + +using namespace std; + + + +// Forward declaration +class dimgeneric_dh; +class dimgeneric_gf; + +// Output +ostream& operator<< (ostream& os, const dimgeneric_dh& d); + + + +// A data hierarchy (grid hierarchy plus ghost zones) +class dimgeneric_dh { + +public: // should be readonly + + // Fields + int prolongation_order; // order of spatial prolongation operator + +public: + + // Constructors + dimgeneric_dh (int prolongation_order); + + // Destructors + virtual ~dimgeneric_dh (); + + // Helpers + int prolongation_stencil_size () const; + + // Modifiers + virtual void recompose () = 0; + + // Output + virtual void output (ostream& os) const = 0; +}; + +inline ostream& operator<< (ostream& os, const dimgeneric_dh& d) { + d.output(os); + return os; +} + + + +#if defined(TMPL_IMPLICIT) +# include "dgdh.cc" +#endif + +#endif // DGDH_HH diff --git a/Carpet/CarpetLib/src/dggf.cc b/Carpet/CarpetLib/src/dggf.cc new file mode 100644 index 000000000..43c72a1df --- /dev/null +++ b/Carpet/CarpetLib/src/dggf.cc @@ -0,0 +1,61 @@ +/*************************************************************************** + dggf.cc - Dimension Generic Grid Function + grid function without type information + ------------------- + begin : Sun Jun 11 2000 + copyright : (C) 2000 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dggf.cc,v 1.1 2001/06/12 14:56:58 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <assert.h> +#include <stdlib.h> + +// #include <iostream> +// #include <string> + +// #include "defs.hh" +// #include "dh.hh" +// #include "th.hh" + +#if !defined(TMPL_IMPLICIT) || !defined(GGF_HH) +# include "dggf.hh" +#endif + +using namespace std; + + + +// Constructors +dimgeneric_gf::dimgeneric_gf (const string name, th& t, + const int tmin, const int tmax) + : name(name), t(t), tmin(tmin), tmax(tmax) +{ + assert (tmin<=tmax+1); +} + +// Destructors +dimgeneric_gf::~dimgeneric_gf () +{ +} + +// Comparison +bool dimgeneric_gf::operator== (const dimgeneric_gf& f) const { + return this == &f; +} + + + +#if defined(TMPL_EXPLICIT) +#endif diff --git a/Carpet/CarpetLib/src/dggf.hh b/Carpet/CarpetLib/src/dggf.hh new file mode 100644 index 000000000..31a2cc1fc --- /dev/null +++ b/Carpet/CarpetLib/src/dggf.hh @@ -0,0 +1,147 @@ +/*************************************************************************** + dggf.hh - Dimension Generic Grid Function + grid function without type information + ------------------- + begin : Sun Jun 11 2000 + 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 $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DGGF_HH +#define DGGF_HH + +#include <assert.h> + +#include <iostream> +#include <string> + +#include "defs.hh" +#include "dgdata.hh" +#include "th.hh" + +using namespace std; + + + +// Forward declaration +class dimgeneric_gf; + +// Output +ostream& operator<< (ostream& os, const dimgeneric_gf& f); + + + +// A generic grid function without type information +class dimgeneric_gf { + +public: // should be readonly + + // Fields + string name; + + th &t; // time hierarchy + int tmin, tmax; // timelevels + +public: + + // Constructors + dimgeneric_gf (const string name, th& t, + const int tmin, const int tmax); + + // Destructors + virtual ~dimgeneric_gf (); + + // Comparison + bool operator== (const dimgeneric_gf& f) const; + + + + // Modifiers + virtual void recompose () = 0; + + // Cycle the time levels by rotating the data sets + virtual void cycle (int rl, int c, int ml) = 0; + + + + // are these necessary in dimgeneric_gf, or is it sufficient to have + // them in generic_gf<D>? + + // do i really want all dims, or do i just want to disregard the z + // dim in carpet? + + // 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. + + // "Updating" means here that the boundaries have to be + // synchronised. They don't need to be prolongated. + + // Copy a component from the next time level + virtual void copy (int tl, int rl, int c, int ml) = 0; + + // Synchronise the boundaries of a component + virtual void sync (int tl, int rl, int c, int ml) = 0; + + // Prolongate the boundaries of a component + virtual void ref_bnd_prolongate (int tl, int rl, int c, int ml, + int order_space=1, int order_time=1) = 0; + + // Restrict a multigrid level + virtual void mg_restrict (int tl, int rl, int c, int ml, int order_space=1) + = 0; + + // Prolongate a multigrid level + virtual void mg_prolongate (int tl, int rl, int c, int ml, int order_space=1) + = 0; + + // Restrict a refinement level + virtual void ref_restrict (int tl, int rl, int c, int ml, int order_space=1) + = 0; + + // 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; + + virtual dimgeneric_data* operator() (int tl, int rl, int c, int ml); + + + + // Output + virtual ostream& output (ostream& os) const = 0; +}; + + + +inline ostream& operator<< (ostream& os, const dimgeneric_gf& f) { + return f.output(os); +} + + + +#if defined(TMPL_IMPLICIT) +# include "dggf.cc" +#endif + +#endif // DGGF_HH diff --git a/Carpet/CarpetLib/src/dggh.cc b/Carpet/CarpetLib/src/dggh.cc new file mode 100644 index 000000000..9c6bbfd5c --- /dev/null +++ b/Carpet/CarpetLib/src/dggh.cc @@ -0,0 +1,66 @@ +/*************************************************************************** + dggh.cc - Dimension Generic Grid Hierarchy + bounding boxes for each multigrid level of each + component of each refinement level + ------------------- + begin : Sun Jun 11 2000 + copyright : (C) 2000 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dggh.cc,v 1.1 2001/06/12 14:56:58 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <assert.h> +#include <stdlib.h> +#include <iostream> + +#include "defs.hh" +#include "dh.hh" +#include "th.hh" + +#if !defined(TMPL_IMPLICIT) || !defined(DGGH_HH) +# include "dggh.hh" +#endif + +using namespace std; + + + + // Constructors +dimgeneric_gh::dimgeneric_gh (const int reffact, const centering refcent, + const int mgfact, const centering mgcent) + : reffact(reffact), refcent(refcent), + mgfact(mgfact), mgcent(mgcent) +{ + assert (reffact>=1); + assert (mgfact>=1); + assert (refcent==vertex_centered || refcent==cell_centered); + assert (mgcent==vertex_centered || mgcent==cell_centered); +} + +// Destructors +dimgeneric_gh::~dimgeneric_gh () { } + +// Time hierarchy management +void dimgeneric_gh::add (th* t) { + ths.push_back(t); +} + +void dimgeneric_gh::remove (th* t) { + ths.remove(t); +} + + + +#if defined(TMPL_EXPLICIT) +#endif diff --git a/Carpet/CarpetLib/src/dggh.hh b/Carpet/CarpetLib/src/dggh.hh new file mode 100644 index 000000000..983ec73ad --- /dev/null +++ b/Carpet/CarpetLib/src/dggh.hh @@ -0,0 +1,99 @@ +/*************************************************************************** + dggh.hh - Dimension Generic Grid Hierarchy + bounding boxes for each multigrid level of each + component of each refinement level + ------------------- + begin : Sun Jun 10 2001 + copyright : (C) 2001 by Erik Schnetter + email : schnetter@astro.psu.edu + + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/Attic/dggh.hh,v 1.1 2001/06/12 14:56:58 schnetter Exp $ + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DGGH_HH +#define DGGH_HH + +#include <assert.h> + +#include <iostream> +#include <list> + +#include "defs.hh" +#include "dist.hh" + +using namespace std; + + + +// Forward declaration +class dimgeneric_dh; +class dimgeneric_gh; +class th; + +// Output +ostream& operator<< (ostream& os, const dimgeneric_gh& h); + + + +// A refinement hierarchy, where higher levels are finer than the base +// level. The extents do not include ghost zones. +class dimgeneric_gh { + +public: // should be readonly + + // Fields + int reffact; // refinement factor + centering refcent; // vertex or cell centered + + int mgfact; // default multigrid factor + centering mgcent; // default (vertex or cell centered) + + list<th*> ths; // list of all time hierarchies + +public: + + // Constructors + dimgeneric_gh (const int reffact, const centering refcent, + const int mgfact, const centering mgcent); + + // Destructors + virtual ~dimgeneric_gh (); + + // Accessors + virtual int reflevels () const = 0; + virtual int components (const int rl) const = 0; + virtual int mglevels (const int rl, const int c) const = 0; + virtual int proc (const int rl, const int c) const = 0; + virtual bool is_local (const int rl, const int c) const = 0; + + // Time hierarchy management + void add (th* t); + void remove (th* t); + + // Output + virtual ostream& output (ostream& os) const = 0; +}; + + + +inline ostream& operator<< (ostream& os, const dimgeneric_gh& h) { + return h.output(os); +} + + + +#if defined(TMPL_IMPLICIT) +# include "dggh.cc" +#endif + +#endif // DGGH_HH diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc index 449ba1dc5..366f525a2 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.13 2001/04/23 08:10:15 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.14 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -40,30 +40,24 @@ using namespace std; template<int D> dh<D>::dh (gh<D>& h, const ivect& lghosts, const ivect& ughosts, int prolongation_order) - : h(h), lghosts(lghosts), ughosts(ughosts), - prolongation_order(prolongation_order) + : dimgeneric_dh(prolongation_order), + h(h), + lghosts(lghosts), ughosts(ughosts) { assert (all(lghosts>=0 && ughosts>=0)); - assert (prolongation_order>=0); - CHECKPOINT; h.add(this); + CHECKPOINT; recompose(); } // Destructors template<int D> -dh<D>::~dh () { +dh<D>::~dh () +{ CHECKPOINT; h.remove(this); } -// Helpers -template<int D> -int dh<D>::prolongation_stencil_size () const { - assert (prolongation_order>=0); - return prolongation_order/2; -} - // Modifiers template<int D> void dh<D>::recompose () { @@ -331,6 +325,8 @@ void dh<D>::recompose () { } } + + // Grid function management template<int D> void dh<D>::add (generic_gf<D>* f) { diff --git a/Carpet/CarpetLib/src/dh.hh b/Carpet/CarpetLib/src/dh.hh index 70ffe3803..7ba680691 100644 --- a/Carpet/CarpetLib/src/dh.hh +++ b/Carpet/CarpetLib/src/dh.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/dh.hh,v 1.7 2001/04/23 08:10:15 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.hh,v 1.8 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -32,6 +32,7 @@ #include "bbox.hh" #include "bboxset.hh" #include "defs.hh" +#include "dgdh.hh" #include "gh.hh" #include "vect.hh" @@ -40,18 +41,13 @@ using namespace std; // Forward declaration -template<int D> class dh; template<int D> class generic_gf; -// Output -template<int D> -ostream& operator<< (ostream& os, const dh<D>& d); - // A data hierarchy (grid hierarchy plus ghost zones) template<int D> -class dh { +class dh: public dimgeneric_dh { // Types typedef vect<int,D> ivect; @@ -82,6 +78,7 @@ public: ibset sync_not; // not received while syncing (outer boundary of that level) ibset recv_not; // not received while syncing or prolongating (globally outer boundary) }; + private: struct dbases { @@ -100,14 +97,13 @@ private: public: // should be readonly // Fields - gh<D> &h; // hierarchy + gh<D>& h; // hierarchy ivect lghosts, ughosts; // ghost zones - int prolongation_order; // order of spatial prolongation operator rboxes boxes; rbases bases; - list<generic_gf<D>*> gfs; + list<generic_gf<D>*> gfs; // list of all grid functions public: @@ -116,10 +112,7 @@ public: int prolongation_order); // Destructors - ~dh (); - - // Helpers - int prolongation_stencil_size () const; + virtual ~dh (); // Modifiers void recompose (); @@ -129,15 +122,9 @@ public: void remove (generic_gf<D>* f); // Output - void output (ostream& os) const; + virtual void output (ostream& os) const; }; -template<int D> -inline ostream& operator<< (ostream& os, const dh<D>& d) { - d.output(os); - return os; -} - #if defined(TMPL_IMPLICIT) diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc index 7eafeed28..84691b475 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.11 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.12 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -39,7 +39,6 @@ using namespace std; // Constructors template<int D> generic_data<D>::generic_data () - : _has_storage(false) { } // Destructors diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh index e359e8286..8e561c073 100644 --- a/Carpet/CarpetLib/src/gdata.hh +++ b/Carpet/CarpetLib/src/gdata.hh @@ -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.hh,v 1.8 2001/03/30 00:50:21 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.9 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -29,6 +29,7 @@ #include <string> #include "defs.hh" +#include "dgdata.hh" #include "dist.hh" #include "bbox.hh" #include "vect.hh" @@ -37,18 +38,9 @@ using namespace std; -// Forward declaration -template<int D> class generic_data; - -// Output -template<int D> -ostream& operator<< (ostream& os, const generic_data<D>& d); - - - // A generic data storage without type information template<int D> -class generic_data { +class generic_data: public dimgeneric_data { // Types typedef vect<int,D> ivect; @@ -57,13 +49,8 @@ class generic_data { protected: // should be readonly // Fields - bool _has_storage; // has storage associated (on some processor) - bool _owns_storage; // owns the storage ivect _shape, _stride; // shape and index order - int _size; // size - - int _proc; // stored on processor - + ibbox _extent; // bbox for all data public: @@ -75,29 +62,16 @@ public: virtual ~generic_data (); // Pseudo constructors - virtual generic_data* make_typed () const = 0; + virtual generic_data<D>* make_typed () const = 0; // Storage management + virtual void transfer_from (generic_data<D>* src) = 0; + virtual void allocate (const ibbox& extent, const int proc, void* const mem=0) = 0; virtual void free () = 0; - virtual void transfer_from (generic_data* src) = 0; - - // Processor management - virtual void change_processor (const int newproc, void* const mem=0) = 0; - - // Accessors - bool has_storage () const { - return _has_storage; - } - bool owns_storage () const { - assert (_has_storage); - return _owns_storage; - } - - virtual const void* storage () const = 0; - virtual void* storage () = 0; + // Accessors const ivect& shape () const { assert (_has_storage); @@ -108,17 +82,7 @@ public: assert (_has_storage); return _stride; } - - int size () const { - assert (_has_storage); - return _size; - } - - int proc () const { - assert (_has_storage); - return _proc; - } - + const ibbox& extent () const { assert (_has_storage); return _extent; @@ -171,20 +135,10 @@ public: // const int tl, const int rl, const int c, const int ml) // const; public: - - // Output - virtual ostream& output (ostream& os) const = 0; }; -template<int D> -inline ostream& operator<< (ostream& os, const generic_data<D>& d) { - return d.output(os); -} - - - #if defined(TMPL_IMPLICIT) # include "gdata.cc" #endif diff --git a/Carpet/CarpetLib/src/gf.cc b/Carpet/CarpetLib/src/gf.cc index c3f923cc6..d7b183cd8 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.4 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.cc,v 1.5 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -33,7 +33,7 @@ using namespace std; // Constructors template<class T,int D> -gf<T,D>::gf (const string name, th<D>& t, dh<D>& d, +gf<T,D>::gf (const string name, th& t, dh<D>& d, const int tmin, const int tmax) : generic_gf<D>(name, t, d, tmin, tmax) { diff --git a/Carpet/CarpetLib/src/gf.hh b/Carpet/CarpetLib/src/gf.hh index 2b4d8254c..4a51bc98d 100644 --- a/Carpet/CarpetLib/src/gf.hh +++ b/Carpet/CarpetLib/src/gf.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/gf.hh,v 1.3 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gf.hh,v 1.4 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -61,7 +61,7 @@ class gf: public generic_gf<D> { public: // Constructors - gf (const string name, th<D>& t, dh<D>& d, const int tmin, const int tmax); + gf (const string name, th& t, dh<D>& d, const int tmin, const int tmax); // Destructors virtual ~gf (); diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc index e4c890497..b1af8103a 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.9 2001/04/23 08:10:15 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.10 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -39,12 +39,12 @@ using namespace std; // Constructors template<int D> -generic_gf<D>::generic_gf (const string name, th<D>& t, dh<D>& 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), storage(tmax-tmin+1) { - assert (&t.h == &d.h); + assert (t.h == &d.h); assert (tmin<=tmax+1); d.add(this); diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh index 28710c2b8..44ea800f0 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.5 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.hh,v 1.6 2001/06/12 14:56:59 schnetter Exp $ ***************************************************************************/ @@ -71,7 +71,7 @@ public: // should be readonly string name; gh<D> &h; // grid hierarchy - th<D> &t; // time hierarchy + th &t; // time hierarchy dh<D> &d; // data hierarchy int tmin, tmax; // timelevels @@ -81,7 +81,7 @@ protected: public: // Constructors - generic_gf (const string name, th<D>& t, dh<D>& d, + generic_gf (const string name, th& t, dh<D>& d, const int tmin, const int tmax); // Destructors diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc index 0c3d59502..ed2235f98 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.6 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.7 2001/06/12 14:57:00 schnetter Exp $ ***************************************************************************/ @@ -41,14 +41,9 @@ template<int D> gh<D>::gh (const int reffact, const centering refcent, const int mgfact, const centering mgcent, const ibbox& baseextent) - : reffact(reffact), refcent(refcent), - mgfact(mgfact), mgcent(mgcent), + : dimgeneric_gh (reffact, refcent, mgfact, mgcent), baseextent(baseextent) { - assert (reffact>=1); - assert (mgfact>=1); - assert (refcent==vertex_centered || refcent==cell_centered); - assert (mgcent==vertex_centered || mgcent==cell_centered); } // Destructors @@ -145,7 +140,7 @@ void gh<D>::recompose (const rexts& exts, const rprocs& procs) { // Recompose the other hierarchies - for (list<th<D>*>::iterator t=ths.begin(); t!=ths.end(); ++t) { + for (list<th*>::iterator t=ths.begin(); t!=ths.end(); ++t) { (*t)->recompose(); } @@ -204,16 +199,7 @@ gh<D>::rexts gh<D>::make_multigrid_boxes (const vector<vector<ibbox> >& exts, return mexts; } -// Time hierarchy management -template<int D> -void gh<D>::add (th<D>* t) { - ths.push_back(t); -} -template<int D> -void gh<D>::remove (th<D>* t) { - ths.remove(t); -} // Data hierarchy management template<int D> @@ -229,7 +215,7 @@ void gh<D>::remove (dh<D>* d) { template<int D> -void gh<D>::output (ostream& os) const { +ostream& gh<D>::output (ostream& os) const { os << "gh<" << D << ">:" << "reffactor=" << reffact << ",refcentering=" << refcent << "," << "mgfactor=" << mgfact << ",mgcentering=" << mgcent << "," @@ -243,6 +229,7 @@ void gh<D>::output (ostream& os) const { (*d)->output(os); } os << "}"; + return os; } diff --git a/Carpet/CarpetLib/src/gh.hh b/Carpet/CarpetLib/src/gh.hh index 48f166e2b..3fa42421a 100644 --- a/Carpet/CarpetLib/src/gh.hh +++ b/Carpet/CarpetLib/src/gh.hh @@ -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.hh,v 1.5 2001/04/06 10:37:36 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.hh,v 1.6 2001/06/12 14:57:00 schnetter Exp $ ***************************************************************************/ @@ -31,6 +31,7 @@ #include "bbox.hh" #include "defs.hh" +#include "dggh.hh" #include "dist.hh" #include "vect.hh" @@ -39,20 +40,15 @@ using namespace std; // Forward declaration -template<int D> class gh; -template<int D> class th; template<int D> class dh; - -// Output -template<int D> -ostream& operator<< (ostream& os, const gh<D>& h); +template<int D> class gh; // A refinement hierarchy, where higher levels are finer than the base // level. The extents do not include ghost zones. template<int D> -class gh { +class gh: public dimgeneric_gh { // Types typedef vect<int,D> ivect; @@ -67,20 +63,12 @@ class gh { public: // should be readonly - // Fields - int reffact; // refinement factor - centering refcent; // vertex or cell centered - - int mgfact; // default multigrid factor - centering mgcent; // default (vertex or cell centered) - ibbox baseextent; // bounds (inclusive) of base level vector<vector<ibbox> > bases; // [rl][ml] rexts extents; // bounds of all grids rprocs processors; // processor numbers of all grids - list<th<D>*> ths; // list of all time hierarchies list<dh<D>*> dhs; // list of all data hierarchies public: @@ -91,7 +79,7 @@ public: const ibbox& baseextent); // Destructors - ~gh (); + virtual ~gh (); // Modifiers void recompose (const rexts& exts, const rprocs& procs); @@ -128,29 +116,17 @@ public: MPI_Comm_rank (dist::comm, &rank); return proc(rl,c) == rank; } - - // Time hierarchy management - void add (th<D>* t); - void remove (th<D>* t); // Data hierarchy management void add (dh<D>* d); void remove (dh<D>* d); // Output - void output (ostream& os) const; + virtual ostream& output (ostream& os) const; }; -template<int D> -inline ostream& operator<< (ostream& os, gh<D>& h) { - h.output(os); - return os; -} - - - #if defined(TMPL_IMPLICIT) # include "gh.cc" #endif diff --git a/Carpet/CarpetLib/src/make.code.defn b/Carpet/CarpetLib/src/make.code.defn index b072b8c62..f2c5d3cfc 100644 --- a/Carpet/CarpetLib/src/make.code.defn +++ b/Carpet/CarpetLib/src/make.code.defn @@ -1,8 +1,8 @@ # Main make.code.defn file for thorn CarpetLib -*-Makefile-*- -# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/make.code.defn,v 1.4 2001/03/24 22:38:48 eschnett Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/make.code.defn,v 1.5 2001/06/12 14:57:00 schnetter Exp $ # Source files in this directory -SRCS = bbox.cc bboxset.cc data.cc defs.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 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/th.cc b/Carpet/CarpetLib/src/th.cc index 4a6638b63..18e26de1e 100644 --- a/Carpet/CarpetLib/src/th.cc +++ b/Carpet/CarpetLib/src/th.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/th.cc,v 1.4 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/th.cc,v 1.5 2001/06/12 14:57:00 schnetter Exp $ ***************************************************************************/ @@ -24,7 +24,7 @@ #include <iostream> #include "defs.hh" -#include "gh.hh" +#include "dggh.hh" #if !defined(TMPL_IMPLICIT) || !defined(TH_HH) # include "th.hh" @@ -35,23 +35,20 @@ using namespace std; // Constructors -template<int D> -th<D>::th (gh<D>& h, const int basedelta) : h(h), delta(basedelta) { - h.add(this); +th::th (dimgeneric_gh* h, const int basedelta) : h(h), delta(basedelta) { + h->add(this); } // Destructors -template<int D> -th<D>::~th () { - h.remove(this); +th::~th () { + h->remove(this); } // Modifiers -template<int D> -void th<D>::recompose () { - times.resize(h.reflevels()); - deltas.resize(h.reflevels()); - for (int rl=0; rl<h.reflevels(); ++rl) { +void th::recompose () { + times.resize(h->reflevels()); + deltas.resize(h->reflevels()); + for (int rl=0; rl<h->reflevels(); ++rl) { const int old_mglevels = times[rl].size(); int mgtime; // Select default time @@ -62,16 +59,16 @@ void th<D>::recompose () { } else { mgtime = times[rl][old_mglevels-1]; } - times[rl].resize(h.mglevels(rl,0), mgtime); - deltas[rl].resize(h.mglevels(rl,0)); - for (int ml=0; ml<h.mglevels(rl,0); ++ml) { + times[rl].resize(h->mglevels(rl,0), mgtime); + deltas[rl].resize(h->mglevels(rl,0)); + for (int ml=0; ml<h->mglevels(rl,0); ++ml) { if (rl==0 && ml==0) { deltas[rl][ml] = delta; } else if (ml==0) { - assert (deltas[rl-1][ml] % h.reffact == 0); - deltas[rl][ml] = deltas[rl-1][ml] / h.reffact; + assert (deltas[rl-1][ml] % h->reffact == 0); + deltas[rl][ml] = deltas[rl-1][ml] / h->reffact; } else { - deltas[rl][ml] = deltas[rl][ml-1] * h.mgfact; + deltas[rl][ml] = deltas[rl][ml-1] * h->mgfact; } } } @@ -80,12 +77,11 @@ void th<D>::recompose () { // Output -template<int D> -void th<D>::output (ostream& os) const { - os << "th<" << D << ">:" +void th::output (ostream& os) const { + os << "th:" << "times={"; - for (int rl=0; rl<h.reflevels(); ++rl) { - for (int ml=0; ml<h.mglevels(rl,0); ++ml) { + for (int rl=0; rl<h->reflevels(); ++rl) { + for (int ml=0; ml<h->mglevels(rl,0); ++ml) { if (!(rl==0 && ml==0)) os << ","; os << rl << ":" << ml << ":" << times[rl][ml] << "(" << deltas[rl][ml] << ")"; @@ -97,5 +93,4 @@ void th<D>::output (ostream& os) const { #if defined(TMPL_EXPLICIT) -template class th<3>; #endif diff --git a/Carpet/CarpetLib/src/th.hh b/Carpet/CarpetLib/src/th.hh index 7abb657a5..444b0d1f0 100644 --- a/Carpet/CarpetLib/src/th.hh +++ b/Carpet/CarpetLib/src/th.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/th.hh,v 1.3 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/th.hh,v 1.4 2001/06/12 14:57:00 schnetter Exp $ ***************************************************************************/ @@ -28,29 +28,27 @@ #include <vector> #include "defs.hh" -#include "gh.hh" +#include "dggh.hh" using namespace std; // Forward declaration -template<int D> class th; +class th; // Output -template<int D> -ostream& operator<< (ostream& os, const th<D>& t); +ostream& operator<< (ostream& os, const th& t); // The time hierarchy (information about the current time) -template<int D> class th { public: // should be readonly // Fields - gh<D> &h; // hierarchy + dimgeneric_gh *h; // hierarchy private: @@ -61,7 +59,7 @@ private: public: // Constructors - th (gh<D>& h, const int basedelta); + th (dimgeneric_gh* h, const int basedelta); // Destructors ~th (); @@ -71,14 +69,14 @@ public: // Time management int get_time (const int rl, const int ml) const { - assert (rl>=0 && rl<h.reflevels()); - assert (ml>=0 && ml<h.mglevels(rl,0)); + assert (rl>=0 && rl<h->reflevels()); + assert (ml>=0 && ml<h->mglevels(rl,0)); return times[rl][ml]; } void set_time (const int rl, const int ml, const int t) { - assert (rl>=0 && rl<h.reflevels()); - assert (ml>=0 && ml<h.mglevels(rl,0)); + assert (rl>=0 && rl<h->reflevels()); + assert (ml>=0 && ml<h->mglevels(rl,0)); times[rl][ml] = t; } @@ -87,14 +85,14 @@ public: } int get_delta (const int rl, const int ml) const { - assert (rl>=0 && rl<h.reflevels()); - assert (ml>=0 && ml<h.mglevels(rl,0)); + assert (rl>=0 && rl<h->reflevels()); + assert (ml>=0 && ml<h->mglevels(rl,0)); return deltas[rl][ml]; } int time (const int tl, const int rl, const int ml) const { - assert (rl>=0 && rl<h.reflevels()); - assert (ml>=0 && ml<h.mglevels(rl,0)); + assert (rl>=0 && rl<h->reflevels()); + assert (ml>=0 && ml<h->mglevels(rl,0)); return get_time(rl, ml) + tl * get_delta(rl, ml); } @@ -104,8 +102,7 @@ public: -template<int D> -ostream& operator<< (ostream& os, const th<D>& t) { +inline ostream& operator<< (ostream& os, const th& t) { t.output(os); return os; } |