diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index ac398b1a9..dc0071003 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -399,13 +399,10 @@ namespace Opm const Grid& G , const double grav) { - for (typename RMap::RegionId - r = 0, nr = reg.numRegions(); - r < nr; ++r) - { - const typename RMap::CellRange cells = reg.cells(r); - + for (const auto& r : reg.activeRegions()) { + const auto& cells = reg.cells(r); const int repcell = *cells.begin(); + const RhoCalc calc(props, repcell); const EqReg eqreg(rec[r], calc, rs_func_[r], rv_func_[r], diff --git a/tests/test_equil.cpp b/tests/test_equil.cpp index b029f5276..d7436195a 100644 --- a/tests/test_equil.cpp +++ b/tests/test_equil.cpp @@ -307,10 +307,8 @@ BOOST_AUTO_TEST_CASE (RegMapping) Opm::RegionMapping<> eqlmap(eqlnum); PPress ppress(2, PVal(G->number_of_cells, 0)); - for (int r = 0, e = eqlmap.numRegions(); r != e; ++r) - { - const Opm::RegionMapping<>::CellRange& - rng = eqlmap.cells(r); + for (const auto& r : eqlmap.activeRegions()) { + const auto& rng = eqlmap.cells(r); const int rno = r; const double grav = 10; @@ -318,14 +316,13 @@ BOOST_AUTO_TEST_CASE (RegMapping) Opm::Equil::phasePressures(*G, region[rno], rng, grav); PVal::size_type i = 0; - for (Opm::RegionMapping<>::CellRange::const_iterator - c = rng.begin(), ce = rng.end(); - c != ce; ++c, ++i) - { + for (const auto& c : rng) { assert (i < p[0].size()); - ppress[0][*c] = p[0][i]; - ppress[1][*c] = p[1][i]; + ppress[0][c] = p[0][i]; + ppress[1][c] = p[1][i]; + + ++i; } }