Merge pull request #2778 from blattms/fix-parallel-summary-output

Fixes determining whether index of summary keyword is on process.
This commit is contained in:
Bård Skaflestad 2020-09-08 22:04:10 +02:00 committed by GitHub
commit c8ae87b8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -309,7 +309,16 @@ public:
typedef Dune::MultipleCodimMultipleGeomTypeMapper<LocalGridView> ElementMapper;
ElementMapper elemMapper(localGridView, Dune::mcmgElementLayout());
const auto& cartMapper = vanguard.cartesianIndexMapper();
sortedCartesianIdx_.reserve(vanguard.gridView().size(0));
for(const auto& elem: elements(localGridView))
{
auto idx = elemMapper.index(elem);
sortedCartesianIdx_.push_back(cartMapper.cartesianIndex(idx));
}
std::sort(sortedCartesianIdx_.begin(), sortedCartesianIdx_.end());
localIdxToGlobalIdx_.resize(localGridView.size(0), -1);
// the I/O rank receives from all other ranks
@ -747,15 +756,14 @@ public:
const std::vector<int>& globalRanks() const
{ return globalRanks_; }
bool isGlobalIdxOnThisRank(unsigned globalIdx) const
bool isCartIdxOnThisRank(int cartIdx) const
{
if (!isParallel())
return true;
if (localIdxToGlobalIdx_.empty())
throw std::logic_error("index map is not created on this rank");
return std::find(localIdxToGlobalIdx_.begin(), localIdxToGlobalIdx_.end(), globalIdx) != localIdxToGlobalIdx_.end();
assert(!needsReordering);
auto candidate = std::lower_bound(sortedCartesianIdx_.begin(), sortedCartesianIdx_.end(), cartIdx);
return (candidate != sortedCartesianIdx_.end() && *candidate == cartIdx);
}
protected:
@ -769,6 +777,10 @@ protected:
Opm::data::Wells globalWellData_;
Opm::data::GroupValues globalGroupData_;
std::vector<int> localIdxToGlobalIdx_;
/// \brief sorted list of cartesian indices present-
///
/// non-empty only when running in parallel
std::vector<int> sortedCartesianIdx_;
};
} // end namespace Opm

View File

@ -194,7 +194,7 @@ public:
// Initialize block output
for (const auto& node: summaryConfig) {
if (node.category() == SummaryConfigNode::Category::Block) {
if (collectToIORank.isGlobalIdxOnThisRank(node.number() - 1)) {
if (collectToIORank.isCartIdxOnThisRank(node.number() - 1)) {
std::pair<std::string, int> key = std::make_pair(node.keyword(), node.number());
blockData_[key] = 0.0;
}