From f7f69d561635cfdcc5dfb610184e581086b4e7af Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 22 May 2011 21:31:32 -0400 Subject: CarpetLib: Pre-calculate bbox regions for reduction mask Pre-calculate and store the regions for CarpetReduce's reduction weight. Add new dh fields prolongation_boundary and restriction_boundary. Remove field fine_active. Disable also the dh fields buffers_stepped. --- Carpet/CarpetLib/src/dh.cc | 228 ++++++++++++++++++++++++++++++++++++++++----- Carpet/CarpetLib/src/dh.hh | 14 ++- 2 files changed, 215 insertions(+), 27 deletions(-) diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc index a3ac5cc10..b789601cd 100644 --- a/Carpet/CarpetLib/src/dh.cc +++ b/Carpet/CarpetLib/src/dh.cc @@ -27,6 +27,26 @@ list dh::alldh; +// Indexing over neighbours + +static int num_nbs () +{ + return ipow(3,dim); +} + +static ivect ind2nb (int ind) +{ + ivect nb; + for (int d=0; d,dim> dh::fast_dboxes:: fast_ref_refl_sendrecv; @@ -556,11 +576,13 @@ regrid (bool const do_init) // Stepped buffer zones: local_box.buffers = box.buffers; +#if 0 local_box.buffers_stepped.resize (num_substeps); for (int substep = 0; substep < num_substeps; ++ substep) { local_box.buffers_stepped.AT(substep) = box.owned & allbuffers_stepped.AT(substep); } +#endif local_box.active = box.active; } // for lc @@ -1263,37 +1285,173 @@ regrid (bool const do_init) - // Mask: + // Reduction mask: + static Carpet::Timer timer_mask ("CarpetLib::dh::regrid::mask"); timer_mask.start(); + for (int lc=0; lc 0) { int const orl = rl - 1; + + // Set the weight in the interior of the notactive and the + // allactive regions to zero, and set the weight on the + // boundary of the notactive and allactive regions to 1/2. + // + // For the prolongation region, the "boundary" is the first + // layer outside of the region, and the "region" consists of + // the inactive points. This corresponds to the outermost + // layer of active grid points. + // + // For the restricted region, the "boundary" is the outermost + // layer of grid points if this layer is aligned with the next + // coarser (i.e. the current) grid; otherwise, the boundary is + // empty. The "region" consists of the active points. + + // Note: We calculate the prolongation information for the + // current level, and the restriction information for the next + // coarser level. We do it this way because both calculations + // start from the current level's set of active grid points. + full_cboxes const& full_olevel = full_boxes.AT(ml).AT(orl); // Local boxes are not communicated or post-processed, and // thus can be modified even for coarser levels local_cboxes& local_olevel = local_boxes.AT(ml).AT(orl); - for (int lc = 0; lc < h.local_components(orl); ++ lc) { - int const c = h.get_component(orl, lc); - full_dboxes const& full_obox = full_olevel.AT(c); - // Local boxes are not communicated or post-processed, and - // thus can be modified even for coarser levels - local_dboxes& local_obox = local_olevel.AT(lc); + if (verbose) { + ostringstream buf; + buf << "Setting prolongation region " << notactive << " on level " << rl; + CCTK_INFO (buf.str().c_str()); + } + if (verbose) { + ostringstream buf; + buf << "Setting restriction region " << allactive << " on level " << orl; + CCTK_INFO (buf.str().c_str()); + } + + // ibset test_boxes; + // ibset test_cfboxes; + + for (int neighbour=0; neighbour> buffers; skipws (is); - consume (is, "buffers_stepped:"); - is >> buffers_stepped; - skipws (is); consume (is, "active:"); is >> active; +#if 0 skipws (is); - consume (is, "restricted_region:"); - is >> restricted_region; + consume (is, "buffers_stepped:"); + is >> buffers_stepped; +#endif +#if 0 skipws (is); consume (is, "fine_active:"); is >> fine_active; +#endif + skipws (is); + consume (is, "prolongation_boundary:"); + is >> prolongation_boundary; + skipws (is); + consume (is, "restriction_boundary:"); + is >> restriction_boundary; + skipws (is); + consume (is, "restricted_region:"); + is >> restricted_region; skipws (is); consume (is, "unused_region:"); is >> unused_region; @@ -2404,10 +2578,16 @@ output (ostream & os) // Regions: os << "dh::local_dboxes:{" << eol << " buffers: " << buffers << eol - << " buffers_stepped: " << buffers_stepped << eol << " active: " << active << eol - << " restricted_region: " << restricted_region << eol +#if 0 + << " buffers_stepped: " << buffers_stepped << eol +#endif +#if 0 << " fine_active: " << fine_active << eol +#endif + << " prolongation_boundary: " << prolongation_boundary << eol + << " restriction_boundary: " << restriction_boundary << eol + << " restricted_region: " << restricted_region << eol << " unused_region: " << unused_region << eol << " coarse_boundary: " << coarse_boundary << eol << " fine_boundary: " << fine_boundary << eol diff --git a/Carpet/CarpetLib/src/dh.hh b/Carpet/CarpetLib/src/dh.hh index 7b5f595c1..28cccedf9 100644 --- a/Carpet/CarpetLib/src/dh.hh +++ b/Carpet/CarpetLib/src/dh.hh @@ -62,13 +62,21 @@ public: // Information about the processor-local region: ibset buffers; // buffer zones - vector buffers_stepped; // buffer zones [substep] ibset active; // owned minus buffers +#if 0 + vector buffers_stepped; // buffer zones [substep] +#endif // Mask - ibset restricted_region; // filled by restriction +#if 0 ibset fine_active; - ibset unused_region; // not used (overwritten later) +#endif + vector prolongation_boundary; + vector restriction_boundary; + + ibset restricted_region; // filled by restriction + // Does not influence anything but the restricted_region + ibset unused_region; // Refluxing vect,dim> coarse_boundary; -- cgit v1.2.3