From a412f02d6591af00d4765f1da8a32506e98f1f62 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 27 Apr 2010 10:21:08 -0500 Subject: CarpetReduce: Set up mask from new dh class entries Simplify mask setup code and improve its performance by using the new dh classes and their new entries. --- Carpet/CarpetReduce/src/mask_carpet.cc | 257 ++++++++++----------------------- 1 file changed, 73 insertions(+), 184 deletions(-) diff --git a/Carpet/CarpetReduce/src/mask_carpet.cc b/Carpet/CarpetReduce/src/mask_carpet.cc index 260afb23d..e469d105b 100644 --- a/Carpet/CarpetReduce/src/mask_carpet.cc +++ b/Carpet/CarpetReduce/src/mask_carpet.cc @@ -22,28 +22,6 @@ namespace CarpetMask { - void ibbox2iminimax (ibbox const& ext, // component extent - ibbox const& box, // this bbox - ivect const& lsh, // component's lsh - ivect& imin, ivect& imax) - { - ivect const izero = ivect(0); - - assert (all ((box.lower() - ext.lower() ) >= 0)); - assert (all ((box.upper() - ext.lower() + ext.stride()) >= 0)); - assert (all ((box.lower() - ext.lower() ) % ext.stride() == 0)); - assert (all ((box.upper() - ext.lower() + ext.stride()) % ext.stride() == 0)); - - imin = (box.lower() - ext.lower() ) / ext.stride(); - imax = (box.upper() - ext.lower() + ext.stride()) / ext.stride(); - - assert (all (izero <= imin)); - assert (box.empty() xor all (imin <= imax)); - assert (all (imax <= lsh)); - } - - - /** * Reduce the weight on the current and the next coarser level to * make things consistent. Set the weight to 0 inside the @@ -76,86 +54,27 @@ namespace CarpetMask { - // Calculate the union of all refined regions - ibset active; - for (int c=0; c const & boundaries = + dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).prolongation_boundaries; - ibset notactive = ext - active; - notactive.normalize(); + ibset const notactive = ext - active; for (int d=0; d const & boundaries = + dd.local_boxes.AT(mglevel).AT(reflevel).AT(local_component).restriction_boundaries; - for (ibset::const_iterator bi = refined.begin(); - bi != refined.end(); - ++bi) - { + LOOP_OVER_BSET (cctkGH, refined, box, imin, imax) { - ibbox const & box = (*bi).contracted_for(ext) & ext; - if (not box.empty()) { - - ivect imin, imax; - ibbox2iminimax (ext, box, ivect::ref(cctk_lsh), 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); + 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); #pragma omp parallel - LC_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); - weight[ind] = 0; - } LC_ENDLOOP3(CarpetMaskSetup_restriction); - - } // if box not empty - - } // for box + LC_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); + weight[ind] = 0; + } LC_ENDLOOP3(CarpetMaskSetup_restriction); + + } END_LOOP_OVER_BSET; assert (dim == 3); vector mask (cctk_lsh[0] * cctk_lsh[1] * cctk_lsh[2]); @@ -282,41 +182,30 @@ namespace CarpetMask { } LC_ENDLOOP3(CarpetMaskSetup_restriction_boundary_init); for (int d=0; d