aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetRegrid/src
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2006-09-25 22:08:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2006-09-25 22:08:00 +0000
commit9ada0ba4e7f5aec9c695d79224b590ab4745d86b (patch)
tree011f7559f867ec95f0bf91535d325de0298e8ee1 /Carpet/CarpetRegrid/src
parent6a650651d99b4d99799cebfa79f9521af804ae92 (diff)
CarpetRegrid: Simplify logic for merge_overlapping_components
darcs-hash:20060925220844-dae7b-d634dcf36d11a36dd214f75ab86465d7d0d5031c.gz
Diffstat (limited to 'Carpet/CarpetRegrid/src')
-rw-r--r--Carpet/CarpetRegrid/src/manualcoordinatelist.cc69
1 files changed, 18 insertions, 51 deletions
diff --git a/Carpet/CarpetRegrid/src/manualcoordinatelist.cc b/Carpet/CarpetRegrid/src/manualcoordinatelist.cc
index bd189db0a..faf49a25c 100644
--- a/Carpet/CarpetRegrid/src/manualcoordinatelist.cc
+++ b/Carpet/CarpetRegrid/src/manualcoordinatelist.cc
@@ -197,58 +197,25 @@ namespace CarpetRegrid {
ext.lower() + offset, ext.upper() + offset, ob, bbs, obs);
}
-
- // if we have more than 1 component, we might want to
- // check if merging them makes sense
- if(merge_overlapping_components && bbs.size() > 1) {
-
- // now let's check if one or more of our components touch...
-
-
- // we use this array to keep track of which component was merged
- // with another.
- vector<bool> merged_component (bbs.size(), false);
-
- // loop over all components, starting at c=1
- for (int c=1; c<(int)bbs.size(); ++c) {
-
- ibset fun = bbs.at(c);
- ibbox morefun = bbs.at(c);
-
- // loop over all components with index < c
- for(int sc=0; sc<c; ++sc) {
-
- // calculate overlap of this and the previous component
- fun &= bbs.at(sc);
-
- // do we overlap ?
- if(fun.size() > 0) {
- // uh. this component will be merged
- merged_component.at(c) = true;
-
- // calculate union
- morefun = morefun.expanded_containing(bbs.at(sc));
-
- // update the previous component with the union !
- bbs.at(sc) = morefun;
-
- }
- }
+ if (merge_overlapping_components) {
+
+ // Check if one or more of our components touch
+ again:
+ // Loop over all pairs of components
+ for (int c=0; c<(int)bbs.size(); ++c) {
+ for (int cc=0; cc<c; ++cc) {
+ ibbox const overlap = bbs.at(c) & bbs.at(cc);
+ if (not overlap.empty()) {
+ ibbox const combined =
+ bbs.at(c).expanded_containing (bbs.at(cc));
+ bbs.at(c) = combined;
+ bbs.erase (bbs.begin() + cc);
+ goto again;
+ }
+ }
}
-
- // now we need to get rid of those bboxes that were merged
- vector<ibbox> mergedbbs;
- for (int c=0;c<(int)bbs.size(); ++c) {
-
- if (not merged_component.at(c)) {
- mergedbbs.push_back (bbs.at(c));
- }
-
- }
-
- bbs = mergedbbs;
-
- } // if (merge_overlapping_components && ...)
+
+ } // if merge_overlapping_components
// make multiprocessor aware
gh::cprocs ps;