aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2009-09-21 11:32:26 -0500
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 16:45:09 +0000
commitac982406eb912fae3838d1cd0c012676134ee1d6 (patch)
treefbfeb06c9e5d15fc2e68ed3fadf32dcc6d2de70a /Carpet/CarpetLib
parent29e373ad99f97175fd6443dd7e9307e10cc125f2 (diff)
CarpetLib: Add new routine bbox::index to calculate linear index in a region
Ignore-this: 14ce4ae43aea75443c9b77d106436795
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/bbox.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/bbox.hh b/Carpet/CarpetLib/src/bbox.hh
index 8386f58a2..9ac9a9af3 100644
--- a/Carpet/CarpetLib/src/bbox.hh
+++ b/Carpet/CarpetLib/src/bbox.hh
@@ -189,6 +189,17 @@ public:
which means that it also points to the first point. */
iterator end () const;
+ size_type index (const vect<T,D>& pos) const
+ {
+ assert (not empty());
+ bbox const posbox (pos, pos, stride());
+ assert (is_aligned_with (posbox));
+ assert (contains(pos));
+ size_type const i = ::index (shape(), (pos - lower()) / stride());
+ assert (i>=0 and i<size());
+ return i;
+ }
+
// Memory usage
size_t memory () const CCTK_ATTRIBUTE_CONST
{