mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Schedule: explicitly instantiated
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
|
||||
#if HAVE_MPI
|
||||
#include <mpi.h>
|
||||
@@ -103,10 +104,12 @@ public:
|
||||
* management of these two objects, i.e., they are not allowed to be deleted as long
|
||||
* as the grid manager object is alive.
|
||||
*/
|
||||
static void setExternalDeck(Opm::Deck* deck, Opm::EclipseState* eclState)
|
||||
static void setExternalDeck(Opm::Deck* deck, Opm::EclipseState* eclState, Opm::Schedule* schedule, Opm::SummaryConfig* summaryConfig)
|
||||
{
|
||||
externalDeck_ = deck;
|
||||
externalEclState_ = eclState;
|
||||
externalSchedule_ = schedule;
|
||||
externalSummaryConfig_ = summaryConfig;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -164,20 +167,33 @@ public:
|
||||
|
||||
internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName , parseContext)));
|
||||
internalEclState_.reset(new Opm::EclipseState(*internalDeck_, parseContext));
|
||||
{
|
||||
const auto& grid = internalEclState_->getInputGrid();
|
||||
const Opm::TableManager table ( *internalDeck_ );
|
||||
const Opm::Eclipse3DProperties eclipseProperties (*internalDeck_ , table, grid);
|
||||
internalSchedule_.reset(new Opm::Schedule(*internalDeck_, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext ));
|
||||
internalSummaryConfig_.reset(new Opm::SummaryConfig(*internalDeck_, *internalSchedule_, table, parseContext));
|
||||
}
|
||||
|
||||
|
||||
deck_ = &(*internalDeck_);
|
||||
eclState_ = &(*internalEclState_);
|
||||
summaryConfig_ = &(*internalSummaryConfig_);
|
||||
schedule_ = &(*internalSchedule_);
|
||||
}
|
||||
else {
|
||||
assert(externalDeck_);
|
||||
assert(externalEclState_);
|
||||
assert(externalSchedule_);
|
||||
assert(externalSummaryConfig_);
|
||||
|
||||
deck_ = externalDeck_;
|
||||
eclState_ = externalEclState_;
|
||||
schedule_ = externalSchedule_;
|
||||
summaryConfig_ = externalSummaryConfig_;
|
||||
}
|
||||
|
||||
asImp_().createGrids_();
|
||||
|
||||
asImp_().finalizeInit_();
|
||||
}
|
||||
|
||||
@@ -199,6 +215,13 @@ public:
|
||||
Opm::EclipseState& eclState()
|
||||
{ return *eclState_; }
|
||||
|
||||
const Opm::Schedule& schedule() const {
|
||||
return *schedule_;
|
||||
}
|
||||
|
||||
const Opm::SummaryConfig& summaryConfig() const {
|
||||
return *summaryConfig_;
|
||||
}
|
||||
/*!
|
||||
* \brief Returns the name of the case.
|
||||
*
|
||||
@@ -292,13 +315,19 @@ private:
|
||||
|
||||
static Opm::Deck* externalDeck_;
|
||||
static Opm::EclipseState* externalEclState_;
|
||||
static Opm::Schedule* externalSchedule_;
|
||||
static Opm::SummaryConfig* externalSummaryConfig_;
|
||||
std::unique_ptr<Opm::Deck> internalDeck_;
|
||||
std::unique_ptr<Opm::EclipseState> internalEclState_;
|
||||
std::unique_ptr<Opm::Schedule> internalSchedule_;
|
||||
std::unique_ptr<Opm::SummaryConfig> internalSummaryConfig_;
|
||||
|
||||
// these two attributes point either to the internal or to the external version of the
|
||||
// Deck and EclipsState objects.
|
||||
Opm::Deck* deck_;
|
||||
Opm::EclipseState* eclState_;
|
||||
Opm::Schedule* schedule_;
|
||||
Opm::SummaryConfig* summaryConfig_;
|
||||
};
|
||||
|
||||
template <class TypeTag>
|
||||
@@ -307,6 +336,13 @@ Opm::Deck* EclBaseGridManager<TypeTag>::externalDeck_ = nullptr;
|
||||
template <class TypeTag>
|
||||
Opm::EclipseState* EclBaseGridManager<TypeTag>::externalEclState_;
|
||||
|
||||
template <class TypeTag>
|
||||
Opm::Schedule* EclBaseGridManager<TypeTag>::externalSchedule_ = nullptr;
|
||||
|
||||
template <class TypeTag>
|
||||
Opm::SummaryConfig* EclBaseGridManager<TypeTag>::externalSummaryConfig_ = nullptr;
|
||||
|
||||
|
||||
} // namespace Ewoms
|
||||
|
||||
#endif
|
||||
|
||||
@@ -180,7 +180,10 @@ public:
|
||||
}
|
||||
|
||||
//distribute the grid and switch to the distributed view.
|
||||
defunctWellNames_ = std::get<1>(grid_->loadBalance(&this->eclState(), faceTrans.data()));
|
||||
{
|
||||
const auto wells = this->schedule().getWells();
|
||||
defunctWellNames_ = std::get<1>(grid_->loadBalance(&wells, faceTrans.data()));
|
||||
}
|
||||
grid_->switchToDistributedView();
|
||||
|
||||
delete cartesianIndexMapper_;
|
||||
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
readInitialCondition_();
|
||||
|
||||
// Set the start time of the simulation
|
||||
const auto& timeMap = simulator.gridManager().eclState().getSchedule().getTimeMap();
|
||||
const auto& timeMap = simulator.gridManager().schedule().getTimeMap();
|
||||
simulator.setStartTime( timeMap.getStartTime(/*timeStepIdx=*/0) );
|
||||
|
||||
// We want the episode index to be the same as the report step index to make
|
||||
@@ -435,7 +435,7 @@ public:
|
||||
// Proceed to the next report step
|
||||
Simulator& simulator = this->simulator();
|
||||
auto& eclState = this->simulator().gridManager().eclState();
|
||||
const auto& schedule = eclState.getSchedule();
|
||||
const auto& schedule = this->simulator().gridManager().schedule();
|
||||
const auto& events = schedule.getEvents();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
|
||||
@@ -495,7 +495,8 @@ public:
|
||||
|
||||
if (!GET_PROP_VALUE(TypeTag, DisableWells))
|
||||
// set up the wells
|
||||
wellManager_.beginEpisode(this->simulator().gridManager().eclState(), isOnRestart);
|
||||
wellManager_.beginEpisode(this->simulator().gridManager().eclState(),
|
||||
this->simulator().gridManager().schedule(), isOnRestart);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -563,10 +564,11 @@ public:
|
||||
void endEpisode()
|
||||
{
|
||||
auto& simulator = this->simulator();
|
||||
const auto& eclState = simulator.gridManager().eclState();
|
||||
const auto& schedule = simulator.gridManager().schedule();
|
||||
|
||||
int episodeIdx = simulator.episodeIndex();
|
||||
|
||||
const auto& timeMap = eclState.getSchedule().getTimeMap();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
int numReportSteps = timeMap.size() - 1;
|
||||
if (episodeIdx + 1 >= numReportSteps) {
|
||||
simulator.setFinished(true);
|
||||
@@ -962,7 +964,7 @@ public:
|
||||
// initialize the wells. Note that this needs to be done after initializing the
|
||||
// intrinsic permeabilities and the after applying the initial solution because
|
||||
// the well model uses these...
|
||||
wellManager_.init(this->simulator().gridManager().eclState());
|
||||
wellManager_.init(this->simulator().gridManager().eclState(), this->simulator().gridManager().schedule());
|
||||
}
|
||||
|
||||
// let the object for threshold pressures initialize itself. this is done only at
|
||||
|
||||
@@ -95,9 +95,9 @@ public:
|
||||
*
|
||||
* I.e., well positions, names etc...
|
||||
*/
|
||||
void init(const Opm::EclipseState& eclState)
|
||||
void init(const Opm::EclipseState& eclState,
|
||||
const Opm::Schedule& deckSchedule)
|
||||
{
|
||||
const auto& deckSchedule = eclState.getSchedule();
|
||||
|
||||
// create the wells which intersect with the current process' grid
|
||||
for (size_t deckWellIdx = 0; deckWellIdx < deckSchedule.numWells(); ++deckWellIdx)
|
||||
@@ -121,15 +121,14 @@ public:
|
||||
* \brief This should be called the problem before each simulation
|
||||
* episode to adapt the well controls.
|
||||
*/
|
||||
void beginEpisode(const Opm::EclipseState& eclState, bool wasRestarted=false)
|
||||
void beginEpisode(const Opm::EclipseState& eclState, const Opm::Schedule& deckSchedule, bool wasRestarted=false)
|
||||
{
|
||||
unsigned episodeIdx = simulator_.episodeIndex();
|
||||
|
||||
const auto& deckSchedule = eclState.getSchedule();
|
||||
WellCompletionsMap wellCompMap;
|
||||
computeWellCompletionsMap_(episodeIdx, wellCompMap);
|
||||
|
||||
if (wasRestarted || wellTopologyChanged_(eclState, episodeIdx))
|
||||
if (wasRestarted || wellTopologyChanged_(eclState, deckSchedule, episodeIdx))
|
||||
updateWellTopology_(episodeIdx, wellCompMap, gridDofIsPenetrated_);
|
||||
|
||||
// set those parameters of the wells which do not change the topology of the
|
||||
@@ -557,7 +556,7 @@ public:
|
||||
void deserialize(Restarter& res OPM_UNUSED)
|
||||
{
|
||||
// initialize the wells for the current episode
|
||||
beginEpisode(simulator_.gridManager().eclState(), /*wasRestarted=*/true);
|
||||
beginEpisode(simulator_.gridManager().eclState(), simulator_.gridManager().schedule(), /*wasRestarted=*/true);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -567,12 +566,13 @@ public:
|
||||
* "Something" can either be the well topology (i.e., which grid blocks are contained
|
||||
* in which well) or it can be a well parameter like the bottom hole pressure...
|
||||
*/
|
||||
bool wellsChanged(const Opm::EclipseState& eclState, unsigned reportStepIdx) const
|
||||
bool wellsChanged(const Opm::EclipseState& eclState,
|
||||
const Opm::Schedule& schedule,
|
||||
unsigned reportStepIdx) const
|
||||
{
|
||||
if (wellTopologyChanged_(eclState, reportStepIdx))
|
||||
return true;
|
||||
|
||||
const auto& schedule = eclState.getSchedule();
|
||||
if (schedule.getTimeMap().numTimesteps() <= (unsigned) reportStepIdx)
|
||||
// for the "until the universe dies" episode, the wells don't change
|
||||
return false;
|
||||
@@ -585,7 +585,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool wellTopologyChanged_(const Opm::EclipseState& eclState, unsigned reportStepIdx) const
|
||||
bool wellTopologyChanged_(const Opm::EclipseState& eclState,
|
||||
const Opm::Schedule& schedule,
|
||||
unsigned reportStepIdx) const
|
||||
{
|
||||
if (reportStepIdx == 0) {
|
||||
// the well topology has always been changed relative to before the
|
||||
@@ -593,7 +595,6 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& schedule = eclState.getSchedule();
|
||||
if (schedule.getTimeMap().numTimesteps() <= (unsigned) reportStepIdx)
|
||||
// for the "until the universe dies" episode, the wells don't change
|
||||
return false;
|
||||
@@ -666,10 +667,10 @@ protected:
|
||||
|
||||
void computeWellCompletionsMap_(unsigned reportStepIdx OPM_UNUSED, WellCompletionsMap& cartesianIdxToCompletionMap)
|
||||
{
|
||||
const auto& eclState = simulator_.gridManager().eclState();
|
||||
const auto& deckSchedule = eclState.getSchedule();
|
||||
const auto& deckSchedule = simulator_.gridManager().schedule();
|
||||
|
||||
#ifndef NDEBUG
|
||||
const auto& eclState = simulator_.gridManager().eclState();
|
||||
const auto& eclGrid = eclState.getInputGrid();
|
||||
assert( int(eclGrid.getNX()) == simulator_.gridManager().cartesianDimensions()[ 0 ] );
|
||||
assert( int(eclGrid.getNY()) == simulator_.gridManager().cartesianDimensions()[ 1 ] );
|
||||
@@ -718,8 +719,7 @@ protected:
|
||||
|
||||
void updateWellParameters_(unsigned reportStepIdx, const WellCompletionsMap& wellCompletions)
|
||||
{
|
||||
const auto& eclState = simulator_.gridManager().eclState();
|
||||
const auto& deckSchedule = eclState.getSchedule();
|
||||
const auto& deckSchedule = simulator_.gridManager().schedule();
|
||||
const std::vector<const Opm::Well*>& deckWells = deckSchedule.getWells(reportStepIdx);
|
||||
|
||||
// set the reference depth for all wells
|
||||
|
||||
Reference in New Issue
Block a user