#include #include #include #include #include "cctk.h" #include "cctk_Parameters.h" #include "defs.hh" #include "dh.hh" #include "th.hh" #include "vect.hh" #include "gh.hh" using namespace std; // Constructors gh::gh (const vector & reffacts_, const centering refcent_, const int mgfact_, const centering mgcent_, const ibbox baseextent_) : reffacts(reffacts_), refcent(refcent_), mgfact(mgfact_), mgcent(mgcent_), baseextent(baseextent_) { assert (reffacts.size() >= 1); assert (all (reffacts.front() == 1)); for (size_t n = 1; n < reffacts.size(); ++ n) { assert (all (reffacts.at(n) >= reffacts.at(n-1))); assert (all (reffacts.at(n) % reffacts.at(n-1) == 0)); } } // Destructors gh::~gh () { } // Modifiers void gh::regrid (mregs const & regs) { DECLARE_CCTK_PARAMETERS; // Save the old grid hierarchy _oldregions = _regions; _regions = regs; // Consistency checks // nota bene: there might be 0 refinement levels. check_multigrid_consistency (); check_component_consistency (); check_base_grid_extent (); check_refinement_levels (); calculate_base_extents_of_all_levels (); if (output_bboxes) { do_output_bboxes (cout); do_output_bases (cout); } // Recompose the other hierarchies for (list::iterator t=ths.begin(); t!=ths.end(); ++t) { (*t)->regrid(); } for (list::iterator d=dhs.begin(); d!=dhs.end(); ++d) { (*d)->regrid(); } } bool gh::recompose (const int rl, const bool do_prolongate) { // Handle changes in number of mglevels if (_oldregions.size() != _regions.size()) { _oldregions.resize (_regions.size()); } bool const do_recompose = level_did_change(rl); if (do_recompose) { // Recompose the other hierarchies for (list::iterator d=dhs.begin(); d!=dhs.end(); ++d) { (*d)->recompose (rl, do_prolongate); } // Overwrite old with new grid hierarchy for (int ml=0; ml=0 and rl= (int)_oldregions.at(ml).size()) return true; if (_regions.at(ml).at(rl).size() != _oldregions.at(ml).at(rl).size()) { return true; } for (int c=0; c0); for (int ml=1; ml0); for (int c=0; c0) { for (int c=0; c::const_iterator d = dhs.begin(); d != dhs.end(); ++d) { os << sep; (*d)->output(os); sep = ","; } os << "}"; return os; }