From 9dab0323ce5291d90337330d3f2565308c1bbd87 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 21 Feb 2017 13:53:08 +0100 Subject: [PATCH] flow_ebos FIP: create the element iterator object as part of the for statement IMO, the previous solution was easier to read and a few lines shorter, but I don't really care about how this is done... --- opm/autodiff/BlackoilModelEbos.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 7542fbfd8..5276fe46e 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -1013,9 +1013,11 @@ namespace Opm { } ElementContext elemCtx(ebosSimulator_); - auto elemIt = elemCtx.gridView().template begin(); const auto& elemEndIt = elemCtx.gridView().template end(); - for (; elemIt != elemEndIt; ++elemIt) { + for (auto elemIt = elemCtx.gridView().template begin(); + elemIt != elemEndIt; + ++elemIt) + { const auto& elem = *elemIt; if (elem.partitionType() != Dune::InteriorEntity) { continue; @@ -1085,8 +1087,10 @@ namespace Opm { std::vector hcpv(dims, 0.0); std::vector pres(dims, 0.0); - elemIt = elemCtx.gridView().template begin(); - for (; elemIt != elemEndIt; ++elemIt) { + for (auto elemIt = elemCtx.gridView().template begin(); + elemIt != elemEndIt; + ++elemIt) + { const auto& elem = *elemIt; if (elem.partitionType() != Dune::InteriorEntity) { continue; @@ -1121,8 +1125,10 @@ namespace Opm { comm.sum(hcpv.data(), hcpv.size()); comm.sum(pres.data(), pres.size()); - elemIt = elemCtx.gridView().template begin(); - for (; elemIt != elemEndIt; ++elemIt) { + for (auto elemIt = elemCtx.gridView().template begin(); + elemIt != elemEndIt; + ++elemIt) + { const auto& elem = *elemIt; if (elem.partitionType() != Dune::InteriorEntity) { continue;