Merge pull request #5547 from lisajulia/feature/action-parsing-strictness

Add action-parsing-strictness command line parameter
This commit is contained in:
Markus Blatt 2024-08-26 09:06:25 +02:00 committed by GitHub
commit 7ebb6e7034
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 7 deletions

View File

@ -149,7 +149,7 @@ void FlowGenericVanguard::readDeck(const std::string& filename)
modelParams_.actionState_, modelParams_.actionState_,
modelParams_.wtestState_, modelParams_.wtestState_,
modelParams_.eclSummaryConfig_, modelParams_.eclSummaryConfig_,
nullptr, "normal", "100", false, false, {}); nullptr, "normal", "normal", "100", false, false, {});
modelParams_.setupTime_ = setupTimer.stop(); modelParams_.setupTime_ = setupTimer.stop();
} }
@ -401,6 +401,10 @@ void FlowGenericVanguard::registerParameters_()
"high (stop for all errors) and " "high (stop for all errors) and "
"low (as normal, except do not stop due to unsupported " "low (as normal, except do not stop due to unsupported "
"keywords even if marked critical"); "keywords even if marked critical");
Parameters::Register<Parameters::ActionParsingStrictness>
("Set strictness of parsing process for ActionX and PyAction. Available options are "
"normal (do not apply keywords that have not been tested for ActionX or PyAction) and "
"low (try to apply all keywords, beware: the simulation outcome might be incorrect).");
Parameters::Register<Parameters::InputSkipMode> Parameters::Register<Parameters::InputSkipMode>
("Set compatibility mode for the SKIP100/SKIP300 keywords. Options are " ("Set compatibility mode for the SKIP100/SKIP300 keywords. Options are "
"100 (skip SKIP100..ENDSKIP, keep SKIP300..ENDSKIP) [default], " "100 (skip SKIP100..ENDSKIP, keep SKIP300..ENDSKIP) [default], "

View File

@ -67,6 +67,7 @@ struct NumJacobiBlocks { static constexpr int value = 0; };
struct OwnerCellsFirst { static constexpr bool value = true; }; struct OwnerCellsFirst { static constexpr bool value = true; };
struct ParsingStrictness { static constexpr auto value = "normal"; }; struct ParsingStrictness { static constexpr auto value = "normal"; };
struct ActionParsingStrictness { static constexpr auto value = "normal"; };
// 0: simple, 1: Zoltan, 2: METIS, see GridEnums.hpp // 0: simple, 1: Zoltan, 2: METIS, see GridEnums.hpp
struct PartitionMethod { static constexpr int value = 1; }; struct PartitionMethod { static constexpr int value = 1; };

View File

@ -200,6 +200,7 @@ void Main::readDeck(const std::string& deckFilename,
const bool init_from_restart_file, const bool init_from_restart_file,
const bool allRanksDbgPrtLog, const bool allRanksDbgPrtLog,
const std::string& parsingStrictness, const std::string& parsingStrictness,
const std::string& actionParsingStrictness,
const std::string& inputSkipMode, const std::string& inputSkipMode,
const std::size_t numThreads, const std::size_t numThreads,
const int output_param, const int output_param,
@ -233,6 +234,7 @@ void Main::readDeck(const std::string& deckFilename,
summaryConfig_, summaryConfig_,
std::make_shared<Python>(), std::make_shared<Python>(),
parsingStrictness, parsingStrictness,
actionParsingStrictness,
inputSkipMode, inputSkipMode,
init_from_restart_file, init_from_restart_file,
outputCout_, outputCout_,

View File

@ -421,6 +421,7 @@ private:
!Parameters::Get<Parameters::SchedRestart>(), !Parameters::Get<Parameters::SchedRestart>(),
Parameters::Get<Parameters::EnableLoggingFalloutWarning>(), Parameters::Get<Parameters::EnableLoggingFalloutWarning>(),
Parameters::Get<Parameters::ParsingStrictness>(), Parameters::Get<Parameters::ParsingStrictness>(),
Parameters::Get<Parameters::ActionParsingStrictness>(),
Parameters::Get<Parameters::InputSkipMode>(), Parameters::Get<Parameters::InputSkipMode>(),
getNumThreads(), getNumThreads(),
Parameters::Get<Parameters::EclOutputInterval>(), Parameters::Get<Parameters::EclOutputInterval>(),
@ -696,6 +697,7 @@ private:
const bool init_from_restart_file, const bool init_from_restart_file,
const bool allRanksDbgPrtLog, const bool allRanksDbgPrtLog,
const std::string& parsingStrictness, const std::string& parsingStrictness,
const std::string& actionParsingStrictness,
const std::string& inputSkipMode, const std::string& inputSkipMode,
const std::size_t numThreads, const std::size_t numThreads,
const int output_param, const int output_param,

View File

@ -104,6 +104,7 @@ namespace {
const Opm::ParseContext& parseContext, const Opm::ParseContext& parseContext,
const bool initFromRestart, const bool initFromRestart,
const std::optional<int>& outputInterval, const std::optional<int>& outputInterval,
const bool lowActionParsingStrictness,
Opm::EclipseState& eclipseState, Opm::EclipseState& eclipseState,
std::shared_ptr<Opm::Python> python, std::shared_ptr<Opm::Python> python,
std::shared_ptr<Opm::Schedule>& schedule, std::shared_ptr<Opm::Schedule>& schedule,
@ -151,7 +152,7 @@ namespace {
if (schedule == nullptr) { if (schedule == nullptr) {
schedule = std::make_shared<Opm::Schedule> schedule = std::make_shared<Opm::Schedule>
(deck, eclipseState, parseContext, errorGuard, (deck, eclipseState, parseContext, errorGuard,
std::move(python), outputInterval, init_state); std::move(python), lowActionParsingStrictness, outputInterval, init_state);
} }
// Read network pressures from restart // Read network pressures from restart
@ -172,6 +173,7 @@ namespace {
void createNonRestartDynamicObjects(const Opm::Deck& deck, void createNonRestartDynamicObjects(const Opm::Deck& deck,
const Opm::EclipseState& eclipseState, const Opm::EclipseState& eclipseState,
const Opm::ParseContext& parseContext, const Opm::ParseContext& parseContext,
const bool lowActionParsingStrictness,
std::shared_ptr<Opm::Python> python, std::shared_ptr<Opm::Python> python,
std::shared_ptr<Opm::Schedule>& schedule, std::shared_ptr<Opm::Schedule>& schedule,
std::unique_ptr<Opm::UDQState>& udqState, std::unique_ptr<Opm::UDQState>& udqState,
@ -182,7 +184,7 @@ namespace {
if (schedule == nullptr) { if (schedule == nullptr) {
schedule = std::make_shared<Opm::Schedule> schedule = std::make_shared<Opm::Schedule>
(deck, eclipseState, parseContext, (deck, eclipseState, parseContext,
errorGuard, std::move(python)); errorGuard, std::move(python), lowActionParsingStrictness);
} }
udqState = std::make_unique<Opm::UDQState> udqState = std::make_unique<Opm::UDQState>
@ -243,6 +245,7 @@ namespace {
const bool initFromRestart, const bool initFromRestart,
const bool checkDeck, const bool checkDeck,
const bool treatCriticalAsNonCritical, const bool treatCriticalAsNonCritical,
const bool lowActionParsingStrictness,
const std::optional<int>& outputInterval, const std::optional<int>& outputInterval,
Opm::ErrorGuard& errorGuard) Opm::ErrorGuard& errorGuard)
{ {
@ -267,13 +270,14 @@ namespace {
if (eclipseState->getInitConfig().restartRequested()) { if (eclipseState->getInitConfig().restartRequested()) {
loadObjectsFromRestart(deck, parser, *parseContext, loadObjectsFromRestart(deck, parser, *parseContext,
initFromRestart, outputInterval, initFromRestart, outputInterval,
lowActionParsingStrictness,
*eclipseState, std::move(python), *eclipseState, std::move(python),
schedule, udqState, actionState, wtestState, schedule, udqState, actionState, wtestState,
errorGuard); errorGuard);
} }
else { else {
createNonRestartDynamicObjects(deck, *eclipseState, createNonRestartDynamicObjects(deck, *eclipseState, *parseContext,
*parseContext, std::move(python), lowActionParsingStrictness, std::move(python),
schedule, udqState, actionState, wtestState, schedule, udqState, actionState, wtestState,
errorGuard); errorGuard);
} }
@ -535,6 +539,7 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
std::shared_ptr<SummaryConfig>& summaryConfig, std::shared_ptr<SummaryConfig>& summaryConfig,
std::shared_ptr<Python> python, std::shared_ptr<Python> python,
const std::string& parsingStrictness, const std::string& parsingStrictness,
const std::string& actionParsingStrictness,
const std::string& inputSkipMode, const std::string& inputSkipMode,
const bool initFromRestart, const bool initFromRestart,
const bool checkDeck, const bool checkDeck,
@ -549,7 +554,10 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
OPM_THROW(std::runtime_error, OPM_THROW(std::runtime_error,
fmt::format("Incorrect value {} for parameter ParsingStrictness, must be 'high', 'normal', or 'low'", parsingStrictness)); fmt::format("Incorrect value {} for parameter ParsingStrictness, must be 'high', 'normal', or 'low'", parsingStrictness));
} }
if (actionParsingStrictness != "normal" && actionParsingStrictness != "low") {
OPM_THROW(std::runtime_error,
fmt::format("Incorrect value {} for parameter ActionParsingStrictness, must be 'normal', or 'low'", actionParsingStrictness));
}
if (inputSkipMode != "100" && inputSkipMode != "300" && inputSkipMode != "all") { if (inputSkipMode != "100" && inputSkipMode != "300" && inputSkipMode != "all") {
OPM_THROW(std::runtime_error, OPM_THROW(std::runtime_error,
fmt::format("Incorrect value {} for parameter InputSkipMode, must be '100', '300', or 'all'", inputSkipMode)); fmt::format("Incorrect value {} for parameter InputSkipMode, must be '100', '300', or 'all'", inputSkipMode));
@ -558,6 +566,7 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
if (comm.rank() == 0) { // Always true when !HAVE_MPI if (comm.rank() == 0) { // Always true when !HAVE_MPI
const bool exitOnAllErrors = (parsingStrictness == "high"); const bool exitOnAllErrors = (parsingStrictness == "high");
const bool treatCriticalAsNonCritical = (parsingStrictness == "low"); const bool treatCriticalAsNonCritical = (parsingStrictness == "low");
const bool lowActionParsingStrictness = (actionParsingStrictness == "low");
try { try {
auto parseContext = setupParseContext(exitOnAllErrors); auto parseContext = setupParseContext(exitOnAllErrors);
if (treatCriticalAsNonCritical) { // Continue with invalid names if parsing strictness is set to low if (treatCriticalAsNonCritical) { // Continue with invalid names if parsing strictness is set to low
@ -567,7 +576,8 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
readOnIORank(comm, deckFilename, parseContext.get(), readOnIORank(comm, deckFilename, parseContext.get(),
eclipseState, schedule, udqState, actionState, wtestState, eclipseState, schedule, udqState, actionState, wtestState,
summaryConfig, std::move(python), initFromRestart, summaryConfig, std::move(python), initFromRestart,
checkDeck, treatCriticalAsNonCritical, outputInterval, *errorGuard); checkDeck, treatCriticalAsNonCritical, lowActionParsingStrictness,
outputInterval, *errorGuard);
// Update schedule so that re-parsing after actions use same strictness // Update schedule so that re-parsing after actions use same strictness
assert(schedule); assert(schedule);

View File

@ -91,6 +91,7 @@ void readDeck(Parallel::Communication comm,
std::shared_ptr<SummaryConfig>& summaryConfig, std::shared_ptr<SummaryConfig>& summaryConfig,
std::shared_ptr<Python> python, std::shared_ptr<Python> python,
const std::string& parsingStrictness, const std::string& parsingStrictness,
const std::string& actionParsingStrictness,
const std::string& inputSkipMode, const std::string& inputSkipMode,
bool initFromRestart, bool initFromRestart,
bool checkDeck, bool checkDeck,