Only consider perforation in the interior of the local grid.

This is needed for distributed wells to save most of the code
from checking whether a perforation is in the interior.

We add new methods compressedIndexForInterior that return -1
for non-interior cells and use that for the wells. This restores
the old behaviour before 1cfe3e0aad
This commit is contained in:
Markus Blatt 2021-10-19 16:50:42 +02:00
parent 23e0b06387
commit fa9e93529b
5 changed files with 47 additions and 8 deletions

View File

@ -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<Scalar> cellThickness_;
/*! \brief Whether a cells is in the interior.
*/
std::vector<int> is_interior_;
};
} // namespace Opm

View File

@ -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:

View File

@ -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)

View File

@ -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_;

View File

@ -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);