mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-27 01:31:00 -06:00
RegionMapping<>: Support arbitrary region IDs
This commit introduces a new public method, activeRegions(), that retrieves those region IDs that contain at least one active cell. We furthermore extend the cells() method to support lookup of arbitrary region IDs. Non-active region IDs produce empty cell ranges. Intended use case is for (const auto& reg : rmap.activeRegions()) { const auto& c = rmap.cells(reg); // use c }
This commit is contained in:
parent
b5ba068309
commit
99368d73d2
@ -399,13 +399,10 @@ namespace Opm
|
|||||||
const Grid& G ,
|
const Grid& G ,
|
||||||
const double grav)
|
const double grav)
|
||||||
{
|
{
|
||||||
for (typename RMap::RegionId
|
for (const auto& r : reg.activeRegions()) {
|
||||||
r = 0, nr = reg.numRegions();
|
const auto& cells = reg.cells(r);
|
||||||
r < nr; ++r)
|
|
||||||
{
|
|
||||||
const typename RMap::CellRange cells = reg.cells(r);
|
|
||||||
|
|
||||||
const int repcell = *cells.begin();
|
const int repcell = *cells.begin();
|
||||||
|
|
||||||
const RhoCalc calc(props, repcell);
|
const RhoCalc calc(props, repcell);
|
||||||
const EqReg eqreg(rec[r], calc,
|
const EqReg eqreg(rec[r], calc,
|
||||||
rs_func_[r], rv_func_[r],
|
rs_func_[r], rv_func_[r],
|
||||||
|
@ -307,10 +307,8 @@ BOOST_AUTO_TEST_CASE (RegMapping)
|
|||||||
Opm::RegionMapping<> eqlmap(eqlnum);
|
Opm::RegionMapping<> eqlmap(eqlnum);
|
||||||
|
|
||||||
PPress ppress(2, PVal(G->number_of_cells, 0));
|
PPress ppress(2, PVal(G->number_of_cells, 0));
|
||||||
for (int r = 0, e = eqlmap.numRegions(); r != e; ++r)
|
for (const auto& r : eqlmap.activeRegions()) {
|
||||||
{
|
const auto& rng = eqlmap.cells(r);
|
||||||
const Opm::RegionMapping<>::CellRange&
|
|
||||||
rng = eqlmap.cells(r);
|
|
||||||
|
|
||||||
const int rno = r;
|
const int rno = r;
|
||||||
const double grav = 10;
|
const double grav = 10;
|
||||||
@ -318,14 +316,13 @@ BOOST_AUTO_TEST_CASE (RegMapping)
|
|||||||
Opm::Equil::phasePressures(*G, region[rno], rng, grav);
|
Opm::Equil::phasePressures(*G, region[rno], rng, grav);
|
||||||
|
|
||||||
PVal::size_type i = 0;
|
PVal::size_type i = 0;
|
||||||
for (Opm::RegionMapping<>::CellRange::const_iterator
|
for (const auto& c : rng) {
|
||||||
c = rng.begin(), ce = rng.end();
|
|
||||||
c != ce; ++c, ++i)
|
|
||||||
{
|
|
||||||
assert (i < p[0].size());
|
assert (i < p[0].size());
|
||||||
|
|
||||||
ppress[0][*c] = p[0][i];
|
ppress[0][c] = p[0][i];
|
||||||
ppress[1][*c] = p[1][i];
|
ppress[1][c] = p[1][i];
|
||||||
|
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user