20 #ifndef OPM_REGIONMAPPING_HEADER_INCLUDED
21 #define OPM_REGIONMAPPING_HEADER_INCLUDED
23 #include <boost/range.hpp>
25 #include <unordered_map>
42 template <
class Region = std::vector<
int> >
68 typedef typename Region::size_type
CellId;
74 typedef typename std::vector<CellId>::const_iterator
CellIter;
76 typedef boost::iterator_range<CellIter>
Range;
85 region(
const CellId
c)
const {
return reg_[
c]; }
87 const std::vector<RegionId>&
103 const auto id = rev_.binid.find(r);
105 if (
id == rev_.binid.end()) {
107 return Range(rev_.c.end(), rev_.c.end());
110 const auto i =
id->second;
112 return Range(rev_.c.begin() + rev_.p[i + 0],
113 rev_.c.begin() + rev_.p[i + 1]);
126 typedef typename std::vector<CellId>::size_type
Pos;
128 std::unordered_map<RegionId, Pos>
binid;
132 std::vector<CellId>
c;
139 init(
const Region& reg)
142 for (
const auto& r : reg) {
146 p .clear(); p.emplace_back(0);
150 for (
auto&
id : binid) {
151 active.push_back(
id.first);
158 for (decltype(p.size()) i = 1, sz = p.size(); i < sz; ++i) {
163 assert (p[0] == static_cast<Pos>(reg.size()));
165 c.resize(reg.size());
168 for (
const auto& r : reg) {
169 auto& pos = p[ binid[r] + 1 ];
181 #endif // OPM_REGIONMAPPING_HEADER_INCLUDED
const std::vector< RegionId > & activeRegions() const
Definition: RegionMapping.hpp:88
boost::iterator_range< CellIter > Range
Definition: RegionMapping.hpp:76
Definition: AnisotropicEikonal.hpp:43
std::vector< CellId >::const_iterator CellIter
Definition: RegionMapping.hpp:74
RegionId region(const CellId c) const
Definition: RegionMapping.hpp:85
const double second
Definition: Units.hpp:93
std::vector< Pos > p
Definition: RegionMapping.hpp:131
std::unordered_map< RegionId, Pos > binid
Definition: RegionMapping.hpp:128
Range cells(const RegionId r) const
Definition: RegionMapping.hpp:102
RegionMapping(const Region ®)
Definition: RegionMapping.hpp:52
Definition: RegionMapping.hpp:43
Region::size_type CellId
Definition: RegionMapping.hpp:68
std::vector< CellId >::size_type Pos
Definition: RegionMapping.hpp:126
std::vector< RegionId > active
Definition: RegionMapping.hpp:129
std::vector< CellId > c
Definition: RegionMapping.hpp:132
Region::value_type RegionId
Definition: RegionMapping.hpp:62