From aacbdb177783a1c5623387c176524e811d384d94 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 11 Jan 2017 12:20:32 +0100 Subject: [PATCH] Switch off non-owner entries during accumulation. Previously entries attached to cells that are present on multiply processes were acumulated several times. --- opm/autodiff/BlackoilModelEbos.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 1c346a8fe..0567f7bb9 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -787,11 +787,23 @@ namespace Opm { R_sum.resize(np); maxNormWell.resize(np); + const std::vector* mask = nullptr; + +#if HAVE_MPI + if ( comm.size() > 1 ) + { + // mask[c] is 1 if we need to compute something in parallel + const auto & pinfo = + boost::any_cast(istlSolver().parallelInformation()); + mask = &pinfo.updateOwnerMask( B[ 0 ] ); + } +#endif + // computation for ( int idx = 0; idx < np; ++idx ) { - B_avg[idx] = std::accumulate( B[ idx ].begin(), B[ idx ].end(), 0.0 ) / double(ncGlobal); - R_sum[idx] = std::accumulate( R[ idx ].begin(), R[ idx ].end(), 0.0 ); + B_avg[idx] = accumulateMaskedValues(B[ idx ], mask) / double(ncGlobal); + R_sum[idx] = accumulateMaskedValues(R[ idx ], mask); maxCoeff[idx] = *(std::max_element( tempV[ idx ].begin(), tempV[ idx ].end() )); assert(np >= np); @@ -803,8 +815,8 @@ namespace Opm { } } - // Compute total pore volume - double pvSum = std::accumulate(pv.begin(), pv.end(), 0.0); + // Compute total pore volume (use only owned entries) + double pvSum = accumulateMaskedValues(pv, mask); if( comm.size() > 1 ) {