changed: make the deck an implementation detail in Opm::readDeck

This commit is contained in:
Arne Morten Kvarving 2022-11-23 13:21:28 +01:00
parent f4f8c033d8
commit c7016854d9
6 changed files with 20 additions and 32 deletions

View File

@ -26,7 +26,6 @@
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/EclipseState/Tables/OverburdTable.hpp>

View File

@ -91,7 +91,6 @@ void EclGenericVanguard::readDeck(const std::string& filename)
Dune::Timer setupTimer;
setupTimer.start();
std::shared_ptr<Opm::Deck> deck;
std::shared_ptr<Opm::EclipseState> eclipseState;
std::shared_ptr<Opm::Schedule> schedule;
std::unique_ptr<Opm::UDQState> udqState;
@ -107,7 +106,7 @@ void EclGenericVanguard::readDeck(const std::string& filename)
{ParseContext::SUMMARY_UNKNOWN_GROUP, InputError::WARN}});
Opm::readDeck(EclGenericVanguard::comm(),
filename, deck, eclipseState, schedule, udqState,
filename, eclipseState, schedule, udqState,
actionState, wtestState,
summaryConfig, nullptr, nullptr, std::move(parseContext),
false, false, {});

View File

@ -47,12 +47,10 @@
#include <flow/flow_ebos_oilwater_polymer_injectivity.hpp>
#include <flow/flow_ebos_micp.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/checkDeck.hpp>
#include <opm/input/eclipse/Schedule/ArrayDimChecker.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
#include <opm/input/eclipse/Schedule/Action/State.hpp>
@ -135,16 +133,15 @@ public:
// This constructor can be called from Python when Python has
// already parsed a deck
Main(std::shared_ptr<Deck> deck,
Main(const std::string& filename,
std::shared_ptr<EclipseState> eclipseState,
std::shared_ptr<Schedule> schedule,
std::shared_ptr<SummaryConfig> summaryConfig)
: deck_{std::move(deck)}
, eclipseState_{std::move(eclipseState)}
: eclipseState_{std::move(eclipseState)}
, schedule_{std::move(schedule)}
, summaryConfig_{std::move(summaryConfig)}
{
setArgvArgc_(deck_->getDataFile());
setArgvArgc_(filename);
initMPI();
}
@ -523,7 +520,8 @@ private:
if (output_param >= 0)
outputInterval = output_param;
readDeck(EclGenericVanguard::comm(), deckFilename, deck_, eclipseState_, schedule_, udqState_, actionState_, wtestState_,
readDeck(EclGenericVanguard::comm(), deckFilename, eclipseState_,
schedule_, udqState_, actionState_, wtestState_,
summaryConfig_, nullptr, python, std::move(parseContext),
init_from_restart_file, outputCout_, outputInterval);
@ -818,7 +816,6 @@ private:
std::unique_ptr<WellTestState> wtestState_{};
// These variables may be owned by both Python and the simulator
std::shared_ptr<Deck> deck_{};
std::shared_ptr<EclipseState> eclipseState_{};
std::shared_ptr<Schedule> schedule_{};
std::shared_ptr<SummaryConfig> summaryConfig_{};

View File

@ -181,15 +181,14 @@ namespace {
wtestState = std::make_unique<Opm::WellTestState>();
}
std::shared_ptr<Opm::Deck>
Opm::Deck
readDeckFile(const std::string& deckFilename,
const bool checkDeck,
const Opm::Parser& parser,
const Opm::ParseContext& parseContext,
Opm::ErrorGuard& errorGuard)
{
auto deck = std::make_shared<Opm::Deck>
(parser.parseFile(deckFilename, parseContext, errorGuard));
Opm::Deck deck(parser.parseFile(deckFilename, parseContext, errorGuard));
auto keyword_validator = Opm::KeywordValidation::KeywordValidator {
Opm::FlowKeywordValidation::unsupportedKeywords(),
@ -199,10 +198,10 @@ namespace {
Opm::KeywordValidation::specialValidation()
};
keyword_validator.validateDeck(*deck, parseContext, errorGuard);
keyword_validator.validateDeck(deck, parseContext, errorGuard);
if (checkDeck) {
Opm::checkDeck(*deck, parser, parseContext, errorGuard);
Opm::checkDeck(deck, parser, parseContext, errorGuard);
}
return deck;
@ -222,7 +221,6 @@ namespace {
void readOnIORank(Opm::Parallel::Communication comm,
const std::string& deckFilename,
const Opm::ParseContext* parseContext,
std::shared_ptr<Opm::Deck>& deck,
std::shared_ptr<Opm::EclipseState>& eclipseState,
std::shared_ptr<Opm::Schedule>& schedule,
std::unique_ptr<Opm::UDQState>& udqState,
@ -235,33 +233,31 @@ namespace {
const std::optional<int>& outputInterval,
Opm::ErrorGuard& errorGuard)
{
if (((deck == nullptr) || (schedule == nullptr) || (summaryConfig == nullptr)) &&
if (((schedule == nullptr) || (summaryConfig == nullptr)) &&
(parseContext == nullptr))
{
OPM_THROW(std::logic_error,
"We need a parse context if deck, schedule, "
"We need a parse context if schedule "
"or summaryConfig are not initialized");
}
auto parser = Opm::Parser{};
if (deck == nullptr) {
deck = readDeckFile(deckFilename, checkDeck, parser,
*parseContext, errorGuard);
}
const auto deck = readDeckFile(deckFilename, checkDeck, parser,
*parseContext, errorGuard);
if (eclipseState == nullptr) {
eclipseState = createEclipseState(comm, *deck);
eclipseState = createEclipseState(comm, deck);
}
if (eclipseState->getInitConfig().restartRequested()) {
loadObjectsFromRestart(*deck, parser, *parseContext,
loadObjectsFromRestart(deck, parser, *parseContext,
initFromRestart, outputInterval,
*eclipseState, std::move(python),
schedule, udqState, actionState, wtestState,
errorGuard);
}
else {
createNonRestartDynamicObjects(*deck, *eclipseState,
createNonRestartDynamicObjects(deck, *eclipseState,
*parseContext, std::move(python),
schedule, udqState, actionState, wtestState,
errorGuard);
@ -274,7 +270,7 @@ namespace {
if (summaryConfig == nullptr) {
summaryConfig = std::make_shared<Opm::SummaryConfig>
(*deck, *schedule, eclipseState->fieldProps(),
(deck, *schedule, eclipseState->fieldProps(),
eclipseState->aquifer(), *parseContext, errorGuard);
}
@ -480,7 +476,6 @@ Opm::setupLogging(const int mpi_rank_,
void Opm::readDeck(Opm::Parallel::Communication comm,
const std::string& deckFilename,
std::shared_ptr<Deck>& deck,
std::shared_ptr<EclipseState>& eclipseState,
std::shared_ptr<Schedule>& schedule,
std::unique_ptr<UDQState>& udqState,
@ -503,7 +498,7 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
if (comm.rank() == 0) { // Always true when !HAVE_MPI
try {
readOnIORank(comm, deckFilename, parseContext.get(), deck,
readOnIORank(comm, deckFilename, parseContext.get(),
eclipseState, schedule, udqState, actionState, wtestState,
summaryConfig, std::move(python), initFromRestart,
checkDeck, outputInterval, *errorGuard);

View File

@ -29,7 +29,6 @@
#include <string>
namespace Opm {
class Deck;
class EclipseState;
class ErrorGuard;
class ParseContext;
@ -77,7 +76,6 @@ setupLogging(int mpi_rank_,
/// are created and can be used outside later.
void readDeck(Parallel::Communication comm,
const std::string& deckFilename,
std::shared_ptr<Deck>& deck,
std::shared_ptr<EclipseState>& eclipseState,
std::shared_ptr<Schedule>& schedule,
std::unique_ptr<UDQState>& udqState,

View File

@ -147,7 +147,7 @@ int PyBlackOilSimulator::stepInit()
}
if (this->deck_) {
main_ = std::make_unique<Opm::Main>(
this->deck_,
this->deck_->getDataFile(),
this->eclipse_state_,
this->schedule_,
this->summary_config_