#include #include #include #include #include #include "cctk.h" #include "cctk_Parameters.h" #include "gh.hh" #include "carpet.hh" #include "CAR.hh" namespace CarpetAdaptiveRegrid { using namespace std; using namespace Carpet; int ManualCoordinateList (cGH const * const cctkGH, gh const & hh, gh::mexts & bbsss, gh::rbnds & obss, gh::rbnds & rbss, gh::rprocs & pss, gh::mexts & local_bbsss, gh::rbnds & local_obss, gh::rbnds & local_rbss) { DECLARE_CCTK_PARAMETERS; int ierr; assert (refinement_levels >= 1); // do nothing if the levels already exist if (reflevel == refinement_levels) return 0; assert (bbsss.size() >= 1); vector > bbss = bbsss.at(0); vector > local_bbss = local_bbsss.at(0); jjvect nboundaryzones, is_internal, is_staggered, shiftout; ierr = GetBoundarySpecification (2*dim, &nboundaryzones[0][0], &is_internal[0][0], &is_staggered[0][0], &shiftout[0][0]); assert (!ierr); rvect physical_min, physical_max; rvect interior_min, interior_max; rvect exterior_min, exterior_max; rvect base_spacing; ierr = GetDomainSpecification (dim, &physical_min[0], &physical_max[0], &interior_min[0], &interior_max[0], &exterior_min[0], &exterior_max[0], &base_spacing[0]); assert (!ierr); bbss.resize (refinement_levels); local_bbss.resize (refinement_levels); obss.resize (refinement_levels); local_obss.resize (refinement_levels); rbss.resize (refinement_levels); local_rbss.resize (refinement_levels); pss.resize (refinement_levels); vector > newbbss; if (strcmp(coordinates, "") != 0) { istringstream gp_str(coordinates); try { gp_str >> newbbss; } catch (input_error) { CCTK_WARN (0, "Could not parse parameter \"coordinates\""); } } vector > newobss; vector > newrbss; newobss.resize(newbbss.size()); newrbss.resize(newbbss.size()); for (size_t rl=0; rl bbs; gh::cbnds obs; gh::cbnds rbs; bbs.reserve (newbbss.at(rl-1).size()); obs.reserve (newbbss.at(rl-1).size()); rbs.reserve (newbbss.at(rl-1).size()); for (size_t c=0; c & bbs, vector & obs, vector & rbs) { if (rl >= numrl) return; jvect const ilower = pos2int (cctkGH, hh, lower, rl); jvect const iupper = pos2int (cctkGH, hh, upper, rl); ManualGridpoints_OneLevel (cctkGH, hh, rl, numrl, ilower, iupper, obound, rbound, bbs, obs, rbs); } void ManualGridpoints_OneLevel (const cGH * const cctkGH, const gh & hh, const int rl, const int numrl, const ivect ilower, const ivect iupper, const bbvect obound, const bbvect rbound, vector & bbs, vector & obs, vector & rbs) { const ivect rstr = hh.baseextent.stride(); const ivect rlb = hh.baseextent.lower(); const ivect rub = hh.baseextent.upper(); const ivect levfac = hh.reffacts.at(rl); assert (all (rstr % levfac == 0)); const ivect str (rstr / levfac); const ivect lb (ilower); const ivect ub (iupper); if (! all(lb>=rlb && ub<=rub)) { ostringstream buf; buf << "The refinement region boundaries for refinement level #" << rl << " are not within the main grid. Allowed are the grid point boundaries " << rlb << " - " << rub << "; specified were " << lb << " - " << ub << ends; CCTK_WARN (0, buf.str().c_str()); } if (! all(lb<=ub)) { ostringstream buf; buf << "The refinement region boundaries for refinement level #" << rl << " have the upper boundary (" << ub << ") less than the lower boundary (" << lb << ")" << ends; CCTK_WARN (0, buf.str().c_str()); } if (! all(lb%str==0 && ub%str==0)) { CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, "The refinement region boundaries for refinement level #%d are not a multiple of the stride for that level", rl); } assert (all(lb>=rlb && ub<=rub)); assert (all(lb<=ub)); assert (all(lb%str==0 && ub%str==0)); bbs.push_back (ibbox(lb, ub, str)); obs.push_back (obound); rbs.push_back (rbound); } } // namespace CarpetRegrid