aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-05-26 16:22:04 -0400
committerErik Schnetter <schnetter@gmail.com>2013-05-26 16:22:04 -0400
commit606c70ba30488ae8b5bf9384bbe85dc94e0cc522 (patch)
tree3df92973b2a6b6d4aae57c7a8c2e0268380ff6c8 /Carpet/CarpetLib
parent7183bf5dff80a6f7ed563f633598fd1fa84d77fe (diff)
CarpetLib: New function bbox::anti_contracted_for
anti_contracted_for is the exact opposite of contracted for. It is similar to expanded_for, but may return different results in corner cases.
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/bbox.cc20
-rw-r--r--Carpet/CarpetLib/src/bbox.hh3
2 files changed, 23 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc
index 5c561c498..63f2040e2 100644
--- a/Carpet/CarpetLib/src/bbox.cc
+++ b/Carpet/CarpetLib/src/bbox.cc
@@ -222,6 +222,26 @@ bbox<T,D> bbox<T,D>::contracted_for (const bbox& b) const {
return bbox(lo,up,str);
}
+// Find the smallest open b-compatible box around *this:
+// This routine is similar to expanded_for. However, it returns a box
+// that is possibly larger than the box returned by expanded_for.
+template<typename T, int D>
+bbox<T,D> bbox<T,D>::anti_contracted_for (const bbox& b) const {
+ if (empty()) return bbox(b.lower(), b.lower()-b.stride(), b.stride());
+ return expand(1, 1).expanded_for(b).expand(-1, -1);
+ // if (all(stride() <= b.stride())) {
+ // // New stride is larger or equal to current stride: forward call
+ // // to expanded_for
+ // return expanded_for(b);
+ // }
+ // if (all(stride() > b.stride())) {
+ // // New stride is smaller than current stride: expand box by one
+ // // stride, call expanded_for, and shrink box by on stride again
+ // return expand(1, 1).expanded_for(b).expand(-1, -1);
+ // }
+ // __builtin_unreachable();
+}
+
// Smallest bbox containing both boxes
template<typename T, int D>
bbox<T,D> bbox<T,D>::expanded_containing (const bbox& b) const {
diff --git a/Carpet/CarpetLib/src/bbox.hh b/Carpet/CarpetLib/src/bbox.hh
index d65928e02..5dea7f9d3 100644
--- a/Carpet/CarpetLib/src/bbox.hh
+++ b/Carpet/CarpetLib/src/bbox.hh
@@ -184,6 +184,9 @@ public:
/** Find the largest b-compatible box inside this bbox. */
bbox contracted_for (const bbox& b) const CCTK_MEMBER_ATTRIBUTE_PURE;
+ /** Find the smallest open b-compatible box around *this */
+ bbox anti_contracted_for (const bbox& b) const CCTK_MEMBER_ATTRIBUTE_PURE;
+
/** Find the smallest bbox containing both boxes. */
bbox expanded_containing (const bbox<T,D>& b) const
CCTK_MEMBER_ATTRIBUTE_PURE;