From 45f11d8820b5f99999e81f5e12d2385726709b31 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Fri, 14 Oct 2016 23:13:23 +0200 Subject: [PATCH 1/2] StandardWellsDense: fix some valgrind complaints note that I don't know if these changes are semantically correct (I doubt it), but this patch fixes the valgrind complaints I saw for SPE9_CP and on Norne. Also, this makes the timing of flow_ebos for SPE9 determinisic between runs: without this, I got some random time steps fail in a given run and in the next run a completely different set of timesteps failed. Since this was on the same same machine, without any recompiles and no changes to the deck or any other input parameters, I initially attributed the behavior to cosmic rays ;) @totto82: could you have a thorough look on this? --- opm/autodiff/BlackoilDetails.hpp | 5 ++--- opm/autodiff/BlackoilModelEbos.hpp | 2 +- opm/autodiff/StandardWellsDense.hpp | 14 ++++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/opm/autodiff/BlackoilDetails.hpp b/opm/autodiff/BlackoilDetails.hpp index 16b2ab06b..068388156 100644 --- a/opm/autodiff/BlackoilDetails.hpp +++ b/opm/autodiff/BlackoilDetails.hpp @@ -226,8 +226,7 @@ namespace detail { assert(nw * np == int(residual_well.size())); // Do the global reductions -#if 0 - HAVE_MPI +#if 0 // HAVE_MPI if ( linsolver_.parallelInformation().type() == typeid(ParallelISTLInformation) ) { const ParallelISTLInformation& info = @@ -276,7 +275,7 @@ namespace detail { for ( int idx = 0; idx < np; ++idx ) { B_avg[idx] = B.col(idx).sum()/nc; - maxCoeff[idx] = tempV.col(idx).maxCoeff(); + //maxCoeff[idx] = tempV.col(idx).maxCoeff(); R_sum[idx] = R.col(idx).sum(); assert(np >= np); diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index afcfa17eb..11e21d15e 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -168,8 +168,8 @@ namespace Opm { , well_model_ (well_model) , terminal_output_ (terminal_output) , current_relaxation_(1.0) - , isBeginReportStep_(false) , dx_old_(AutoDiffGrid::numCells(grid_)) + , isBeginReportStep_(false) { const double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_)); const std::vector pv(geo_.poreVolume().data(), geo_.poreVolume().data() + geo_.poreVolume().size()); diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index 5f7409f34..fb916c901 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -829,13 +829,14 @@ namespace Opm { if (pu.phase_used[BlackoilPhases::Vapour]) { int gaspos = pu.phase_pos[BlackoilPhases::Vapour] + perf * pu.num_phases; + int gaspos_well = pu.phase_pos[BlackoilPhases::Vapour] + w * pu.num_phases; if (pu.phase_used[BlackoilPhases::Liquid]) { - int oilpos = pu.phase_pos[BlackoilPhases::Liquid] + perf * pu.num_phases; - const double oilrate = std::abs(xw.wellRates()[oilpos]); //in order to handle negative rates in producers + int oilpos_well = pu.phase_pos[BlackoilPhases::Liquid] + w * pu.num_phases; + const double oilrate = std::abs(xw.wellRates()[oilpos_well]); //in order to handle negative rates in producers rvmax_perf[perf] = FluidSystem::gasPvt().saturatedOilVaporizationFactor(fs.pvtRegionIndex(), temperature, p_avg); if (oilrate > 0) { - const double gasrate = std::abs(xw.wellRates()[gaspos]); + const double gasrate = std::abs(xw.wellRates()[gaspos_well]); double rv = 0.0; if (gasrate > 0) { rv = oilrate / gasrate; @@ -855,12 +856,13 @@ namespace Opm { if (pu.phase_used[BlackoilPhases::Liquid]) { int oilpos = pu.phase_pos[BlackoilPhases::Liquid] + perf * pu.num_phases; + int oilpos_well = pu.phase_pos[BlackoilPhases::Liquid] + w * pu.num_phases; if (pu.phase_used[BlackoilPhases::Vapour]) { rsmax_perf[perf] = FluidSystem::oilPvt().saturatedGasDissolutionFactor(fs.pvtRegionIndex(), temperature, p_avg); - int gaspos = pu.phase_pos[BlackoilPhases::Vapour] + perf * pu.num_phases; - const double gasrate = std::abs(xw.wellRates()[gaspos]); + int gaspos_well = pu.phase_pos[BlackoilPhases::Vapour] + w * pu.num_phases; + const double gasrate = std::abs(xw.wellRates()[gaspos_well]); if (gasrate > 0) { - const double oilrate = std::abs(xw.wellRates()[oilpos]); + const double oilrate = std::abs(xw.wellRates()[oilpos_well]); double rs = 0.0; if (oilrate > 0) { rs = gasrate / oilrate; From 5007d99c0dbcdd7d8481649b1089130a74240ef7 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 19 Oct 2016 12:24:33 +0200 Subject: [PATCH 2/2] flow_ebos: re-eanable the 'tempV.maxCoff()' convergence check for the well model the 'tempV' object currently only contains garbagee but the condition is needed and will thus be fixed in a different PR. thanks goes to @totto82 for the clarifications. --- opm/autodiff/BlackoilDetails.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/BlackoilDetails.hpp b/opm/autodiff/BlackoilDetails.hpp index 068388156..d0afc2e8a 100644 --- a/opm/autodiff/BlackoilDetails.hpp +++ b/opm/autodiff/BlackoilDetails.hpp @@ -275,7 +275,7 @@ namespace detail { for ( int idx = 0; idx < np; ++idx ) { B_avg[idx] = B.col(idx).sum()/nc; - //maxCoeff[idx] = tempV.col(idx).maxCoeff(); + maxCoeff[idx] = tempV.col(idx).maxCoeff(); R_sum[idx] = R.col(idx).sum(); assert(np >= np);