Add Procedure for Calculating Basic FIP Region Statistics

This commit implements the parallel version of

    EclipseState::computeFipRegionStatistics()

which computes a FIPRegionStatistics object for the current run's
fluid-in-place regions.  The object construction uses an MPI-aware
reduction process to compute the maximum region IDs across all MPI
ranks.

While here, also unconditionally form the statistics object as part
of the EclWriter's constructor to ensure that all ranks participate
in the process.  The initial approach of constructing the object on
first use is not robust in parallel.  We may however wish to compute
these statistics only when needed.  If so, that will be the subject
of follow-up work.
This commit is contained in:
Bård Skaflestad 2024-03-07 11:39:29 +01:00
parent c2184219fa
commit 10d2f52cd2
3 changed files with 27 additions and 0 deletions

View File

@ -170,6 +170,8 @@ public:
}
this->rank_ = this->simulator_.vanguard().grid().comm().rank();
this->simulator_.vanguard().eclState().computeFipRegionStatistics();
}
~EclWriter()

View File

@ -20,13 +20,18 @@
#include <config.h>
#include <opm/simulators/utils/ParallelEclipseState.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FIPRegionStatistics.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FieldData.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <cstddef>
#include <map>
#include <regex>
#include <stdexcept>
#include <string>
#include <vector>
namespace {
bool is_FIP(const std::string& keyword)
@ -280,6 +285,20 @@ const FieldPropsManager& ParallelEclipseState::globalFieldProps() const
}
void ParallelEclipseState::computeFipRegionStatistics()
{
if (! this->fipRegionStatistics_.has_value()) {
this->fipRegionStatistics_
.emplace(declaredMaxRegionID(this->runspec()),
this->fieldProps(),
[this](std::vector<int>& maxRegionID)
{
this->m_comm.max(maxRegionID.data(), maxRegionID.size());
});
}
}
const EclipseGrid& ParallelEclipseState::getInputGrid() const
{
if (m_comm.rank() != 0)

View File

@ -179,6 +179,12 @@ public:
//! \details Can only be called on root process.
const FieldPropsManager& globalFieldProps() const override;
//! \brief Compute basic descriptive statistics about all FIP region sets
//!
//! MPI-aware version which knows how to compute statistics across all
//! ranks.
void computeFipRegionStatistics() override;
//! \brief Returns a const ref to the eclipse grid.
//! \details Can only be called on root process.
const EclipseGrid& getInputGrid() const override;