mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Defer SummaryConfig Initialisation
In the current approach, the full list of summary vectors, especially those that are defined at the region level, is not known until we've processed all UDQ and/or ACTIONX definitions. As a quick solution to this, switch to using the 'SummaryConfig' object that's defined in the EclipseIO container instead of the object that gets constructed when reading the input files. It is likely that we will have to rethink and refactor this construction process later.
This commit is contained in:
@@ -36,6 +36,9 @@
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
#include <mpi.h>
|
||||
#include <opm/simulators/utils/MPISerializer.hpp>
|
||||
|
||||
#include <opm/simulators/flow/countGlobalCells.hpp>
|
||||
#include <opm/simulators/flow/DamarisProperties.hpp>
|
||||
#include <opm/simulators/flow/EclGenericWriter.hpp>
|
||||
@@ -149,25 +152,56 @@ public:
|
||||
simulator.vanguard().eclState(),
|
||||
simulator.vanguard().summaryConfig(),
|
||||
simulator.vanguard().grid(),
|
||||
simulator.vanguard().grid().comm().rank() == 0 ? &simulator.vanguard().equilGrid() : nullptr,
|
||||
((simulator.vanguard().grid().comm().rank() == 0)
|
||||
? &simulator.vanguard().equilGrid()
|
||||
: nullptr),
|
||||
simulator.vanguard().gridView(),
|
||||
simulator.vanguard().cartesianIndexMapper(),
|
||||
simulator.vanguard().grid().comm().rank() == 0 ? &simulator.vanguard().equilCartesianIndexMapper() : nullptr,
|
||||
((simulator.vanguard().grid().comm().rank() == 0)
|
||||
? &simulator.vanguard().equilCartesianIndexMapper()
|
||||
: nullptr),
|
||||
false, false)
|
||||
, simulator_(simulator)
|
||||
{
|
||||
this->damarisUpdate_ = true ;
|
||||
|
||||
rank_ = simulator_.vanguard().grid().comm().rank() ;
|
||||
nranks_ = simulator_.vanguard().grid().comm().size();
|
||||
|
||||
const auto& gridView = simulator_.gridView();
|
||||
const auto& interior_elements = elements(gridView, Dune::Partitions::interior);
|
||||
// Get the size of the unique vector elements (excludes the shared 'ghost' elements)
|
||||
numElements_ = std::distance(interior_elements.begin(), interior_elements.end());
|
||||
this->rank_ = this->simulator_.vanguard().grid().comm().rank() ;
|
||||
this->nranks_ = this->simulator_.vanguard().grid().comm().size();
|
||||
|
||||
this->elements_rank_offsets_.resize(nranks_) ;
|
||||
this->damarisOutputModule_ = std::make_unique<OutputBlackOilModule<TypeTag>>(simulator, this->collectOnIORank_);
|
||||
this->elements_rank_offsets_.resize(this->nranks_);
|
||||
|
||||
// Get the size of the unique vector elements (excludes the shared 'ghost' elements)
|
||||
//
|
||||
// Might possibly use
|
||||
//
|
||||
// detail::countLocalInteriorCellsGridView(this->simulator_.gridView())
|
||||
//
|
||||
// from countGlobalCells.hpp instead of calling std::distance() directly.
|
||||
{
|
||||
const auto& gridView = this->simulator_.gridView();
|
||||
const auto& interior_elements = elements(gridView, Dune::Partitions::interior);
|
||||
|
||||
this->numElements_ = std::distance(interior_elements.begin(), interior_elements.end());
|
||||
}
|
||||
|
||||
if (this->nranks_ > 1) {
|
||||
auto smryCfg = (this->rank_ == 0)
|
||||
? this->eclIO_->finalSummaryConfig()
|
||||
: SummaryConfig{};
|
||||
|
||||
auto serialiser = Parallel::MpiSerializer {
|
||||
this->simulator_.vanguard().grid().comm()
|
||||
};
|
||||
|
||||
serialiser.broadcast(0, smryCfg);
|
||||
|
||||
this->damarisOutputModule_ = std::make_unique<OutputBlackOilModule<TypeTag>>
|
||||
(simulator, smryCfg, this->collectOnIORank_);
|
||||
}
|
||||
else {
|
||||
this->damarisOutputModule_ = std::make_unique<OutputBlackOilModule<TypeTag>>
|
||||
(simulator, this->eclIO_->finalSummaryConfig(), this->collectOnIORank_);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -154,7 +154,6 @@ protected:
|
||||
const GridView& gridView_;
|
||||
const Schedule& schedule_;
|
||||
const EclipseState& eclState_;
|
||||
const SummaryConfig& summaryConfig_;
|
||||
std::unique_ptr<EclipseIO> eclIO_;
|
||||
std::unique_ptr<TaskletRunner> taskletRunner_;
|
||||
Scalar restartTimeStepSize_;
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Action/State.hpp>
|
||||
#include <opm/input/eclipse/Schedule/Schedule.hpp>
|
||||
#include <opm/input/eclipse/Schedule/SummaryState.hpp>
|
||||
#include <opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp>
|
||||
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
|
||||
#include <opm/input/eclipse/Schedule/Well/WellMatcher.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
@@ -207,7 +209,6 @@ EclGenericWriter(const Schedule& schedule,
|
||||
, gridView_ (gridView)
|
||||
, schedule_ (schedule)
|
||||
, eclState_ (eclState)
|
||||
, summaryConfig_ (summaryConfig)
|
||||
, cartMapper_ (cartMapper)
|
||||
, equilCartMapper_(equilCartMapper)
|
||||
, equilGrid_ (equilGrid)
|
||||
@@ -216,7 +217,7 @@ EclGenericWriter(const Schedule& schedule,
|
||||
this->eclIO_ = std::make_unique<EclipseIO>
|
||||
(this->eclState_,
|
||||
UgGridHelpers::createEclipseGrid(*equilGrid, eclState_.getInputGrid()),
|
||||
this->schedule_, this->summaryConfig_, "", enableEsmry);
|
||||
this->schedule_, summaryConfig, "", enableEsmry);
|
||||
}
|
||||
|
||||
// create output thread if enabled and rank is I/O rank
|
||||
|
||||
@@ -36,6 +36,11 @@
|
||||
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
|
||||
#if HAVE_MPI
|
||||
#include <mpi.h>
|
||||
#include <opm/simulators/utils/MPISerializer.hpp>
|
||||
#endif
|
||||
|
||||
#include <opm/simulators/flow/CollectDataOnIORank.hpp>
|
||||
#include <opm/simulators/flow/countGlobalCells.hpp>
|
||||
#include <opm/simulators/flow/EclGenericWriter.hpp>
|
||||
@@ -151,10 +156,29 @@ public:
|
||||
EWOMS_GET_PARAM(TypeTag, bool, EnableEsmry))
|
||||
, simulator_(simulator)
|
||||
{
|
||||
this->outputModule_ = std::make_unique<OutputBlackOilModule<TypeTag>>
|
||||
(simulator, this->collectOnIORank_);
|
||||
|
||||
rank_ = simulator_.vanguard().grid().comm().rank() ;
|
||||
#if HAVE_MPI
|
||||
if (this->simulator_.vanguard().grid().comm().size() > 1) {
|
||||
auto smryCfg = (this->simulator_.vanguard().grid().comm().rank() == 0)
|
||||
? this->eclIO_->finalSummaryConfig()
|
||||
: SummaryConfig{};
|
||||
|
||||
auto serialiser = Parallel::MpiSerializer {
|
||||
this->simulator_.vanguard().grid().comm()
|
||||
};
|
||||
|
||||
serialiser.broadcast(0, smryCfg);
|
||||
|
||||
this->outputModule_ = std::make_unique<OutputBlackOilModule<TypeTag>>
|
||||
(simulator, smryCfg, this->collectOnIORank_);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
this->outputModule_ = std::make_unique<OutputBlackOilModule<TypeTag>>
|
||||
(simulator, this->eclIO_->finalSummaryConfig(), this->collectOnIORank_);
|
||||
}
|
||||
|
||||
this->rank_ = this->simulator_.vanguard().grid().comm().rank();
|
||||
}
|
||||
|
||||
~EclWriter()
|
||||
|
||||
@@ -184,8 +184,8 @@ GenericOutputBlackoilModule(const EclipseState& eclState,
|
||||
bool enableMICP)
|
||||
: eclState_(eclState)
|
||||
, schedule_(schedule)
|
||||
, summaryConfig_(summaryConfig)
|
||||
, summaryState_(summaryState)
|
||||
, summaryConfig_(summaryConfig)
|
||||
, interRegionFlows_(numCells(eclState),
|
||||
defineInterRegionFlowArrays(eclState, summaryConfig),
|
||||
declaredMaxRegionID(eclState.runspec()))
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define OPM_GENERIC_OUTPUT_BLACK_OIL_MODULE_HPP
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/eclipse/Inplace.hpp>
|
||||
@@ -376,9 +377,10 @@ protected:
|
||||
|
||||
const EclipseState& eclState_;
|
||||
const Schedule& schedule_;
|
||||
const SummaryConfig& summaryConfig_;
|
||||
const SummaryState& summaryState_;
|
||||
|
||||
SummaryConfig summaryConfig_;
|
||||
|
||||
InterRegFlowMap interRegionFlows_;
|
||||
LogOutputHelper<Scalar> logOutput_;
|
||||
|
||||
|
||||
@@ -143,10 +143,11 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule<GetPropType<Type
|
||||
public:
|
||||
template <class CollectDataToIORankType>
|
||||
OutputBlackOilModule(const Simulator& simulator,
|
||||
const SummaryConfig& smryCfg,
|
||||
const CollectDataToIORankType& collectToIORank)
|
||||
: BaseType(simulator.vanguard().eclState(),
|
||||
simulator.vanguard().schedule(),
|
||||
simulator.vanguard().summaryConfig(),
|
||||
smryCfg,
|
||||
simulator.vanguard().summaryState(),
|
||||
moduleVersionName(),
|
||||
getPropValue<TypeTag, Properties::EnableEnergy>(),
|
||||
@@ -185,9 +186,7 @@ public:
|
||||
OPM_THROW_NOLOG(std::runtime_error, msg);
|
||||
}
|
||||
|
||||
if (const auto& smryCfg = simulator.vanguard().summaryConfig();
|
||||
smryCfg.match("[FB]PP[OGW]") || smryCfg.match("RPP[OGW]*"))
|
||||
{
|
||||
if (smryCfg.match("[FB]PP[OGW]") || smryCfg.match("RPP[OGW]*")) {
|
||||
auto rset = this->eclState_.fieldProps().fip_regions();
|
||||
rset.push_back("PVTNUM");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user