Hooops to support CPR in both SUMMARY and RUNSPEC.
This commit is contained in:
parent
e7f7c3ca3e
commit
8fc2927beb
@ -40,15 +40,21 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
SimulationConfig::SimulationConfig(const ParseMode& parseMode , DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties) {
|
||||
initThresholdPressure(parseMode , deck, gridProperties);
|
||||
SimulationConfig::SimulationConfig(const ParseMode& parseMode , DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties) :
|
||||
m_useCPR( false )
|
||||
{
|
||||
if (Section::hasRUNSPEC(deck)) {
|
||||
const RUNSPECSection runspec(deck);
|
||||
if (runspec.hasKeyword<ParserKeywords::CPR>()) {
|
||||
std::shared_ptr<const DeckKeyword> cpr = runspec.getKeyword<ParserKeywords::CPR>();
|
||||
if (cpr->size() > 0)
|
||||
throw std::invalid_argument("ERROR: In the RUNSPEC section the CPR keyword should EXACTLY one empty record.");
|
||||
|
||||
m_useCPR = false;
|
||||
/*
|
||||
if(deck->hasKeyword<ParserKeywords::CPR>()){
|
||||
m_useCPR = true;
|
||||
}
|
||||
*/
|
||||
m_useCPR = true;
|
||||
}
|
||||
}
|
||||
|
||||
initThresholdPressure(parseMode , deck, gridProperties);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/core/utility/platform_dependent/reenable_warnings.h>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Section.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
@ -68,12 +69,29 @@ const std::string& inputStr_noTHPRES = "RUNSPEC\n"
|
||||
"\n";
|
||||
|
||||
const std::string& inputStr_cpr = "RUNSPEC\n"
|
||||
"CPR\n"
|
||||
"/\n";
|
||||
"CPR\n"
|
||||
"/\n"
|
||||
"SUMMARY\n";
|
||||
|
||||
const std::string& inputStr_cprWithData = "RUNSPEC\n"
|
||||
|
||||
const std::string& inputStr_INVALID = "RUNSPEC\n"
|
||||
"CPR\n"
|
||||
"WEll 10 10 17/"
|
||||
"/\n"
|
||||
"SUMMARY\n";
|
||||
|
||||
|
||||
|
||||
const std::string& inputStr_cpr_in_SUMMARY = "SUMMARY\n"
|
||||
"CPR\n"
|
||||
"data/\n";
|
||||
"well1 10 27 10/\n/\n";
|
||||
|
||||
const std::string& inputStr_cpr_BOTH = "RUNSPEC\n"
|
||||
"CPR\n"
|
||||
"/\n"
|
||||
"SUMMARY\n"
|
||||
"CPR\n"
|
||||
"well1 10 20 30/\n/\n";
|
||||
|
||||
static DeckPtr createDeck(const ParseMode& parseMode , const std::string& input) {
|
||||
Opm::Parser parser;
|
||||
@ -116,16 +134,46 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRNotUsed) {
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsed) {
|
||||
ParseMode parseMode;
|
||||
DeckPtr deck = createDeck(parseMode , inputStr_cpr);
|
||||
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
||||
//BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
|
||||
ParseMode parseMode;
|
||||
DeckPtr deck = createDeck(parseMode , inputStr_cpr);
|
||||
SUMMARYSection summary(deck);
|
||||
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
||||
BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
|
||||
BOOST_CHECK_EQUAL( false , summary.hasKeyword("CPR"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsedWithData) {
|
||||
ParseMode parseMode;
|
||||
BOOST_CHECK_THROW(createDeck(parseMode , inputStr_cprWithData), std::invalid_argument);
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRInSUMMARYSection) {
|
||||
ParseMode parseMode;
|
||||
DeckPtr deck = createDeck(parseMode , inputStr_cpr_in_SUMMARY);
|
||||
SUMMARYSection summary(deck);
|
||||
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
||||
BOOST_CHECK_EQUAL( false , simulationConfig.useCPR());
|
||||
BOOST_CHECK_EQUAL( true , summary.hasKeyword("CPR"));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRBoth) {
|
||||
ParseMode parseMode;
|
||||
DeckPtr deck = createDeck(parseMode , inputStr_cpr_BOTH);
|
||||
SUMMARYSection summary(deck);
|
||||
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
||||
BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
|
||||
BOOST_CHECK_EQUAL( true , summary.hasKeyword("CPR"));
|
||||
|
||||
std::shared_ptr<const DeckKeyword> cpr = summary.getKeyword<ParserKeywords::CPR>();
|
||||
std::shared_ptr<const DeckRecord> record = cpr->getRecord(0);
|
||||
BOOST_CHECK_EQUAL( 1 , cpr->size());
|
||||
BOOST_CHECK_EQUAL( record->getItem<ParserKeywords::CPR::WELL>()->getString(0) , "well1");
|
||||
BOOST_CHECK_EQUAL( record->getItem<ParserKeywords::CPR::I>()->getInt(0) , 10);
|
||||
BOOST_CHECK_EQUAL( record->getItem<ParserKeywords::CPR::J>()->getInt(0) , 20);
|
||||
BOOST_CHECK_EQUAL( record->getItem<ParserKeywords::CPR::K>()->getInt(0) , 30);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRRUnspecWithData) {
|
||||
ParseMode parseMode;
|
||||
BOOST_CHECK_THROW( createDeck(parseMode , inputStr_INVALID) , std::invalid_argument );
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name" : "CONNECTION_PROBE",
|
||||
"sections" : ["SUMMARY"],
|
||||
|
||||
"comment": "E100 only",
|
||||
"deck_names" : [
|
||||
"comment" : "See comment in CPR keyword file - there is some serious special casing involved here",
|
||||
"deck_names" : [
|
||||
"COFR",
|
||||
"COFRF",
|
||||
"COFRS",
|
||||
@ -72,7 +72,6 @@
|
||||
"CWGRL",
|
||||
"CGLR",
|
||||
"CGLRL",
|
||||
"CPR",
|
||||
"CPI",
|
||||
"CTFAC",
|
||||
"CDBF",
|
||||
@ -127,7 +126,11 @@
|
||||
"comment":"Some keywords need to be suffixed by a tracer name...",
|
||||
"deck_name_regex":"CU.+|CTFR.+|CTPR.+|CTPT.+|CTPC.+|CTIR.+|CTIT.+|CTIC.+|CTFR.+|CTPR.+|CTPT.+|CTPC.+|CTIR.+|CTIT.+|CTIC.+|CTIRF.+|CTIRS.+|CTPRF.+|CTPRS.+|CTITF.+|CTITS.+|CTPTF.+|CTPTS.+|CTICF.+|CTICS.+|CTPCF.+|CTPCS",
|
||||
|
||||
"items" : [{
|
||||
"name" : "MNEMONIC_LIST" , "size_type" : "ALL" , "value_type" : "STRING"
|
||||
}]
|
||||
"items" : [
|
||||
{"name" : "WELL" , "value_type" : "STRING"},
|
||||
{"name" : "I" , "value_type" : "INT"},
|
||||
{"name" : "J" , "value_type" : "INT"},
|
||||
{"name" : "K" , "value_type" : "INT"}
|
||||
]
|
||||
|
||||
}
|
||||
|
14
opm/parser/share/keywords/000_Eclipse100/C/CPR
Normal file
14
opm/parser/share/keywords/000_Eclipse100/C/CPR
Normal file
@ -0,0 +1,14 @@
|
||||
{"name" : "CPR" ,
|
||||
"items" : [
|
||||
{"name" : "WELL" , "value_type" : "STRING"},
|
||||
{"name" : "I" , "value_type" : "INT"},
|
||||
{"name" : "J" , "value_type" : "INT"},
|
||||
{"name" : "K" , "value_type" : "INT"}],
|
||||
"sections" : ["RUNSPEC" , "SUMMARY"],
|
||||
"comment" : "The CPR keyword can occur both in the RUNSPEC section and in the SUMMARY section",
|
||||
"comment" : "the meaning of the keyword is completely different in the sections, but we just barely",
|
||||
"comment" : "manage to get away by using the same configuration for both sections. When occuring",
|
||||
"comment" : "in the RUNSPEC section the keyword should have exactly one-empty-record - that is enforced",
|
||||
"comment" : "in the SimulationConfig() constructor"}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user