diff --git a/ebos/collecttoiorank_impl.hh b/ebos/collecttoiorank_impl.hh index 667c6649c..43c341791 100644 --- a/ebos/collecttoiorank_impl.hh +++ b/ebos/collecttoiorank_impl.hh @@ -31,6 +31,8 @@ #include #include #include +#include + #include #include @@ -865,7 +867,7 @@ CollectDataToIORank(const Grid& grid, const EquilGrid* equilGrid, ElementMapper elemMapper(localGridView, Dune::mcmgElementLayout()); sortedCartesianIdx_.reserve(localGridView.size(0)); - for (const auto& elem : elements(localGridView)) + for (const auto& elem : elements(localGridView, Dune::Partitions::interior)) { auto idx = elemMapper.index(elem); sortedCartesianIdx_.push_back(cartMapper.cartesianIndex(idx)); @@ -934,12 +936,12 @@ CollectDataToIORank(const Grid& grid, const EquilGrid* equilGrid, distributedCartesianIndex.resize(gridSize, -1); // A mapping for the whole grid (including the ghosts) is needed for restarts - for (const auto& elem : elements(localGridView)) { + for (const auto& elem : elements(localGridView, Dune::Partitions::interior)) { int elemIdx = elemMapper.index(elem); distributedCartesianIndex[elemIdx] = cartMapper.cartesianIndex(elemIdx); // only store interior element for collection - //assert(element.partitionType() == Dune::InteriorEntity); + assert(elem.partitionType() == Dune::InteriorEntity); localIndexMap_.push_back(elemIdx); } diff --git a/ebos/damariswriter.hh b/ebos/damariswriter.hh index 232e35701..791aa3405 100644 --- a/ebos/damariswriter.hh +++ b/ebos/damariswriter.hh @@ -516,17 +516,18 @@ private: } const auto& gridView = simulator_.vanguard().gridView(); - const int numElements = gridView.size(/*codim=*/0); + const int num_interior = Opm::detail:: + countLocalInteriorCellsGridView(gridView); const bool log = this->collectToIORank_.isIORank(); - damarisOutputModule_->allocBuffers(numElements, reportStepNum, + damarisOutputModule_->allocBuffers(num_interior, reportStepNum, isSubStep, log, /*isRestart*/ false); ElementContext elemCtx(simulator_); OPM_BEGIN_PARALLEL_TRY_CATCH(); { OPM_TIMEBLOCK(prepareCellBasedData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); @@ -535,7 +536,7 @@ private: } if(!simulator_.model().linearizer().getFlowsInfo().empty()){ OPM_TIMEBLOCK(prepareFlowsData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); damarisOutputModule_->processElementFlows(elemCtx); @@ -543,7 +544,7 @@ private: } { OPM_TIMEBLOCK(prepareBlockData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); damarisOutputModule_->processElementBlockData(elemCtx); @@ -554,7 +555,7 @@ private: #ifdef _OPENMP #pragma omp parallel for #endif - for (int dofIdx=0; dofIdx < numElements; ++dofIdx){ + for (int dofIdx=0; dofIdx < num_interior; ++dofIdx){ const auto& intQuants = *(simulator_.model().cachedIntensiveQuantities(dofIdx, /*timeIdx=*/0)); const auto totVolume = simulator_.model().dofTotalVolume(dofIdx); damarisOutputModule_->updateFluidInPlace(dofIdx, intQuants, totVolume); diff --git a/ebos/eclgenericoutputblackoilmodule.cc b/ebos/eclgenericoutputblackoilmodule.cc index 38fa64b8e..f2b3184bd 100644 --- a/ebos/eclgenericoutputblackoilmodule.cc +++ b/ebos/eclgenericoutputblackoilmodule.cc @@ -707,8 +707,13 @@ regionSum(const ScalarBuffer& property, if (property.empty()) return totals; - assert(regionId.size() == property.size()); - for (std::size_t j = 0; j < regionId.size(); ++j) { + // the regionId contains the ghost cells + // the property does not contain the ghostcells + // This code assumes that that the ghostcells are + // added after the interior cells + // Is this a valid assumption? + assert(regionId.size() >= property.size()); + for (std::size_t j = 0; j < property.size(); ++j) { const int regionIdx = regionId[j] - 1; // the cell is not attributed to any region. ignore it! if (regionIdx < 0) diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index 8279f9c40..1d335f71c 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -41,6 +41,8 @@ #include #include +#include + #include @@ -329,15 +331,16 @@ public: } const auto& gridView = simulator_.vanguard().gridView(); - const int numElements = gridView.size(/*codim=*/0); + const int num_interior = Opm::detail:: + countLocalInteriorCellsGridView(gridView); this->eclOutputModule_-> - allocBuffers(numElements, 0, false, false, /*isRestart*/ false); + allocBuffers(num_interior, 0, false, false, /*isRestart*/ false); #ifdef _OPENMP #pragma omp parallel for #endif - for (int dofIdx = 0; dofIdx < numElements; ++dofIdx) { + for (int dofIdx = 0; dofIdx < num_interior; ++dofIdx) { const auto& intQuants = *simulator_.model().cachedIntensiveQuantities(dofIdx, /*timeIdx=*/0); const auto totVolume = simulator_.model().dofTotalVolume(dofIdx); @@ -557,11 +560,12 @@ private: } const auto& gridView = simulator_.vanguard().gridView(); - const int numElements = gridView.size(/*codim=*/0); const bool log = this->collectToIORank_.isIORank(); + const int num_interior = Opm::detail:: + countLocalInteriorCellsGridView(gridView); this->eclOutputModule_-> - allocBuffers(numElements, reportStepNum, + allocBuffers(num_interior, reportStepNum, isSubStep, log, /*isRestart*/ false); ElementContext elemCtx(simulator_); @@ -570,7 +574,7 @@ private: { OPM_TIMEBLOCK(prepareCellBasedData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); @@ -581,7 +585,7 @@ private: if constexpr (enableMech) { if (simulator_.vanguard().eclState().runspec().mech()) { OPM_TIMEBLOCK(prepareMechData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); eclOutputModule_->processElementMech(elemCtx); @@ -591,7 +595,7 @@ private: if (! this->simulator_.model().linearizer().getFlowsInfo().empty()) { OPM_TIMEBLOCK(prepareFlowsData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); @@ -601,7 +605,7 @@ private: { OPM_TIMEBLOCK(prepareBlockData); - for (const auto& elem : elements(gridView)) { + for (const auto& elem : elements(gridView, Dune::Partitions::interior)) { elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); @@ -615,7 +619,7 @@ private: #ifdef _OPENMP #pragma omp parallel for #endif - for (int dofIdx = 0; dofIdx < numElements; ++dofIdx) { + for (int dofIdx = 0; dofIdx < num_interior; ++dofIdx) { const auto& intQuants = *simulator_.model().cachedIntensiveQuantities(dofIdx, /*timeIdx=*/0); const auto totVolume = simulator_.model().dofTotalVolume(dofIdx);