20#ifndef OPM_REGIONMAPPING_HEADER_INCLUDED
21#define OPM_REGIONMAPPING_HEADER_INCLUDED
23#include <opm/grid/utility/IteratorRange.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;
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;
129 std::vector<RegionId> active;
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);
152 p .push_back(
id.second);
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 ];
Forward and reverse mappings between cells and regions/partitions (e.g., the ECLIPSE-style 'SATNUM',...
Definition RegionMapping.hpp:43
Region::value_type RegionId
Type of forward (cell-to-region) mapping result.
Definition RegionMapping.hpp:62
std::vector< CellId >::const_iterator CellIter
Type of reverse region-to-cell range bounds and iterators.
Definition RegionMapping.hpp:74
std::vector< CellId > c
Region cells.
Definition RegionMapping.hpp:132
Range cells(const RegionId r) const
Extract active cells in particular region.
Definition RegionMapping.hpp:102
RegionMapping(const Region ®)
Constructor.
Definition RegionMapping.hpp:52
std::vector< Pos > p
Region start pointers.
Definition RegionMapping.hpp:131
Region::size_type CellId
Type of reverse (region-to-cell) mapping (element) result.
Definition RegionMapping.hpp:68
RegionId region(const CellId c) const
Compute region number of given active cell.
Definition RegionMapping.hpp:85
Holds the implementation of the CpGrid as a pimple.
Definition CellQuadrature.cpp:68
Definition IteratorRange.hpp:50