From 689586c9cd4d28909c8443e2e16b3d16d517edd3 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 3 Dec 2010 16:17:20 -0500 Subject: CarpetReduce: Adapt handling mesh refinement to changes in CarpetLib Completely rewrite the code, using the active and fine_active data provided by CarpetLib. --- Carpet/CarpetReduce/src/mask_carpet.cc | 358 ++++++++++++++++----------------- 1 file changed, 179 insertions(+), 179 deletions(-) (limited to 'Carpet/CarpetReduce') diff --git a/Carpet/CarpetReduce/src/mask_carpet.cc b/Carpet/CarpetReduce/src/mask_carpet.cc index 08c8e4a5c..81c53e7b7 100644 --- a/Carpet/CarpetReduce/src/mask_carpet.cc +++ b/Carpet/CarpetReduce/src/mask_carpet.cc @@ -1,4 +1,5 @@ #include +#include #include #include @@ -12,26 +13,26 @@ #include #include "bits.h" -#include "mask_carpet.hh" - - - -#define SWITCH_TO_LEVEL(cctkGH, rl) \ - do { \ - bool switch_to_level_ = true; \ - assert (is_singlemap_mode()); \ - int const rl_ = (rl); \ - int const m_ = Carpet::map; \ - BEGIN_GLOBAL_MODE (cctkGH) { \ - ENTER_LEVEL_MODE (cctkGH, rl_) { \ - ENTER_SINGLEMAP_MODE (cctkGH, m_, CCTK_GF) { -#define END_SWITCH_TO_LEVEL \ - } LEAVE_SINGLEMAP_MODE; \ - } LEAVE_LEVEL_MODE; \ - } END_GLOBAL_MODE; \ - assert (switch_to_level_); \ - switch_to_level_ = false; \ - } while (false) + + + +#define LOOP_OVER_NEIGHBOURS(dir) \ +{ \ + ivect dir_(-1); \ + do { \ + ivect const& dir = dir_; \ + { +#define END_LOOP_OVER_NEIGHBOURS \ + } \ + for (int d_=0; d_ 0) { - - ivect const ione = ivect(1); - - dh const & dd = *vdd.AT(Carpet::map); - ivect const reffact = spacereffacts.AT(reflevel) / spacereffacts.AT(reflevel-1); assert (all (reffact == 2)); + } + + // Set prolongation boundaries and restricted region of this level + BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { + DECLARE_CCTK_ARGUMENTS; + ibbox const& ext = + dd.light_boxes.AT(mglevel).AT(reflevel).AT(component).exterior; + ibbox const& owned = + dd.light_boxes.AT(mglevel).AT(reflevel).AT(component).owned; + ibbox const world = owned; + ibset const& active = + dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).active; + // There are no prolongation boundaries on the coarsest level; + // the outer boundary is treated elsewhere + ibset const not_active = reflevel==0 ? ibset() : world - active; + ibset const& fine_active = + dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).fine_active; + if (verbose) { + ostringstream buf; + buf << "Setting prolongation region " << not_active << " on level " << reflevel; + CCTK_INFO (buf.str().c_str()); + buf << "Setting restriction region " << fine_active << " on level " << reflevel; + CCTK_INFO (buf.str().c_str()); + } + // Set the weight in the interior of the not_active and the + // fine_active regions to zero, and set the weight on the + // boundary of the not_active and fine_active regions to 1/2. + // + // For the prolongation region, the "boundary" is the first + // layer outside of the region. 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. + ibset test_boxes; + ibset test_cfboxes; - // Set prolongation boundaries of this level - BEGIN_LOCAL_COMPONENT_LOOP (cctkGH, CCTK_GF) { - DECLARE_CCTK_ARGUMENTS; + LOOP_OVER_NEIGHBOURS (shift) { + // In this loop, shift [1,1,1] denotes a convex corner of the + // region which should be masked out, i.e. a region where only + // a small bit (1/8) of the region should be masked out. + // Concave edges are treated implicitly (sequentially), i.e. + // larger chunks are cut out multiple times: a concave xy edge + // counts as both an x face and a y face. - ibbox const & ext = - dd.light_boxes.AT(mglevel).AT(reflevel).AT(component).exterior; - ibset const & active = - dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).active; - - vect,dim> const & boundaries = - dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).prolongation_boundaries; + ibset boxes = not_active; + ibset fboxes = fine_active; + for (int d=0; d,dim> const & boundaries = - dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).restriction_boundaries; - - LOOP_OVER_BSET (cctkGH, refined, box, imin, imax) { - - if (verbose) { - ostringstream buf; - buf << "Setting restricted region on level " << reflevel << " to weight 0: " << imin << ":" << imax-ione; - CCTK_INFO (buf.str().c_str()); - } - - // Set weight in the restricted region to 0 - assert (dim == 3); + // Handle restricted region + LOOP_OVER_BSET (cctkGH, cfboxes, box, imin, imax) { + if (verbose) { + ostringstream buf; + buf << "Setting restricted region "<< imin << ":" << imax-ivect(1) << " on level " << reflevel << " boundary " << shift << " to bmask " << bmask; + CCTK_INFO (buf.str().c_str()); + } #pragma omp parallel - LC_LOOP3(CarpetMaskSetup_restriction, + CCTK_LOOP3(CarpetMaskSetup_restriction, i,j,k, imin[0],imin[1],imin[2], imax[0],imax[1],imax[2], cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) - { - int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k); - iweight[ind] = 0; - } LC_ENDLOOP3(CarpetMaskSetup_restriction); - - } END_LOOP_OVER_BSET; - - vector imask (prod(ivect::ref(cctk_lsh))); - - assert (dim == 3); -#pragma omp parallel - LC_LOOP3(CarpetMaskSetup_restriction_boundary_init, - i,j,k, - 0,0,0, cctk_lsh[0],cctk_lsh[1],cctk_lsh[2], - cctk_lsh[0],cctk_lsh[1],cctk_lsh[2]) { int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k); - imask[ind] = 0; - } LC_ENDLOOP3(CarpetMaskSetup_restriction_boundary_init); - - for (int d=0; d0 + } END_LOCAL_COMPONENT_LOOP; } } // namespace CarpetMask -- cgit v1.2.3