diff --git a/opm/core/transport/implicit/ImplicitAssembly.hpp b/opm/core/transport/implicit/ImplicitAssembly.hpp index b6facff..672623c 100644 --- a/opm/core/transport/implicit/ImplicitAssembly.hpp +++ b/opm/core/transport/implicit/ImplicitAssembly.hpp @@ -107,13 +107,13 @@ namespace Opm { template int countConnections(const Grid& g, int c) const { - int i, f, c1, c2, n; + int n = 0; - for (i = g.cell_facepos[c + 0], n = 0; + for (auto i = g.cell_facepos[c + 0]; i < g.cell_facepos[c + 1]; ++i) { - f = g.cell_faces[i]; - c1 = g.face_cells[2*f + 0]; - c2 = g.face_cells[2*f + 1]; + const auto f = g.cell_faces[i]; + const auto c1 = g.face_cells[2*f + 0]; + const auto c2 = g.face_cells[2*f + 1]; n += (c1 >= 0) && (c2 >= 0); } @@ -145,7 +145,7 @@ namespace Opm { connections.reserve (nconn + 1); connections.push_back(c); - for (int i = g.cell_facepos[c + 0]; + for (auto i = g.cell_facepos[c + 0]; i < g.cell_facepos[c + 1]; ++i) { int f = g.cell_faces[i]; int c1 = g.face_cells[2*f + 0]; @@ -180,11 +180,11 @@ namespace Opm { model_.initResidual(c, F); F += ndof; - for (int i = g.cell_facepos[c + 0]; + for (auto i = g.cell_facepos[c + 0]; i < g.cell_facepos[c + 1]; ++i) { - int f = g.cell_faces[i]; - int c1 = g.face_cells[2*f + 0]; - int c2 = g.face_cells[2*f + 1]; + auto f = g.cell_faces[i]; + auto c1 = g.face_cells[2*f + 0]; + auto c2 = g.face_cells[2*f + 1]; if ((c1 >= 0) && (c2 >= 0)) { model_.fluxConnection(state, g, dt, c, f, J1, J2, F); @@ -212,11 +212,11 @@ namespace Opm { sys.matasm().assembleBlock(ndof, c, c, J1); J1 += ndof2; // Assemble connection contributions. - for (int i = g.cell_facepos[c + 0]; + for (auto i = g.cell_facepos[c + 0]; i < g.cell_facepos[c + 1]; ++i) { - int f = g.cell_faces[i]; - int c1 = g.face_cells[2*f + 0]; - int c2 = g.face_cells[2*f + 1]; + auto f = g.cell_faces[i]; + auto c1 = g.face_cells[2*f + 0]; + auto c2 = g.face_cells[2*f + 1]; c2 = (c1 == c) ? c2 : c1; diff --git a/opm/core/transport/implicit/SinglePointUpwindTwoPhase.hpp b/opm/core/transport/implicit/SinglePointUpwindTwoPhase.hpp index 741331a..0c8fcd8 100644 --- a/opm/core/transport/implicit/SinglePointUpwindTwoPhase.hpp +++ b/opm/core/transport/implicit/SinglePointUpwindTwoPhase.hpp @@ -296,7 +296,8 @@ namespace Opm { store_.drho() = fluid_.density(0) - fluid_.density(1); } - for (int c = 0, i = 0; c < g.number_of_cells; ++c) { + auto i = grid_size_t(0); + for (int c = 0; c < g.number_of_cells; ++c) { for (; i < g.cell_facepos[c + 1]; ++i) { const int f = g.cell_faces[i]; const int p = 1 - (g.face_cells[2*f + 0] == c); @@ -481,7 +482,8 @@ namespace Opm { store_.trans(f) = 0.0; } - for (int c = 0, i = 0; c < g.number_of_cells; ++c) { + auto i = grid_size_t(0); + for (int c = 0; c < g.number_of_cells; ++c) { for (; i < g.cell_facepos[c + 1]; ++i) { int f = g.cell_faces[i]; @@ -666,8 +668,9 @@ namespace Opm { computeStaticGravity(const Grid& g) { const int d = g.dimensions; + auto i = grid_size_t(0); - for (int c = 0, i = 0; c < g.number_of_cells; ++c) { + for (int c = 0; c < g.number_of_cells; ++c) { const double* cc = g.cell_centroids + (c * d); for (; i < g.cell_facepos[c + 1]; ++i) { diff --git a/opm/porsol/euler/EulerUpstreamImplicit_impl.hpp b/opm/porsol/euler/EulerUpstreamImplicit_impl.hpp index 200deb2..9877bf9 100644 --- a/opm/porsol/euler/EulerUpstreamImplicit_impl.hpp +++ b/opm/porsol/euler/EulerUpstreamImplicit_impl.hpp @@ -246,12 +246,15 @@ namespace Opm std::vector faceflux(numhf); - for (int c = 0, i = 0; c < cgrid->number_of_cells; ++c){ - for (; i < cgrid->cell_facepos[c + 1]; ++i) { - int f= cgrid->cell_faces[i]; - double outflux = pressure_sol.outflux(i); - double sgn = 2.0*(cgrid->face_cells[2*f + 0] == c) - 1; - faceflux[f] = sgn * outflux; + { + auto i = grid_size_t(0); + for (int c = 0; c < cgrid->number_of_cells; ++c){ + for (; i < cgrid->cell_facepos[c + 1]; ++i) { + int f= cgrid->cell_faces[i]; + double outflux = pressure_sol.outflux(i); + double sgn = 2.0*(cgrid->face_cells[2*f + 0] == c) - 1; + faceflux[f] = sgn * outflux; + } } } int num_db=direclet_hfaces_.size();