diff options
44 files changed, 773 insertions, 896 deletions
diff --git a/Carpet/Carpet/interface.ccl b/Carpet/Carpet/interface.ccl index 3f32a6bb0..414e43d0e 100644 --- a/Carpet/Carpet/interface.ccl +++ b/Carpet/Carpet/interface.ccl @@ -77,9 +77,9 @@ USES FUNCTION ConvertFromExteriorBoundary # The true prototype of the routine below: # int Carpet_Regrid (const cGH * cctkGH, -# gh<dim>::rexts * bbsss, -# gh<dim>::rbnds * obss, -# gh<dim>::rprocs * pss); +# gh::rexts * bbsss, +# gh::rbnds * obss, +# gh::rprocs * pss); CCTK_INT FUNCTION Carpet_Regrid (CCTK_POINTER_TO_CONST IN cctkGH, \ CCTK_POINTER IN bbsss, \ CCTK_POINTER IN obss, \ diff --git a/Carpet/Carpet/src/Comm.cc b/Carpet/Carpet/src/Comm.cc index c4319781a..93e17a01b 100644 --- a/Carpet/Carpet/src/Comm.cc +++ b/Carpet/Carpet/src/Comm.cc @@ -20,8 +20,8 @@ namespace Carpet { const char *groupname ); static void ProlongateGroupBoundaries ( const cGH* cgh, CCTK_REAL initial_time, int group ); - static void SyncGFGroup ( const cGH* cgh, comm_state<dim> &state, int group ); - static void SyncGFArrayGroup ( const cGH* cgh, comm_state<dim> &state, int group ); + static void SyncGFGroup ( const cGH* cgh, comm_state &state, int group ); + static void SyncGFArrayGroup ( const cGH* cgh, comm_state &state, int group ); int SyncGroup (const cGH* cgh, const char* groupname) { @@ -66,7 +66,7 @@ namespace Carpet { } // Sync - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { switch (CCTK_GroupTypeI(group)) { case CCTK_GF: @@ -93,7 +93,7 @@ namespace Carpet { const CCTK_REAL time = (cgh->cctk_time - initial_time) / delta_time; const int tl = 0; - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { for (int m=0; m<(int)arrdata.at(group).size(); ++m) { for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) { for (int c=0; c<vhh.at(m)->components(reflevel); ++c) { @@ -105,7 +105,7 @@ namespace Carpet { } } - void SyncGFGroup ( const cGH* cgh, comm_state<dim> &state, int group ) + void SyncGFGroup ( const cGH* cgh, comm_state &state, int group ) { const int tl = 0; for (int m=0; m<(int)arrdata.at(group).size(); ++m) { @@ -118,7 +118,7 @@ namespace Carpet { } } - void SyncGFArrayGroup ( const cGH* cgh, comm_state<dim> &state, int group ) + void SyncGFArrayGroup ( const cGH* cgh, comm_state &state, int group ) { for (int var=0; var<(int)arrdata.at(group).at(0).data.size(); ++var) { arrdata.at(group).at(0).data.at(var)->sync (state, 0, 0, 0, 0); diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc index bcb1ac378..8e4618c5a 100644 --- a/Carpet/Carpet/src/Recompose.cc +++ b/Carpet/Carpet/src/Recompose.cc @@ -65,9 +65,9 @@ namespace Carpet { - void CheckRegions (const gh<dim>::rexts & bbsss, - const gh<dim>::rbnds & obss, - const gh<dim>::rprocs& pss) + void CheckRegions (const gh::rexts & bbsss, + const gh::rbnds & obss, + const gh::rprocs& pss) { // At least one level if (bbsss.size() == 0) { @@ -128,9 +128,9 @@ namespace Carpet { bool did_change = false; BEGIN_MAP_LOOP(cgh, CCTK_GF) { - gh<dim>::rexts bbsss = vhh.at(map)->extents(); - gh<dim>::rbnds obss = vhh.at(map)->outer_boundaries(); - gh<dim>::rprocs pss = vhh.at(map)->processors(); + gh::rexts bbsss = vhh.at(map)->extents(); + gh::rbnds obss = vhh.at(map)->outer_boundaries(); + gh::rprocs pss = vhh.at(map)->processors(); // Check whether to recompose CCTK_INT const do_recompose @@ -173,7 +173,7 @@ namespace Carpet { - void OutputGrids (const cGH* cgh, const int m, const gh<dim>& hh) + void OutputGrids (const cGH* cgh, const int m, const gh& hh) { CCTK_INFO ("New grid structure (grid points):"); cout << " Refinement level " << reflevel << ", map " << map << endl; @@ -230,9 +230,9 @@ namespace Carpet { void OutputGridStructure (const cGH * const cgh, const int m, - const gh<dim>::rexts & bbsss, - const gh<dim>::rbnds & obss, - const gh<dim>::rprocs& pss) + const gh::rexts & bbsss, + const gh::rbnds & obss, + const gh::rprocs& pss) { DECLARE_CCTK_PARAMETERS; diff --git a/Carpet/Carpet/src/Restrict.cc b/Carpet/Carpet/src/Restrict.cc index b3186c1a6..95c473b2d 100644 --- a/Carpet/Carpet/src/Restrict.cc +++ b/Carpet/Carpet/src/Restrict.cc @@ -33,7 +33,7 @@ namespace Carpet { // Restrict if (reflevel < reflevels-1) { - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { for (int group=0; group<CCTK_NumGroups(); ++group) { if (CCTK_GroupTypeI(group) == CCTK_GF) { if (CCTK_QueryGroupStorageI(cgh, group)) { @@ -71,7 +71,7 @@ namespace Carpet { // Sync if (reflevel < reflevels-1) { - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { for (int group=0; group<CCTK_NumGroups(); ++group) { if (CCTK_GroupTypeI(group) == CCTK_GF) { if (CCTK_QueryGroupStorageI(cgh, group)) { diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc index 7ca40d935..65c71745e 100644 --- a/Carpet/Carpet/src/SetupGH.cc +++ b/Carpet/Carpet/src/SetupGH.cc @@ -306,7 +306,7 @@ namespace Carpet { CCTK_INT ghost_size_z); static ivect make_global_number_of_grid_points (CCTK_INT global_nsize, CCTK_INT global_nx, CCTK_INT global_ny, CCTK_INT global_nz); - static void check_time_hierarchy (const vector<dh<dim>*> &vdd, int m, + static void check_time_hierarchy (const vector<dh*> &vdd, int m, CCTK_INT max_refinement_levels, CCTK_INT refinement_factor, CCTK_INT prolongation_order_space, @@ -340,7 +340,7 @@ namespace Carpet { static void handle_group_tags_table (cGH* cgh, int group, cGroup &gp, jvect &convpowers, jvect &convoffsets); static void finish_initialisation (cGH* cgh); - static void print_grid_structure (vector<gh<dim>*> & vhh, int m); + static void print_grid_structure (vector<gh*> & vhh, int m); static void print_some_statistics (cGH* cgh); static void enable_storage_for_all_groups (cGH* cgh); static void leave_all_modes (cGH* cgh); @@ -563,15 +563,15 @@ namespace Carpet { const ibbox baseext (lb, ub, str); // Allocate grid hierarchy - vhh.at(m) = new gh<dim> (refinement_factor, vertex_centered, - convergence_factor, vertex_centered, baseext); + vhh.at(m) = new gh (refinement_factor, vertex_centered, + convergence_factor, vertex_centered, baseext); // Allocate data hierarchy - vdd.at(m) = new dh<dim> (*vhh.at(m), lghosts, ughosts, - prolongation_order_space, buffer_width); + vdd.at(m) = new dh (*vhh.at(m), lghosts, ughosts, + prolongation_order_space, buffer_width); // Allocate time hierarchy - vtt.at(m) = new th<dim> (*vhh.at(m), 1.0); + vtt.at(m) = new th (*vhh.at(m), 1.0); check_time_hierarchy (vdd, m, max_refinement_levels, refinement_factor, prolongation_order_space, lghosts, ughosts); @@ -719,7 +719,7 @@ namespace Carpet { } } - void check_time_hierarchy (const vector<dh<dim>*> &vdd, int m, + void check_time_hierarchy (const vector<dh*> &vdd, int m, CCTK_INT max_refinement_levels, CCTK_INT refinement_factor, CCTK_INT prolongation_order_space, @@ -743,8 +743,10 @@ namespace Carpet { } void read_explicit_grid_components (CCTK_STRING base_extents, - CCTK_STRING base_outerbounds, - vector<ibbox> & bbs, vector<bbvect> & obs) { + CCTK_STRING base_outerbounds, + vector<ibbox> & bbs, + vector<bbvect> & obs) + { // TODO: invent something for the other convergence levels istringstream ext_str (base_extents); try { @@ -766,7 +768,7 @@ namespace Carpet { assert (obs.size() == bbs.size()); } - void print_grid_structure (vector<gh<dim>*> & vhh, int m) { + void print_grid_structure (vector<gh*> & vhh, int m) { const int rl = 0; for (int c=0; c<vhh.at(m)->components(rl); ++c) { for (int ml=0; ml<vhh.at(m)->mglevels(rl,c); ++ml) { @@ -925,15 +927,15 @@ namespace Carpet { const int amgfact1 = ipow(mgfact, convpowers[0]); arrdata.at (group).at (0).hh - = new gh<dim> (refinement_factor, vertex_centered, - amgfact1, vertex_centered, - abaseext); + = new gh (refinement_factor, vertex_centered, + amgfact1, vertex_centered, + abaseext); arrdata.at (group).at (0).dd - = new dh<dim> (*arrdata.at (group).at (0).hh, alghosts, aughosts, 0, 0); + = new dh (*arrdata.at (group).at (0).hh, alghosts, aughosts, 0, 0); arrdata.at (group).at (0).tt - = new th<dim> (*arrdata.at (group).at (0).hh, 1.0); + = new th (*arrdata.at (group).at (0).hh, 1.0); diff --git a/Carpet/Carpet/src/Storage.cc b/Carpet/Carpet/src/Storage.cc index 79f9d3f30..9a07dee7b 100644 --- a/Carpet/Carpet/src/Storage.cc +++ b/Carpet/Carpet/src/Storage.cc @@ -85,7 +85,7 @@ namespace Carpet { for (int m=0; m<(int)arrdata.at(group).size(); ++m) { for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) { const int vectorindex = gp.vectorgroup ? var % vectorlength : 0; - ggf<dim>* vectorleader + ggf* vectorleader = (gp.vectorgroup && vectorindex>0 ? arrdata.at(group).at(m).data.at(var - vectorindex) : NULL); @@ -93,11 +93,11 @@ namespace Carpet { switch (CCTK_VarTypeI(n)) { #define TYPECASE(N,T) \ case N: \ - arrdata.at(group).at(m).data.at(var) = new gf<T,dim> \ + arrdata.at(group).at(m).data.at(var) = new gf<T> \ (n, groupdata.at(group).transport_operator, \ *arrdata.at(group).at(m).tt, *arrdata.at(group).at(m).dd, \ tmin, tmax, prolongation_order_time, \ - vectorlength, vectorindex, (gf<T,dim>*)vectorleader); \ + vectorlength, vectorindex, (gf<T>*)vectorleader); \ break; #include "typecase" #undef TYPECASE @@ -156,7 +156,7 @@ namespace Carpet { #define TYPECASE(N,T) \ case N: \ assert (arrdata.at(group).at(m).data.at(var)); \ - delete (gf<T,dim>*)arrdata.at(group).at(m).data.at(var); \ + delete (gf<T>*)arrdata.at(group).at(m).data.at(var); \ arrdata.at(group).at(m).data.at(var) = NULL; \ break; #include "typecase" diff --git a/Carpet/Carpet/src/defines.hh b/Carpet/Carpet/src/defines.hh index f0d4a646b..878407b69 100644 --- a/Carpet/Carpet/src/defines.hh +++ b/Carpet/Carpet/src/defines.hh @@ -3,27 +3,17 @@ #include "cctk.h" -#include <bbox.hh> -#include <bboxset.hh> -#include <vect.hh> +#include <defs.hh> namespace Carpet { - const int dim = 3; - - typedef vect<bool,dim> bvect; - typedef vect<int,dim> ivect; typedef vect<CCTK_INT,dim> jvect; typedef vect<CCTK_REAL,dim> rvect; - typedef bbox<int,dim> ibbox; typedef bbox<CCTK_INT,dim> jbbox; typedef bbox<CCTK_REAL,dim> rbbox; - typedef bboxset<int,dim> ibset; - typedef vect<vect<bool,2>,dim> bbvect; - typedef vect<vect<int,2>,dim> iivect; typedef vect<vect<CCTK_INT,2>,dim> jjvect; } // namespace Carpet diff --git a/Carpet/Carpet/src/functions.hh b/Carpet/Carpet/src/functions.hh index 4a92d0624..be95997c9 100644 --- a/Carpet/Carpet/src/functions.hh +++ b/Carpet/Carpet/src/functions.hh @@ -36,17 +36,17 @@ namespace Carpet { // Helpers for recomposing the grid hierarchy - void CheckRegions (const gh<dim>::rexts & bbsss, - const gh<dim>::rbnds & obss, - const gh<dim>::rprocs& pss); + void CheckRegions (const gh::rexts & bbsss, + const gh::rbnds & obss, + const gh::rprocs& pss); - void OutputGrids (const cGH* cgh, const int m, const gh<dim>& hh); + void OutputGrids (const cGH* cgh, const int m, const gh& hh); void OutputGridStructure (const cGH *cgh, const int m, - const gh<dim>::rexts & bbsss, - const gh<dim>::rbnds & obss, - const gh<dim>::rprocs& pss); + const gh::rexts & bbsss, + const gh::rbnds & obss, + const gh::rprocs& pss); diff --git a/Carpet/Carpet/src/modes.cc b/Carpet/Carpet/src/modes.cc index 91de2a58b..d489cf88b 100644 --- a/Carpet/Carpet/src/modes.cc +++ b/Carpet/Carpet/src/modes.cc @@ -134,9 +134,9 @@ namespace Carpet { for (int var=0; var<numvars; ++var) { assert (firstvar+var<CCTK_NumVars()); for (int tl=0; tl<num_tl; ++tl) { - ggf<dim> * const ff = arrdata.at(group).at(m).data.at(var); + ggf * const ff = arrdata.at(group).at(m).data.at(var); if (ff) { - gdata<dim> * const data = (*ff) (-tl, rl, c, ml); + gdata * const data = (*ff) (-tl, rl, c, ml); assert (data); cgh->data[firstvar+var][tl] = data->storage(); } else { @@ -414,10 +414,9 @@ namespace Carpet { for (int var=0; var<numvars; ++var) { assert (firstvar+var<CCTK_NumVars()); for (int tl=0; tl<num_tl; ++tl) { - ggf<dim> * const ff = arrdata.at(group).at(map).data.at(var); + ggf * const ff = arrdata.at(group).at(map).data.at(var); if (ff) { - gdata<dim> * const data - = (*ff) (-tl, reflevel, component, mglevel); + gdata * const data = (*ff) (-tl, reflevel, component, mglevel); assert (data); cgh->data[firstvar+var][tl] = data->storage(); } else { diff --git a/Carpet/Carpet/src/variables.cc b/Carpet/Carpet/src/variables.cc index fe3d10d4a..190878acb 100644 --- a/Carpet/Carpet/src/variables.cc +++ b/Carpet/Carpet/src/variables.cc @@ -82,9 +82,9 @@ namespace Carpet { // Data for grid functions // The grid hierarchy - vector<gh<dim>*> vhh; // [map] - vector<dh<dim>*> vdd; // [map] - vector<th<dim>*> vtt; // [map] + vector<gh*> vhh; // [map] + vector<dh*> vdd; // [map] + vector<th*> vtt; // [map] // Data for the groups vector<groupdesc> groupdata; // [group] diff --git a/Carpet/Carpet/src/variables.hh b/Carpet/Carpet/src/variables.hh index cdf8567a2..ae5ade6df 100644 --- a/Carpet/Carpet/src/variables.hh +++ b/Carpet/Carpet/src/variables.hh @@ -108,9 +108,9 @@ namespace Carpet { // Data for grid functions // The grid hierarchy - extern vector<gh<dim>*> vhh; // [map] - extern vector<dh<dim>*> vdd; // [map] - extern vector<th<dim>*> vtt; // [map] + extern vector<gh*> vhh; // [map] + extern vector<dh*> vdd; // [map] + extern vector<th*> vtt; // [map] // Data for the groups struct groupdesc { @@ -122,10 +122,10 @@ namespace Carpet { // Data for everything struct arrdesc { // points to hh etc. for GF, and is unique for SCALAR and ARRAY - gh<dim>* hh; - dh<dim>* dd; - th<dim>* tt; - vector<ggf<dim>*> data; // [var] + gh* hh; + dh* dd; + th* tt; + vector<ggf*> data; // [var] }; extern vector<vector<arrdesc> > arrdata; // [group][map] diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc index 2b0cdb46f..296957809 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.cc +++ b/Carpet/CarpetIOASCII/src/ioascii.cc @@ -73,22 +73,22 @@ namespace CarpetIOASCII { - template<int D,int DD> + template<int outdim> void WriteASCII (ostream& os, - const gdata<D>* const gfdata, - const bbox<int,D>& gfext, + const gdata* const gfdata, + const bbox<int,dim>& gfext, const int vi, const int time, - const vect<int,D>& org, - const vect<int,DD>& dirs, + const vect<int,dim>& org, + const vect<int,outdim>& dirs, const int rl, const int ml, const int m, const int c, const int tl, const CCTK_REAL coord_time, - const vect<CCTK_REAL,D>& coord_lower, - const vect<CCTK_REAL,D>& coord_upper); + const vect<CCTK_REAL,dim>& coord_lower, + const vect<CCTK_REAL,dim>& coord_upper); @@ -495,16 +495,16 @@ namespace CarpetIOASCII { // refinement level and map BEGIN_COMPONENT_LOOP(cgh, grouptype) { - const ggf<dim>* ff = 0; + const ggf* ff = 0; assert (var < (int)arrdata.at(group).at(Carpet::map).data.size()); - ff = (ggf<dim>*)arrdata.at(group).at(Carpet::map).data.at(var); + ff = (ggf*)arrdata.at(group).at(Carpet::map).data.at(var); const int mintl = output_all_timelevels ? 1-num_tl : 0; const int maxtl = 0; for (int tl=mintl; tl<=maxtl; ++tl) { - const gdata<dim>* const data + const gdata* const data = (*ff) (tl, rl, component, mglevel); ibbox ext = data->extent(); @@ -983,24 +983,24 @@ namespace CarpetIOASCII { // Output - template<int D,int DD> + template<int outdim> void WriteASCII (ostream& os, - const gdata<D>* const gfdata, - const bbox<int,D>& gfext, + const gdata* const gfdata, + const bbox<int,dim>& gfext, const int vi, const int time, - const vect<int,D>& org, - const vect<int,DD>& dirs, + const vect<int,dim>& org, + const vect<int,outdim>& dirs, const int rl, const int ml, const int m, const int c, const int tl, const CCTK_REAL coord_time, - const vect<CCTK_REAL,D>& coord_lower, - const vect<CCTK_REAL,D>& coord_upper) + const vect<CCTK_REAL,dim>& coord_lower, + const vect<CCTK_REAL,dim>& coord_upper) { - assert (DD<=D); + assert (outdim<=dim); if (gfdata->proc()==0) { // output on processor 0 @@ -1019,34 +1019,34 @@ namespace CarpetIOASCII { << " time level " << tl << endl << "# column format: it\ttl rl c ml\t"; - assert (D>=1 && D<=3); + assert (dim>=1 && dim<=3); const char* const coords = "xyz"; - for (int d=0; d<D-1; ++d) os << "i" << coords[d] << " "; os << "i" << coords[D-1]; + for (int d=0; d<dim-1; ++d) os << "i" << coords[d] << " "; os << "i" << coords[dim-1]; os << "\ttime\t"; - for (int d=0; d<D-1; ++d) os << coords[d] << " "; os << coords[D-1]; + for (int d=0; d<dim-1; ++d) os << coords[d] << " "; os << coords[dim-1]; os << "\tdata" << endl; - const vect<int,DD> lo = gfext.lower()[dirs]; - const vect<int,DD> up = gfext.upper()[dirs]; - const vect<int,DD> str = gfext.stride()[dirs]; - const bbox<int,DD> ext(lo,up,str); + const vect<int,outdim> lo = gfext.lower()[dirs]; + const vect<int,outdim> up = gfext.upper()[dirs]; + const vect<int,outdim> str = gfext.stride()[dirs]; + const bbox<int,outdim> ext(lo,up,str); // Check whether the output origin is contained in the extent // of the data that should be output ivect org1(org); - for (int d=0; d<DD; ++d) org1[dirs[d]] = ext.lower()[d]; + for (int d=0; d<outdim; ++d) org1[dirs[d]] = ext.lower()[d]; if (gfext.contains(org1)) { - typename bbox<int,DD>::iterator it=ext.begin(); + typename bbox<int,outdim>::iterator it=ext.begin(); do { ivect index(org); - for (int d=0; d<DD; ++d) index[dirs[d]] = (*it)[d]; + for (int d=0; d<outdim; ++d) index[dirs[d]] = (*it)[d]; os << time << "\t" << tl << " " << rl << " " << c << " " << ml << "\t"; - for (int d=0; d<D-1; ++d) os << index[d] << " "; os << index[D-1]; + for (int d=0; d<dim-1; ++d) os << index[d] << " "; os << index[dim-1]; os << "\t" << coord_time << "\t"; - for (int d=0; d<D; ++d) { + for (int d=0; d<dim; ++d) { assert (gfext.upper()[d] - gfext.lower()[d] >= 0); if (gfext.upper()[d] - gfext.lower()[d] == 0) { os << coord_lower[d]; @@ -1057,13 +1057,13 @@ namespace CarpetIOASCII { (coord_lower[d] + (index[d] - gfext.lower()[d]) * dx, dx * 1.0e-8)); } - if (d != D-1) os << " "; + if (d != dim-1) os << " "; } os << "\t"; switch (CCTK_VarTypeI(vi)) { #define TYPECASE(N,T) \ case N: \ - os << (*(const data<T,D>*)gfdata)[index]; \ + os << (*(const data<T>*)gfdata)[index]; \ break; #include "carpet_typecase.hh" #undef TYPECASE @@ -1074,7 +1074,7 @@ namespace CarpetIOASCII { ++it; - for (int d=0; d<DD; ++d) { + for (int d=0; d<outdim; ++d) { if ((*it)[d]!=(*ext.end())[d]) break; os << endl; } @@ -1094,9 +1094,9 @@ namespace CarpetIOASCII { } else { // copy to processor 0 and output there - gdata<D>* const tmp = gfdata->make_typed(vi); + gdata* const tmp = gfdata->make_typed(vi); tmp->allocate(gfdata->extent(), 0); - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { tmp->copy_from (state, gfdata, gfdata->extent()); } WriteASCII (os, tmp, gfext, vi, time, org, dirs, rl, ml, m, c, tl, @@ -1118,11 +1118,11 @@ namespace CarpetIOASCII { template void WriteASCII (ostream& os, - const gdata<3>* const gfdata, - const bbox<int,3>& gfext, + const gdata* const gfdata, + const bbox<int,dim>& gfext, const int vi, const int time, - const vect<int,3>& org, + const vect<int,dim>& org, const vect<int,0>& dirs, const int rl, const int ml, @@ -1130,16 +1130,16 @@ namespace CarpetIOASCII { const int c, const int tl, const CCTK_REAL coord_time, - const vect<CCTK_REAL,3>& coord_lower, - const vect<CCTK_REAL,3>& coord_upper); + const vect<CCTK_REAL,dim>& coord_lower, + const vect<CCTK_REAL,dim>& coord_upper); template void WriteASCII (ostream& os, - const gdata<3>* const gfdata, - const bbox<int,3>& gfext, + const gdata* const gfdata, + const bbox<int,dim>& gfext, const int vi, const int time, - const vect<int,3>& org, + const vect<int,dim>& org, const vect<int,1>& dirs, const int rl, const int ml, @@ -1147,16 +1147,16 @@ namespace CarpetIOASCII { const int c, const int tl, const CCTK_REAL coord_time, - const vect<CCTK_REAL,3>& coord_lower, - const vect<CCTK_REAL,3>& coord_upper); + const vect<CCTK_REAL,dim>& coord_lower, + const vect<CCTK_REAL,dim>& coord_upper); template void WriteASCII (ostream& os, - const gdata<3>* const gfdata, - const bbox<int,3>& gfext, + const gdata* const gfdata, + const bbox<int,dim>& gfext, const int vi, const int time, - const vect<int,3>& org, + const vect<int,dim>& org, const vect<int,2>& dirs, const int rl, const int ml, @@ -1164,16 +1164,16 @@ namespace CarpetIOASCII { const int c, const int tl, const CCTK_REAL coord_time, - const vect<CCTK_REAL,3>& coord_lower, - const vect<CCTK_REAL,3>& coord_upper); + const vect<CCTK_REAL,dim>& coord_lower, + const vect<CCTK_REAL,dim>& coord_upper); template void WriteASCII (ostream& os, - const gdata<3>* const gfdata, - const bbox<int,3>& gfext, + const gdata* const gfdata, + const bbox<int,dim>& gfext, const int vi, const int time, - const vect<int,3>& org, + const vect<int,dim>& org, const vect<int,3>& dirs, const int rl, const int ml, @@ -1181,7 +1181,7 @@ namespace CarpetIOASCII { const int c, const int tl, const CCTK_REAL coord_time, - const vect<CCTK_REAL,3>& coord_lower, - const vect<CCTK_REAL,3>& coord_upper); + const vect<CCTK_REAL,dim>& coord_lower, + const vect<CCTK_REAL,dim>& coord_upper); } // namespace CarpetIOASCII diff --git a/Carpet/CarpetIOHDF5/src/Output.cc b/Carpet/CarpetIOHDF5/src/Output.cc index 32749d043..f5351b748 100644 --- a/Carpet/CarpetIOHDF5/src/Output.cc +++ b/Carpet/CarpetIOHDF5/src/Output.cc @@ -381,15 +381,14 @@ int WriteVar (const cGH* const cctkGH, const hid_t writer, } // Copy the overlap to the local processor - const ggf<dim>* ff = arrdata.at(gindex).at(Carpet::map).data.at(var); - const gdata<dim>* const data = (*ff) (-request->timelevel, - refinementlevel, - component, mglevel); - gdata<dim>* const processor_component = - data->make_typed (request->vindex); + const ggf* ff = arrdata.at(gindex).at(Carpet::map).data.at(var); + const gdata* const data = (*ff) (-request->timelevel, + refinementlevel, + component, mglevel); + gdata* const processor_component = data->make_typed (request->vindex); processor_component->allocate (overlap, 0); - for (comm_state<dim> state; !state.done(); state.step()) + for (comm_state state; !state.done(); state.step()) { processor_component->copy_from (state, data, overlap); } diff --git a/Carpet/CarpetIOHDF5/src/Recover.cc b/Carpet/CarpetIOHDF5/src/Recover.cc index 1f8ebe04f..4809c1470 100644 --- a/Carpet/CarpetIOHDF5/src/Recover.cc +++ b/Carpet/CarpetIOHDF5/src/Recover.cc @@ -514,14 +514,14 @@ int ReadVar (const cGH* const cctkGH, const int vindex, { did_read_something = true; - ggf<dim>* ff = 0; + ggf* ff = 0; assert (var < (int)arrdata.at(group).at(Carpet::map).data.size()); - ff = (ggf<dim>*)arrdata.at(group).at(Carpet::map).data.at(var); + ff = (ggf*)arrdata.at(group).at(Carpet::map).data.at(var); if(called_from_recovery) tl = group_timelevel; - gdata<dim>* const data = (*ff) (tl, reflevel, component, mglevel); + gdata* const data = (*ff) (tl, reflevel, component, mglevel); // Create temporary data storage on processor 0 vect<int,dim> str = vect<int,dim>(maxreflevelfact/reflevelfact); @@ -533,7 +533,7 @@ int ReadVar (const cGH* const cctkGH, const int vindex, vect<int,dim> ub = lb + (vect<int,dim>::ref(amr_dims) - 1) * str; - gdata<dim>* const tmp = data->make_typed (vindex); + gdata* const tmp = data->make_typed (vindex); cGroup cgdata; @@ -604,7 +604,7 @@ int ReadVar (const cGH* const cctkGH, const int vindex, MPI_Barrier(MPI_COMM_WORLD); // Copy into grid function - for (comm_state<dim> state; !state.done(); state.step()) + for (comm_state state; !state.done(); state.step()) { data->copy_from (state, tmp, overlap); } @@ -757,7 +757,7 @@ static int InputVarAs (const cGH* const cctkGH, const int vindex, { for (int m=0; m<Carpet::maps; ++m) { - dh<dim>& thedd = *arrdata.at(group).at(m).dd; + dh& thedd = *arrdata.at(group).at(m).dd; ibset all_exterior; for (size_t c=0; c<thedd.boxes.at(rl).size(); ++c) { diff --git a/Carpet/CarpetInterp/src/interp.cc b/Carpet/CarpetInterp/src/interp.cc index a35807272..0d8b14705 100644 --- a/Carpet/CarpetInterp/src/interp.cc +++ b/Carpet/CarpetInterp/src/interp.cc @@ -40,7 +40,7 @@ namespace CarpetInterp { static inline int ind_rc_(int const m, int const rl, int const minrl, int const maxrl, int const c, int const maxncomps, - vector<gh<dim> *> const hh) + vector<gh*> const hh) { assert (m>=0 && m<maps); assert (rl>=minrl && rl<maxrl); @@ -59,7 +59,7 @@ namespace CarpetInterp { int const rl, int const minrl, int const maxrl, int const c, int const maxncomps, cGH const * const cgh, - vector<gh<dim> *> const hh) + vector<gh*> const hh) { assert (p>=0 && p<nprocs); assert (nprocs==CCTK_nProcs(cgh)); @@ -307,8 +307,7 @@ namespace CarpetInterp { // Create coordinate patches - vector<data<CCTK_REAL,dim> > allcoords - (nprocs * (maxrl-minrl) * maxncomps); + vector<data<CCTK_REAL> > allcoords (nprocs * (maxrl-minrl) * maxncomps); for (int p=0; p<nprocs; ++p) { for (int rl=minrl; rl<maxrl; ++rl) { for (int c=0; c<vhh.at(m)->components(rl); ++c) { @@ -348,7 +347,7 @@ namespace CarpetInterp { } // Transfer coordinate patches - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { for (int p=0; p<nprocs; ++p) { for (int rl=minrl; rl<maxrl; ++rl) { for (int c=0; c<vhh.at(m)->components(rl); ++c) { @@ -362,9 +361,9 @@ namespace CarpetInterp { // Create output patches - vector<data<CCTK_REAL,dim> > alloutputs + vector<data<CCTK_REAL> > alloutputs (nprocs * (maxrl-minrl) * maxncomps, -1); - vector<data<CCTK_INT,dim> > allstatuses + vector<data<CCTK_INT> > allstatuses (nprocs * (maxrl-minrl) * maxncomps, -1); for (int p=0; p<nprocs; ++p) { for (int rl=minrl; rl<maxrl; ++rl) { @@ -756,7 +755,7 @@ namespace CarpetInterp { // Transfer output patches back - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { for (int p=0; p<nprocs; ++p) { for (int rl=minrl; rl<maxrl; ++rl) { for (int c=0; c<vhh.at(m)->components(rl); ++c) { 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; } diff --git a/Carpet/CarpetReduce/src/mask_carpet.cc b/Carpet/CarpetReduce/src/mask_carpet.cc index 5f754a271..c068a2fde 100644 --- a/Carpet/CarpetReduce/src/mask_carpet.cc +++ b/Carpet/CarpetReduce/src/mask_carpet.cc @@ -42,8 +42,8 @@ namespace CarpetMask { ivect const izero = ivect(0); ivect const ione = ivect(1); - gh<dim> const & hh = *vhh.at(Carpet::map); - dh<dim> const & dd = *vdd.at(Carpet::map); + gh const & hh = *vhh.at(Carpet::map); + dh const & dd = *vdd.at(Carpet::map); ibbox const & base = hh.bases().at(reflevel).at(mglevel); diff --git a/Carpet/CarpetRegrid/interface.ccl b/Carpet/CarpetRegrid/interface.ccl index 5a7e2c4b6..7c38c0efb 100644 --- a/Carpet/CarpetRegrid/interface.ccl +++ b/Carpet/CarpetRegrid/interface.ccl @@ -52,9 +52,9 @@ USES FUNCTION ConvertFromPhysicalBoundary # The true prototype of the routine below: # int Carpet_Regrid (const cGH * cctkGH, -# gh<dim>::rexts * bbsss, -# gh<dim>::rbnds * obss, -# gh<dim>::rprocs * pss); +# gh::rexts * bbsss, +# gh::rbnds * obss, +# gh::rprocs * pss); CCTK_INT FUNCTION Carpet_Regrid (CCTK_POINTER_TO_CONST IN cctkGH, \ CCTK_POINTER IN bbsss, \ CCTK_POINTER IN obss, \ diff --git a/Carpet/CarpetRegrid/src/automatic.cc b/Carpet/CarpetRegrid/src/automatic.cc index 2ccdc0b3d..2e29195e5 100644 --- a/Carpet/CarpetRegrid/src/automatic.cc +++ b/Carpet/CarpetRegrid/src/automatic.cc @@ -25,10 +25,10 @@ namespace CarpetRegrid { int Automatic (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; @@ -50,14 +50,14 @@ namespace CarpetRegrid { assert (CCTK_GroupDimI(gi) == dim); assert (arrdata.at(gi).at(Carpet::map).data.at(vi-v1)); - const gf<CCTK_REAL,dim>& errorgf - = (*dynamic_cast<const gf<CCTK_REAL,dim>*> + const gf<CCTK_REAL>& errorgf + = (*dynamic_cast<const gf<CCTK_REAL>*> (arrdata.at(gi).at(Carpet::map).data.at(vi-v1))); assert (! smart_outer_boundaries); vector<ibbox> bbs; - gh<dim>::cbnds obs; + gh::cbnds obs; Automatic_OneLevel (cctkGH, hh, reflevel, min(reflevels+1, maxreflevels), @@ -65,7 +65,7 @@ namespace CarpetRegrid { bbs, obs); // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware @@ -100,13 +100,13 @@ namespace CarpetRegrid { void Automatic_OneLevel (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int rl, const int numrl, const int minwidth, const CCTK_REAL minfraction, const CCTK_REAL maxerror, - const gf<CCTK_REAL,dim> & errorgf, + const gf<CCTK_REAL> & errorgf, vector<ibbox> & bbs, vector<bbvect> & obs) { @@ -123,7 +123,7 @@ namespace CarpetRegrid { const ibbox region = hh.extents().at(rl).at(c).at(ml); assert (! region.empty()); - const data<CCTK_REAL,dim>& errordata = *errorgf(tl,rl,c,ml); + const data<CCTK_REAL>& errordata = *errorgf(tl,rl,c,ml); Automatic_Recursive (cctkGH, hh, minwidth, minfraction, maxerror, errordata, bbl, region); @@ -168,11 +168,11 @@ namespace CarpetRegrid { void Automatic_Recursive (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int minwidth, const CCTK_REAL minfraction, const CCTK_REAL maxerror, - const data<CCTK_REAL,dim> & errordata, + const data<CCTK_REAL> & errordata, list<ibbox> & bbl, const ibbox & region) { diff --git a/Carpet/CarpetRegrid/src/baselevel.cc b/Carpet/CarpetRegrid/src/baselevel.cc index 441ba57bc..ce4aee1c2 100644 --- a/Carpet/CarpetRegrid/src/baselevel.cc +++ b/Carpet/CarpetRegrid/src/baselevel.cc @@ -18,10 +18,10 @@ namespace CarpetRegrid { int BaseLevel (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; diff --git a/Carpet/CarpetRegrid/src/centre.cc b/Carpet/CarpetRegrid/src/centre.cc index 4a560c955..2c5dd6ce0 100644 --- a/Carpet/CarpetRegrid/src/centre.cc +++ b/Carpet/CarpetRegrid/src/centre.cc @@ -18,10 +18,10 @@ namespace CarpetRegrid { int Centre (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; @@ -67,11 +67,11 @@ namespace CarpetRegrid { bbs.at(0) = bb; bbvect const ob (false); - gh<dim>::cbnds obs (1); + gh::cbnds obs (1); obs.at(0) = ob; // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware diff --git a/Carpet/CarpetRegrid/src/manualcoordinatelist.cc b/Carpet/CarpetRegrid/src/manualcoordinatelist.cc index d62e2cce3..04dffd5e5 100644 --- a/Carpet/CarpetRegrid/src/manualcoordinatelist.cc +++ b/Carpet/CarpetRegrid/src/manualcoordinatelist.cc @@ -22,10 +22,10 @@ namespace CarpetRegrid { int ManualCoordinateList (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; int ierr; @@ -143,7 +143,7 @@ namespace CarpetRegrid { for (size_t rl=1; rl<refinement_levels; ++rl) { vector<ibbox> bbs; - gh<dim>::cbnds obs; + gh::cbnds obs; bbs.reserve (newbbss.at(rl-1).size()); obs.reserve (newbbss.at(rl-1).size()); @@ -180,7 +180,7 @@ namespace CarpetRegrid { } // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware diff --git a/Carpet/CarpetRegrid/src/manualcoordinates.cc b/Carpet/CarpetRegrid/src/manualcoordinates.cc index 4b45687da..cc757fdce 100644 --- a/Carpet/CarpetRegrid/src/manualcoordinates.cc +++ b/Carpet/CarpetRegrid/src/manualcoordinates.cc @@ -20,10 +20,10 @@ namespace CarpetRegrid { int ManualCoordinates (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; @@ -56,14 +56,14 @@ namespace CarpetRegrid { bbvect const ob (false); vector<ibbox> bbs; - gh<dim>::cbnds obs; + gh::cbnds obs; ManualCoordinates_OneLevel (cctkGH, hh, rl, refinement_levels, lower.at(rl-1), upper.at(rl-1), ob, bbs, obs); // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware @@ -82,7 +82,7 @@ namespace CarpetRegrid { void ManualCoordinates_OneLevel (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int rl, const int numrl, const rvect lower, @@ -102,7 +102,7 @@ namespace CarpetRegrid { - ivect delta2int (const cGH * const cctkGH, const gh<dim>& hh, + ivect delta2int (const cGH * const cctkGH, const gh& hh, const rvect & rpos, const int rl) { rvect global_lower, global_upper; @@ -132,7 +132,7 @@ namespace CarpetRegrid { - ivect pos2int (const cGH* const cctkGH, const gh<dim>& hh, + ivect pos2int (const cGH* const cctkGH, const gh& hh, const rvect & rpos, const int rl) { rvect global_lower, global_upper; diff --git a/Carpet/CarpetRegrid/src/manualgridpointlist.cc b/Carpet/CarpetRegrid/src/manualgridpointlist.cc index feae9544b..c4f534fd1 100644 --- a/Carpet/CarpetRegrid/src/manualgridpointlist.cc +++ b/Carpet/CarpetRegrid/src/manualgridpointlist.cc @@ -22,10 +22,10 @@ namespace CarpetRegrid { int ManualGridpointList (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; @@ -87,7 +87,7 @@ namespace CarpetRegrid { for (size_t rl=1; rl<refinement_levels; ++rl) { vector<ibbox> bbs; - gh<dim>::cbnds obs; + gh::cbnds obs; bbs.reserve (newbbss.at(rl-1).size()); obs.reserve (newbbss.at(rl-1).size()); @@ -101,7 +101,7 @@ namespace CarpetRegrid { } // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware diff --git a/Carpet/CarpetRegrid/src/manualgridpoints.cc b/Carpet/CarpetRegrid/src/manualgridpoints.cc index 64692e105..b4cb85a17 100644 --- a/Carpet/CarpetRegrid/src/manualgridpoints.cc +++ b/Carpet/CarpetRegrid/src/manualgridpoints.cc @@ -21,10 +21,10 @@ namespace CarpetRegrid { int ManualGridpoints (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_PARAMETERS; @@ -57,14 +57,14 @@ namespace CarpetRegrid { bbvect const ob (false); vector<ibbox> bbs; - gh<dim>::cbnds obs; + gh::cbnds obs; ManualGridpoints_OneLevel (cctkGH, hh, rl,refinement_levels, ilower.at(rl-1), iupper.at(rl-1), ob, bbs, obs); // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware @@ -83,7 +83,7 @@ namespace CarpetRegrid { void ManualGridpoints_OneLevel (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int rl, const int numrl, const ivect ilower, diff --git a/Carpet/CarpetRegrid/src/moving.cc b/Carpet/CarpetRegrid/src/moving.cc index 58a010e8a..0985399d5 100644 --- a/Carpet/CarpetRegrid/src/moving.cc +++ b/Carpet/CarpetRegrid/src/moving.cc @@ -19,10 +19,10 @@ namespace CarpetRegrid { int Moving (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss) + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss) { DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; @@ -54,13 +54,13 @@ namespace CarpetRegrid { rvect const rub (symmetric.ifthen (rvect(radius), pos + rvect(radius))); vector<ibbox> bbs; - gh<dim>::cbnds obs; + gh::cbnds obs; ManualCoordinates_OneLevel (cctkGH, hh, rl, refinement_levels, rlb, rub, ob, bbs, obs); // make multiprocessor aware - gh<dim>::cprocs ps; + gh::cprocs ps; SplitRegions (cctkGH, bbs, obs, ps); // make multigrid aware diff --git a/Carpet/CarpetRegrid/src/regrid.cc b/Carpet/CarpetRegrid/src/regrid.cc index c51ea97c1..94b281513 100644 --- a/Carpet/CarpetRegrid/src/regrid.cc +++ b/Carpet/CarpetRegrid/src/regrid.cc @@ -28,11 +28,11 @@ namespace CarpetRegrid { const cGH * const cctkGH = (const cGH *) cctkGH_; - gh<dim>::rexts & bbsss = * (gh<dim>::rexts *) bbsss_; - gh<dim>::rbnds & obss = * (gh<dim>::rbnds *) obss_; - gh<dim>::rprocs & pss = * (gh<dim>::rprocs *) pss_; + gh::rexts & bbsss = * (gh::rexts *) bbsss_; + gh::rbnds & obss = * (gh::rbnds *) obss_; + gh::rprocs & pss = * (gh::rprocs *) pss_; - gh<dim> const & hh = *vhh.at(Carpet::map); + gh const & hh = *vhh.at(Carpet::map); assert (is_singlemap_mode()); diff --git a/Carpet/CarpetRegrid/src/regrid.hh b/Carpet/CarpetRegrid/src/regrid.hh index 460290646..fea47e073 100644 --- a/Carpet/CarpetRegrid/src/regrid.hh +++ b/Carpet/CarpetRegrid/src/regrid.hh @@ -43,25 +43,25 @@ namespace CarpetRegrid { int BaseLevel (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); int Centre (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); int ManualGridpoints (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); void ManualGridpoints_OneLevel (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int rl, const int numrl, const ivect ilower, @@ -71,13 +71,13 @@ namespace CarpetRegrid { vector<bbvect> & obs); int ManualCoordinates (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); void ManualCoordinates_OneLevel (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int rl, const int numrl, const rvect lower, @@ -87,55 +87,55 @@ namespace CarpetRegrid { vector<bbvect> & obs); ivect delta2int (const cGH * const cctkGH, - const gh<dim>& hh, + const gh& hh, const rvect & rpos, const int rl); ivect pos2int (const cGH* const cctkGH, - const gh<dim>& hh, + const gh& hh, const rvect & rpos, const int rl); int ManualGridpointList (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); int ManualCoordinateList (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); int Moving (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); int Automatic (cGH const * const cctkGH, - gh<dim> const & hh, - gh<dim>::rexts & bbsss, - gh<dim>::rbnds & obss, - gh<dim>::rprocs & pss); + gh const & hh, + gh::rexts & bbsss, + gh::rbnds & obss, + gh::rprocs & pss); void Automatic_OneLevel (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int rl, const int numrl, const int minwidth, const CCTK_REAL minfraction, const CCTK_REAL maxerror, - const gf<CCTK_REAL,dim> & errorvar, + const gf<CCTK_REAL> & errorvar, vector<ibbox> & bbs, vector<bbvect> & obs); void Automatic_Recursive (const cGH * const cctkGH, - const gh<dim> & hh, + const gh & hh, const int minwidth, const CCTK_REAL minfraction, const CCTK_REAL maxerror, - const data<CCTK_REAL,dim> & errorvar, + const data<CCTK_REAL> & errorvar, list<ibbox> & bbl, const ibbox & region); diff --git a/Carpet/CarpetSlab/src/GetHyperslab.cc b/Carpet/CarpetSlab/src/GetHyperslab.cc index c84691e6e..c22e0b1b4 100644 --- a/Carpet/CarpetSlab/src/GetHyperslab.cc +++ b/Carpet/CarpetSlab/src/GetHyperslab.cc @@ -107,9 +107,9 @@ namespace CarpetSlab { // } // Get insider information about variable - const gh<dim>* myhh; - const dh<dim>* mydd; - const ggf<dim>* myff; + const gh* myhh; + const dh* mydd; + const ggf* myff; assert (group < (int)arrdata.size()); myhh = arrdata.at(group).at(m).hh; assert (myhh); @@ -141,7 +141,7 @@ namespace CarpetSlab { } // Get sample data - const gdata<dim>* mydata; + const gdata* mydata; mydata = (*myff)(tl, rl, 0, 0); // Stride of data in memory @@ -171,13 +171,13 @@ namespace CarpetSlab { // Create collector data object void* myhdata = rank==collect_proc ? hdata : 0; - gdata<dim>* const alldata = mydata->make_typed(-1); + gdata* const alldata = mydata->make_typed(-1); alldata->allocate (hextent, collect_proc, myhdata); // Done with the temporary stuff mydata = 0; - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { // Loop over all components, copying data from them BEGIN_LOCAL_COMPONENT_LOOP (cgh, gp.grouptype) { @@ -207,8 +207,8 @@ namespace CarpetSlab { // Copy result to all processors if (dest_proc == -1) { - vector<gdata<dim>*> tmpdata(CCTK_nProcs(cgh)); - vector<comm_state<dim> > state; + vector<gdata*> tmpdata(CCTK_nProcs(cgh)); + vector<comm_state> state; for (int proc=0; proc<CCTK_nProcs(cgh); ++proc) { if (proc != collect_proc) { diff --git a/Carpet/CarpetSlab/src/slab.cc b/Carpet/CarpetSlab/src/slab.cc index ad111617a..9ca04ae6a 100644 --- a/Carpet/CarpetSlab/src/slab.cc +++ b/Carpet/CarpetSlab/src/slab.cc @@ -131,9 +131,9 @@ namespace CarpetSlab { } // Get insider information about variable - const gh<dim>* myhh; - const dh<dim>* mydd; - const ggf<dim>* myff; + const gh* myhh; + const dh* mydd; + const ggf* myff; assert (group < (int)arrdata.size()); myhh = arrdata.at(group).at(m).hh; assert (myhh); @@ -173,7 +173,7 @@ namespace CarpetSlab { } // Get sample data - const gdata<dim>* mydata; + const gdata* mydata; mydata = (*myff)(tl, rl, 0, 0); // Stride of data in memory @@ -203,13 +203,13 @@ namespace CarpetSlab { // Create collector data object void* myhdata = rank==collect_proc ? hdata : 0; - gdata<dim>* const alldata = mydata->make_typed(-1); + gdata* const alldata = mydata->make_typed(-1); alldata->allocate (hextent, collect_proc, myhdata); // Done with the temporary stuff mydata = 0; - for (comm_state<dim> state; !state.done(); state.step()) { + for (comm_state state; !state.done(); state.step()) { // Loop over all components, copying data from them BEGIN_LOCAL_COMPONENT_LOOP (cgh, gp.grouptype) { @@ -239,8 +239,8 @@ namespace CarpetSlab { // Copy result to all processors if (dest_proc == -1) { - vector<gdata<dim>*> tmpdata(CCTK_nProcs(cgh)); - vector<comm_state<dim> > state; + vector<gdata*> tmpdata(CCTK_nProcs(cgh)); + vector<comm_state> state; for (int proc=0; proc<CCTK_nProcs(cgh); ++proc) { if (proc != collect_proc) { |