diff options
author | Erik Schnetter <schnetter@aei.mpg.de> | 2005-01-01 18:22:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@aei.mpg.de> | 2005-01-01 18:22:00 +0000 |
commit | 2a38d7eb6a6db8b150a9f6fd5f1c844b8d0ef74a (patch) | |
tree | 1c5e763b0ffee9744ee708d6016bdbd36b8f8312 /Carpet/CarpetLib/src | |
parent | 049cec8e042a508511fdb0f0948de63f84f9b8be (diff) |
global: Turn CarpetLib templates into classes
Turn most of the templates in CarpetLib, which used to have the form
template<int D> class XXX
into classes, i.e., into something like
class XXX
by setting D to the new global integer constant dim, which in turn is set to 3.
The templates gf and data, which used to be of the form
template<typename T, int D> class XXX
are now of the form
template<typename T> class XXX
The templates vect, bbox, and bboxset remain templates.
This change simplifies the code somewhat.
darcs-hash:20050101182234-891bb-c3063528841f0d078b12cc506309ea27d8ce730d.gz
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r-- | Carpet/CarpetLib/src/data.cc | 211 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/data.hh | 37 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/defs.hh | 26 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dh.cc | 169 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dh.hh | 32 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.cc | 91 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.hh | 37 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gf.cc | 48 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gf.hh | 30 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.cc | 216 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.hh | 98 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.cc | 75 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.hh | 35 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/th.cc | 18 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/th.hh | 13 |
15 files changed, 512 insertions, 624 deletions
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc index 758bd47a1..4615b7d8d 100644 --- a/Carpet/CarpetLib/src/data.cc +++ b/Carpet/CarpetLib/src/data.cc @@ -35,11 +35,11 @@ static size_t total_allocated_objects = 0; static const CCTK_REAL eps = 1.0e-10; // Constructors -template<class T, int D> -data<T,D>::data (const int varindex_, const operator_type transport_operator_, - const int vectorlength_, const int vectorindex_, - data* const vectorleader_) - : gdata<D>(varindex_, transport_operator_), +template<typename T> +data<T>::data (const int varindex_, const operator_type transport_operator_, + const int vectorlength_, const int vectorindex_, + data* const vectorleader_) + : gdata(varindex_, transport_operator_), _storage(NULL), _allocated_bytes(0), vectorlength(vectorlength_), vectorindex(vectorindex_), vectorleader(vectorleader_) @@ -52,12 +52,12 @@ data<T,D>::data (const int varindex_, const operator_type transport_operator_, if (vectorleader) vectorleader->register_client (vectorindex); } -template<class T, int D> -data<T,D>::data (const int varindex_, const operator_type transport_operator_, - const int vectorlength_, const int vectorindex_, - data* const vectorleader_, - const ibbox& extent_, const int proc_) - : gdata<D>(varindex_, transport_operator_), +template<typename T> +data<T>::data (const int varindex_, const operator_type transport_operator_, + const int vectorlength_, const int vectorindex_, + data* const vectorleader_, + const ibbox& extent_, const int proc_) + : gdata(varindex_, transport_operator_), _storage(NULL), _allocated_bytes(0), vectorlength(vectorlength_), vectorindex(vectorindex_), vectorleader(vectorleader_) @@ -72,8 +72,8 @@ data<T,D>::data (const int varindex_, const operator_type transport_operator_, } // Destructors -template<class T, int D> -data<T,D>::~data () +template<typename T> +data<T>::~data () { if (vectorleader) vectorleader->unregister_client (vectorindex); if (vectorindex==0) assert (! has_clients()); @@ -81,9 +81,9 @@ data<T,D>::~data () } // Pseudo constructors -template<class T, int D> -data<T,D>* data<T,D>::make_typed (const int varindex_, - const operator_type transport_operator_) +template<typename T> +data<T>* data<T>::make_typed (const int varindex_, + const operator_type transport_operator_) const { return new data(varindex_, transport_operator_); @@ -92,22 +92,22 @@ data<T,D>* data<T,D>::make_typed (const int varindex_, // Vector mamagement -template<class T, int D> -void data<T,D>::register_client (const int index) +template<typename T> +void data<T>::register_client (const int index) { assert (! vectorclients.at(index)); vectorclients.at(index) = true; } -template<class T, int D> -void data<T,D>::unregister_client (const int index) +template<typename T> +void data<T>::unregister_client (const int index) { assert (vectorclients.at(index)); vectorclients.at(index) = false; } -template<class T, int D> -bool data<T,D>::has_clients () +template<typename T> +bool data<T>::has_clients () { bool retval = false; for (int n=0; n<vectorlength; ++n) { @@ -119,8 +119,8 @@ bool data<T,D>::has_clients () // Storage management -template<class T, int D> -void data<T,D>::getmem (const size_t nelems) +template<typename T> +void data<T>::getmem (const size_t nelems) { const size_t nbytes = nelems * sizeof(T); try { @@ -143,8 +143,8 @@ void data<T,D>::getmem (const size_t nelems) -template<class T, int D> -void data<T,D>::freemem () +template<typename T> +void data<T>::freemem () { delete [] _storage; assert (total_allocated_bytes > this->_allocated_bytes); @@ -156,10 +156,10 @@ void data<T,D>::freemem () -template<class T, int D> -void data<T,D>::allocate (const ibbox& extent_, - const int proc_, - void* const mem) +template<typename T> +void data<T>::allocate (const ibbox& extent_, + const int proc_, + void* const mem) { assert (!this->_has_storage); this->_has_storage = true; @@ -172,7 +172,7 @@ void data<T,D>::allocate (const ibbox& 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) { + for (int d=0; d<dim; ++d) { this->_stride[d] = this->_size; assert (this->_shape[d]==0 || this->_size <= INT_MAX / this->_shape[d]); this->_size *= this->_shape[d]; @@ -196,8 +196,8 @@ void data<T,D>::allocate (const ibbox& extent_, } } -template<class T, int D> -void data<T,D>::free () +template<typename T> +void data<T>::free () { if (this->_storage && this->_owns_storage && this->vectorindex==0) { freemem (); @@ -206,8 +206,8 @@ void data<T,D>::free () this->_has_storage = false; } -template<class T, int D> -void data<T,D>::transfer_from (gdata<D>* gsrc) +template<typename T> +void data<T>::transfer_from (gdata* gsrc) { assert (this->vectorlength==1); data* src = (data*)gsrc; @@ -217,8 +217,8 @@ void data<T,D>::transfer_from (gdata<D>* gsrc) *src = data(this->varindex, this->transport_operator); } -template<class T, int D> -T* data<T,D>::vectordata (const int vectorindex_) const +template<typename T> +T* data<T>::vectordata (const int vectorindex_) const { assert (this->vectorindex==0); assert (! this->vectorleader); @@ -230,10 +230,10 @@ T* data<T,D>::vectordata (const int vectorindex_) const // Processor management -template<class T, int D> -void data<T,D>::change_processor_recv (comm_state<D>& state, - const int newproc, - void* const mem) +template<typename T> +void data<T>::change_processor_recv (comm_state& state, + const int newproc, + void* const mem) { DECLARE_CCTK_PARAMETERS; @@ -283,10 +283,10 @@ void data<T,D>::change_processor_recv (comm_state<D>& state, -template<class T, int D> -void data<T,D>::change_processor_send (comm_state<D>& state, - const int newproc, - void* const mem) +template<typename T> +void data<T>::change_processor_send (comm_state& state, + const int newproc, + void* const mem) { DECLARE_CCTK_PARAMETERS; @@ -329,10 +329,10 @@ void data<T,D>::change_processor_send (comm_state<D>& state, -template<class T, int D> -void data<T,D>::change_processor_wait (comm_state<D>& state, - const int newproc, - void* const mem) +template<typename T> +void data<T>::change_processor_wait (comm_state& state, + const int newproc, + void* const mem) { DECLARE_CCTK_PARAMETERS; @@ -400,9 +400,9 @@ void data<T,D>::change_processor_wait (comm_state<D>& state, // Data manipulators -template<class T, int D> -void data<T,D> -::copy_from_innerloop (const gdata<D>* gsrc, const ibbox& box) +template<typename T> +void data<T> +::copy_from_innerloop (const gdata* gsrc, const ibbox& box) { const data* src = (const data*)gsrc; assert (this->has_storage() && src->has_storage()); @@ -438,9 +438,9 @@ void data<T,D> -template<class T, int D> -void data<T,D> -::interpolate_from_innerloop (const vector<const gdata<D>*> gsrcs, +template<typename T> +void data<T> +::interpolate_from_innerloop (const vector<const gdata*> gsrcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, const int order_space, @@ -471,8 +471,8 @@ void data<T,D> char* groupname = CCTK_GroupName(groupindex); T Tdummy; CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, - "There is no interpolator available for the group \"%s\" with variable type %s, dimension %d, spatial interpolation order %d, temporal interpolation order %d.", - groupname, typestring(Tdummy), D, order_space, order_time); + "There is no interpolator available for the group \"%s\" with variable type %s, spatial interpolation order %d, temporal interpolation order %d.", + groupname, typestring(Tdummy), order_space, order_time); ::free (groupname); } @@ -505,15 +505,18 @@ extern "C" { const int regbbox[3][3]); } -template<class T,int D> -void data<T,D> -::fill_bbox_arrays (int srcshp[D], int dstshp[D], - int srcbbox[D][D], int dstbbox[D][D], int regbbox[D][D], - const data<T,D>::ibbox & box, - const data<T,D>::ibbox & sext, - const data<T,D>::ibbox & dext) +template<class T> +void data<T> +::fill_bbox_arrays (int srcshp[dim], + int dstshp[dim], + int srcbbox[dim][dim], + int dstbbox[dim][dim], + int regbbox[dim][dim], + const ibbox & box, + const ibbox & sext, + const ibbox & dext) { - for (int d=0; d<D; ++d) { + for (int d=0; d<dim; ++d) { srcshp[d] = (sext.shape() / sext.stride())[d]; dstshp[d] = (dext.shape() / dext.stride())[d]; @@ -532,8 +535,8 @@ void data<T,D> } template<> -void data<CCTK_INT4,3> -::copy_from_innerloop (const gdata<3>* gsrc, const ibbox& box) +void data<CCTK_INT4> +::copy_from_innerloop (const gdata* gsrc, const ibbox& box) { const data* src = (const data*)gsrc; assert (has_storage() && src->has_storage()); @@ -575,8 +578,8 @@ void data<CCTK_INT4,3> } template<> -void data<CCTK_REAL8,3> -::copy_from_innerloop (const gdata<3>* gsrc, const ibbox& box) +void data<CCTK_REAL8> +::copy_from_innerloop (const gdata* gsrc, const ibbox& box) { const data* src = (const data*)gsrc; assert (has_storage() && src->has_storage()); @@ -618,8 +621,8 @@ void data<CCTK_REAL8,3> } template<> -void data<CCTK_COMPLEX16,3> -::copy_from_innerloop (const gdata<3>* gsrc, const ibbox& box) +void data<CCTK_COMPLEX16> +::copy_from_innerloop (const gdata* gsrc, const ibbox& box) { const data* src = (const data*)gsrc; assert (has_storage() && src->has_storage()); @@ -877,15 +880,15 @@ extern "C" { } template<> -bool data<CCTK_REAL8,3> -::interpolate_in_time (const vector<const gdata<3>*> & gsrcs, - const vector<CCTK_REAL> & times, - const ibbox& box, const CCTK_REAL time, - const int order_space, - const int order_time) { +bool data<CCTK_REAL8> +::interpolate_in_time (const vector<const gdata*> & gsrcs, + const vector<CCTK_REAL> & times, + const ibbox& box, const CCTK_REAL time, + const int order_space, + const int order_time) { for (size_t tl=0; tl<times.size(); ++tl) { if (abs(times[tl] - time) < eps) { - vector<const gdata<3>*> my_gsrcs(1); + vector<const gdata*> my_gsrcs(1); vector<CCTK_REAL> my_times(1); my_gsrcs[0] = gsrcs[tl]; my_times[0] = times[tl]; @@ -898,11 +901,11 @@ bool data<CCTK_REAL8,3> return false; } -template<class T, int D> -void data<T,D> -::interpolate_restrict (const vector<const data<T,D>*> & srcs, - const vector<CCTK_REAL> & times, - const ibbox& box) +template<typename T> +void data<T> +::interpolate_restrict (const vector<const data<T>*> & srcs, + const vector<CCTK_REAL> & times, + const ibbox& box) { const ibbox& sext = srcs[0]->extent(); const ibbox& dext = this->extent(); @@ -910,8 +913,8 @@ void data<T,D> int srcshp[3], dstshp[3]; int srcbbox[3][3], dstbbox[3][3], regbbox[3][3]; - fill_bbox_arrays( srcshp, dstshp, srcbbox, dstbbox, regbbox, - box, sext, dext ); + fill_bbox_arrays (srcshp, dstshp, srcbbox, dstbbox, regbbox, + box, sext, dext ); switch (this->transport_operator) { @@ -941,24 +944,24 @@ void data<T,D> } } -template<class T, int D> -void data<T,D> -::interpolate_prolongate (const vector<const data<T,D>*> & srcs, - const vector<CCTK_REAL> & times, - const ibbox& box, const CCTK_REAL time, - const int order_space, - const int order_time) +template<typename T> +void data<T> +::interpolate_prolongate (const vector<const data<T>*> & srcs, + const vector<CCTK_REAL> & times, + const ibbox& box, const CCTK_REAL time, + const int order_space, + const int order_time) { const ibbox& sext = srcs[0]->extent(); const ibbox& dext = this->extent(); - int srcshp[3], dstshp[3]; - int srcbbox[3][3], dstbbox[3][3], regbbox[3][3]; + int srcshp[dim], dstshp[dim]; + int srcbbox[dim][dim], dstbbox[dim][dim], regbbox[dim][dim]; - fill_bbox_arrays( srcshp, dstshp, srcbbox, dstbbox, regbbox, - box, sext, dext ); + fill_bbox_arrays (srcshp, dstshp, srcbbox, dstbbox, regbbox, + box, sext, dext); switch (this->transport_operator) { - + case op_Lagrange: switch (order_time) { @@ -1308,7 +1311,7 @@ void data<T,D> } template<> -void data<CCTK_REAL8,3> +void data<CCTK_REAL8> ::Check_that_the_times_are_consistent (const vector<CCTK_REAL> & times, const CCTK_REAL time) { @@ -1329,8 +1332,8 @@ void data<CCTK_REAL8,3> } template<> -void data<CCTK_REAL8,3> -::interpolate_from_innerloop (const vector<const gdata<3>*> gsrcs, +void data<CCTK_REAL8> +::interpolate_from_innerloop (const vector<const gdata*> gsrcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, const int order_space, @@ -1392,11 +1395,11 @@ void data<CCTK_REAL8,3> } // Output -template<class T,int D> -ostream& data<T,D>::output (ostream& os) const +template<typename T> +ostream& data<T>::output (ostream& os) const { T Tdummy; - os << "data<" << typestring(Tdummy) << "," << D << ">:" + os << "data<" << typestring(Tdummy) << ">:" << "extent=" << this->extent() << "," << "stride=" << this->stride() << ",size=" << this->size(); return os; @@ -1405,7 +1408,7 @@ ostream& data<T,D>::output (ostream& os) const #define INSTANTIATE(T) \ -template class data<T,3>; +template class data<T>; #include "instantiate" diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh index f9c6d55d5..e85a60f9c 100644 --- a/Carpet/CarpetLib/src/data.hh +++ b/Carpet/CarpetLib/src/data.hh @@ -19,14 +19,10 @@ using namespace std; // A distributed multi-dimensional array -template<class T,int D> -class data: public gdata<D> +template<typename T> +class data: public gdata { - // Types - typedef vect<int,D> ivect; - typedef bbox<int,D> ibbox; - // Fields T* _storage; // the data (if located on this processor) size_t _allocated_bytes; // number of allocated bytes @@ -68,7 +64,7 @@ public: virtual void allocate (const ibbox& extent, const int proc, void* const mem=0); virtual void free (); - virtual void transfer_from (gdata<D>* gsrc); + virtual void transfer_from (gdata* gsrc); private: T* vectordata (const int vectorindex) const; @@ -76,13 +72,13 @@ public: // Processor management private: - virtual void change_processor_recv (comm_state<D>& state, + virtual void change_processor_recv (comm_state& state, const int newproc, void* const mem=0); - virtual void change_processor_send (comm_state<D>& state, + virtual void change_processor_send (comm_state& state, const int newproc, void* const mem=0); - virtual void change_processor_wait (comm_state<D>& state, + virtual void change_processor_wait (comm_state& state, const int newproc, void* const mem=0); public: @@ -115,13 +111,16 @@ public: // Data manipulators private: static void - fill_bbox_arrays (int srcshp[D], int dstshp[D], - int srcbbox[D][D], int dstbbox[D][D], int regbbox[D][D], + fill_bbox_arrays (int srcshp[dim], + int dstshp[dim], + int srcbbox[dim][dim], + int dstbbox[dim][dim], + int regbbox[dim][dim], const ibbox & box, const ibbox & sext, const ibbox & dext); public: - void copy_from_innerloop (const gdata<D>* gsrc, + void copy_from_innerloop (const gdata* gsrc, const ibbox& box); - void interpolate_from_innerloop (const vector<const gdata<D>*> gsrcs, + void interpolate_from_innerloop (const vector<const gdata*> gsrcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, const int order_space, @@ -133,15 +132,15 @@ public: // Output ostream& output (ostream& os) const; private: - bool interpolate_in_time (const vector<const gdata<D>*> & gsrcs, + bool interpolate_in_time (const vector<const gdata*> & gsrcs, const vector<CCTK_REAL> & times, const ibbox& box, const CCTK_REAL time, const int order_space, const int order_time); - void interpolate_restrict (const vector<const data<T,D>*> & gsrcs, + void interpolate_restrict (const vector<const data<T>*> & gsrcs, const vector<CCTK_REAL> & times, const ibbox& box); - void interpolate_prolongate (const vector<const data<T,D>*> & gsrcs, + void interpolate_prolongate (const vector<const data<T>*> & gsrcs, const vector<CCTK_REAL> & times, const ibbox& box, const CCTK_REAL time, const int order_space, @@ -155,8 +154,8 @@ private: // Declare a specialisation template<> -void data<CCTK_REAL8,3> -::interpolate_from_innerloop (const vector<const gdata<3>*> gsrcs, +void data<CCTK_REAL8> +::interpolate_from_innerloop (const vector<const gdata*> gsrcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, const int order_space, diff --git a/Carpet/CarpetLib/src/defs.hh b/Carpet/CarpetLib/src/defs.hh index 54219ecc3..0ca508771 100644 --- a/Carpet/CarpetLib/src/defs.hh +++ b/Carpet/CarpetLib/src/defs.hh @@ -18,11 +18,37 @@ #include "cctk.h" + + using namespace std; + + +// Number of dimensions +const int dim = 3; + + + +// Some shortcuts for type names +template<typename T, int D> class bbox; +template<typename T, int D> class bboxset; +template<typename T, int D> class vect; + +typedef vect<bool,dim> bvect; +typedef vect<int,dim> ivect; +typedef bbox<int,dim> ibbox; +typedef bboxset<int,dim> ibset; + +typedef vect<vect<bool,2>,dim> bbvect; +typedef vect<vect<int,2>,dim> iivect; + + + // A general type enum centering { vertex_centered, cell_centered }; + + // Useful helper template<class T> inline T square (const T& x) { return x*x; } diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc index b232c7312..ae2025ddc 100644 --- a/Carpet/CarpetLib/src/dh.cc +++ b/Carpet/CarpetLib/src/dh.cc @@ -15,10 +15,9 @@ using namespace std; // Constructors -template<int D> -dh<D>::dh (gh<D>& h, - const ivect& lghosts, const ivect& ughosts, - const int prolongation_order_space, const int buffer_width) +dh::dh (gh& h, + const ivect& lghosts, const ivect& ughosts, + const int prolongation_order_space, const int buffer_width) : h(h), lghosts(lghosts), ughosts(ughosts), prolongation_order_space(prolongation_order_space), @@ -33,23 +32,20 @@ dh<D>::dh (gh<D>& h, } // Destructors -template<int D> -dh<D>::~dh () +dh::~dh () { CHECKPOINT; h.remove(this); } // Helpers -template<int D> -int dh<D>::prolongation_stencil_size () const { +int dh::prolongation_stencil_size () const { assert (prolongation_order_space>=0); return prolongation_order_space/2; } // Modifiers -template<int D> -void dh<D>::recompose (const bool do_prolongate) { +void dh::recompose (const bool do_prolongate) { DECLARE_CCTK_PARAMETERS; CHECKPOINT; @@ -58,23 +54,23 @@ void dh<D>::recompose (const bool do_prolongate) { allocate_bboxes(); - foreach_reflevel_component_mglevel (&dh<D>::setup_sync_and_refine_boxes ); - foreach_reflevel_component_mglevel (&dh<D>::intersect_sync_with_interior ); - foreach_reflevel_component_mglevel (&dh<D>::setup_multigrid_boxes ); - foreach_reflevel_component_mglevel (&dh<D>::setup_refinement_interior_boxes ); - foreach_reflevel_component_mglevel (&dh<D>::setup_refinement_exterior_boxes ); - foreach_reflevel_component_mglevel (&dh<D>::setup_restrict_interior_boxes ); - foreach_reflevel_component_mglevel (&dh<D>::trim_unsynced_boundaries ); + foreach_reflevel_component_mglevel (&dh::setup_sync_and_refine_boxes ); + foreach_reflevel_component_mglevel (&dh::intersect_sync_with_interior ); + foreach_reflevel_component_mglevel (&dh::setup_multigrid_boxes ); + foreach_reflevel_component_mglevel (&dh::setup_refinement_interior_boxes ); + foreach_reflevel_component_mglevel (&dh::setup_refinement_exterior_boxes ); + foreach_reflevel_component_mglevel (&dh::setup_restrict_interior_boxes ); + foreach_reflevel_component_mglevel (&dh::trim_unsynced_boundaries ); calculate_bases(); if (output_bboxes) { cout << endl << h << endl; - foreach_reflevel_component_mglevel (&dh<D>::output_bboxes ); + foreach_reflevel_component_mglevel (&dh::output_bboxes ); output_bases(); } - foreach_reflevel_component_mglevel (&dh<D>::assert_assert_assert ); + foreach_reflevel_component_mglevel (&dh::assert_assert_assert ); if (! save_memory_during_regridding) { save_time( do_prolongate); @@ -83,8 +79,7 @@ void dh<D>::recompose (const bool do_prolongate) { } } -template<int D> -void dh<D>::allocate_bboxes() { +void dh::allocate_bboxes() { boxes.resize(h.reflevels()); for (int rl=0; rl<h.reflevels(); ++rl) { boxes.at(rl).resize(h.components(rl)); @@ -104,7 +99,7 @@ void dh<D>::allocate_bboxes() { // the interior of this or other components; the content of // the exterior is redundant) ivect ldist(lghosts), udist(ughosts); - for (int d=0; d<D; ++d) { + for (int d=0; d<dim; ++d) { if (h.outer_boundaries().at(rl).at(c)[d][0]) ldist[d] = 0; if (h.outer_boundaries().at(rl).at(c)[d][1]) udist[d] = 0; } @@ -122,8 +117,7 @@ void dh<D>::allocate_bboxes() { // Loops over each refinement level, each component, and each multigrid // level, executing the "boxesop" member function argument on the corresponding // element of the "boxes" member -template<int D> -void dh<D>::foreach_reflevel_component_mglevel (dh<D>::boxesop op) { +void dh::foreach_reflevel_component_mglevel (dh::boxesop op) { for (int rl=0; rl<h.reflevels(); ++rl) { for (int c=0; c<h.components(rl); ++c) { @@ -135,8 +129,7 @@ void dh<D>::foreach_reflevel_component_mglevel (dh<D>::boxesop op) { } } -template<int D> -void dh<D>::setup_sync_and_refine_boxes( dh<D>::dboxes & b, int rl, int c, int ml ) +void dh::setup_sync_and_refine_boxes( dh::dboxes & b, int rl, int c, int ml ) { // Sync boxes const int cs = h.components(rl); @@ -158,8 +151,7 @@ void dh<D>::setup_sync_and_refine_boxes( dh<D>::dboxes & b, int rl, int c, int m } } -template<int D> -void dh<D>::intersect_sync_with_interior( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::intersect_sync_with_interior( dh::dboxes & box, int rl, int c, int ml ) { const ibset& bnds = box.boundaries; @@ -170,15 +162,14 @@ void dh<D>::intersect_sync_with_interior( dh<D>::dboxes & box, int rl, int c, in // intersect boundaries with interior of that component ibset ovlp = bnds & box1.interior; ovlp.normalize(); - for (typename ibset::const_iterator b=ovlp.begin();b!=ovlp.end(); ++b) { + for (ibset::const_iterator b=ovlp.begin();b!=ovlp.end(); ++b) { box .recv_sync.at(cc).push_back(*b); box1.send_sync.at(c ).push_back(*b); } } } -template<int D> -void dh<D>::setup_multigrid_boxes( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::setup_multigrid_boxes( dh::dboxes & box, int rl, int c, int ml ) { const ibbox& intr = box.interior; const ibbox& extr = box.exterior; @@ -219,8 +210,7 @@ void dh<D>::setup_multigrid_boxes( dh<D>::dboxes & box, int rl, int c, int ml ) } // if not finest multigrid level } -template<int D> -void dh<D>::setup_refinement_interior_boxes( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::setup_refinement_interior_boxes( dh::dboxes & box, int rl, int c, int ml ) { const ibbox& intr = box.interior; const ibbox& extr = box.exterior; @@ -239,9 +229,9 @@ void dh<D>::setup_refinement_interior_boxes( dh<D>::dboxes & box, int rl, int c, const int pss = prolongation_stencil_size(); ibset recvs = extr.expand(-pss,-pss).contracted_for(intrf) & intrf; const iblistvect& rrc = box1.recv_ref_coarse; - for (typename iblistvect::const_iterator lvi=rrc.begin(); + for (iblistvect::const_iterator lvi=rrc.begin(); lvi!=rrc.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { recvs -= *li; } @@ -261,8 +251,7 @@ void dh<D>::setup_refinement_interior_boxes( dh<D>::dboxes & box, int rl, int c, } // if not finest refinement level } -template<int D> -void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::setup_refinement_exterior_boxes( dh::dboxes & box, int rl, int c, int ml ) { const ibbox& intr = box.interior; const ibbox& extr = box.exterior; @@ -275,7 +264,7 @@ void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, const ibbox& extrf = box1.exterior; const ibset& bndsf = box1.boundaries; // Prolongation (boundaries) - // TODO: prefer boxes from the same processor + // TODO: prefer boxes from the same processor { // (the prolongation may use the exterior of the coarse // grid, and must fill all of the boundary of the fine @@ -286,9 +275,9 @@ void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, { // Do not count what is synced const iblistvect& rs = box1.recv_sync; - for (typename iblistvect::const_iterator lvi=rs.begin(); + for (iblistvect::const_iterator lvi=rs.begin(); lvi!=rs.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { pbndsf -= *li; } @@ -298,7 +287,7 @@ void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, // Buffer zones ibset buffers; { - for (typename ibset::const_iterator pbi=pbndsf.begin(); + for (ibset::const_iterator pbi=pbndsf.begin(); pbi!=pbndsf.end(); ++pbi) { buffers |= (*pbi).expand(buffer_width, buffer_width) & extrf; } @@ -311,9 +300,9 @@ void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, { // Do not prolongate what is already prolongated const iblistvect& rrbc = box1.recv_ref_bnd_coarse; - for (typename iblistvect::const_iterator lvi=rrbc.begin(); + for (iblistvect::const_iterator lvi=rrbc.begin(); lvi!=rrbc.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { recvs -= *li; } @@ -321,7 +310,7 @@ void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, recvs.normalize(); } { - for (typename ibset::const_iterator ri = recvs.begin(); + for (ibset::const_iterator ri = recvs.begin(); ri != recvs.end(); ++ri) { const ibbox & recv = *ri; const ibbox send = recv.expanded_for(extr); @@ -338,8 +327,7 @@ void dh<D>::setup_refinement_exterior_boxes( dh<D>::dboxes & box, int rl, int c, } // if not finest refinement level } -template<int D> -void dh<D>::setup_restrict_interior_boxes( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::setup_restrict_interior_boxes( dh::dboxes & box, int rl, int c, int ml ) { const ibbox& intr = box.interior; const ibbox& extr = box.exterior; @@ -360,13 +348,13 @@ void dh<D>::setup_restrict_interior_boxes( dh<D>::dboxes & box, int rl, int c, i // remove what is received during boundary prolongation for (int ccc=0; ccc<h.components(rl); ++ccc) { const iblist& sendlist = box1.recv_ref_bnd_coarse.at(ccc); - for (typename iblist::const_iterator sli = sendlist.begin(); + for (iblist::const_iterator sli = sendlist.begin(); sli != sendlist.end(); ++sli) { sends -= *sli; } } sends.normalize(); - for (typename ibset::const_iterator si = sends.begin(); + for (ibset::const_iterator si = sends.begin(); si != sends.end(); ++si) { const ibbox recv = (*si).contracted_for(intr); if (! recv.empty()) { @@ -382,8 +370,7 @@ void dh<D>::setup_restrict_interior_boxes( dh<D>::dboxes & box, int rl, int c, i } // if not finest refinement level } -template<int D> -void dh<D>::trim_unsynced_boundaries( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::trim_unsynced_boundaries( dh::dboxes & box, int rl, int c, int ml ) { // Boundaries that are not synced, or are neither synced nor // prolonged to from coarser grids (outer boundaries) @@ -396,9 +383,9 @@ void dh<D>::trim_unsynced_boundaries( dh<D>::dboxes & box, int rl, int c, int ml // Subtract boxes received during synchronisation const iblistvect& recv_sync = box.recv_sync; - for (typename iblistvect::const_iterator lvi=recv_sync.begin(); + for (iblistvect::const_iterator lvi=recv_sync.begin(); lvi!=recv_sync.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { sync_not -= *li; recv_not -= *li; @@ -407,17 +394,16 @@ void dh<D>::trim_unsynced_boundaries( dh<D>::dboxes & box, int rl, int c, int ml // Subtract boxes received during prolongation const iblistvect& recv_ref_bnd_coarse = box.recv_ref_bnd_coarse; - for (typename iblistvect::const_iterator lvi=recv_ref_bnd_coarse.begin(); + for (iblistvect::const_iterator lvi=recv_ref_bnd_coarse.begin(); lvi!=recv_ref_bnd_coarse.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { recv_not -= *li; } } } -template<int D> -void dh<D>::assert_assert_assert( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::assert_assert_assert( dh::dboxes & box, int rl, int c, int ml ) { // Assert that all boundaries are synced or received { @@ -442,10 +428,10 @@ void dh<D>::assert_assert_assert( dh<D>::dboxes & box, int rl, int c, int ml ) } else { // rl!=0 const iblistvect& recv_ref_coarse = box.recv_ref_coarse; ibset intr = box.interior; - for (typename iblistvect::const_iterator + for (iblistvect::const_iterator lvi=recv_ref_coarse.begin(); lvi!=recv_ref_coarse.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { const int old_sz = intr.size(); const int this_sz = li->size(); @@ -472,9 +458,9 @@ void dh<D>::assert_assert_assert( dh<D>::dboxes & box, int rl, int c, int ml ) const iblistvect& recv_sync = box.recv_sync; const iblistvect& recv_ref_bnd_coarse = box.recv_ref_bnd_coarse; ibset bnds = box.boundaries; - for (typename iblistvect::const_iterator lvi=recv_sync.begin(); + for (iblistvect::const_iterator lvi=recv_sync.begin(); lvi!=recv_sync.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { const int old_sz = bnds.size(); const int this_sz = li->size(); @@ -483,10 +469,10 @@ void dh<D>::assert_assert_assert( dh<D>::dboxes & box, int rl, int c, int ml ) assert (new_sz + this_sz == old_sz); } } - for (typename iblistvect::const_iterator + for (iblistvect::const_iterator lvi=recv_ref_bnd_coarse.begin(); lvi!=recv_ref_bnd_coarse.end(); ++lvi) { - for (typename iblist::const_iterator li=lvi->begin(); + for (iblist::const_iterator li=lvi->begin(); li!=lvi->end(); ++li) { const int old_sz = bnds.size(); const int this_sz = li->size(); @@ -509,8 +495,7 @@ void dh<D>::assert_assert_assert( dh<D>::dboxes & box, int rl, int c, int ml ) } } -template<int D> -void dh<D>::calculate_bases () { +void dh::calculate_bases () { // Calculate bases bases.resize(h.reflevels()); for (int rl=0; rl<h.reflevels(); ++rl) { @@ -533,45 +518,43 @@ void dh<D>::calculate_bases () { } } -template<int D> -void dh<D>::save_time ( bool do_prolongate ) { - for (typename list<ggf<D>*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { +void dh::save_time ( bool do_prolongate ) { + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_crop (); } for (int rl=0; rl<h.reflevels(); ++rl) { - for (typename list<ggf<D>*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_allocate (rl); } - for (comm_state<D> state; !state.done(); state.step()) { - for (typename list<ggf<D>*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { + for (comm_state state; !state.done(); state.step()) { + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_fill (state, rl, do_prolongate); } } - for (typename list<ggf<D>*>::reverse_iterator f=gfs.rbegin(); f!=gfs.rend(); ++f) { + for (list<ggf*>::reverse_iterator f=gfs.rbegin(); f!=gfs.rend(); ++f) { (*f)->recompose_free (rl); } - for (comm_state<D> state; !state.done(); state.step()) { - for (typename list<ggf<D>*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { + for (comm_state state; !state.done(); state.step()) { + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_bnd_prolongate (state, rl, do_prolongate); } } - for (comm_state<D> state; !state.done(); state.step()) { - for (typename list<ggf<D>*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { + for (comm_state state; !state.done(); state.step()) { + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_sync (state, rl, do_prolongate); } } } // for rl } -template<int D> -void dh<D>::save_memory ( bool do_prolongate ) { - ggf<D>* vectorleader = NULL; - for (typename list<ggf<D>*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { +void dh::save_memory ( bool do_prolongate ) { + ggf* vectorleader = NULL; + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_crop (); for (int rl=0; rl<h.reflevels(); ++rl) { (*f)->recompose_allocate (rl); - for (comm_state<D> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { (*f)->recompose_fill (state, rl, do_prolongate); } assert ((*f)->vectorlength >= 1); @@ -600,10 +583,10 @@ void dh<D>::save_memory ( bool do_prolongate ) { } } } - for (comm_state<D> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { (*f)->recompose_bnd_prolongate (state, rl, do_prolongate); } - for (comm_state<D> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { (*f)->recompose_sync (state, rl, do_prolongate); } } // for rl @@ -613,27 +596,24 @@ void dh<D>::save_memory ( bool do_prolongate ) { } // Grid function management -template<int D> -void dh<D>::add (ggf<D>* f) { +void dh::add (ggf* f) { CHECKPOINT; gfs.push_back(f); } -template<int D> -void dh<D>::remove (ggf<D>* f) { +void dh::remove (ggf* f) { CHECKPOINT; gfs.remove(f); } // Output -template<int D> -void dh<D>::output (ostream& os) const { - os << "dh<" << D << ">:" +void dh::output (ostream& os) const { + os << "dh:" << "ghosts=[" << lghosts << "," << ughosts << "]," << "gfs={"; int cnt=0; - for (typename list<ggf<D>*>::const_iterator f = gfs.begin(); + for (list<ggf*>::const_iterator f = gfs.begin(); f != gfs.end(); ++f) { if (cnt++) os << ","; (*f)->output(os); @@ -641,8 +621,7 @@ void dh<D>::output (ostream& os) const { os << "}"; } -template<int D> -void dh<D>::output_bboxes( dh<D>::dboxes & box, int rl, int c, int ml ) +void dh::output_bboxes( dh::dboxes & box, int rl, int c, int ml ) { cout << endl; cout << "dh bboxes:" << endl; @@ -666,8 +645,7 @@ void dh<D>::output_bboxes( dh<D>::dboxes & box, int rl, int c, int ml ) cout << "recv_not=" << box.recv_not << endl; } -template<int D> -void dh<D>::output_bases () { +void dh::output_bases () { for (int rl=0; rl<h.reflevels(); ++rl) { if (h.components(rl)>0) { for (int ml=0; ml<h.mglevels(rl,0); ++ml) { @@ -682,6 +660,3 @@ void dh<D>::output_bases () { } } } - - -template class dh<3>; diff --git a/Carpet/CarpetLib/src/dh.hh b/Carpet/CarpetLib/src/dh.hh index dccd0d381..a5aac5abf 100644 --- a/Carpet/CarpetLib/src/dh.hh +++ b/Carpet/CarpetLib/src/dh.hh @@ -18,28 +18,23 @@ using namespace std; // Forward declaration -template<int D> class ggf; -template<int D> class dh; +class ggf; +class dh; // Output -template<int D> -ostream& operator<< (ostream& os, const dh<D>& d); +ostream& operator<< (ostream& os, const dh& d); // A data hierarchy (grid hierarchy plus ghost zones) -template<int D> class dh { // Types - typedef vect<int,D> ivect; - typedef bbox<int,D> ibbox; - typedef bboxset<int,D> ibset; - typedef list<ibbox> iblist; public: + typedef list<ibbox> iblist; typedef vector<iblist> iblistvect; // vector of lists - - + + // in here, the term "boundary" means both ghost zones and // refinement boundaries, but does not refer to outer (physical) // boundaries. @@ -97,7 +92,7 @@ private: // generic member function taking a dboxes, // a refinement level, a component, and a // multigrid level - typedef void (dh<D>::*boxesop)( dboxes &, int rl, int c, int ml ); + typedef void (dh::*boxesop)( dboxes &, int rl, int c, int ml ); void foreach_reflevel_component_mglevel ( boxesop op ); // these all of form 'boxesop' @@ -119,7 +114,7 @@ private: public: // should be readonly // Fields - gh<D>& h; // hierarchy + gh& h; // hierarchy ivect lghosts, ughosts; // ghost zones int prolongation_order_space; // order of spatial prolongation operator @@ -128,12 +123,12 @@ public: // should be readonly rboxes boxes; rbases bases; - list<ggf<D>*> gfs; // list of all grid functions + list<ggf*> gfs; // list of all grid functions public: // Constructors - dh (gh<D>& h, const ivect& lghosts, const ivect& ughosts, + dh (gh& h, const ivect& lghosts, const ivect& ughosts, int prolongation_order_space, int buffer_width); // Destructors @@ -146,8 +141,8 @@ public: void recompose (const bool do_prolongate); // Grid function management - void add (ggf<D>* f); - void remove (ggf<D>* f); + void add (ggf* f); + void remove (ggf* f); // Output virtual void output (ostream& os) const; @@ -155,8 +150,7 @@ public: -template<int D> -inline ostream& operator<< (ostream& os, const dh<D>& d) { +inline ostream& operator<< (ostream& os, const dh& d) { d.output(os); return os; } diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc index 37a78069a..2a921807c 100644 --- a/Carpet/CarpetLib/src/gdata.cc +++ b/Carpet/CarpetLib/src/gdata.cc @@ -20,14 +20,12 @@ using namespace std; // Communication state control -template<int D> -comm_state<D>::comm_state () +comm_state::comm_state () : thestate(state_recv) { } -template<int D> -void comm_state<D>::step () +void comm_state::step () { DECLARE_CCTK_PARAMETERS; @@ -73,14 +71,12 @@ void comm_state<D>::step () } } -template<int D> -bool comm_state<D>::done () +bool comm_state::done () { return thestate==state_done; } -template<int D> -comm_state<D>::~comm_state () +comm_state::~comm_state () { assert (thestate==state_recv || thestate==state_done); assert (tmps1.empty()); @@ -105,8 +101,7 @@ static int nexttag () // Constructors -template<int D> -gdata<D>::gdata (const int varindex_, const operator_type transport_operator_) +gdata::gdata (const int varindex_, const operator_type transport_operator_) : varindex(varindex_), transport_operator(transport_operator_), _has_storage(false), comm_active(false), @@ -119,8 +114,7 @@ gdata<D>::gdata (const int varindex_, const operator_type transport_operator_) } // Destructors -template<int D> -gdata<D>::~gdata () +gdata::~gdata () { DECLARE_CCTK_PARAMETERS; if (barriers) { @@ -129,8 +123,7 @@ gdata<D>::~gdata () } // Assignment -template<int D> -gdata<D> & gdata<D>::operator= (gdata const & from) +gdata & gdata::operator= (gdata const & from) { return * this = from; } @@ -138,10 +131,9 @@ gdata<D> & gdata<D>::operator= (gdata const & from) // Processor management -template<int D> -void gdata<D>::change_processor (comm_state<D>& state, - const int newproc, - void* const mem) +void gdata::change_processor (comm_state& state, + const int newproc, + void* const mem) { DECLARE_CCTK_PARAMETERS; @@ -172,9 +164,8 @@ void gdata<D>::change_processor (comm_state<D>& state, // Data manipulators -template<int D> -void gdata<D>::copy_from (comm_state<D>& state, - const gdata* src, const ibbox& box) +void gdata::copy_from (comm_state& state, + const gdata* src, const ibbox& box) { DECLARE_CCTK_PARAMETERS; @@ -204,8 +195,7 @@ void gdata<D>::copy_from (comm_state<D>& state, -template<int D> -void gdata<D>::copy_from_nocomm (const gdata* src, const ibbox& box) +void gdata::copy_from_nocomm (const gdata* src, const ibbox& box) { assert (has_storage() && src->has_storage()); assert (all(box.lower()>=extent().lower() @@ -230,9 +220,8 @@ void gdata<D>::copy_from_nocomm (const gdata* src, const ibbox& box) -template<int D> -void gdata<D>::copy_from_recv (comm_state<D>& state, - const gdata* src, const ibbox& box) +void gdata::copy_from_recv (comm_state& state, + const gdata* src, const ibbox& box) { assert (has_storage() && src->has_storage()); assert (all(box.lower()>=extent().lower() @@ -255,7 +244,7 @@ void gdata<D>::copy_from_recv (comm_state<D>& state, // copy to different processor wtime_copyfrom_recv_maketyped.start(); - gdata<D>* const tmp = make_typed(varindex, transport_operator); + gdata* const tmp = make_typed(varindex, transport_operator); wtime_copyfrom_recv_maketyped.stop(); state.tmps1.push (tmp); wtime_copyfrom_recv_allocate.start(); @@ -272,9 +261,8 @@ void gdata<D>::copy_from_recv (comm_state<D>& state, -template<int D> -void gdata<D>::copy_from_send (comm_state<D>& state, - const gdata* src, const ibbox& box) +void gdata::copy_from_send (comm_state& state, + const gdata* src, const ibbox& box) { assert (has_storage() && src->has_storage()); assert (all(box.lower()>=extent().lower() @@ -300,7 +288,7 @@ void gdata<D>::copy_from_send (comm_state<D>& state, } else { // copy to different processor - gdata<D>* const tmp = state.tmps1.front(); + gdata* const tmp = state.tmps1.front(); state.tmps1.pop(); state.tmps2.push (tmp); assert (tmp); @@ -318,9 +306,8 @@ void gdata<D>::copy_from_send (comm_state<D>& state, -template<int D> -void gdata<D>::copy_from_wait (comm_state<D>& state, - const gdata* src, const ibbox& box) +void gdata::copy_from_wait (comm_state& state, + const gdata* src, const ibbox& box) { assert (has_storage() && src->has_storage()); assert (all(box.lower()>=extent().lower() @@ -342,7 +329,7 @@ void gdata<D>::copy_from_wait (comm_state<D>& state, } else { // copy to different processor - gdata<D>* const tmp = state.tmps2.front(); + gdata* const tmp = state.tmps2.front(); state.tmps2.pop(); assert (tmp); wtime_copyfrom_wait_changeproc_wait.start(); @@ -362,9 +349,8 @@ void gdata<D>::copy_from_wait (comm_state<D>& state, -template<int D> -void gdata<D> -::interpolate_from (comm_state<D>& state, +void gdata +::interpolate_from (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, @@ -401,8 +387,7 @@ void gdata<D> -template<int D> -void gdata<D> +void gdata ::interpolate_from_nocomm (const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, @@ -438,9 +423,8 @@ void gdata<D> -template<int D> -void gdata<D> -::interpolate_from_recv (comm_state<D>& state, +void gdata +::interpolate_from_recv (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, @@ -468,7 +452,7 @@ void gdata<D> } else { // interpolate from other processor - gdata<D>* const tmp = make_typed(varindex, transport_operator); + gdata* const tmp = make_typed(varindex, transport_operator); state.tmps1.push (tmp); tmp->allocate (box, srcs.at(0)->proc()); tmp->change_processor_recv (state, proc()); @@ -478,9 +462,8 @@ void gdata<D> -template<int D> -void gdata<D> -::interpolate_from_send (comm_state<D>& state, +void gdata +::interpolate_from_send (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, @@ -510,7 +493,7 @@ void gdata<D> } else { // interpolate from other processor - gdata<D>* const tmp = state.tmps1.front(); + gdata* const tmp = state.tmps1.front(); state.tmps1.pop(); state.tmps2.push (tmp); assert (tmp); @@ -522,9 +505,8 @@ void gdata<D> -template<int D> -void gdata<D> -::interpolate_from_wait (comm_state<D>& state, +void gdata +::interpolate_from_wait (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, @@ -552,7 +534,7 @@ void gdata<D> } else { // interpolate from other processor - gdata<D>* const tmp = state.tmps2.front(); + gdata* const tmp = state.tmps2.front(); state.tmps2.pop(); assert (tmp); tmp->change_processor_wait (state, proc()); @@ -561,8 +543,3 @@ void gdata<D> } } - - - -template class comm_state<3>; -template class gdata<3>; diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh index 9d08a5b63..37343b18b 100644 --- a/Carpet/CarpetLib/src/gdata.hh +++ b/Carpet/CarpetLib/src/gdata.hh @@ -21,7 +21,6 @@ using namespace std; -template<int D> class gdata; @@ -29,7 +28,6 @@ class gdata; // State information for communications enum astate { state_recv, state_send, state_wait, state_done }; -template<int D> struct comm_state { astate thestate; comm_state (); @@ -43,20 +41,15 @@ private: comm_state& operator= (comm_state const &); public: - queue<gdata<D>*> tmps1, tmps2; + queue<gdata*> tmps1, tmps2; vector<MPI_Request> requests; // for use_waitall }; // A generic data storage without type information -template<int D> class gdata { - // Types - typedef vect<int,D> ivect; - typedef bbox<int,D> ibbox; - protected: // should be readonly // Fields @@ -90,7 +83,7 @@ public: virtual ~gdata (); // Pseudo constructors - virtual gdata<D>* + virtual gdata* make_typed (const int varindex, const operator_type transport_operator = op_error) const = 0; @@ -98,26 +91,26 @@ public: gdata & operator= (gdata const & from); // Processor management - void change_processor (comm_state<D>& state, + void change_processor (comm_state& state, const int newproc, void* const mem=0); protected: - virtual void change_processor_recv (comm_state<D>& state, + virtual void change_processor_recv (comm_state& state, const int newproc, void* const mem=0) = 0; - virtual void change_processor_send (comm_state<D>& state, + virtual void change_processor_send (comm_state& state, const int newproc, void* const mem=0) = 0; - virtual void change_processor_wait (comm_state<D>& state, + virtual void change_processor_wait (comm_state& state, const int newproc, void* const mem=0) = 0; public: // Storage management - virtual void transfer_from (gdata<D>* src) = 0; + virtual void transfer_from (gdata* src) = 0; virtual void allocate (const ibbox& extent, const int proc, void* const mem=0) = 0; @@ -173,18 +166,18 @@ public: // Data manipulators public: - void copy_from (comm_state<D>& state, + void copy_from (comm_state& state, const gdata* src, const ibbox& box); private: void copy_from_nocomm (const gdata* src, const ibbox& box); - void copy_from_recv (comm_state<D>& state, + void copy_from_recv (comm_state& state, const gdata* src, const ibbox& box); - void copy_from_send (comm_state<D>& state, + void copy_from_send (comm_state& state, const gdata* src, const ibbox& box); - void copy_from_wait (comm_state<D>& state, + void copy_from_wait (comm_state& state, const gdata* src, const ibbox& box); public: - void interpolate_from (comm_state<D>& state, + void interpolate_from (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, @@ -196,19 +189,19 @@ public: const ibbox& box, const CCTK_REAL time, const int order_space, const int order_time); - void interpolate_from_recv (comm_state<D>& state, + void interpolate_from_recv (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, const int order_space, const int order_time); - void interpolate_from_send (comm_state<D>& state, + void interpolate_from_send (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, const int order_space, const int order_time); - void interpolate_from_wait (comm_state<D>& state, + void interpolate_from_wait (comm_state& state, const vector<const gdata*> srcs, const vector<CCTK_REAL> times, const ibbox& box, const CCTK_REAL time, diff --git a/Carpet/CarpetLib/src/gf.cc b/Carpet/CarpetLib/src/gf.cc index 0053d731e..0b0cbad0f 100644 --- a/Carpet/CarpetLib/src/gf.cc +++ b/Carpet/CarpetLib/src/gf.cc @@ -11,31 +11,31 @@ using namespace std; // Constructors -template<class T,int D> -gf<T,D>::gf (const int varindex, const operator_type transport_operator, - th<D>& t, dh<D>& d, - const int tmin, const int tmax, const int prolongation_order_time, - const int vectorlength, const int vectorindex, - gf* const vectorleader) - : ggf<D>(varindex, transport_operator, - t, d, tmin, tmax, prolongation_order_time, - vectorlength, vectorindex, vectorleader) +template<typename T> +gf<T>::gf (const int varindex, const operator_type transport_operator, + th& t, dh& d, + const int tmin, const int tmax, const int prolongation_order_time, + const int vectorlength, const int vectorindex, + gf* const vectorleader) + : ggf(varindex, transport_operator, + t, d, tmin, tmax, prolongation_order_time, + vectorlength, vectorindex, vectorleader) { // this->recompose (); this->recompose_crop (); for (int rl=0; rl<this->h.reflevels(); ++rl) { this->recompose_allocate (rl); #if 0 - for (comm_state<D> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { this->recompose_fill (state, rl, false); } #endif this->recompose_free (rl); #if 0 - for (comm_state<D> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { this->recompose_bnd_prolongate (state, rl, false); } - for (comm_state<D> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { this->recompose_sync (state, rl, false); } #endif @@ -43,37 +43,37 @@ gf<T,D>::gf (const int varindex, const operator_type transport_operator, } // Destructors -template<class T,int D> -gf<T,D>::~gf () { } +template<typename T> +gf<T>::~gf () { } // Access to the data -template<class T,int D> -const data<T,D>* gf<T,D>::operator() (int tl, int rl, int c, int ml) const { +template<typename T> +const data<T>* gf<T>::operator() (int tl, int rl, int c, int ml) const { assert (tl>=this->tmin && tl<=this->tmax); assert (rl>=0 && rl<this->h.reflevels()); assert (c>=0 && c<this->h.components(rl)); assert (ml>=0 && ml<this->h.mglevels(rl,c)); - return (const data<T,D>*)this->storage.at(tl-this->tmin).at(rl).at(c).at(ml); + return (const data<T>*)this->storage.at(tl-this->tmin).at(rl).at(c).at(ml); } -template<class T,int D> -data<T,D>* gf<T,D>::operator() (int tl, int rl, int c, int ml) { +template<typename T> +data<T>* gf<T>::operator() (int tl, int rl, int c, int ml) { assert (tl>=this->tmin && tl<=this->tmax); assert (rl>=0 && rl<this->h.reflevels()); assert (c>=0 && c<this->h.components(rl)); assert (ml>=0 && ml<this->h.mglevels(rl,c)); - return (data<T,D>*)this->storage.at(tl-this->tmin).at(rl).at(c).at(ml); + return (data<T>*)this->storage.at(tl-this->tmin).at(rl).at(c).at(ml); } // Output -template<class T,int D> -ostream& gf<T,D>::output (ostream& os) const { +template<typename T> +ostream& gf<T>::output (ostream& os) const { T Tdummy; - os << "gf<" << typestring(Tdummy) << "," << D << ">:" + os << "gf<" << typestring(Tdummy) << ">:" << this->varindex << "[" << CCTK_VarName(this->varindex) << "]," << "dt=[" << this->tmin << ":" << this->tmax<< "]"; return os; @@ -82,7 +82,7 @@ ostream& gf<T,D>::output (ostream& os) const { #define INSTANTIATE(T) \ -template class gf<T,3>; +template class gf<T>; #include "instantiate" diff --git a/Carpet/CarpetLib/src/gf.hh b/Carpet/CarpetLib/src/gf.hh index 470127b97..f3436d43b 100644 --- a/Carpet/CarpetLib/src/gf.hh +++ b/Carpet/CarpetLib/src/gf.hh @@ -20,17 +20,11 @@ using namespace std; // A real grid function -template<class T,int D> -class gf: public ggf<D> { +template<typename T> +class gf: public ggf { // Types - typedef vect<int,D> ivect; - typedef bbox<int,D> ibbox; - typedef bboxset<int,D> ibset; - typedef list<ibbox> iblist; - typedef vector<iblist> iblistvect; - - typedef data<T,D>* tdata; // data ... + typedef data<T>* tdata; // data ... typedef vector<tdata> mdata; // ... for each multigrid level typedef vector<mdata> cdata; // ... for each component typedef vector<cdata> rdata; // ... for each refinement level @@ -40,7 +34,7 @@ public: // Constructors gf (const int varindex, const operator_type transport_operator, - th<D>& t, dh<D>& d, + th& t, dh& d, const int tmin, const int tmax, const int prolongation_order_time, const int vectorlength, const int vectorindex, gf* const vectorleader); @@ -54,13 +48,13 @@ public: protected: - virtual gdata<D>* typed_data (int tl, int rl, int c, int ml) + virtual gdata* typed_data (int tl, int rl, int c, int ml) { - return new data<T,D>(this->varindex, this->transport_operator, - this->vectorlength, this->vectorindex, - this->vectorleader - ? (data<T,D>*)(*this->vectorleader)(tl,rl,c,ml) - : NULL); + return new data<T>(this->varindex, this->transport_operator, + this->vectorlength, this->vectorindex, + this->vectorleader + ? (data<T>*)(*this->vectorleader)(tl,rl,c,ml) + : NULL); } @@ -69,9 +63,9 @@ protected: public: - virtual const data<T,D>* operator() (int tl, int rl, int c, int ml) const; + virtual const data<T>* operator() (int tl, int rl, int c, int ml) const; - virtual data<T,D>* operator() (int tl, int rl, int c, int ml); + virtual data<T>* operator() (int tl, int rl, int c, int ml); diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc index 75a6feee8..4755cb2ac 100644 --- a/Carpet/CarpetLib/src/ggf.cc +++ b/Carpet/CarpetLib/src/ggf.cc @@ -17,13 +17,12 @@ using namespace std; // Constructors -template<int D> -ggf<D>::ggf (const int varindex, const operator_type transport_operator, - th<D>& t, dh<D>& d, - const int tmin, const int tmax, - const int prolongation_order_time, - const int vectorlength, const int vectorindex, - ggf* const vectorleader) +ggf::ggf (const int varindex, const operator_type transport_operator, + th& t, dh& d, + const int tmin, const int tmax, + const int prolongation_order_time, + const int vectorlength, const int vectorindex, + ggf* const vectorleader) : varindex(varindex), transport_operator(transport_operator), t(t), tmin(tmin), tmax(tmax), prolongation_order_time(prolongation_order_time), @@ -43,22 +42,19 @@ ggf<D>::ggf (const int varindex, const operator_type transport_operator, } // Destructors -template<int D> -ggf<D>::~ggf () { +ggf::~ggf () { d.remove(this); } // Comparison -template<int D> -bool ggf<D>::operator== (const ggf<D>& f) const { +bool ggf::operator== (const ggf& f) const { return this == &f; } // Modifiers -template<int D> -void ggf<D>::recompose_crop () +void ggf::recompose_crop () { // Free storage that will not be needed storage.resize(tmax-tmin+1); @@ -74,8 +70,7 @@ void ggf<D>::recompose_crop () } // for tl } -template<int D> -void ggf<D>::recompose_allocate (const int rl) +void ggf::recompose_allocate (const int rl) { // TODO: restructure storage only when needed @@ -104,9 +99,8 @@ void ggf<D>::recompose_allocate (const int rl) } // for tl } -template<int D> -void ggf<D>::recompose_fill (comm_state<D>& state, const int rl, - const bool do_prolongate) +void ggf::recompose_fill (comm_state& state, const int rl, + const bool do_prolongate) { // Initialise the new storage for (int c=0; c<h.components(rl); ++c) { @@ -128,7 +122,7 @@ void ggf<D>::recompose_fill (comm_state<D>& state, const int rl, = work & oldstorage.at(tl-tmin).at(rl).at(cc).at(ml)->extent(); ovlp.normalize(); work -= ovlp; - for (typename ibset::const_iterator r=ovlp.begin(); r!=ovlp.end(); ++r) { + for (ibset::const_iterator r=ovlp.begin(); r!=ovlp.end(); ++r) { storage.at(tl-tmin).at(rl).at(c).at(ml)->copy_from (state, oldstorage.at(tl-tmin).at(rl).at(cc).at(ml), *r); } @@ -149,7 +143,7 @@ void ggf<D>::recompose_fill (comm_state<D>& state, const int rl, times.at(i) = t.time(tls.at(i),rl-1,ml); } for (int cc=0; cc<(int)storage.at(tl-tmin).at(rl-1).size(); ++cc) { - vector<const gdata<D>*> gsrcs(numtl); + vector<const gdata*> gsrcs(numtl); for (int i=0; i<numtl; ++i) { gsrcs.at(i) = storage.at(tls.at(i)-tmin).at(rl-1).at(cc).at(ml); @@ -161,11 +155,11 @@ void ggf<D>::recompose_fill (comm_state<D>& state, const int rl, // TODO: prefer regions from the same processor const iblist& list = d.boxes.at(rl).at(c).at(ml).recv_ref_coarse.at(cc); - for (typename iblist::const_iterator iter=list.begin(); iter!=list.end(); ++iter) { + for (iblist::const_iterator iter=list.begin(); iter!=list.end(); ++iter) { ibset ovlp = work & *iter; ovlp.normalize(); work -= ovlp; - for (typename ibset::const_iterator r=ovlp.begin(); r!=ovlp.end(); ++r) { + for (ibset::const_iterator r=ovlp.begin(); r!=ovlp.end(); ++r) { storage.at(tl-tmin).at(rl).at(c).at(ml)->interpolate_from (state, gsrcs, times, *r, time, d.prolongation_order_space, prolongation_order_time); @@ -186,8 +180,7 @@ void ggf<D>::recompose_fill (comm_state<D>& state, const int rl, } // for c } -template<int D> -void ggf<D>::recompose_free (const int rl) +void ggf::recompose_free (const int rl) { // Delete old storage for (int tl=tmin; tl<=tmax; ++tl) { @@ -200,8 +193,7 @@ void ggf<D>::recompose_free (const int rl) } // for tl } -template<int D> -void ggf<D>::recompose_bnd_prolongate (comm_state<D>& state, const int rl, +void ggf::recompose_bnd_prolongate (comm_state& state, const int rl, const bool do_prolongate) { if (do_prolongate) { @@ -222,8 +214,7 @@ void ggf<D>::recompose_bnd_prolongate (comm_state<D>& state, const int rl, } // if do_prolongate } -template<int D> -void ggf<D>::recompose_sync (comm_state<D>& state, const int rl, +void ggf::recompose_sync (comm_state& state, const int rl, const bool do_prolongate) { if (do_prolongate) { @@ -243,12 +234,11 @@ void ggf<D>::recompose_sync (comm_state<D>& state, const int rl, // Cycle the time levels by rotating the data sets -template<int D> -void ggf<D>::cycle (int rl, int c, int ml) { +void ggf::cycle (int rl, int c, int ml) { assert (rl>=0 && rl<h.reflevels()); assert (c>=0 && c<h.components(rl)); assert (ml>=0 && ml<h.mglevels(rl,c)); - gdata<D>* tmpdata = storage.at(tmin-tmin).at(rl).at(c).at(ml); + gdata* tmpdata = storage.at(tmin-tmin).at(rl).at(c).at(ml); for (int tl=tmin; tl<=tmax-1; ++tl) { storage.at(tl-tmin).at(rl).at(c).at(ml) = storage.at(tl+1-tmin).at(rl).at(c).at(ml); } @@ -256,8 +246,7 @@ void ggf<D>::cycle (int rl, int c, int ml) { } // Flip the time levels by exchanging the data sets -template<int D> -void ggf<D>::flip (int rl, int c, int ml) { +void ggf::flip (int rl, int c, int ml) { assert (rl>=0 && rl<h.reflevels()); assert (c>=0 && c<h.components(rl)); assert (ml>=0 && ml<h.mglevels(rl,c)); @@ -265,7 +254,7 @@ void ggf<D>::flip (int rl, int c, int ml) { const int tl1 = tmin + t; const int tl2 = tmax - t; assert (tl1 < tl2); - gdata<D>* tmpdata = storage.at(tl1-tmin).at(rl).at(c).at(ml); + gdata* tmpdata = storage.at(tl1-tmin).at(rl).at(c).at(ml); storage.at(tl1-tmin).at(rl).at(c).at(ml) = storage.at(tl2-tmin).at(rl).at(c).at(ml); storage.at(tl2-tmin).at(rl).at(c).at(ml) = tmpdata; } @@ -276,12 +265,11 @@ void ggf<D>::flip (int rl, int c, int ml) { // Operations // Copy a region -template<int D> -void ggf<D>::copycat (comm_state<D>& state, - int tl1, int rl1, int c1, int ml1, - const ibbox dh<D>::dboxes::* recv_box, - int tl2, int rl2, int ml2, - const ibbox dh<D>::dboxes::* send_box) +void ggf::copycat (comm_state& state, + int tl1, int rl1, int c1, int ml1, + const ibbox dh::dboxes::* recv_box, + int tl2, int rl2, int ml2, + const ibbox dh::dboxes::* send_box) { assert (tl1>=tmin && tl1<=tmax); assert (rl1>=0 && rl1<h.reflevels()); @@ -301,12 +289,11 @@ void ggf<D>::copycat (comm_state<D>& state, } // Copy regions -template<int D> -void ggf<D>::copycat (comm_state<D>& state, - int tl1, int rl1, int c1, int ml1, - const iblist dh<D>::dboxes::* recv_list, - int tl2, int rl2, int ml2, - const iblist dh<D>::dboxes::* send_list) +void ggf::copycat (comm_state& state, + int tl1, int rl1, int c1, int ml1, + const iblist dh::dboxes::* recv_list, + int tl2, int rl2, int ml2, + const iblist dh::dboxes::* send_list) { assert (tl1>=tmin && tl1<=tmax); assert (rl1>=0 && rl1<h.reflevels()); @@ -320,7 +307,7 @@ void ggf<D>::copycat (comm_state<D>& state, const iblist send = d.boxes.at(rl2).at(c2).at(ml2).*send_list; assert (recv.size()==send.size()); // walk all boxes - for (typename iblist::const_iterator r=recv.begin(), s=send.begin(); + for (iblist::const_iterator r=recv.begin(), s=send.begin(); r!=recv.end(); ++r, ++s) { // (use the send boxes for communication) // copy the content @@ -330,12 +317,11 @@ void ggf<D>::copycat (comm_state<D>& state, } // Copy regions -template<int D> -void ggf<D>::copycat (comm_state<D>& state, - int tl1, int rl1, int c1, int ml1, - const iblistvect dh<D>::dboxes::* recv_listvect, - int tl2, int rl2, int ml2, - const iblistvect dh<D>::dboxes::* send_listvect) +void ggf::copycat (comm_state& state, + int tl1, int rl1, int c1, int ml1, + const iblistvect dh::dboxes::* recv_listvect, + int tl2, int rl2, int ml2, + const iblistvect dh::dboxes::* send_listvect) { assert (tl1>=tmin && tl1<=tmax); assert (rl1>=0 && rl1<h.reflevels()); @@ -350,7 +336,7 @@ void ggf<D>::copycat (comm_state<D>& state, const iblist send = (d.boxes.at(rl2).at(c2).at(ml2).*send_listvect).at(c1); assert (recv.size()==send.size()); // walk all boxes - for (typename iblist::const_iterator r=recv.begin(), s=send.begin(); + for (iblist::const_iterator r=recv.begin(), s=send.begin(); r!=recv.end(); ++r, ++s) { // (use the send boxes for communication) // copy the content @@ -361,13 +347,12 @@ void ggf<D>::copycat (comm_state<D>& state, } // Interpolate a region -template<int D> -void ggf<D>::intercat (comm_state<D>& state, - int tl1, int rl1, int c1, int ml1, - const ibbox dh<D>::dboxes::* recv_list, - const vector<int> tl2s, int rl2, int ml2, - const ibbox dh<D>::dboxes::* send_list, - CCTK_REAL time) +void ggf::intercat (comm_state& state, + int tl1, int rl1, int c1, int ml1, + const ibbox dh::dboxes::* recv_list, + const vector<int> tl2s, int rl2, int ml2, + const ibbox dh::dboxes::* send_list, + CCTK_REAL time) { assert (tl1>=tmin && tl1<=tmax); assert (rl1>=0 && rl1<h.reflevels()); @@ -380,7 +365,7 @@ void ggf<D>::intercat (comm_state<D>& state, const int c2=c1; assert (ml2>=0 && ml2<h.mglevels(rl2,c2)); - vector<const gdata<D>*> gsrcs(tl2s.size()); + vector<const gdata*> gsrcs(tl2s.size()); vector<CCTK_REAL> times(tl2s.size()); for (int i=0; i<(int)gsrcs.size(); ++i) { assert (rl2<(int)storage.at(tl2s.at(i)-tmin).size()); @@ -401,13 +386,12 @@ void ggf<D>::intercat (comm_state<D>& state, } // Interpolate regions -template<int D> -void ggf<D>::intercat (comm_state<D>& state, - int tl1, int rl1, int c1, int ml1, - const iblist dh<D>::dboxes::* recv_list, - const vector<int> tl2s, int rl2, int ml2, - const iblist dh<D>::dboxes::* send_list, - const CCTK_REAL time) +void ggf::intercat (comm_state& state, + int tl1, int rl1, int c1, int ml1, + const iblist dh::dboxes::* recv_list, + const vector<int> tl2s, int rl2, int ml2, + const iblist dh::dboxes::* send_list, + const CCTK_REAL time) { assert (tl1>=tmin && tl1<=tmax); assert (rl1>=0 && rl1<h.reflevels()); @@ -420,7 +404,7 @@ void ggf<D>::intercat (comm_state<D>& state, const int c2=c1; assert (ml2>=0 && ml2<h.mglevels(rl2,c2)); - vector<const gdata<D>*> gsrcs(tl2s.size()); + vector<const gdata*> gsrcs(tl2s.size()); vector<CCTK_REAL> times(tl2s.size()); for (int i=0; i<(int)gsrcs.size(); ++i) { assert (rl2<(int)storage.at(tl2s.at(i)-tmin).size()); @@ -434,7 +418,7 @@ void ggf<D>::intercat (comm_state<D>& state, const iblist send = d.boxes.at(rl2).at(c2).at(ml2).*send_list; assert (recv.size()==send.size()); // walk all boxes - for (typename iblist::const_iterator r=recv.begin(), s=send.begin(); + for (iblist::const_iterator r=recv.begin(), s=send.begin(); r!=recv.end(); ++r, ++s) { // (use the send boxes for communication) // interpolate the content @@ -445,13 +429,12 @@ void ggf<D>::intercat (comm_state<D>& state, } // Interpolate regions -template<int D> -void ggf<D>::intercat (comm_state<D>& state, - int tl1, int rl1, int c1, int ml1, - const iblistvect dh<D>::dboxes::* recv_listvect, - const vector<int> tl2s, int rl2, int ml2, - const iblistvect dh<D>::dboxes::* send_listvect, - const CCTK_REAL time) +void ggf::intercat (comm_state& state, + int tl1, int rl1, int c1, int ml1, + const iblistvect dh::dboxes::* recv_listvect, + const vector<int> tl2s, int rl2, int ml2, + const iblistvect dh::dboxes::* send_listvect, + const CCTK_REAL time) { assert (tl1>=tmin && tl1<=tmax); assert (rl1>=0 && rl1<h.reflevels()); @@ -465,7 +448,7 @@ void ggf<D>::intercat (comm_state<D>& state, for (int c2=0; c2<h.components(rl2); ++c2) { assert (ml2>=0 && ml2<h.mglevels(rl2,c2)); - vector<const gdata<D>*> gsrcs(tl2s.size()); + vector<const gdata*> gsrcs(tl2s.size()); vector<CCTK_REAL> times(tl2s.size()); for (int i=0; i<(int)gsrcs.size(); ++i) { assert (rl2<(int)storage.at(tl2s.at(i)-tmin).size()); @@ -479,7 +462,7 @@ void ggf<D>::intercat (comm_state<D>& state, const iblist send = (d.boxes.at(rl2).at(c2).at(ml2).*send_listvect).at(c1); assert (recv.size()==send.size()); // walk all boxes - for (typename iblist::const_iterator r=recv.begin(), s=send.begin(); + for (iblist::const_iterator r=recv.begin(), s=send.begin(); r!=recv.end(); ++r, ++s) { // (use the send boxes for communication) // interpolate the content @@ -493,30 +476,27 @@ void ggf<D>::intercat (comm_state<D>& state, // Copy a component from the next time level -template<int D> -void ggf<D>::copy (comm_state<D>& state, int tl, int rl, int c, int ml) +void ggf::copy (comm_state& state, int tl, int rl, int c, int ml) { // Copy copycat (state, - tl ,rl,c,ml, &dh<D>::dboxes::exterior, - tl+1,rl, ml, &dh<D>::dboxes::exterior); + tl ,rl,c,ml, &dh::dboxes::exterior, + tl+1,rl, ml, &dh::dboxes::exterior); } // Synchronise the boundaries a component -template<int D> -void ggf<D>::sync (comm_state<D>& state, int tl, int rl, int c, int ml) +void ggf::sync (comm_state& state, int tl, int rl, int c, int ml) { // Copy copycat (state, - tl,rl,c,ml, &dh<D>::dboxes::recv_sync, - tl,rl, ml, &dh<D>::dboxes::send_sync); + tl,rl,c,ml, &dh::dboxes::recv_sync, + tl,rl, ml, &dh::dboxes::send_sync); } // Prolongate the boundaries of a component -template<int D> -void ggf<D>::ref_bnd_prolongate (comm_state<D>& state, - int tl, int rl, int c, int ml, - CCTK_REAL time) +void ggf::ref_bnd_prolongate (comm_state& state, + int tl, int rl, int c, int ml, + CCTK_REAL time) { // Interpolate assert (rl>=1); @@ -527,48 +507,45 @@ void ggf<D>::ref_bnd_prolongate (comm_state<D>& state, tl2s.resize(prolongation_order_time+1); for (int i=0; i<=prolongation_order_time; ++i) tl2s.at(i) = tmax - i; intercat (state, - tl ,rl ,c,ml, &dh<D>::dboxes::recv_ref_bnd_coarse, - tl2s,rl-1, ml, &dh<D>::dboxes::send_ref_bnd_fine, + tl ,rl ,c,ml, &dh::dboxes::recv_ref_bnd_coarse, + tl2s,rl-1, ml, &dh::dboxes::send_ref_bnd_fine, time); } // Restrict a multigrid level -template<int D> -void ggf<D>::mg_restrict (comm_state<D>& state, - int tl, int rl, int c, int ml, - CCTK_REAL time) +void ggf::mg_restrict (comm_state& state, + int tl, int rl, int c, int ml, + CCTK_REAL time) { // Require same times assert (abs(t.get_time(rl,ml) - t.get_time(rl,ml-1)) <= 1.0e-8 * abs(t.get_time(rl,ml))); const vector<int> tl2s(1,tl); intercat (state, - tl ,rl,c,ml, &dh<D>::dboxes::recv_mg_coarse, - tl2s,rl, ml-1, &dh<D>::dboxes::send_mg_fine, + tl ,rl,c,ml, &dh::dboxes::recv_mg_coarse, + tl2s,rl, ml-1, &dh::dboxes::send_mg_fine, time); } // Prolongate a multigrid level -template<int D> -void ggf<D>::mg_prolongate (comm_state<D>& state, - int tl, int rl, int c, int ml, - CCTK_REAL time) +void ggf::mg_prolongate (comm_state& state, + int tl, int rl, int c, int ml, + CCTK_REAL time) { // Require same times assert (abs(t.get_time(rl,ml) - t.get_time(rl,ml+1)) <= 1.0e-8 * abs(t.get_time(rl,ml))); const vector<int> tl2s(1,tl); intercat (state, - tl ,rl,c,ml, &dh<D>::dboxes::recv_mg_coarse, - tl2s,rl, ml+1, &dh<D>::dboxes::send_mg_fine, + tl ,rl,c,ml, &dh::dboxes::recv_mg_coarse, + tl2s,rl, ml+1, &dh::dboxes::send_mg_fine, time); } // Restrict a refinement level -template<int D> -void ggf<D>::ref_restrict (comm_state<D>& state, - int tl, int rl, int c, int ml, - CCTK_REAL time) +void ggf::ref_restrict (comm_state& state, + int tl, int rl, int c, int ml, + CCTK_REAL time) { // Require same times assert (abs(t.get_time(rl,ml) - t.get_time(rl+1,ml)) @@ -576,16 +553,15 @@ void ggf<D>::ref_restrict (comm_state<D>& state, if (transport_operator == op_none) return; const vector<int> tl2s(1,tl); intercat (state, - tl ,rl ,c,ml, &dh<D>::dboxes::recv_ref_fine, - tl2s,rl+1, ml, &dh<D>::dboxes::send_ref_coarse, + tl ,rl ,c,ml, &dh::dboxes::recv_ref_fine, + tl2s,rl+1, ml, &dh::dboxes::send_ref_coarse, time); } // Prolongate a refinement level -template<int D> -void ggf<D>::ref_prolongate (comm_state<D>& state, - int tl, int rl, int c, int ml, - CCTK_REAL time) +void ggf::ref_prolongate (comm_state& state, + int tl, int rl, int c, int ml, + CCTK_REAL time) { assert (rl>=1); if (transport_operator == op_none) return; @@ -595,11 +571,7 @@ void ggf<D>::ref_prolongate (comm_state<D>& state, tl2s.resize(prolongation_order_time+1); for (int i=0; i<=prolongation_order_time; ++i) tl2s.at(i) = tmax - i; intercat (state, - tl ,rl ,c,ml, &dh<D>::dboxes::recv_ref_coarse, - tl2s,rl-1, ml, &dh<D>::dboxes::send_ref_fine, + tl ,rl ,c,ml, &dh::dboxes::recv_ref_coarse, + tl2s,rl-1, ml, &dh::dboxes::send_ref_fine, time); } - - - -template class ggf<3>; diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh index a1b1bc494..f1ac54baa 100644 --- a/Carpet/CarpetLib/src/ggf.hh +++ b/Carpet/CarpetLib/src/ggf.hh @@ -19,27 +19,21 @@ using namespace std; // Forward declaration -template<int D> class ggf; +class ggf; // Output -template<int D> -ostream& operator<< (ostream& os, const ggf<D>& f); +ostream& operator<< (ostream& os, const ggf& f); // A generic grid function without type information -template<int D> class ggf { // Types - - typedef vect<int,D> ivect; - typedef bbox<int,D> ibbox; - typedef bboxset<int,D> ibset; typedef list<ibbox> iblist; typedef vector<iblist> iblistvect; - - typedef gdata<D>* tdata; // data ... + + typedef gdata* tdata; // data ... typedef vector<tdata> mdata; // ... for each multigrid level typedef vector<mdata> cdata; // ... for each component typedef vector<cdata> rdata; // ... for each refinement level @@ -48,23 +42,23 @@ class ggf { public: // should be readonly // Fields - const int varindex; // Cactus variable index + const int varindex; // Cactus variable index const operator_type transport_operator; - const th<D> &t; // time hierarchy + const th &t; // time hierarchy const int tmin, tmax; // timelevels - const int prolongation_order_time; // order of temporal prolongation operator + const int prolongation_order_time; // order of temporal prolongation operator - const gh<D> &h; // grid hierarchy - dh<D> &d; // data hierarchy + const gh &h; // grid hierarchy + dh &d; // data hierarchy protected: fdata storage; // storage public: - const int vectorlength; // vector length - const int vectorindex; // index of *this - const ggf* vectorleader; // first vector element + const int vectorlength; // vector length + const int vectorindex; // index of *this + const ggf* vectorleader; // first vector element private: fdata oldstorage; @@ -73,7 +67,7 @@ public: // Constructors ggf (const int varindex, const operator_type transport_operator, - th<D>& t, dh<D>& d, + th& t, dh& d, const int tmin, const int tmax, const int prolongation_order_time, const int vectorlength, const int vectorindex, @@ -83,7 +77,7 @@ public: virtual ~ggf (); // Comparison - bool operator== (const ggf<D>& f) const; + bool operator== (const ggf& f) const; @@ -91,10 +85,10 @@ public: // void recompose (); void recompose_crop (); void recompose_allocate (int rl); - void recompose_fill (comm_state<D>& state, int rl, bool do_prolongate); + void recompose_fill (comm_state& state, int rl, bool do_prolongate); void recompose_free (int rl); - void recompose_bnd_prolongate (comm_state<D>& state, int rl, bool do_prolongate); - void recompose_sync (comm_state<D>& state, int rl, bool do_prolongate); + void recompose_bnd_prolongate (comm_state& state, int rl, bool do_prolongate); + void recompose_sync (comm_state& state, int rl, bool do_prolongate); // Cycle the time levels by rotating the data sets void cycle (int rl, int c, int ml); @@ -108,7 +102,7 @@ public: protected: - virtual gdata<D>* typed_data (int tl, int rl, int c, int ml) = 0; + virtual gdata* typed_data (int tl, int rl, int c, int ml) = 0; @@ -117,48 +111,48 @@ protected: protected: // Copy a region - void copycat (comm_state<D>& state, + void copycat (comm_state& state, int tl1, int rl1, int c1, int ml1, - const ibbox dh<D>::dboxes::* recv_list, + const ibbox dh::dboxes::* recv_list, int tl2, int rl2, int ml2, - const ibbox dh<D>::dboxes::* send_list); + const ibbox dh::dboxes::* send_list); // Copy regions - void copycat (comm_state<D>& state, + void copycat (comm_state& state, int tl1, int rl1, int c1, int ml1, - const iblist dh<D>::dboxes::* recv_list, + const iblist dh::dboxes::* recv_list, int tl2, int rl2, int ml2, - const iblist dh<D>::dboxes::* send_list); + const iblist dh::dboxes::* send_list); // Copy regions - void copycat (comm_state<D>& state, + void copycat (comm_state& state, int tl1, int rl1, int c1, int ml1, - const iblistvect dh<D>::dboxes::* recv_listvect, + const iblistvect dh::dboxes::* recv_listvect, int tl2, int rl2, int ml2, - const iblistvect dh<D>::dboxes::* send_listvect); + const iblistvect dh::dboxes::* send_listvect); // Interpolate a region - void intercat (comm_state<D>& state, + void intercat (comm_state& state, int tl1, int rl1, int c1, int ml1, - const ibbox dh<D>::dboxes::* recv_list, + const ibbox dh::dboxes::* recv_list, const vector<int> tl2s, int rl2, int ml2, - const ibbox dh<D>::dboxes::* send_list, + const ibbox dh::dboxes::* send_list, CCTK_REAL time); // Interpolate regions - void intercat (comm_state<D>& state, + void intercat (comm_state& state, int tl1, int rl1, int c1, int ml1, - const iblist dh<D>::dboxes::* recv_list, + const iblist dh::dboxes::* recv_list, const vector<int> tl2s, int rl2, int ml2, - const iblist dh<D>::dboxes::* send_list, + const iblist dh::dboxes::* send_list, CCTK_REAL time); // Interpolate regions - void intercat (comm_state<D>& state, + void intercat (comm_state& state, int tl1, int rl1, int c1, int ml1, - const iblistvect dh<D>::dboxes::* recv_listvect, + const iblistvect dh::dboxes::* recv_listvect, const vector<int> tl2s, int rl2, int ml2, - const iblistvect dh<D>::dboxes::* send_listvect, + const iblistvect dh::dboxes::* send_listvect, CCTK_REAL time); @@ -172,37 +166,37 @@ public: // synchronised. They don't need to be prolongated. // Copy a component from the next time level - void copy (comm_state<D>& state, int tl, int rl, int c, int ml); + void copy (comm_state& state, int tl, int rl, int c, int ml); // Synchronise the boundaries of a component - void sync (comm_state<D>& state, int tl, int rl, int c, int ml); + void sync (comm_state& state, int tl, int rl, int c, int ml); // Prolongate the boundaries of a component - void ref_bnd_prolongate (comm_state<D>& state, + void ref_bnd_prolongate (comm_state& state, int tl, int rl, int c, int ml, CCTK_REAL time); // Restrict a multigrid level - void mg_restrict (comm_state<D>& state, + void mg_restrict (comm_state& state, int tl, int rl, int c, int ml, CCTK_REAL time); // Prolongate a multigrid level - void mg_prolongate (comm_state<D>& state, + void mg_prolongate (comm_state& state, int tl, int rl, int c, int ml, CCTK_REAL time); // Restrict a refinement level - void ref_restrict (comm_state<D>& state, + void ref_restrict (comm_state& state, int tl, int rl, int c, int ml, CCTK_REAL time); // Prolongate a refinement level - void ref_prolongate (comm_state<D>& state, + void ref_prolongate (comm_state& state, int tl, int rl, int c, int ml, CCTK_REAL time); // Access to the data - virtual const gdata<D>* operator() (int tl, int rl, int c, int ml) const = 0; + virtual const gdata* operator() (int tl, int rl, int c, int ml) const = 0; - virtual gdata<D>* operator() (int tl, int rl, int c, int ml) = 0; + virtual gdata* operator() (int tl, int rl, int c, int ml) = 0; @@ -219,7 +213,7 @@ private: template<int D> -inline ostream& operator<< (ostream& os, const ggf<D>& f) { +inline ostream& operator<< (ostream& os, const ggf& f) { return f.output(os); } diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc index d06b3d35c..5c8ea079c 100644 --- a/Carpet/CarpetLib/src/gh.cc +++ b/Carpet/CarpetLib/src/gh.cc @@ -16,10 +16,9 @@ using namespace std; // Constructors -template<int D> -gh<D>::gh (const int reffact, const centering refcent, - const int mgfact, const centering mgcent, - const ibbox baseextent) +gh::gh (const int reffact, const centering refcent, + const int mgfact, const centering mgcent, + const ibbox baseextent) : reffact(reffact), refcent(refcent), mgfact(mgfact), mgcent(mgcent), baseextent(baseextent) @@ -27,15 +26,13 @@ gh<D>::gh (const int reffact, const centering refcent, } // Destructors -template<int D> -gh<D>::~gh () { } +gh::~gh () { } // Modifiers -template<int D> -void gh<D>::recompose (const rexts& exts, - const rbnds& outer_bounds, - const rprocs& procs, - const bool do_prolongate) +void gh::recompose (const rexts& exts, + const rbnds& outer_bounds, + const rprocs& procs, + const bool do_prolongate) { DECLARE_CCTK_PARAMETERS; @@ -62,17 +59,16 @@ void gh<D>::recompose (const rexts& exts, // Recompose the other hierarchies - for (typename list<th<D>*>::iterator t=ths.begin(); t!=ths.end(); ++t) { + for (list<th*>::iterator t=ths.begin(); t!=ths.end(); ++t) { (*t)->recompose(); } - for (typename list<dh<D>*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) { + for (list<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) { (*d)->recompose (do_prolongate); } } -template<int D> -void gh<D>::check_processor_number_consistency () { +void gh::check_processor_number_consistency () { for (int rl=0; rl<reflevels(); ++rl) { assert (processors().size() == extents().size()); assert (outer_boundaries().size() == extents().size()); @@ -83,8 +79,7 @@ void gh<D>::check_processor_number_consistency () { } } -template<int D> -void gh<D>::check_multigrid_consistency () { +void gh::check_multigrid_consistency () { for (int rl=0; rl<reflevels(); ++rl) { for (int c=0; c<components(rl); ++c) { assert (mglevels(rl,c)>0); @@ -103,8 +98,7 @@ void gh<D>::check_multigrid_consistency () { } } -template<int D> -void gh<D>::check_component_consistency () { +void gh::check_component_consistency () { for (int rl=0; rl<reflevels(); ++rl) { assert (components(rl)>0); for (int c=0; c<components(rl); ++c) { @@ -121,8 +115,7 @@ void gh<D>::check_component_consistency () { } } -template<int D> -void gh<D>::check_base_grid_extent () { +void gh::check_base_grid_extent () { if (reflevels()>0) { for (int c=0; c<components(0); ++c) { // TODO: put the check back in, taking outer boundaries into @@ -134,14 +127,13 @@ void gh<D>::check_base_grid_extent () { } } -template<int D> -void gh<D>::check_refinement_levels () { +void gh::check_refinement_levels () { for (int rl=1; rl<reflevels(); ++rl) { assert (all(extents().at(rl-1).at(0).at(0).stride() == ivect(reffact) * extents().at(rl).at(0).at(0).stride())); // Check contained-ness: // first take all coarse grids ... - bboxset<int,D> all; + ibset all; for (int c=0; c<components(rl-1); ++c) { all |= extents().at(rl-1).at(c).at(0); } @@ -156,8 +148,7 @@ void gh<D>::check_refinement_levels () { } } -template<int D> -void gh<D>::calculate_base_extents_of_all_levels () { +void gh::calculate_base_extents_of_all_levels () { _bases.resize(reflevels()); for (int rl=0; rl<reflevels(); ++rl) { if (components(rl)==0) { @@ -176,8 +167,7 @@ void gh<D>::calculate_base_extents_of_all_levels () { } // Accessors -template<int D> -int gh<D>::local_components (const int rl) const { +int gh::local_components (const int rl) const { int lc = 0; for (int c=0; c<components(rl); ++c) { if (is_local(rl,c)) ++lc; @@ -188,32 +178,27 @@ int gh<D>::local_components (const int rl) const { // Time hierarchy management -template<int D> -void gh<D>::add (th<D>* t) { +void gh::add (th* t) { ths.push_back(t); } -template<int D> -void gh<D>::remove (th<D>* t) { +void gh::remove (th* t) { ths.remove(t); } // Data hierarchy management -template<int D> -void gh<D>::add (dh<D>* d) { +void gh::add (dh* d) { dhs.push_back(d); } -template<int D> -void gh<D>::remove (dh<D>* d) { +void gh::remove (dh* d) { dhs.remove(d); } -template<int D> -void gh<D>::do_output_bboxes (ostream& os) const { +void gh::do_output_bboxes (ostream& os) const { for (int rl=0; rl<reflevels(); ++rl) { for (int c=0; c<components(rl); ++c) { for (int ml=0; ml<mglevels(rl,c); ++ml) { @@ -228,8 +213,7 @@ void gh<D>::do_output_bboxes (ostream& os) const { } } -template<int D> -void gh<D>::do_output_bases (ostream& os) const { +void gh::do_output_bases (ostream& os) const { for (int rl=0; rl<reflevels(); ++rl) { if (components(rl)>0) { for (int ml=0; ml<mglevels(rl,0); ++ml) { @@ -242,9 +226,8 @@ void gh<D>::do_output_bases (ostream& os) const { } } -template<int D> -ostream& gh<D>::output (ostream& os) const { - os << "gh<" << D << ">:" +ostream& gh::output (ostream& os) const { + os << "gh:" << "reffactor=" << reffact << ",refcentering=" << refcent << "," << "mgfactor=" << mgfact << ",mgcentering=" << mgcent << "," << "extents=" << extents() << "," @@ -252,7 +235,7 @@ ostream& gh<D>::output (ostream& os) const { << "processors=" << processors() << "," << "dhs={"; const char * sep = ""; - for (typename list<dh<D>*>::const_iterator d = dhs.begin(); + for (list<dh*>::const_iterator d = dhs.begin(); d != dhs.end(); ++d) { os << sep; @@ -262,7 +245,3 @@ ostream& gh<D>::output (ostream& os) const { os << "}"; return os; } - - - -template class gh<3>; diff --git a/Carpet/CarpetLib/src/gh.hh b/Carpet/CarpetLib/src/gh.hh index 696c47243..6a7bb2e83 100644 --- a/Carpet/CarpetLib/src/gh.hh +++ b/Carpet/CarpetLib/src/gh.hh @@ -7,6 +7,7 @@ #include <vector> #include "bbox.hh" +#include "bboxset.hh" #include "defs.hh" #include "dist.hh" #include "vect.hh" @@ -16,34 +17,27 @@ using namespace std; // Forward declaration -template<int D> class dh; -template<int D> class th; -template<int D> class gh; +class dh; +class th; +class gh; // Output -template<int D> -ostream& operator<< (ostream& os, const gh<D>& h); +ostream& operator<< (ostream& os, const gh& h); // A refinement hierarchy, where higher levels are finer than the base // level. The extents do not include ghost zones. -template<int D> class gh { public: // Types - typedef vect<int,D> ivect; - typedef bbox<int,D> ibbox; - - typedef vect<vect<bool,2>,D> bvect; - typedef vector<ibbox> mexts; // ... for each multigrid level typedef vector<mexts> cexts; // ... for each component typedef vector<cexts> rexts; // ... for each refinement level - typedef vector<bvect> cbnds; // ... for each component + typedef vector<bbvect> cbnds; // ... for each component typedef vector<cbnds> rbnds; // ... for each refinement level typedef vector<int> cprocs; // ... for each component @@ -68,8 +62,8 @@ private: rbnds _outer_boundaries; // boundary descriptions 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 + list<th*> ths; // list of all time hierarchies + list<dh*> dhs; // list of all data hierarchies public: @@ -115,7 +109,7 @@ public: return (int)_extents.at(rl).at(c).size(); } - bvect outer_boundary (const int rl, const int c) const { + bbvect outer_boundary (const int rl, const int c) const { return _outer_boundaries.at(rl).at(c); } @@ -132,12 +126,12 @@ public: int local_components (const int rl) const; // Time hierarchy management - void add (th<D>* t); - void remove (th<D>* t); + void add (th* t); + void remove (th* t); // Data hierarchy management - void add (dh<D>* d); - void remove (dh<D>* d); + void add (dh* d); + void remove (dh* d); // Output virtual ostream& output (ostream& os) const; @@ -156,8 +150,7 @@ private: -template<int D> -inline ostream& operator<< (ostream& os, const gh<D>& h) { +inline ostream& operator<< (ostream& os, const gh& h) { h.output(os); return os; } diff --git a/Carpet/CarpetLib/src/th.cc b/Carpet/CarpetLib/src/th.cc index 1a85d78a3..b25361262 100644 --- a/Carpet/CarpetLib/src/th.cc +++ b/Carpet/CarpetLib/src/th.cc @@ -14,21 +14,18 @@ using namespace std; // Constructors -template<int D> -th<D>::th (gh<D>& h, const CCTK_REAL basedelta) +th::th (gh& h, const CCTK_REAL basedelta) : h(h), delta(basedelta) { h.add(this); } // Destructors -template<int D> -th<D>::~th () { +th::~th () { h.remove(this); } // Modifiers -template<int D> -void th<D>::recompose () { +void th::recompose () { times.resize(h.reflevels()); deltas.resize(h.reflevels()); for (int rl=0; rl<h.reflevels(); ++rl) { @@ -59,9 +56,8 @@ 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) { @@ -72,7 +68,3 @@ void th<D>::output (ostream& os) const { } os << "}"; } - - - -template class th<3>; diff --git a/Carpet/CarpetLib/src/th.hh b/Carpet/CarpetLib/src/th.hh index 1211de805..6ef1308aa 100644 --- a/Carpet/CarpetLib/src/th.hh +++ b/Carpet/CarpetLib/src/th.hh @@ -15,22 +15,20 @@ 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 + gh& h; // hierarchy private: @@ -41,7 +39,7 @@ private: public: // Constructors - th (gh<D>& h, const CCTK_REAL basedelta); + th (gh& h, const CCTK_REAL basedelta); // Destructors ~th (); @@ -90,8 +88,7 @@ public: -template<int D> -inline ostream& operator<< (ostream& os, const th<D>& t) { +inline ostream& operator<< (ostream& os, const th& t) { t.output(os); return os; } |