Added support for WCONPROD, with use of predictionMode. Fixed a bug in the TSTEP reading in Schedule.cpp

This commit is contained in:
Kristian Flikka 2013-11-08 15:55:11 +01:00
parent f0def0cdff
commit 862d2ee302
7 changed files with 243 additions and 239 deletions

View File

@ -15,22 +15,21 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
namespace Opm
{
namespace Opm {
Schedule::Schedule(DeckConstPtr deck) {
if (deck->hasKeyword("SCHEDULE"))
initFromDeck( deck );
if (deck->hasKeyword("SCHEDULE"))
initFromDeck(deck);
else
throw std::invalid_argument("Deck does not contain SCHEDULE section.\n");
}
/*void Schedule::initTimeMap(DeckConstPtr deck) {
DeckKeywordConstPtr scheduleKeyword = deck->getKeyword( "SCHEDULE" );
size_t deckIndex = scheduleKeyword->getDeckIndex() + 1;
@ -45,105 +44,106 @@ namespace Opm
deckIndex++;
}
}
*/
*/
void Schedule::createTimeMap(DeckConstPtr deck) {
boost::gregorian::date startDate( defaultStartDate );
boost::gregorian::date startDate(defaultStartDate);
if (deck->hasKeyword("START")) {
DeckKeywordConstPtr startKeyword = deck->getKeyword("START");
startDate = TimeMap::dateFromEclipse( startKeyword->getRecord(0));
startDate = TimeMap::dateFromEclipse(startKeyword->getRecord(0));
}
m_timeMap = TimeMapPtr(new TimeMap(startDate));
}
void Schedule::initFromDeck(DeckConstPtr deck) {
createTimeMap( deck );
iterateScheduleSection( deck );
createTimeMap(deck);
iterateScheduleSection(deck);
}
void Schedule::iterateScheduleSection(DeckConstPtr deck) {
DeckKeywordConstPtr scheduleKeyword = deck->getKeyword( "SCHEDULE" );
DeckKeywordConstPtr scheduleKeyword = deck->getKeyword("SCHEDULE");
size_t deckIndex = scheduleKeyword->getDeckIndex() + 1;
size_t currentStep = 0;
while (deckIndex < deck->size()) {
DeckKeywordConstPtr keyword = deck->getKeyword( deckIndex );
DeckKeywordConstPtr keyword = deck->getKeyword(deckIndex);
if (keyword->name() == "DATES") {
handleDATES( keyword );
handleDATES(keyword);
currentStep += keyword->size();
}
if (keyword->name() == "TSTEP") {
handleTSTEP( keyword );
currentStep += keyword->size();
handleTSTEP(keyword);
currentStep += keyword->getRecord(0)->getItem(0)->size(); // This is a bit weird API.
}
if (keyword->name() == "WELSPECS")
handleWELSPECS( keyword );
if (keyword->name() == "WCONHIST")
handleWCONHIST( keyword , currentStep );
if (keyword->name() == "WELSPECS")
handleWELSPECS(keyword);
if (keyword->name() == "WCONHIST")
handleWCONHIST(keyword, currentStep);
if (keyword->name() == "WCONPROD")
handleWCONPROD(keyword, currentStep);
deckIndex++;
}
}
void Schedule::handleDATES(DeckKeywordConstPtr keyword) {
m_timeMap->addFromDATESKeyword( keyword );
m_timeMap->addFromDATESKeyword(keyword);
}
void Schedule::handleTSTEP(DeckKeywordConstPtr keyword) {
m_timeMap->addFromTSTEPKeyword( keyword );
m_timeMap->addFromTSTEPKeyword(keyword);
}
void Schedule::handleWELSPECS(DeckKeywordConstPtr keyword) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord( recordNr );
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellName = record->getItem(0)->getString(0);
if (!hasWell(wellName))
if (!hasWell(wellName)) {
addWell(wellName);
{
WellPtr well = getWell(wellName);
well->addWELSPECS( record );
}
WellPtr well = getWell(wellName);
well->addWELSPECS(record);
}
}
void Schedule::handleWCONHIST(DeckKeywordConstPtr keyword , size_t currentStep) {
void Schedule::handleWCON(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord( recordNr );
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellName = record->getItem(0)->getString(0);
double orat = record->getItem("ORAT")->getDouble(0);
WellPtr well = getWell(wellName);
well->setOilRate( currentStep , orat );
well->setOilRate(currentStep, orat);
well->setInPredictionMode(currentStep, isPredictionMode);
}
}
void Schedule::handleWCONHIST(DeckKeywordConstPtr keyword, size_t currentStep) {
handleWCON(keyword, currentStep, false);
}
void Schedule::handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep) {
handleWCON(keyword, currentStep, true);
}
boost::gregorian::date Schedule::getStartDate() const {
return m_timeMap->getStartDate();
}
TimeMapConstPtr Schedule::getTimeMap() const {
return m_timeMap;
}
void Schedule::addWell(const std::string& wellName) {
WellPtr well(new Well(wellName , m_timeMap));
WellPtr well(new Well(wellName, m_timeMap));
m_wells[ wellName ] = well;
}
@ -151,17 +151,14 @@ namespace Opm
return m_wells.size();
}
bool Schedule::hasWell(const std::string& wellName) const {
return m_wells.find( wellName ) != m_wells.end();
return m_wells.find(wellName) != m_wells.end();
}
WellPtr Schedule::getWell(const std::string& wellName) const {
if (hasWell(wellName)) {
return m_wells.at(wellName);
}
else
} else
throw std::invalid_argument("Well: " + wellName + " does not exist");
}

View File

@ -55,7 +55,9 @@ namespace Opm
void addWell(const std::string& wellName);
void handleWELSPECS(DeckKeywordConstPtr keyword);
void handleWCON(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode);
void handleWCONHIST(DeckKeywordConstPtr keyword , size_t currentStep);
void handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
void handleDATES(DeckKeywordConstPtr keyword);
void handleTSTEP(DeckKeywordConstPtr keyword);
};

View File

@ -82,8 +82,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithStart) {
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithSCHEDULENoThrow) {
DeckPtr deck(new Deck());
DeckKeywordPtr keyword(new DeckKeyword("SCHEDULE"));

View File

@ -31,31 +31,52 @@
using namespace Opm;
BOOST_AUTO_TEST_CASE( CreateSchedule ) {
BOOST_AUTO_TEST_CASE(CreateSchedule) {
ParserPtr parser(new Parser());
boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE1");
DeckPtr deck = parser->parse(scheduleFile.string());
ScheduleConstPtr sched( new Schedule(deck));
ScheduleConstPtr sched(new Schedule(deck));
TimeMapConstPtr timeMap = sched->getTimeMap();
BOOST_CHECK_EQUAL( boost::gregorian::date( 2007 , boost::gregorian::May , 10 ) , sched->getStartDate());
BOOST_CHECK_EQUAL( 9U , timeMap->size());
BOOST_CHECK_EQUAL(boost::gregorian::date(2007, boost::gregorian::May, 10), sched->getStartDate());
BOOST_CHECK_EQUAL(9U, timeMap->size());
}
BOOST_AUTO_TEST_CASE( WellTesting ) {
BOOST_AUTO_TEST_CASE(WellTesting) {
ParserPtr parser(new Parser());
boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2");
DeckPtr deck = parser->parse(scheduleFile.string());
ScheduleConstPtr sched( new Schedule(deck));
ScheduleConstPtr sched(new Schedule(deck));
BOOST_CHECK_EQUAL(3U, sched->numWells());
BOOST_CHECK(sched->hasWell("OP_1"));
BOOST_CHECK(sched->hasWell("OP_2"));
BOOST_CHECK(sched->hasWell("OP_3"));
BOOST_CHECK_EQUAL( 3U , sched->numWells());
BOOST_CHECK( sched->hasWell("OP_1"));
BOOST_CHECK( sched->hasWell("OP_2"));
BOOST_CHECK( sched->hasWell("OP_3"));
{
WellPtr well1 = sched->getWell("OP_1");
BOOST_CHECK_EQUAL( 14000 , well1->getOilRate( 8 ));
BOOST_CHECK(well1->isInPredictionMode(0));
BOOST_CHECK_EQUAL(0, well1->getOilRate(0));
BOOST_CHECK_EQUAL(0, well1->getOilRate(1));
BOOST_CHECK_EQUAL(0, well1->getOilRate(2));
BOOST_CHECK(!well1->isInPredictionMode(3));
BOOST_CHECK_EQUAL(4000, well1->getOilRate(3));
BOOST_CHECK_EQUAL(4000, well1->getOilRate(4));
BOOST_CHECK_EQUAL(4000, well1->getOilRate(5));
BOOST_CHECK(!well1->isInPredictionMode(6));
BOOST_CHECK_EQUAL(14000, well1->getOilRate(6));
BOOST_CHECK(well1->isInPredictionMode(7));
BOOST_CHECK_EQUAL(11000, well1->getOilRate(7));
BOOST_CHECK(!well1->isInPredictionMode(8));
BOOST_CHECK_EQUAL(13000, well1->getOilRate(8));
BOOST_CHECK_EQUAL(13000, well1->getOilRate(9));
BOOST_CHECK_EQUAL(13000, well1->getOilRate(10));
}
}

View File

@ -33,10 +33,10 @@
namespace Opm {
void ParserKeyword::commonInit(const std::string& name , ParserKeywordActionEnum action) {
void ParserKeyword::commonInit(const std::string& name, ParserKeywordActionEnum action) {
if (!validName(name))
throw std::invalid_argument("Invalid name: " + name + "keyword must be all upper case, max 8 characters. Starting with character.");
m_keywordSizeType = SLASH_TERMINATED;
m_isDataKeyword = false;
m_isTableCollection = false;
@ -45,58 +45,52 @@ namespace Opm {
m_record = ParserRecordPtr(new ParserRecord);
}
ParserKeyword::ParserKeyword(const std::string& name, ParserKeywordActionEnum action) {
commonInit(name , action);
commonInit(name, action);
m_action = action;
}
ParserKeyword::ParserKeyword(const char * name , ParserKeywordActionEnum action) {
commonInit(name , action);
ParserKeyword::ParserKeyword(const char * name, ParserKeywordActionEnum action) {
commonInit(name, action);
m_action = action;
}
ParserKeyword::ParserKeyword(const std::string& name, size_t fixedKeywordSize , ParserKeywordActionEnum action) {
commonInit(name,action);
ParserKeyword::ParserKeyword(const std::string& name, size_t fixedKeywordSize, ParserKeywordActionEnum action) {
commonInit(name, action);
m_keywordSizeType = FIXED;
m_fixedSize = fixedKeywordSize;
}
ParserKeyword::ParserKeyword(const std::string& name , const std::string& sizeKeyword , const std::string& sizeItem , ParserKeywordActionEnum action , bool isTableCollection) {
commonInit(name,action);
ParserKeyword::ParserKeyword(const std::string& name, const std::string& sizeKeyword, const std::string& sizeItem, ParserKeywordActionEnum action, bool isTableCollection) {
commonInit(name, action);
m_isTableCollection = isTableCollection;
initSizeKeyword(sizeKeyword , sizeItem);
initSizeKeyword(sizeKeyword, sizeItem);
}
bool ParserKeyword::isTableCollection() const {
return m_isTableCollection;
}
void ParserKeyword::initSize( const Json::JsonObject& jsonConfig ) {
void ParserKeyword::initSize(const Json::JsonObject& jsonConfig) {
// The number of record has been set explicitly with the size: keyword
if (jsonConfig.has_item("size")) {
Json::JsonObject sizeObject = jsonConfig.get_item("size");
if (sizeObject.is_number()) {
m_fixedSize = (size_t) sizeObject.as_int( );
m_fixedSize = (size_t) sizeObject.as_int();
m_keywordSizeType = FIXED;
} else
initSizeKeyword( sizeObject );
initSizeKeyword(sizeObject);
} else
if (jsonConfig.has_item("num_tables")) {
Json::JsonObject numTablesObject = jsonConfig.get_item("num_tables");
Json::JsonObject numTablesObject = jsonConfig.get_item("num_tables");
if (!numTablesObject.is_object())
throw std::invalid_argument("The num_tables key must point to a {} object");
if (!numTablesObject.is_object())
throw std::invalid_argument("The num_tables key must point to a {} object");
initSizeKeyword( numTablesObject );
m_isTableCollection = true;
initSizeKeyword(numTablesObject);
m_isTableCollection = true;
} else {
if (jsonConfig.has_item("items"))
// The number of records is undetermined - the keyword will be '/' terminated.
@ -111,198 +105,179 @@ namespace Opm {
}
}
ParserKeyword::ParserKeyword(const Json::JsonObject& jsonConfig) {
ParserKeywordActionEnum action = INTERNALIZE;
if (jsonConfig.has_item("action"))
action = ParserKeywordActionEnumFromString( jsonConfig.get_string("action") );
action = ParserKeywordActionEnumFromString(jsonConfig.get_string("action"));
if (jsonConfig.has_item("name")) {
commonInit(jsonConfig.get_string("name") , action);
commonInit(jsonConfig.get_string("name"), action);
} else
throw std::invalid_argument("Json object is missing name: property");
initSize( jsonConfig );
initSize(jsonConfig);
if (jsonConfig.has_item("items"))
addItems(jsonConfig);
if (jsonConfig.has_item("items"))
addItems( jsonConfig );
if (jsonConfig.has_item("data"))
initData( jsonConfig );
initData(jsonConfig);
if (isTableCollection())
addTableItems();
if ((m_fixedSize == 0 && m_keywordSizeType == FIXED) || (m_action != INTERNALIZE))
return;
else {
else {
if (numItems() == 0)
throw std::invalid_argument("Json object for keyword: " + jsonConfig.get_string("name") + " is missing items specifier");
}
}
void ParserKeyword::initSizeKeyword( const std::string& sizeKeyword, const std::string& sizeItem) {
void ParserKeyword::initSizeKeyword(const std::string& sizeKeyword, const std::string& sizeItem) {
m_keywordSizeType = OTHER;
m_sizeDefinitionPair = std::pair<std::string , std::string>(sizeKeyword , sizeItem);
m_sizeDefinitionPair = std::pair<std::string, std::string>(sizeKeyword, sizeItem);
}
void ParserKeyword::initSizeKeyword(const Json::JsonObject& sizeObject) {
std::string sizeKeyword = sizeObject.get_string("keyword");
std::string sizeItem = sizeObject.get_string("item");
initSizeKeyword( sizeKeyword , sizeItem);
initSizeKeyword(sizeKeyword, sizeItem);
}
bool ParserKeyword::validName(const std::string& name) {
if (name.length() > ParserConst::maxKeywordLength)
return false;
if (!isupper(name[0]))
return false;
for (unsigned int i = 1; i < name.length(); i++) {
char c = name[i];
if ( !(isupper(c) || isdigit(c)) )
if (!(isupper(c) || isdigit(c)))
return false;
}
return true;
}
void ParserKeyword::addItem( ParserItemConstPtr item ) {
void ParserKeyword::addItem(ParserItemConstPtr item) {
if (m_isDataKeyword)
throw std::invalid_argument("Keyword:" + getName() + " is already configured as data keyword - can not add more items.");
m_record->addItem( item );
m_record->addItem(item);
}
void ParserKeyword::addDataItem( ParserItemConstPtr item ) {
void ParserKeyword::addDataItem(ParserItemConstPtr item) {
if (m_record->size())
throw std::invalid_argument("Keyword:" + getName() + " already has items - can not add a data item.");
if ((m_fixedSize == 1U) && (m_keywordSizeType == FIXED)) {
addItem( item );
addItem(item);
m_isDataKeyword = true;
} else
throw std::invalid_argument("Keyword:" + getName() + ". When calling addDataItem() the keyword must be configured with fixed size == 1.");
}
void ParserKeyword::addItems( const Json::JsonObject& jsonConfig) {
void ParserKeyword::addItems(const Json::JsonObject& jsonConfig) {
const Json::JsonObject itemsConfig = jsonConfig.get_item("items");
if (itemsConfig.is_array()) {
size_t num_items = itemsConfig.size();
for (size_t i=0; i < num_items; i++) {
const Json::JsonObject itemConfig = itemsConfig.get_array_item( i );
for (size_t i = 0; i < num_items; i++) {
const Json::JsonObject itemConfig = itemsConfig.get_array_item(i);
if (itemConfig.has_item("value_type")) {
ParserValueTypeEnum valueType = ParserValueTypeEnumFromString( itemConfig.get_string("value_type") );
switch( valueType ) {
case INT:
ParserValueTypeEnum valueType = ParserValueTypeEnumFromString(itemConfig.get_string("value_type"));
switch (valueType) {
case INT:
{
ParserIntItemConstPtr item = ParserIntItemConstPtr(new ParserIntItem( itemConfig ));
addItem( item );
ParserIntItemConstPtr item = ParserIntItemConstPtr(new ParserIntItem(itemConfig));
addItem(item);
}
break;
case STRING:
break;
case STRING:
{
ParserStringItemConstPtr item = ParserStringItemConstPtr(new ParserStringItem( itemConfig ));
addItem( item );
ParserStringItemConstPtr item = ParserStringItemConstPtr(new ParserStringItem(itemConfig));
addItem(item);
}
break;
case FLOAT:
break;
case FLOAT:
{
ParserDoubleItemConstPtr item = ParserDoubleItemConstPtr(new ParserDoubleItem( itemConfig ));
addItem( item );
ParserDoubleItemConstPtr item = ParserDoubleItemConstPtr(new ParserDoubleItem(itemConfig));
addItem(item);
}
break;
default:
throw std::invalid_argument("Not implemented.");
break;
default:
throw std::invalid_argument("Not implemented.");
}
} else
throw std::invalid_argument("Json config object missing \"value_type\": ... item");
throw std::invalid_argument("Json config object missing \"value_type\": ... item");
}
} else
throw std::invalid_argument("The items: object must be an array");
throw std::invalid_argument("The items: object must be an array");
}
void ParserKeyword::addTableItems() {
ParserDoubleItemConstPtr item = ParserDoubleItemConstPtr(new ParserDoubleItem("TABLEROW" , ALL , 0));
addItem( item );
ParserDoubleItemConstPtr item = ParserDoubleItemConstPtr(new ParserDoubleItem("TABLEROW", ALL, 0));
addItem(item);
}
void ParserKeyword::initData(const Json::JsonObject& jsonConfig) {
m_fixedSize = 1U;
m_keywordSizeType = FIXED;
const Json::JsonObject dataConfig = jsonConfig.get_item("data");
if (dataConfig.has_item("value_type")) {
ParserValueTypeEnum valueType = ParserValueTypeEnumFromString( dataConfig.get_string("value_type") );
const std::string itemName( getName() );
ParserValueTypeEnum valueType = ParserValueTypeEnumFromString(dataConfig.get_string("value_type"));
const std::string itemName(getName());
bool hasDefault = dataConfig.has_item("default");
switch( valueType ) {
switch (valueType) {
case INT:
{
ParserIntItemPtr item = ParserIntItemPtr(new ParserIntItem( itemName , ALL ));
ParserIntItemPtr item = ParserIntItemPtr(new ParserIntItem(itemName, ALL));
if (hasDefault) {
int defaultValue = dataConfig.get_int("default");
item->setDefault( defaultValue );
item->setDefault(defaultValue);
}
addDataItem( item );
addDataItem(item);
}
break;
case STRING:
break;
case STRING:
{
ParserStringItemPtr item = ParserStringItemPtr(new ParserStringItem( itemName , ALL ));
ParserStringItemPtr item = ParserStringItemPtr(new ParserStringItem(itemName, ALL));
if (hasDefault) {
std::string defaultValue = dataConfig.get_string("default");
item->setDefault( defaultValue );
item->setDefault(defaultValue);
}
addDataItem( item );
addDataItem(item);
}
break;
case FLOAT:
break;
case FLOAT:
{
ParserDoubleItemPtr item = ParserDoubleItemPtr(new ParserDoubleItem( itemName , ALL ));
ParserDoubleItemPtr item = ParserDoubleItemPtr(new ParserDoubleItem(itemName, ALL));
if (hasDefault) {
double defaultValue = dataConfig.get_double("default");
item->setDefault( defaultValue );
item->setDefault(defaultValue);
}
addDataItem( item );
addDataItem(item);
}
break;
default:
throw std::invalid_argument("Not implemented.");
}
break;
default:
throw std::invalid_argument("Not implemented.");
}
} else
throw std::invalid_argument("Json config object missing \"value_type\": ... item");
throw std::invalid_argument("Json config object missing \"value_type\": ... item");
}
ParserRecordPtr ParserKeyword::getRecord() const {
return m_record;
}
ParserKeywordActionEnum ParserKeyword::getAction() const {
return m_action;
}
const std::string& ParserKeyword::getName() const {
return m_name;
}
@ -311,14 +286,12 @@ namespace Opm {
return m_record->size();
}
DeckKeywordPtr ParserKeyword::parse(RawKeywordConstPtr rawKeyword) const {
DeckKeywordPtr keyword(new DeckKeyword(getName()));
DeckKeywordPtr keyword(new DeckKeyword(getName()));
for (size_t i = 0; i < rawKeyword->size(); i++) {
DeckRecordConstPtr deckRecord = m_record->parse(rawKeyword->getRecord(i));
keyword->addRecord(deckRecord);
}
return keyword;
}
@ -337,7 +310,7 @@ namespace Opm {
return m_keywordSizeType;
}
const std::pair<std::string,std::string>& ParserKeyword::getSizeDefinitionPair() const {
const std::pair<std::string, std::string>& ParserKeyword::getSizeDefinitionPair() const {
return m_sizeDefinitionPair;
}
@ -347,14 +320,13 @@ namespace Opm {
bool ParserKeyword::equal(const ParserKeyword& other) const {
if ((m_name == other.m_name) &&
(m_record->equal( *(other.m_record) )) &&
(m_keywordSizeType == other.m_keywordSizeType) &&
(m_isDataKeyword == other.m_isDataKeyword) &&
(m_isTableCollection == other.m_isTableCollection) &&
(m_action == other.m_action))
{
bool equal = false;
switch(m_keywordSizeType) {
(m_record->equal(*(other.m_record))) &&
(m_keywordSizeType == other.m_keywordSizeType) &&
(m_isDataKeyword == other.m_isDataKeyword) &&
(m_isTableCollection == other.m_isTableCollection) &&
(m_action == other.m_action)) {
bool equal = false;
switch (m_keywordSizeType) {
case FIXED:
if (m_fixedSize == other.m_fixedSize)
equal = true;
@ -363,54 +335,52 @@ namespace Opm {
equal = true;
break;
case OTHER:
if ((m_sizeDefinitionPair.first == other.m_sizeDefinitionPair.first) &&
(m_sizeDefinitionPair.second == other.m_sizeDefinitionPair.second))
if ((m_sizeDefinitionPair.first == other.m_sizeDefinitionPair.first) &&
(m_sizeDefinitionPair.second == other.m_sizeDefinitionPair.second))
equal = true;
break;
}
return equal;
}
else
return equal;
} else
return false;
}
void ParserKeyword::inlineNew(std::ostream& os, const std::string& lhs, const std::string& indent) const {
{
const std::string actionString(ParserKeywordActionEnum2String(m_action));
switch (m_keywordSizeType) {
case SLASH_TERMINATED:
os << lhs << " = new ParserKeyword(\"" << m_name << "\"," << actionString << ");" << std::endl;
break;
case FIXED:
os << lhs << " = new ParserKeyword(\"" << m_name << "\",(size_t)" << m_fixedSize << "," << actionString << ");" << std::endl;
break;
case OTHER:
if (isTableCollection())
os << lhs << " = new ParserKeyword(\"" << m_name << "\",\"" << m_sizeDefinitionPair.first << "\",\"" << m_sizeDefinitionPair.second << "\"," << actionString << ", true);" << std::endl;
else
os << lhs << " = new ParserKeyword(\"" << m_name << "\",\"" << m_sizeDefinitionPair.first << "\",\"" << m_sizeDefinitionPair.second << "\"," << actionString << ");" << std::endl;
break;
}
}
void ParserKeyword::inlineNew(std::ostream& os , const std::string& lhs, const std::string& indent) const {
{
const std::string actionString(ParserKeywordActionEnum2String( m_action ));
switch(m_keywordSizeType) {
case SLASH_TERMINATED:
os << lhs << " = new ParserKeyword(\"" << m_name << "\"," << actionString << ");" << std::endl;
break;
case FIXED:
os << lhs << " = new ParserKeyword(\"" << m_name << "\",(size_t)" << m_fixedSize << "," << actionString << ");" << std::endl;
break;
case OTHER:
if (isTableCollection())
os << lhs << " = new ParserKeyword(\"" << m_name << "\",\"" << m_sizeDefinitionPair.first << "\",\"" << m_sizeDefinitionPair.second << "\"," << actionString << ", true);" << std::endl;
else
os << lhs << " = new ParserKeyword(\"" << m_name << "\",\"" << m_sizeDefinitionPair.first << "\",\"" << m_sizeDefinitionPair.second << "\"," << actionString << ");" << std::endl;
break;
}
}
for (size_t i = 0; i < m_record->size(); i++) {
os << indent << "{" << std::endl;
{
const std::string local_indent = indent + " ";
ParserItemConstPtr item = m_record->get(i);
os << local_indent << "ParserItemConstPtr item(";
item->inlineNew(os);
os << ");" << std::endl;
{
std::string addItemMethod = "addItem";
if (m_isDataKeyword)
addItemMethod = "addDataItem";
os << local_indent << lhs << "->" << addItemMethod << "(item);" << std::endl;
}
}
os << indent << "}" << std::endl;
}
}
for (size_t i = 0; i < m_record->size(); i++) {
os << indent << "{" << std::endl;
{
const std::string local_indent = indent + " ";
ParserItemConstPtr item = m_record->get(i);
os << local_indent << "ParserItemConstPtr item(";
item->inlineNew(os);
os << ");" << std::endl;
{
std::string addItemMethod = "addItem";
if (m_isDataKeyword)
addItemMethod = "addDataItem";
os << local_indent << lhs << "->" << addItemMethod << "(item);" << std::endl;
}
}
os << indent << "}" << std::endl;
}
}
}

View File

@ -55,7 +55,6 @@ namespace Opm {
DeckRecordConstPtr ParserRecord::parse(RawRecordPtr rawRecord) const {
DeckRecordPtr deckRecord(new DeckRecord());
for (size_t i = 0; i < size(); i++) {
ParserItemConstPtr parserItem = get(i);
DeckItemConstPtr deckItem = parserItem->scan(rawRecord);

View File

@ -1,15 +1,15 @@
START
START -- 0
10 MAI 2007 /
SCHEDULE
DATES
DATES -- 1
10 'JUN' 2007 /
/
DATES
DATES -- 2,3
10 JLY 2007 /
10 AUG 2007 /
/
@ -28,7 +28,7 @@ WCONHIST
/
TSTEP
TSTEP -- 4,5,6
10 2*10 /
@ -38,8 +38,25 @@ WCONHIST
'OP_3' 'OPEN' 'ORAT' 17999.000 1.000 1471824.000 5* /
/
TSTEP - 7
3 /
DATES
WCONPROD
'OP_1' 'OPEN' 'ORAT' 11000.000 4.000 1.46402E+006 5* /
'OP_2' 'OPEN' 'ORAT' 17998.000 2.000 1461075.000 5* /
'OP_3' 'OPEN' 'ORAT' 17999.000 1.000 1471824.000 5* /
/
TSTEP -- 8
4 /
WCONHIST
'OP_1' 'OPEN' 'ORAT' 13000.000 4.000 1.46402E+006 5* /
'OP_2' 'OPEN' 'ORAT' 17998.000 2.000 1461075.000 5* /
'OP_3' 'OPEN' 'ORAT' 17999.000 1.000 1471824.000 5* /
/
DATES -- 9, 10
10 JLY 2008 /
10 AUG 2008 /
/