diff --git a/ebos/eclbasevanguard.hh b/ebos/eclbasevanguard.hh index fe2611446..1aac6ae29 100644 --- a/ebos/eclbasevanguard.hh +++ b/ebos/eclbasevanguard.hh @@ -296,6 +296,8 @@ public: /*! * \brief Return compressed index from cartesian index * + * \return compressed index of cell is in interior, -1 otherwise + * */ int compressedIndex(int cartesianCellIdx) const { @@ -306,6 +308,25 @@ public: return -1; } + /*! + * \brief Return compressed index from cartesian index only in interior + * + * \return compressed index of cell is in interior, -1 otherwise + * + */ + int compressedIndexForInterior(int cartesianCellIdx) const + { + auto index_pair = cartesianToCompressed_.find(cartesianCellIdx); + if (index_pair == cartesianToCompressed_.end() || + !is_interior_[index_pair->second]) + { + return -1; + } + else + { + return index_pair->second; + } + } /*! * \brief Extract Cartesian index triplet (i,j,k) of an active cell. * @@ -424,9 +445,22 @@ protected: void updateCartesianToCompressedMapping_() { size_t num_cells = asImp_().grid().leafGridView().size(0); - for (unsigned i = 0; i < num_cells; ++i) { - unsigned cartesianCellIdx = cartesianIndex(i); - cartesianToCompressed_[cartesianCellIdx] = i; + is_interior_.resize(num_cells); + + ElementMapper elemMapper(this->gridView(), Dune::mcmgElementLayout()); + for (const auto& element : elements(this->gridView())) + { + const auto elemIdx = elemMapper.index(element); + unsigned cartesianCellIdx = cartesianIndex(elemIdx); + cartesianToCompressed_[cartesianCellIdx] = elemIdx; + if (element.partitionType() == Dune::InteriorEntity) + { + is_interior_[elemIdx] = 1; + } + else + { + is_interior_[elemIdx] = 0; + } } } @@ -515,6 +549,10 @@ protected: /*! \brief Cell thickness */ std::vector cellThickness_; + + /*! \brief Whether a cells is in the interior. + */ + std::vector is_interior_; }; } // namespace Opm diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index a8248c0f8..27e239f4f 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -419,8 +419,8 @@ namespace Opm { void assignWellTracerRates(data::Wells& wsrpt) const; - int compressedIndex(int cartesian_cell_idx) const override { - return ebosSimulator_.vanguard().compressedIndex(cartesian_cell_idx); + int compressedIndexForInterior(int cartesian_cell_idx) const override { + return ebosSimulator_.vanguard().compressedIndexForInterior(cartesian_cell_idx); } private: diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 5125cefc7..36c28d3f7 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -349,7 +349,7 @@ initializeWellPerfData() parallelWellInfo.beginReset(); for (const auto& completion : well.getConnections()) { - const int active_index = compressedIndex(completion.global_index()); + const int active_index = compressedIndexForInterior(completion.global_index()); if (completion.state() == Connection::State::OPEN) { if (active_index >= 0) { if (firstOpenCompletion) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 552df803e..311283637 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -374,7 +374,8 @@ protected: void runWellPIScaling(const int timeStepIdx, DeferredLogger& local_deferredLogger); - virtual int compressedIndex(int cartesian_cell_idx) const = 0; + /// \brief get compressed index for interior cells (-1, otherwise + virtual int compressedIndexForInterior(int cartesian_cell_idx) const = 0; Schedule& schedule_; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 21402e470..c9ef4e0b1 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -125,7 +125,7 @@ namespace Opm { for ( size_t c=0; c < connectionSet.size(); c++ ) { const auto& connection = connectionSet.get(c); - int compressed_idx = compressedIndex(connection.global_index()); + int compressed_idx = compressedIndexForInterior(connection.global_index()); if ( compressed_idx >= 0 ) { // Ignore connections in inactive/remote cells. wellCells.push_back(compressed_idx);