OPM-222: Support COMPORD: Added new class DeckTimeStep and populate SCHEDULESection with DeckTimeSteps

This commit is contained in:
chflo
2015-08-28 16:17:26 +02:00
parent 61c33599cf
commit e5dbfd9359
8 changed files with 316 additions and 9 deletions

View File

@@ -45,6 +45,8 @@ Deck/DeckDoubleItem.cpp
Deck/DeckFloatItem.cpp
Deck/DeckStringItem.cpp
Deck/Section.cpp
Deck/SCHEDULESection.cpp
Deck/DeckTimeStep.cpp
)
set( parser_source
@@ -118,9 +120,8 @@ EclipseState/Grid/NNC.cpp
EclipseState/InitConfig/InitConfig.cpp
EclipseState/SimulationConfig/SimulationConfig.cpp
EclipseState/SimulationConfig/ThresholdPressure.cpp
#
EclipseState/IOConfig/IOConfig.cpp)
#
set( HEADER_FILES
OpmLog/LogBackend.hpp
@@ -146,6 +147,8 @@ Deck/DeckDoubleItem.hpp
Deck/DeckFloatItem.hpp
Deck/DeckStringItem.hpp
Deck/Section.hpp
Deck/SCHEDULESection.hpp
Deck/DeckTimeStep.hpp
#
Parser/ParserEnums.hpp
Parser/ParserKeyword.hpp
@@ -210,7 +213,6 @@ EclipseState/Grid/NNC.hpp
EclipseState/InitConfig/InitConfig.hpp
EclipseState/SimulationConfig/SimulationConfig.hpp
EclipseState/SimulationConfig/ThresholdPressure.hpp
#
EclipseState/IOConfig/IOConfig.hpp
#
EclipseState/Tables/Tabdims.hpp

View File

@@ -0,0 +1,30 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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/Deck/DeckTimeStep.hpp>
namespace Opm {
DeckTimeStep::DeckTimeStep() {
}
}

View File

@@ -0,0 +1,40 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DECKTIMESTEP_HPP
#define DECKTIMESTEP_HPP
#include <opm/parser/eclipse/Deck/Deck.hpp>
namespace Opm {
class DeckTimeStep : public Deck {
public:
DeckTimeStep();
private:
};
typedef std::shared_ptr<DeckTimeStep> DeckTimeStepPtr;
typedef std::shared_ptr<const DeckTimeStep> DeckTimeStepConstPtr;
}
#endif

View File

@@ -0,0 +1,56 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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/Deck/SCHEDULESection.hpp>
namespace Opm {
SCHEDULESection::SCHEDULESection(DeckConstPtr deck) : Section(deck, "SCHEDULE") {
populateDeckTimeSteps();
}
DeckTimeStepConstPtr SCHEDULESection::getDeckTimeStep(size_t timestep) const {
if (timestep < m_decktimesteps.size()) {
return m_decktimesteps[timestep];
} else {
throw std::out_of_range("No DeckTimeStep in ScheduleSection for timestep " + timestep);
}
}
void SCHEDULESection::populateDeckTimeSteps() {
DeckTimeStepPtr currentTimeStep = std::make_shared<DeckTimeStep>();
for (auto iter = begin(); iter != end(); ++iter) { //Loop keywords in schedule section
auto keyword = *iter;
if ((keyword->name() == "TSTEP") || (keyword->name() == "DATES")) {
for (auto key_iter = keyword->begin(); key_iter != keyword->end(); ++key_iter) {
m_decktimesteps.push_back(currentTimeStep);
currentTimeStep = std::make_shared<DeckTimeStep>();
}
} else {
currentTimeStep->addKeyword(keyword);
}
}
//push last step
m_decktimesteps.push_back(currentTimeStep);
}
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCHEDULESECTION_HPP
#define SCHEDULESECTION_HPP
#include <iostream>
#include <string>
#include <memory>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/DeckTimeStep.hpp>
namespace Opm {
class SCHEDULESection : public Section {
public:
SCHEDULESection(DeckConstPtr deck);
DeckTimeStepConstPtr getDeckTimeStep(size_t timestep) const;
private:
void populateDeckTimeSteps();
std::vector<DeckTimeStepPtr> m_decktimesteps;
};
}
#endif // SCHEDULESECTION_HPP

View File

@@ -30,6 +30,7 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
namespace Opm {
class Section : public Deck
@@ -91,11 +92,6 @@ class Section : public Deck
public:
SOLUTIONSection(DeckConstPtr deck) : Section(deck, "SOLUTION") {}
};
class SCHEDULESection : public Section {
public:
SCHEDULESection(DeckConstPtr deck) : Section(deck, "SCHEDULE") {}
};
}
#endif // SECTION_HPP

View File

@@ -1,6 +1,6 @@
foreach(tapp DeckRecordTests DeckIntItemTests DeckDoubleItemTests
DeckFloatItemTests DeckStringItemTests
DeckTests DeckKeywordTests SectionTests)
DeckTests DeckKeywordTests SectionTests DeckTimeStepTests)
opm_add_test(run${tapp} SOURCES ${tapp}.cpp
LIBRARIES opmparser ${Boost_LIBRARIES})
endforeach()

View File

@@ -0,0 +1,136 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_MODULE DeckTimeStepTests
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <opm/parser/eclipse/Deck/DeckTimeStep.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/SCHEDULESection.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(testDeckTimeStepInitialize) {
BOOST_CHECK_NO_THROW(DeckTimeStep deckTimeStep());
}
BOOST_AUTO_TEST_CASE(testDeckTimeStepTSTEP) {
Opm::Parser parser;
std::string input =
"START -- 0 \n"
"19 JUN 2007 / \n"
"SCHEDULE\n"
"DATES -- 1,2\n"
" 10 OKT 2008 / \n"
" 11 OKT 2008 / \n"
"/\n"
"WELSPECS\n"
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
"/\n"
"COMPDAT\n"
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
" 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
"/\n"
"DATES -- 3,4\n"
" 20 JAN 2010 / \n"
" 21 JAN 2010 / \n"
"/\n";
ParseMode parseMode;
DeckPtr deck = parser.parseString(input, parseMode);
SCHEDULESection scheduleSection = SCHEDULESection(deck);
DeckTimeStepConstPtr step1 = scheduleSection.getDeckTimeStep(0);
DeckTimeStepConstPtr step2 = scheduleSection.getDeckTimeStep(1);
DeckTimeStepConstPtr step3 = scheduleSection.getDeckTimeStep(2);
DeckTimeStepConstPtr step4 = scheduleSection.getDeckTimeStep(3);
BOOST_CHECK_EQUAL(step1->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step2->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step3->hasKeyword("WELSPECS"), true);
BOOST_CHECK_EQUAL(step4->hasKeyword("WELSPECS"), false);
}
BOOST_AUTO_TEST_CASE(testDeckTimeStepDATES) {
Opm::Parser parser;
std::string input =
"RUNSPEC\n"
"INIT\n"
"UNIFOUT\n"
"OIL\n"
"GAS\n"
"WATER\n"
"METRIC\n"
"DIMENS\n"
"3 3 3/\n"
"GRID\n"
"DXV\n"
"1.0 2.0 3.0 /\n"
"DYV\n"
"4.0 5.0 6.0 /\n"
"DZV\n"
"7.0 8.0 9.0 /\n"
"TOPS\n"
"9*100 /\n"
"PROPS\n"
"PORO\n"
"27*0.3 /\n"
"PERMX\n"
"27*1 /\n"
"SOLUTION\n"
"RPTRST\n"
"BASIC=2\n"
"/\n"
"SCHEDULE\n"
"TSTEP\n"
"1.0 2.0 3.0 4.0 /\n"
"WELSPECS\n"
"'INJ' 'G' 1 1 2000 'GAS' /\n"
"'PROD' 'G' 3 3 1000 'OIL' /\n"
"/\n";
ParseMode parseMode;
DeckPtr deck = parser.parseString(input, parseMode);
SCHEDULESection scheduleSection = SCHEDULESection(deck);
DeckTimeStepConstPtr step1 = scheduleSection.getDeckTimeStep(0);
DeckTimeStepConstPtr step2 = scheduleSection.getDeckTimeStep(1);
DeckTimeStepConstPtr step3 = scheduleSection.getDeckTimeStep(2);
DeckTimeStepConstPtr step4 = scheduleSection.getDeckTimeStep(3);
DeckTimeStepConstPtr step5 = scheduleSection.getDeckTimeStep(4);
BOOST_CHECK_EQUAL(step1->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step2->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step3->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step4->hasKeyword("WELSPECS"), false);
BOOST_CHECK_EQUAL(step5->hasKeyword("WELSPECS"), true);
}