mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 20:24:48 -06:00
Allow for Sparse Source-Location Subsets
If a well is nominally connected in inactive cells, i.e., if its connections have not been filtered down to the active connections only, then 'allIndices' may not be a permutation of 0 .. allIndices.size()-1 Handle this case by sizing 'storageIndex_' according to the maximum index value insted of 'allIndices.size()'.
This commit is contained in:
parent
4a87dcf5f3
commit
7056c81a7b
@ -148,7 +148,19 @@ void Opm::ParallelPAvgDynamicSourceData::defineCommunication()
|
||||
|
||||
// 4) Build translation mapping from source term element indices to
|
||||
// storage indices.
|
||||
this->storageIndex_.resize(allIndices.size());
|
||||
//
|
||||
// Note that if the source terms aren't all active--e.g., if a well
|
||||
// is connected in deactivated cells--then allIndices is not a
|
||||
// permutation of 0..allIndices.size()-1 and the maximum source
|
||||
// location may exceed size()-1. Resize the storageIndex_ according
|
||||
// to the largest source location ID.
|
||||
if (auto maxIxPos = std::max_element(allIndices.begin(), allIndices.end());
|
||||
maxIxPos != allIndices.end())
|
||||
{
|
||||
// +1 for zero-based indices.
|
||||
this->storageIndex_.resize(*maxIxPos + 1);
|
||||
}
|
||||
|
||||
auto storageIx = std::vector<double>::size_type{0};
|
||||
for (const auto& elemIndex : allIndices) {
|
||||
this->storageIndex_[elemIndex] = storageIx++;
|
||||
|
Loading…
Reference in New Issue
Block a user