aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2006-12-05 17:54:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2006-12-05 17:54:00 +0000
commit6a6787ceb981366ed8327030531f2cd2f79f2ccc (patch)
tree7ca4b63396aeaf757f3ff1e17082e40eb1dd743e /Carpet
parent272f0ffe229970ee8aecd3314d0da97274290b5a (diff)
CarpetRegrid2: Combine all components into a single one if that is efficient
Introduce a parameter "min_fraction" that defines, indirectly, how many additional refined grid points can be introduced if that leads to a simpler structure. If using a single refined region instead of several ones would not introduce too many unnecessarily refined grid points, then do so. darcs-hash:20061205175426-dae7b-18d2467cf123b734aaef19eb2f5f9c4994480b99.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/CarpetRegrid2/param.ccl7
-rw-r--r--Carpet/CarpetRegrid2/src/regrid.cc24
2 files changed, 31 insertions, 0 deletions
diff --git a/Carpet/CarpetRegrid2/param.ccl b/Carpet/CarpetRegrid2/param.ccl
index 41414eda2..df17204dd 100644
--- a/Carpet/CarpetRegrid2/param.ccl
+++ b/Carpet/CarpetRegrid2/param.ccl
@@ -20,6 +20,13 @@ CCTK_INT min_distance "Minimum distance (in grid points) between coarse and fine
+CCTK_REAL min_fraction "Minimum fraction of required refined points that need to be present in a refined region"
+{
+ 0:* :: ""
+} 0.9
+
+
+
CCTK_INT regrid_every "Regrid every n time steps" STEERABLE=always
{
-1 :: "regrid never"
diff --git a/Carpet/CarpetRegrid2/src/regrid.cc b/Carpet/CarpetRegrid2/src/regrid.cc
index 32a590d54..5f581d3b6 100644
--- a/Carpet/CarpetRegrid2/src/regrid.cc
+++ b/Carpet/CarpetRegrid2/src/regrid.cc
@@ -448,6 +448,30 @@ namespace CarpetRegrid2 {
// Simplify the set of refined regions
regions.at(rl).normalize();
+ // Check whether it would be worthwhile to combine the regions
+ // into a single region
+ {
+ ibbox single;
+ for (ibboxset::const_iterator ibb = regions.at(rl).begin();
+ ibb != regions.at(rl).end();
+ ++ ibb)
+ {
+ ibbox bb = * ibb;
+ single = single.expanded_containing (bb);
+ }
+
+ CCTK_REAL const regions_size
+ = static_cast <CCTK_REAL> (regions.at(rl).size());
+ CCTK_REAL const single_size
+ = static_cast <CCTK_REAL> (single.size());
+
+ // Would a single bbox be efficient enough?
+ if (regions_size >= min_fraction * single_size) {
+ // Combine the boxes
+ regions.at(rl) = ibboxset (single);
+ }
+ }
+
// Create a vector of bboxes for this level
gh::cexts bbs;
gh::cbnds obs;