mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
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:
commit
c8ae87b8bb
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user