#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 (const mexts& exts, const rbnds& outer_bounds, const rprocs& procs) { DECLARE_CCTK_PARAMETERS; // Save the old grid hierarchy _oldextents = _extents; _oldouter_boundaries = _outer_boundaries; _oldprocessors = _processors; _extents = exts; _outer_boundaries = outer_bounds; _processors = procs; // Consistency checks // nota bene: there might be 0 refinement levels. check_processor_number_consistency (); 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(); } } void gh::recompose (const int rl, const bool do_prolongate) { // Handle changes in number of mglevels if (_oldextents.size() != _extents.size()) { _oldextents.resize (_extents.size()); } if (level_did_change(rl)) { // 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)_oldextents.at(ml).size()) return true; if (_extents.at(ml).at(rl).size() != _oldextents.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; }