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;
|
typedef Dune::MultipleCodimMultipleGeomTypeMapper<LocalGridView> ElementMapper;
|
||||||
ElementMapper elemMapper(localGridView, Dune::mcmgElementLayout());
|
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);
|
localIdxToGlobalIdx_.resize(localGridView.size(0), -1);
|
||||||
|
|
||||||
// the I/O rank receives from all other ranks
|
// the I/O rank receives from all other ranks
|
||||||
@ -747,15 +756,14 @@ public:
|
|||||||
const std::vector<int>& globalRanks() const
|
const std::vector<int>& globalRanks() const
|
||||||
{ return globalRanks_; }
|
{ return globalRanks_; }
|
||||||
|
|
||||||
bool isGlobalIdxOnThisRank(unsigned globalIdx) const
|
bool isCartIdxOnThisRank(int cartIdx) const
|
||||||
{
|
{
|
||||||
if (!isParallel())
|
if (!isParallel())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (localIdxToGlobalIdx_.empty())
|
assert(!needsReordering);
|
||||||
throw std::logic_error("index map is not created on this rank");
|
auto candidate = std::lower_bound(sortedCartesianIdx_.begin(), sortedCartesianIdx_.end(), cartIdx);
|
||||||
|
return (candidate != sortedCartesianIdx_.end() && *candidate == cartIdx);
|
||||||
return std::find(localIdxToGlobalIdx_.begin(), localIdxToGlobalIdx_.end(), globalIdx) != localIdxToGlobalIdx_.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -769,6 +777,10 @@ protected:
|
|||||||
Opm::data::Wells globalWellData_;
|
Opm::data::Wells globalWellData_;
|
||||||
Opm::data::GroupValues globalGroupData_;
|
Opm::data::GroupValues globalGroupData_;
|
||||||
std::vector<int> localIdxToGlobalIdx_;
|
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
|
} // end namespace Opm
|
||||||
|
@ -194,7 +194,7 @@ public:
|
|||||||
// Initialize block output
|
// Initialize block output
|
||||||
for (const auto& node: summaryConfig) {
|
for (const auto& node: summaryConfig) {
|
||||||
if (node.category() == SummaryConfigNode::Category::Block) {
|
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());
|
std::pair<std::string, int> key = std::make_pair(node.keyword(), node.number());
|
||||||
blockData_[key] = 0.0;
|
blockData_[key] = 0.0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user