Merge master into schedule_groups

This commit is contained in:
Kristian Flikka 2013-11-21 13:43:36 +01:00
commit 0271e5fc03
24 changed files with 1153 additions and 38 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*~
*.user
gmon.out
log.log
build

View File

@ -5,9 +5,9 @@
#
# If found, it sets these variables:
#
# HAVE_OPM_PARSER Defined if a test program compiled
# OPM_PARSER_INCLUDE_DIRS Header file directories
# OPM_PARSER_LIBRARIES Archives and shared objects
# HAVE_OPM_PARSER Defined if a test program compiled
# OPM_PARSER_INCLUDE_DIRS Header file directories
# OPM_PARSER_LIBRARIES Archives and shared objects
include (FindPackageHandleStandardArgs)
@ -61,18 +61,18 @@ find_path (OPM_PARSER_INCLUDE_DIR
# then it is probably a build directory; read the CMake cache of
# opm-parser to figure out where the source directory is
if ((NOT OPM_PARSER_INCLUDE_DIR) AND
(OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt")))
(OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt")))
set (_regex "^OPMParser_SOURCE_DIR:STATIC=\(.*\)$")
file (STRINGS
"${OPM_PARSER_ROOT}/CMakeCache.txt"
_cache_entry
REGEX "${_regex}")
"${OPM_PARSER_ROOT}/CMakeCache.txt"
_cache_entry
REGEX "${_regex}")
string(REGEX REPLACE "${_regex}" "\\1"
OPM_PARSER_INCLUDE_DIR
"${_cache_entry}")
OPM_PARSER_INCLUDE_DIR
"${_cache_entry}")
if (OPM_PARSER_INCLUDE_DIR)
set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}"
CACHE PATH "Path to OPM parser header files" FORCE)
set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}"
CACHE PATH "Path to OPM parser header files" FORCE)
endif ()
endif ()
@ -109,14 +109,16 @@ endif ()
# get the prerequisite Boost libraries
if (NOT Boost_FOUND)
find_package(Boost 1.44.0
COMPONENTS filesystem date_time system unit_test_framework REQUIRED ${OPM_PARSER_QUIET})
COMPONENTS filesystem date_time system unit_test_framework REQUIRED ${OPM_PARSER_QUIET})
endif ()
# setup list of all required libraries to link with opm-parser. notice that
# we use the plural form to get *all* the libraries needed by cjson
set (OPM_PARSER_INCLUDE_DIRS
${OPM_PARSER_INCLUDE_DIR}
${CJSON_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS})
set (OPM_PARSER_LIBRARIES
${OPM_PARSER_LIBRARY}
${OPM_JSON_LIBRARY}
@ -126,7 +128,7 @@ set (OPM_PARSER_LIBRARIES
# see if we can compile a minimum example
# CMake logical test doesn't handle lists (sic)
if (NOT (OPM_PARSER_INCLUDE_DIR MATCHES "-NOTFOUND"
OR OPM_PARSER_LIBRARIES MATCHES "-NOTFOUND"))
OR OPM_PARSER_LIBRARIES MATCHES "-NOTFOUND"))
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()

View File

@ -13,6 +13,6 @@ set (opm-parser_DEPS
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# various runtime library enhancements
"Boost 1.39.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
"Boost 1.44.0 COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
"cJSON"
)

View File

@ -50,6 +50,7 @@ set (state_source
EclipseState/Schedule/TimeMap.cpp
EclipseState/Schedule/Schedule.cpp
EclipseState/Schedule/Well.cpp
EclipseState/Schedule/Group.cpp
EclipseState/Schedule/Completion.cpp
EclipseState/Schedule/CompletionSet.cpp
EclipseState/Schedule/ScheduleEnums.cpp
@ -84,6 +85,7 @@ Parser/ParserStringItem.hpp
EclipseState/Schedule/TimeMap.hpp
EclipseState/Schedule/Schedule.hpp
EclipseState/Schedule/Well.hpp
EclipseState/Schedule/Group.hpp
EclipseState/Schedule/DynamicState.hpp
EclipseState/Schedule/Completion.hpp
EclipseState/Schedule/CompletionSet.hpp

View File

@ -50,6 +50,11 @@ namespace Opm {
}
size_t size() const {
return m_data.size();
}
void add(size_t index , T value) {
if (index >= (m_timeMap->size()))
throw std::range_error("Index value is out range.");

View File

@ -0,0 +1,240 @@
/*
Copyright 2013 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 <boost/date_time.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
namespace Opm {
namespace GroupProduction {
struct ProductionData {
ProductionData(TimeMapConstPtr timeMap);
boost::shared_ptr<DynamicState<GroupProduction::ControlEnum> > controlMode;
boost::shared_ptr<DynamicState<GroupProductionExceedLimit::ActionEnum> > exceedAction;
boost::shared_ptr<DynamicState<double> > oilTarget;
boost::shared_ptr<DynamicState<double> > waterTarget;
boost::shared_ptr<DynamicState<double> > gasTarget;
boost::shared_ptr<DynamicState<double> > liquidTarget;
};
ProductionData::ProductionData(TimeMapConstPtr timeMap) :
controlMode( new DynamicState<GroupProduction::ControlEnum>(timeMap , GroupProduction::NONE)),
exceedAction( new DynamicState<GroupProductionExceedLimit::ActionEnum>(timeMap , GroupProductionExceedLimit::NONE)),
oilTarget( new DynamicState<double>(timeMap , 0)),
waterTarget( new DynamicState<double>(timeMap , 0)),
gasTarget( new DynamicState<double>(timeMap , 0)),
liquidTarget( new DynamicState<double>(timeMap , 0))
{
}
}
namespace GroupInjection {
struct InjectionData {
InjectionData(TimeMapConstPtr timeMap);
boost::shared_ptr<DynamicState<PhaseEnum> > phase;
boost::shared_ptr<DynamicState<GroupInjection::ControlEnum> > controlMode;
boost::shared_ptr<DynamicState<double> > rate;
boost::shared_ptr<DynamicState<double> > surfaceFlowMaxRate;
boost::shared_ptr<DynamicState<double> > reservoirFlowMaxRate;
boost::shared_ptr<DynamicState<double> > targetReinjectFraction;
boost::shared_ptr<DynamicState<double> > targetVoidReplacementFraction;
};
InjectionData::InjectionData(TimeMapConstPtr timeMap) :
phase( new DynamicState<PhaseEnum>( timeMap , WATER )),
controlMode( new DynamicState<GroupInjection::ControlEnum>( timeMap , NONE )),
rate( new DynamicState<double>( timeMap , 0 )),
surfaceFlowMaxRate( new DynamicState<double>( timeMap , 0)),
reservoirFlowMaxRate( new DynamicState<double>( timeMap , 0)),
targetReinjectFraction( new DynamicState<double>( timeMap , 0)),
targetVoidReplacementFraction( new DynamicState<double>( timeMap , 0))
{
}
}
/*****************************************************************/
Group::Group(const std::string& name , TimeMapConstPtr timeMap) :
m_injection( new GroupInjection::InjectionData(timeMap) ),
m_production( new GroupProduction::ProductionData( timeMap ))
{
m_name = name;
}
const std::string& Group::name() const {
return m_name;
}
void Group::setInjectionPhase(size_t time_step , PhaseEnum phase){
if (m_injection->phase->size() == time_step + 1) {
PhaseEnum currentPhase = m_injection->phase->get(time_step);
/*
The ECLIPSE documentation of the GCONINJE keyword seems
to indicate that a group can inject more than one phase
simultaneously. This should be implemented in the input
file as:
GCONINJE
'GROUP' 'PHASE1' 'RATE' ... /
'GROUP' 'PHASE2' 'RATE' ... /
...
/
I.e. the same group occurs more than once at the same
time step, with different phases. This seems quite
weird, and we do currently not support it. Changing the
injected phase from one time step to the next is
supported.
*/
if (phase != currentPhase)
throw std::invalid_argument("Sorry - we currently do not support injecting multiple phases at the same time.");
}
m_injection->phase->add( time_step , phase );
}
PhaseEnum Group::getInjectionPhase( size_t time_step ) const {
return m_injection->phase->get( time_step );
}
void Group::setInjectionRate( size_t time_step , double rate) {
return m_injection->rate->add( time_step , rate);
}
double Group::getInjectionRate( size_t time_step ) const {
return m_injection->rate->get( time_step );
}
void Group::setInjectionControlMode(size_t time_step , GroupInjection::ControlEnum controlMode) {
m_injection->controlMode->add( time_step , controlMode );
}
GroupInjection::ControlEnum Group::getInjectionControlMode( size_t time_step) const {
return m_injection->controlMode->get( time_step );
}
void Group::setSurfaceMaxRate( size_t time_step , double rate) {
return m_injection->surfaceFlowMaxRate->add( time_step , rate);
}
double Group::getSurfaceMaxRate( size_t time_step ) const {
return m_injection->surfaceFlowMaxRate->get( time_step );
}
void Group::setReservoirMaxRate( size_t time_step , double rate) {
return m_injection->reservoirFlowMaxRate->add( time_step , rate);
}
double Group::getReservoirMaxRate( size_t time_step ) const {
return m_injection->reservoirFlowMaxRate->get( time_step );
}
void Group::setTargetReinjectFraction( size_t time_step , double rate) {
return m_injection->targetReinjectFraction->add( time_step , rate);
}
double Group::getTargetReinjectFraction( size_t time_step ) const {
return m_injection->targetReinjectFraction->get( time_step );
}
void Group::setTargetVoidReplacementFraction( size_t time_step , double rate) {
return m_injection->targetVoidReplacementFraction->add( time_step , rate);
}
double Group::getTargetVoidReplacementFraction( size_t time_step ) const {
return m_injection->targetVoidReplacementFraction->get( time_step );
}
/*****************************************************************/
void Group::setProductionControlMode( size_t time_step , GroupProduction::ControlEnum controlMode) {
m_production->controlMode->add(time_step , controlMode );
}
GroupProduction::ControlEnum Group::getProductionControlMode( size_t time_step ) const {
return m_production->controlMode->get(time_step);
}
GroupProductionExceedLimit::ActionEnum Group::getProductionExceedLimitAction( size_t time_step ) const {
return m_production->exceedAction->get(time_step);
}
void Group::setProductionExceedLimitAction( size_t time_step , GroupProductionExceedLimit::ActionEnum action) {
m_production->exceedAction->add(time_step , action);
}
void Group::setOilTargetRate(size_t time_step , double oilTargetRate) {
m_production->oilTarget->add(time_step , oilTargetRate);
}
double Group::getOilTargetRate(size_t time_step) {
return m_production->oilTarget->get(time_step);
}
void Group::setGasTargetRate(size_t time_step , double gasTargetRate) {
m_production->gasTarget->add(time_step , gasTargetRate);
}
double Group::getGasTargetRate(size_t time_step) {
return m_production->gasTarget->get(time_step);
}
void Group::setWaterTargetRate(size_t time_step , double waterTargetRate) {
m_production->waterTarget->add(time_step , waterTargetRate);
}
double Group::getWaterTargetRate(size_t time_step) {
return m_production->waterTarget->get(time_step);
}
void Group::setLiquidTargetRate(size_t time_step , double liquidTargetRate) {
m_production->liquidTarget->add(time_step , liquidTargetRate);
}
double Group::getLiquidTargetRate(size_t time_step) {
return m_production->liquidTarget->get(time_step);
}
}

View File

@ -0,0 +1,97 @@
/*
Copyright 2013 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 GROUP_HPP_
#define GROUP_HPP_
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
#include <boost/shared_ptr.hpp>
#include <string>
namespace Opm {
namespace GroupInjection {
struct InjectionData;
}
namespace GroupProduction {
struct ProductionData;
}
class Group {
public:
Group(const std::string& name, TimeMapConstPtr timeMap);
const std::string& name() const;
void setInjectionPhase(size_t time_step , PhaseEnum phase);
PhaseEnum getInjectionPhase( size_t time_step) const;
void setInjectionControlMode(size_t time_step , GroupInjection::ControlEnum ControlMode);
GroupInjection::ControlEnum getInjectionControlMode( size_t time_step) const;
void setInjectionRate(size_t time_step , double rate);
double getInjectionRate( size_t time_step) const;
void setSurfaceMaxRate( size_t time_step , double rate);
double getSurfaceMaxRate( size_t time_step ) const;
void setReservoirMaxRate( size_t time_step , double rate);
double getReservoirMaxRate( size_t time_step ) const;
void setTargetReinjectFraction( size_t time_step , double rate);
double getTargetReinjectFraction( size_t time_step ) const;
void setTargetVoidReplacementFraction( size_t time_step , double rate);
double getTargetVoidReplacementFraction( size_t time_step ) const;
/*****************************************************************/
void setProductionControlMode( size_t time_step , GroupProduction::ControlEnum controlMode);
GroupProduction::ControlEnum getProductionControlMode( size_t time_step ) const;
GroupProductionExceedLimit::ActionEnum getProductionExceedLimitAction(size_t time_step) const;
void setProductionExceedLimitAction(size_t time_step , GroupProductionExceedLimit::ActionEnum action);
void setOilTargetRate(size_t time_step , double oilTargetRate);
double getOilTargetRate(size_t time_step);
void setGasTargetRate(size_t time_step , double gasTargetRate);
double getGasTargetRate(size_t time_step);
void setWaterTargetRate(size_t time_step , double waterTargetRate);
double getWaterTargetRate(size_t time_step);
void setLiquidTargetRate(size_t time_step , double LiquidTargetRate);
double getLiquidTargetRate(size_t time_step);
private:
std::string m_name;
boost::shared_ptr<GroupInjection::InjectionData> m_injection;
boost::shared_ptr<GroupProduction::ProductionData> m_production;
};
typedef boost::shared_ptr<Group> GroupPtr;
typedef boost::shared_ptr<const Group> GroupConstPtr;
}
#endif /* WELL_HPP_ */

View File

@ -24,9 +24,10 @@
namespace Opm {
Schedule::Schedule(DeckConstPtr deck) {
if (deck->hasKeyword("SCHEDULE"))
if (deck->hasKeyword("SCHEDULE")) {
addGroup( "FIELD" );
initFromDeck(deck);
else
} else
throw std::invalid_argument("Deck does not contain SCHEDULE section.\n");
}
@ -47,7 +48,7 @@ namespace Opm {
startDate = TimeMap::dateFromEclipse(startKeyword->getRecord(0));
}
m_timeMap = TimeMapPtr(new TimeMap(startDate));
m_timeMap.reset(new TimeMap(startDate));
}
void Schedule::iterateScheduleSection(DeckConstPtr deck) {
@ -91,6 +92,12 @@ namespace Opm {
if (keyword->name() == "GRUPTREE")
handleGRUPTREE(keyword, currentStep);
if (keyword->name() == "GCONINJE")
handleGCONINJE( keyword , currentStep );
if (keyword->name() == "GCONPROD")
handleGCONPROD( keyword , currentStep );
deckIndex++;
}
}
@ -118,7 +125,12 @@ namespace Opm {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellName = record->getItem(0)->getString(0);
const std::string& wellName = record->getItem("WELL")->getString(0);
const std::string& groupName = record->getItem("GROUP")->getString(0);
if (!hasGroup(groupName)) {
addGroup(groupName);
}
if (!hasWell(wellName)) {
addWell(wellName);
@ -181,14 +193,57 @@ namespace Opm {
}
}
void Schedule::handleCOMPDAT(DeckKeywordConstPtr keyword, size_t currentStep) {
std::map<std::string, std::vector< CompletionConstPtr> > completionMapList = Completion::completionsFromCOMPDATKeyword(keyword);
std::map<std::string, std::vector< CompletionConstPtr> >::iterator iter;
for (iter = completionMapList.begin(); iter != completionMapList.end(); iter++) {
void Schedule::handleGCONINJE(DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& groupName = record->getItem("GROUP")->getString(0);
GroupPtr group = getGroup(groupName);
{
PhaseEnum phase = PhaseEnumFromString( record->getItem("PHASE")->getString(0) );
group->setInjectionPhase( currentStep , phase );
}
{
GroupInjection::ControlEnum controlMode = GroupInjection::ControlEnumFromString( record->getItem("CONTROL_MODE")->getString(0) );
group->setInjectionControlMode( currentStep , controlMode );
}
group->setSurfaceMaxRate( currentStep , record->getItem("SURFACE_TARGET")->getDouble(0));
group->setReservoirMaxRate( currentStep , record->getItem("RESV_TARGET")->getDouble(0));
group->setTargetReinjectFraction( currentStep , record->getItem("REINJ_TARGET")->getDouble(0));
group->setTargetVoidReplacementFraction( currentStep , record->getItem("VOIDAGE_TARGET")->getDouble(0));
}
}
void Schedule::handleGCONPROD(DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& groupName = record->getItem("GROUP")->getString(0);
GroupPtr group = getGroup(groupName);
{
GroupProduction::ControlEnum controlMode = GroupProduction::ControlEnumFromString( record->getItem("CONTROL_MODE")->getString(0) );
group->setProductionControlMode( currentStep , controlMode );
}
group->setOilTargetRate( currentStep , record->getItem("OIL_TARGET")->getDouble(0));
group->setGasTargetRate( currentStep , record->getItem("GAS_TARGET")->getDouble(0));
group->setWaterTargetRate( currentStep , record->getItem("WATER_TARGET")->getDouble(0));
group->setLiquidTargetRate( currentStep , record->getItem("LIQUID_TARGET")->getDouble(0));
{
GroupProductionExceedLimit::ActionEnum exceedAction = GroupProductionExceedLimit::ActionEnumFromString(record->getItem("EXCEED_PROC")->getString(0) );
group->setProductionExceedLimitAction( currentStep , exceedAction );
}
}
}
void Schedule::handleCOMPDAT(DeckKeywordConstPtr keyword , size_t currentStep) {
std::map<std::string , std::vector< CompletionConstPtr> > completionMapList = Completion::completionsFromCOMPDATKeyword( keyword );
std::map<std::string , std::vector< CompletionConstPtr> >::iterator iter;
for( iter= completionMapList.begin(); iter != completionMapList.end(); iter++) {
const std::string wellName = iter->first;
WellPtr well = getWell(wellName);
well->addCompletions(currentStep, iter->second);
}
}
@ -237,5 +292,26 @@ namespace Opm {
throw std::invalid_argument("Well: " + wellName + " does not exist");
}
void Schedule::addGroup(const std::string& groupName) {
GroupPtr group(new Group(groupName, m_timeMap));
m_groups[ groupName ] = group;
}
size_t Schedule::numGroups() const {
return m_groups.size();
}
bool Schedule::hasGroup(const std::string& groupName) const {
return m_groups.find(groupName) != m_groups.end();
}
GroupPtr Schedule::getGroup(const std::string& groupName) const {
if (hasGroup(groupName)) {
return m_groups.at(groupName);
} else
throw std::invalid_argument("Group: " + groupName + " does not exist");
}
}

View File

@ -19,13 +19,11 @@
#ifndef SCHEDULE_HPP
#define SCHEDULE_HPP
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <boost/shared_ptr.hpp>
@ -48,10 +46,14 @@ namespace Opm
bool hasWell(const std::string& wellName) const;
WellPtr getWell(const std::string& wellName) const;
GroupTreePtr getGroupTree(size_t t) const;
size_t numGroups() const;
bool hasGroup(const std::string& groupName) const;
GroupPtr getGroup(const std::string& groupName) const;
private:
TimeMapPtr m_timeMap;
std::map<std::string , WellPtr> m_wells;
std::map<std::string , GroupPtr> m_groups;
boost::shared_ptr<DynamicState<GroupTreePtr> > m_rootGroupTree;
void initFromDeck(DeckConstPtr deck);
@ -59,16 +61,17 @@ namespace Opm
void initRootGroupTreeNode(TimeMapConstPtr timeMap);
void iterateScheduleSection(DeckConstPtr deck);
bool handleGroupFromWELSPECS(const std::string& groupName, GroupTreePtr newTree) const;
void addGroup(const std::string& groupName);
void addWell(const std::string& wellName);
void handleWELSPECS(DeckKeywordConstPtr keyword, size_t currentStep);
void handleWELSPECS(DeckKeywordConstPtr keyword);
void handleWCONProducer(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode);
void handleWCONHIST(DeckKeywordConstPtr keyword , size_t currentStep);
void handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
void handleCOMPDAT(DeckKeywordConstPtr keyword , size_t currentStep);
void handleWCONINJE(DeckKeywordConstPtr keyword, size_t currentStep);
void handleWCONINJH(DeckKeywordConstPtr keyword, size_t currentStep);
void handleGCONINJE(DeckKeywordConstPtr keyword, size_t currentStep);
void handleGCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
void handleDATES(DeckKeywordConstPtr keyword);
void handleTSTEP(DeckKeywordConstPtr keyword);
void handleGRUPTREE(DeckKeywordConstPtr keyword, size_t currentStep);

View File

@ -49,6 +49,167 @@ namespace Opm {
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
/*****************************************************************/
namespace GroupInjection {
const std::string ControlEnum2String( ControlEnum enumValue ) {
switch( enumValue ) {
case NONE:
return "NONE";
case RATE:
return "RATE";
case RESV:
return "RESV";
case REIN:
return "REIN";
case VREP:
return "VREP";
case FLD:
return "FLD";
default:
throw std::invalid_argument("Unhandled enum value");
}
}
ControlEnum ControlEnumFromString( const std::string& stringValue ) {
if (stringValue == "NONE")
return NONE;
else if (stringValue == "RATE")
return RATE;
else if (stringValue == "RESV")
return RESV;
else if (stringValue == "REIN")
return REIN;
else if (stringValue == "VREP")
return VREP;
else if (stringValue == "FLD")
return FLD;
else
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
}
/*****************************************************************/
namespace GroupProduction {
const std::string ControlEnum2String( ControlEnum enumValue ) {
switch( enumValue ) {
case NONE:
return "NONE";
case ORAT:
return "ORAT";
case WRAT:
return "WRAT";
case GRAT:
return "GRAT";
case LRAT:
return "LRAT";
case CRAT:
return "CRAT";
case RESV:
return "RESV";
case PRBL:
return "PRBL";
default:
throw std::invalid_argument("Unhandled enum value");
}
}
ControlEnum ControlEnumFromString( const std::string& stringValue ) {
if (stringValue == "NONE")
return NONE;
else if (stringValue == "ORAT")
return ORAT;
else if (stringValue == "WRAT")
return WRAT;
else if (stringValue == "GRAT")
return GRAT;
else if (stringValue == "LRAT")
return LRAT;
else if (stringValue == "CRAT")
return CRAT;
else if (stringValue == "RESV")
return RESV;
else if (stringValue == "PRBL")
return PRBL;
else
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
}
/*****************************************************************/
namespace GroupProductionExceedLimit {
const std::string ActionEnum2String( ActionEnum enumValue ) {
switch(enumValue) {
case NONE:
return "NONE";
case CON:
return "CON";
case CON_PLUS:
return "+CON";
case WELL:
return "WELL";
case PLUG:
return "PLUG";
case RATE:
return "RATE";
default:
throw std::invalid_argument("unhandled enum value");
}
}
ActionEnum ActionEnumFromString( const std::string& stringValue ) {
if (stringValue == "NONE")
return NONE;
else if (stringValue == "CON")
return CON;
else if (stringValue == "+CON")
return CON_PLUS;
else if (stringValue == "WELL")
return WELL;
else if (stringValue == "PLUG")
return PLUG;
else if (stringValue == "RATE")
return RATE;
else
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
}
/*****************************************************************/
const std::string PhaseEnum2String( PhaseEnum enumValue ) {
switch( enumValue ) {
case OIL:
return "OIL";
case GAS:
return "GAS";
case WATER:
return "WATER";
default:
throw std::invalid_argument("unhandled enum value");
}
}
PhaseEnum PhaseEnumFromString( const std::string& stringValue ) {
if (stringValue == "OIL")
return OIL;
else if (stringValue == "WATER")
return WATER;
else if (stringValue == "GAS")
return GAS;
else
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
}

View File

@ -30,8 +30,71 @@ namespace Opm {
AUTO = 3
};
enum PhaseEnum {
OIL = 1,
GAS = 2,
WATER = 4
};
namespace GroupInjection {
enum ControlEnum {
NONE = 0,
RATE = 1,
RESV = 2,
REIN = 3,
VREP = 4,
FLD = 5
};
const std::string ControlEnum2String( ControlEnum enumValue );
ControlEnum ControlEnumFromString( const std::string& stringValue );
}
namespace GroupProductionExceedLimit {
enum ActionEnum {
NONE = 0,
CON = 1,
CON_PLUS = 2, // String: "+CON"
WELL = 3,
PLUG = 4,
RATE = 5
};
const std::string ActionEnum2String( ActionEnum enumValue );
ActionEnum ActionEnumFromString( const std::string& stringValue );
}
namespace GroupProduction {
enum ControlEnum {
NONE = 0,
ORAT = 1,
WRAT = 2,
GRAT = 3,
LRAT = 4,
CRAT = 5,
RESV = 6,
PRBL = 7
};
const std::string ControlEnum2String( GroupProduction::ControlEnum enumValue );
GroupProduction::ControlEnum ControlEnumFromString( const std::string& stringValue );
}
const std::string CompletionStateEnum2String( CompletionStateEnum enumValue );
CompletionStateEnum CompletionStateEnumFromString( const std::string& stringValue );
const std::string PhaseEnum2String( PhaseEnum enumValue );
PhaseEnum PhaseEnumFromString( const std::string& stringValue );
}

View File

@ -13,6 +13,11 @@ target_link_libraries(runWellTests Parser ${Boost_LIBRARIES})
add_test(NAME runWellTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runWellTests )
add_executable(runGroupTests GroupTests.cpp)
target_link_libraries(runGroupTests Parser ${Boost_LIBRARIES})
add_test(NAME runGroupTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runGroupTests )
add_executable(runScheduleEnumTests ScheduleEnumTests.cpp)
target_link_libraries(runScheduleEnumTests Parser ${Boost_LIBRARIES})
add_test(NAME runScheduleEnumTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runScheduleEnumTests )

View File

@ -109,3 +109,24 @@ BOOST_AUTO_TEST_CASE(DynamicStateAddIndexAlreadySetThrows) {
BOOST_AUTO_TEST_CASE(DynamicStateCheckSize) {
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
Opm::DynamicState<int> state(timeMap , 137);
for (size_t i = 0; i < 10; i++)
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
BOOST_CHECK_EQUAL( 0U , state.size() );
state.add( 0 , 10 );
BOOST_CHECK_EQUAL( 1U , state.size() );
state.add( 2 , 10 );
BOOST_CHECK_EQUAL( 3U , state.size() );
state.add( 2 , 10 );
BOOST_CHECK_EQUAL( 3U , state.size() );
state.add( 6 , 10 );
BOOST_CHECK_EQUAL( 7U , state.size() );
}

View File

@ -0,0 +1,102 @@
/*
Copyright 2013 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 <stdexcept>
#include <iostream>
#include <boost/filesystem.hpp>
#define BOOST_TEST_MODULE GroupTests
#include <boost/test/unit_test.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) {
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
for (size_t i = 0; i < numDays; i++)
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
return timeMap;
}
BOOST_AUTO_TEST_CASE(CreateGroup_CorrectNameAndDefaultValues) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Group group("G1" , timeMap);
BOOST_CHECK_EQUAL( "G1" , group.name() );
}
BOOST_AUTO_TEST_CASE(InjectRateOK) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Group group("G1" , timeMap);
BOOST_CHECK_EQUAL( 0 , group.getInjectionRate( 0 ));
group.setInjectionRate( 2 , 100 );
BOOST_CHECK_EQUAL( 100 , group.getInjectionRate( 2 ));
BOOST_CHECK_EQUAL( 100 , group.getInjectionRate( 8 ));
}
BOOST_AUTO_TEST_CASE(ControlModeOK) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Group group("G1" , timeMap);
BOOST_CHECK_EQUAL( Opm::GroupInjection::NONE , group.getInjectionControlMode( 0 ));
group.setInjectionControlMode( 2 , Opm::GroupInjection::RESV );
BOOST_CHECK_EQUAL( Opm::GroupInjection::RESV , group.getInjectionControlMode( 2 ));
BOOST_CHECK_EQUAL( Opm::GroupInjection::RESV , group.getInjectionControlMode( 8 ));
}
BOOST_AUTO_TEST_CASE(GroupChangePhaseSameTimeThrows) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Group group("G1" , timeMap);
BOOST_CHECK_EQUAL( Opm::WATER , group.getInjectionPhase( 0 )); // Default phase - assumed WATER
group.setInjectionPhase(5 , Opm::WATER );
BOOST_CHECK_THROW( group.setInjectionPhase( 5 , Opm::GAS ) , std::invalid_argument );
BOOST_CHECK_NO_THROW( group.setInjectionPhase( 5 , Opm::WATER ));
BOOST_CHECK_NO_THROW( group.setInjectionPhase( 6 , Opm::GAS ));
BOOST_CHECK_EQUAL( Opm::GAS , group.getInjectionPhase( 6 ));
BOOST_CHECK_EQUAL( Opm::GAS , group.getInjectionPhase( 8 ));
}
BOOST_AUTO_TEST_CASE(GroupMiscInjection) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Group group("G1" , timeMap);
group.setSurfaceMaxRate( 3 , 100 );
BOOST_CHECK_EQUAL( 100 , group.getSurfaceMaxRate( 5 ));
group.setReservoirMaxRate( 3 , 200 );
BOOST_CHECK_EQUAL( 200 , group.getReservoirMaxRate( 5 ));
group.setTargetReinjectFraction( 3 , 300 );
BOOST_CHECK_EQUAL( 300 , group.getTargetReinjectFraction( 5 ));
group.setTargetVoidReplacementFraction( 3 , 400 );
BOOST_CHECK_EQUAL( 400 , group.getTargetVoidReplacementFraction( 5 ));
}

View File

@ -42,12 +42,178 @@ BOOST_AUTO_TEST_CASE(TestCompletionStateEnumFromString) {
BOOST_AUTO_TEST_CASE(TestCompletionStateEnumLoop) {
BOOST_CHECK_EQUAL( AUTO , CompletionStateEnumFromString( CompletionStateEnum2String( AUTO ) ));
BOOST_CHECK_EQUAL( AUTO , CompletionStateEnumFromString( CompletionStateEnum2String( AUTO ) ));
BOOST_CHECK_EQUAL( SHUT , CompletionStateEnumFromString( CompletionStateEnum2String( SHUT ) ));
BOOST_CHECK_EQUAL( OPEN , CompletionStateEnumFromString( CompletionStateEnum2String( OPEN ) ));
BOOST_CHECK_EQUAL( "AUTO" , CompletionStateEnum2String(CompletionStateEnumFromString( "AUTO" ) ));
BOOST_CHECK_EQUAL( "AUTO" , CompletionStateEnum2String(CompletionStateEnumFromString( "AUTO" ) ));
BOOST_CHECK_EQUAL( "OPEN" , CompletionStateEnum2String(CompletionStateEnumFromString( "OPEN" ) ));
BOOST_CHECK_EQUAL( "SHUT" , CompletionStateEnum2String(CompletionStateEnumFromString( "SHUT" ) ));
}
/*****************************************************************/
BOOST_AUTO_TEST_CASE(TestGroupInjectionControlEnum2String) {
BOOST_CHECK_EQUAL( "NONE" , GroupInjection::ControlEnum2String(GroupInjection::NONE));
BOOST_CHECK_EQUAL( "RATE" , GroupInjection::ControlEnum2String(GroupInjection::RATE));
BOOST_CHECK_EQUAL( "RESV" , GroupInjection::ControlEnum2String(GroupInjection::RESV));
BOOST_CHECK_EQUAL( "REIN" , GroupInjection::ControlEnum2String(GroupInjection::REIN));
BOOST_CHECK_EQUAL( "VREP" , GroupInjection::ControlEnum2String(GroupInjection::VREP));
BOOST_CHECK_EQUAL( "FLD" , GroupInjection::ControlEnum2String(GroupInjection::FLD));
}
BOOST_AUTO_TEST_CASE(TestGroupInjectionControlEnumFromString) {
BOOST_CHECK_THROW( GroupInjection::ControlEnumFromString("XXX") , std::invalid_argument );
BOOST_CHECK_EQUAL( GroupInjection::NONE , GroupInjection::ControlEnumFromString("NONE"));
BOOST_CHECK_EQUAL( GroupInjection::RATE , GroupInjection::ControlEnumFromString("RATE"));
BOOST_CHECK_EQUAL( GroupInjection::RESV , GroupInjection::ControlEnumFromString("RESV"));
BOOST_CHECK_EQUAL( GroupInjection::REIN , GroupInjection::ControlEnumFromString("REIN"));
BOOST_CHECK_EQUAL( GroupInjection::VREP , GroupInjection::ControlEnumFromString("VREP"));
BOOST_CHECK_EQUAL( GroupInjection::FLD , GroupInjection::ControlEnumFromString("FLD"));
}
BOOST_AUTO_TEST_CASE(TestGroupInjectionControlEnumLoop) {
BOOST_CHECK_EQUAL( GroupInjection::NONE , GroupInjection::ControlEnumFromString( GroupInjection::ControlEnum2String( GroupInjection::NONE ) ));
BOOST_CHECK_EQUAL( GroupInjection::RATE , GroupInjection::ControlEnumFromString( GroupInjection::ControlEnum2String( GroupInjection::RATE ) ));
BOOST_CHECK_EQUAL( GroupInjection::RESV , GroupInjection::ControlEnumFromString( GroupInjection::ControlEnum2String( GroupInjection::RESV ) ));
BOOST_CHECK_EQUAL( GroupInjection::REIN , GroupInjection::ControlEnumFromString( GroupInjection::ControlEnum2String( GroupInjection::REIN ) ));
BOOST_CHECK_EQUAL( GroupInjection::VREP , GroupInjection::ControlEnumFromString( GroupInjection::ControlEnum2String( GroupInjection::VREP ) ));
BOOST_CHECK_EQUAL( GroupInjection::FLD , GroupInjection::ControlEnumFromString( GroupInjection::ControlEnum2String( GroupInjection::FLD ) ));
BOOST_CHECK_EQUAL( "NONE" , GroupInjection::ControlEnum2String(GroupInjection::ControlEnumFromString( "NONE" ) ));
BOOST_CHECK_EQUAL( "RATE" , GroupInjection::ControlEnum2String(GroupInjection::ControlEnumFromString( "RATE" ) ));
BOOST_CHECK_EQUAL( "RESV" , GroupInjection::ControlEnum2String(GroupInjection::ControlEnumFromString( "RESV" ) ));
BOOST_CHECK_EQUAL( "REIN" , GroupInjection::ControlEnum2String(GroupInjection::ControlEnumFromString( "REIN" ) ));
BOOST_CHECK_EQUAL( "VREP" , GroupInjection::ControlEnum2String(GroupInjection::ControlEnumFromString( "VREP" ) ));
BOOST_CHECK_EQUAL( "FLD" , GroupInjection::ControlEnum2String(GroupInjection::ControlEnumFromString( "FLD" ) ));
}
/*****************************************************************/
BOOST_AUTO_TEST_CASE(TestGroupProductionControlEnum2String) {
BOOST_CHECK_EQUAL( "NONE" , GroupProduction::ControlEnum2String(GroupProduction::NONE));
BOOST_CHECK_EQUAL( "ORAT" , GroupProduction::ControlEnum2String(GroupProduction::ORAT));
BOOST_CHECK_EQUAL( "WRAT" , GroupProduction::ControlEnum2String(GroupProduction::WRAT));
BOOST_CHECK_EQUAL( "GRAT" , GroupProduction::ControlEnum2String(GroupProduction::GRAT));
BOOST_CHECK_EQUAL( "LRAT" , GroupProduction::ControlEnum2String(GroupProduction::LRAT));
BOOST_CHECK_EQUAL( "CRAT" , GroupProduction::ControlEnum2String(GroupProduction::CRAT));
BOOST_CHECK_EQUAL( "RESV" , GroupProduction::ControlEnum2String(GroupProduction::RESV));
BOOST_CHECK_EQUAL( "PRBL" , GroupProduction::ControlEnum2String(GroupProduction::PRBL));
}
BOOST_AUTO_TEST_CASE(TestGroupProductionControlEnumFromString) {
BOOST_CHECK_THROW( GroupProduction::ControlEnumFromString("XXX") , std::invalid_argument );
BOOST_CHECK_EQUAL(GroupProduction::NONE , GroupProduction::ControlEnumFromString("NONE"));
BOOST_CHECK_EQUAL(GroupProduction::ORAT , GroupProduction::ControlEnumFromString("ORAT"));
BOOST_CHECK_EQUAL(GroupProduction::WRAT , GroupProduction::ControlEnumFromString("WRAT"));
BOOST_CHECK_EQUAL(GroupProduction::GRAT , GroupProduction::ControlEnumFromString("GRAT"));
BOOST_CHECK_EQUAL(GroupProduction::LRAT , GroupProduction::ControlEnumFromString("LRAT"));
BOOST_CHECK_EQUAL(GroupProduction::CRAT , GroupProduction::ControlEnumFromString("CRAT"));
BOOST_CHECK_EQUAL(GroupProduction::RESV , GroupProduction::ControlEnumFromString("RESV"));
BOOST_CHECK_EQUAL(GroupProduction::PRBL , GroupProduction::ControlEnumFromString("PRBL"));
}
BOOST_AUTO_TEST_CASE(TestGroupProductionControlEnumLoop) {
BOOST_CHECK_EQUAL( GroupProduction::NONE, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::NONE ) ));
BOOST_CHECK_EQUAL( GroupProduction::ORAT, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::ORAT ) ));
BOOST_CHECK_EQUAL( GroupProduction::WRAT, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::WRAT ) ));
BOOST_CHECK_EQUAL( GroupProduction::GRAT, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::GRAT ) ));
BOOST_CHECK_EQUAL( GroupProduction::LRAT, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::LRAT ) ));
BOOST_CHECK_EQUAL( GroupProduction::CRAT, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::CRAT ) ));
BOOST_CHECK_EQUAL( GroupProduction::RESV, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::RESV ) ));
BOOST_CHECK_EQUAL( GroupProduction::PRBL, GroupProduction::ControlEnumFromString( GroupProduction::ControlEnum2String( GroupProduction::PRBL ) ));
BOOST_CHECK_EQUAL( "NONE" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "NONE" ) ));
BOOST_CHECK_EQUAL( "ORAT" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "ORAT" ) ));
BOOST_CHECK_EQUAL( "WRAT" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "WRAT" ) ));
BOOST_CHECK_EQUAL( "GRAT" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "GRAT" ) ));
BOOST_CHECK_EQUAL( "LRAT" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "LRAT" ) ));
BOOST_CHECK_EQUAL( "CRAT" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "CRAT" ) ));
BOOST_CHECK_EQUAL( "RESV" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "RESV" ) ));
BOOST_CHECK_EQUAL( "PRBL" , GroupProduction::ControlEnum2String(GroupProduction::ControlEnumFromString( "PRBL" ) ));
}
/*****************************************************************/
BOOST_AUTO_TEST_CASE(TestGroupProductionExceedLimitControlEnum2String) {
BOOST_CHECK_EQUAL( "NONE" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::NONE));
BOOST_CHECK_EQUAL( "CON" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::CON));
BOOST_CHECK_EQUAL( "+CON" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::CON_PLUS));
BOOST_CHECK_EQUAL( "WELL" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::WELL));
BOOST_CHECK_EQUAL( "PLUG" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::PLUG));
BOOST_CHECK_EQUAL( "RATE" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::RATE));
}
BOOST_AUTO_TEST_CASE(TestGroupProductionExceedLimitActionEnumFromString) {
BOOST_CHECK_THROW( GroupProductionExceedLimit::ActionEnumFromString("XXX") , std::invalid_argument );
BOOST_CHECK_EQUAL(GroupProductionExceedLimit::NONE , GroupProductionExceedLimit::ActionEnumFromString("NONE"));
BOOST_CHECK_EQUAL(GroupProductionExceedLimit::CON , GroupProductionExceedLimit::ActionEnumFromString("CON" ));
BOOST_CHECK_EQUAL(GroupProductionExceedLimit::CON_PLUS , GroupProductionExceedLimit::ActionEnumFromString("+CON"));
BOOST_CHECK_EQUAL(GroupProductionExceedLimit::WELL , GroupProductionExceedLimit::ActionEnumFromString("WELL"));
BOOST_CHECK_EQUAL(GroupProductionExceedLimit::PLUG , GroupProductionExceedLimit::ActionEnumFromString("PLUG"));
BOOST_CHECK_EQUAL(GroupProductionExceedLimit::RATE , GroupProductionExceedLimit::ActionEnumFromString("RATE"));
}
BOOST_AUTO_TEST_CASE(TestGroupProductionExceedLimitActionEnumLoop) {
BOOST_CHECK_EQUAL( GroupProductionExceedLimit::NONE , GroupProductionExceedLimit::ActionEnumFromString( GroupProductionExceedLimit::ActionEnum2String( GroupProductionExceedLimit::NONE ) ));
BOOST_CHECK_EQUAL( GroupProductionExceedLimit::CON , GroupProductionExceedLimit::ActionEnumFromString( GroupProductionExceedLimit::ActionEnum2String( GroupProductionExceedLimit::CON ) ));
BOOST_CHECK_EQUAL( GroupProductionExceedLimit::CON_PLUS , GroupProductionExceedLimit::ActionEnumFromString( GroupProductionExceedLimit::ActionEnum2String( GroupProductionExceedLimit::CON_PLUS ) ));
BOOST_CHECK_EQUAL( GroupProductionExceedLimit::WELL , GroupProductionExceedLimit::ActionEnumFromString( GroupProductionExceedLimit::ActionEnum2String( GroupProductionExceedLimit::WELL ) ));
BOOST_CHECK_EQUAL( GroupProductionExceedLimit::PLUG , GroupProductionExceedLimit::ActionEnumFromString( GroupProductionExceedLimit::ActionEnum2String( GroupProductionExceedLimit::PLUG ) ));
BOOST_CHECK_EQUAL( GroupProductionExceedLimit::RATE , GroupProductionExceedLimit::ActionEnumFromString( GroupProductionExceedLimit::ActionEnum2String( GroupProductionExceedLimit::RATE ) ));
BOOST_CHECK_EQUAL("NONE" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::ActionEnumFromString( "NONE" ) ));
BOOST_CHECK_EQUAL("CON" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::ActionEnumFromString( "CON" ) ));
BOOST_CHECK_EQUAL("+CON" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::ActionEnumFromString( "+CON" ) ));
BOOST_CHECK_EQUAL("WELL" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::ActionEnumFromString( "WELL" ) ));
BOOST_CHECK_EQUAL("PLUG" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::ActionEnumFromString( "PLUG" ) ));
BOOST_CHECK_EQUAL("RATE" , GroupProductionExceedLimit::ActionEnum2String(GroupProductionExceedLimit::ActionEnumFromString( "RATE" ) ));
}
/*****************************************************************/
BOOST_AUTO_TEST_CASE(TestPhaseEnum2String) {
BOOST_CHECK_EQUAL( "OIL" , PhaseEnum2String(OIL));
BOOST_CHECK_EQUAL( "GAS" , PhaseEnum2String(GAS));
BOOST_CHECK_EQUAL( "WATER" , PhaseEnum2String(WATER));
}
BOOST_AUTO_TEST_CASE(TestPhaseEnumFromString) {
BOOST_CHECK_THROW( PhaseEnumFromString("XXX") , std::invalid_argument );
BOOST_CHECK_EQUAL( OIL , PhaseEnumFromString("OIL"));
BOOST_CHECK_EQUAL( WATER , PhaseEnumFromString("WATER"));
BOOST_CHECK_EQUAL( GAS , PhaseEnumFromString("GAS"));
}
BOOST_AUTO_TEST_CASE(TestPhaseEnumLoop) {
BOOST_CHECK_EQUAL( OIL , PhaseEnumFromString( PhaseEnum2String( OIL ) ));
BOOST_CHECK_EQUAL( WATER , PhaseEnumFromString( PhaseEnum2String( WATER ) ));
BOOST_CHECK_EQUAL( GAS , PhaseEnumFromString( PhaseEnum2String( GAS ) ));
BOOST_CHECK_EQUAL( "OIL" , PhaseEnum2String(PhaseEnumFromString( "OIL" ) ));
BOOST_CHECK_EQUAL( "GAS" , PhaseEnum2String(PhaseEnumFromString( "GAS" ) ));
BOOST_CHECK_EQUAL( "WATER" , PhaseEnum2String(PhaseEnumFromString( "WATER" ) ));
}
BOOST_AUTO_TEST_CASE(TestPhaseEnumMask) {
BOOST_CHECK_EQUAL( 0 , OIL & GAS );
BOOST_CHECK_EQUAL( 0 , OIL & WATER );
BOOST_CHECK_EQUAL( 0 , WATER & GAS );
}

View File

@ -129,3 +129,14 @@ BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithGRUPTREE_HasRootGroupTreeNodeForTime
BOOST_AUTO_TEST_CASE(EmptyScheduleHasFIELDGroup) {
DeckPtr deck = createDeck();
Schedule schedule(deck);
BOOST_CHECK_EQUAL( 1U , schedule.numGroups() );
BOOST_CHECK_EQUAL( true , schedule.hasGroup("FIELD") );
BOOST_CHECK_EQUAL( false , schedule.hasGroup("GROUP") );
BOOST_CHECK_THROW( schedule.getGroup("GROUP") , std::invalid_argument );
}

View File

@ -44,6 +44,20 @@ BOOST_AUTO_TEST_CASE(CreateSchedule) {
}
BOOST_AUTO_TEST_CASE(CreateSchedule_Comments_After_Keywords) {
ParserPtr parser(new Parser());
boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_COMMENTS_AFTER_KEYWORDS");
DeckPtr deck = parser->parse(scheduleFile.string());
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_AUTO_TEST_CASE(WellTesting) {
ParserPtr parser(new Parser());
boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2");
@ -237,4 +251,38 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_PrintGrouptree) {
}
BOOST_AUTO_TEST_CASE( WellTestGroups ) {
ParserPtr parser(new Parser());
boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_GROUPS");
DeckPtr deck = parser->parse(scheduleFile.string());
ScheduleConstPtr sched( new Schedule(deck));
BOOST_CHECK_EQUAL( 3U , sched->numGroups() );
BOOST_CHECK( sched->hasGroup( "INJ" ));
BOOST_CHECK( sched->hasGroup( "OP" ));
{
GroupPtr group = sched->getGroup("INJ");
BOOST_CHECK_EQUAL( WATER , group->getInjectionPhase( 3 ));
BOOST_CHECK_EQUAL( GroupInjection::VREP , group->getInjectionControlMode( 3 ));
BOOST_CHECK_EQUAL( 10 , group->getSurfaceMaxRate( 3 ));
BOOST_CHECK_EQUAL( 20 , group->getReservoirMaxRate( 3 ));
BOOST_CHECK_EQUAL( 0.75 , group->getTargetReinjectFraction( 3 ));
BOOST_CHECK_EQUAL( 0.95 , group->getTargetVoidReplacementFraction( 3 ));
BOOST_CHECK_EQUAL( OIL , group->getInjectionPhase( 6 ));
BOOST_CHECK_EQUAL( GroupInjection::RATE , group->getInjectionControlMode( 6 ));
BOOST_CHECK_EQUAL( 1000 , group->getSurfaceMaxRate( 6 ));
}
{
GroupPtr group = sched->getGroup("OP");
BOOST_CHECK_EQUAL( GroupProduction::ORAT , group->getProductionControlMode(3));
BOOST_CHECK_EQUAL( 10 , group->getOilTargetRate(3));
BOOST_CHECK_EQUAL( 20 , group->getWaterTargetRate(3));
BOOST_CHECK_EQUAL( 30 , group->getGasTargetRate(3));
BOOST_CHECK_EQUAL( 40 , group->getLiquidTargetRate(3));
}
}

View File

@ -122,7 +122,7 @@ namespace Opm {
}
bool RawKeyword::tryParseKeyword(const std::string& keywordCandidate, std::string& result) {
result = boost::trim_right_copy(keywordCandidate.substr(0, 8));
result = boost::trim_right_copy_if(keywordCandidate.substr(0, 8), boost::is_any_of("- \t"));
if (isValidKeyword(result))
return true;
else

View File

@ -1,8 +1,8 @@
{"name" : "GCONINJE" , "items" : [
{"name" : "group_name" , "value_type" : "STRING" },
{"name" : "GROUP" , "value_type" : "STRING" },
{"name" : "PHASE" , "value_type" : "STRING"},
{"name" : "CONTROL_MODE" , "value_type" : "STRING" , "default" : "NONE"},
{"name" : "PHASE_TARGET" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "SURFACE_TARGET" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "RESV_TARGET" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "REINJ_TARGET" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "VOIDAGE_TARGET" , "value_type" : "FLOAT" , "default" : 0},

View File

@ -0,0 +1,16 @@
{"name" : "GCONPROD" , "items" : [
{"name" : "GROUP" , "value_type" : "STRING" },
{"name" : "CONTROL_MODE" , "value_type" : "STRING" , "default" : "NONE"},
{"name" : "OIL_TARGET" , "value_type" : "FLOAT" },
{"name" : "WATER_TARGET" , "value_type" : "FLOAT"},
{"name" : "GAS_TARGET" , "value_type" : "FLOAT"},
{"name" : "LIQUID_TARGET" , "value_type" : "FLOAT"},
{"name" : "EXCEED_PROC" , "value_type" : "STRING" , "default" : "NONE"},
{"name" : "RESPOND_TO_PARENT" , "value_type" : "STRING" , "default" : "YES"},
{"name" : "GUIDE_RATE" , "value_type" : "FLOAT"},
{"name" : "GUIDE_RATE_DEF" , "value_type" : "STRING"},
{"name" : "WATER_EXCEED_PROCEDURE" , "value_type" : "STRING"},
{"name" : "GAS_EXCEED_PROCEDURE" , "value_type" : "STRING"},
{"name" : "LIQUID_EXCEED_PROCEDURE" , "value_type" : "STRING"},
{"name" : "RESERVOIR_FLUID_TARGET" , "value_type" : "FLOAT"},
{"name" : "RESERVOIR_VOLUME_BALANCE" , "value_type" : "FLOAT"}]}

View File

@ -1,6 +1,6 @@
{"name" : "WELSPECS" , "items" : [
{"name" : "well_name" , "value_type" : "STRING" },
{"name" : "group_name" , "value_type" : "STRING", "default" : "FIELD"},
{"name" : "WELL" , "value_type" : "STRING" },
{"name" : "GROUP" , "value_type" : "STRING" },
{"name" : "HEAD_I" , "value_type" : "INT"},
{"name" : "HEAD_J" , "value_type" : "INT"},
{"name" : "REF_DEPTH" , "value_type" : "FLOAT"},
@ -16,4 +16,4 @@
{"name" : "FRONTSIM2" , "value_type" : "STRING"},
{"name" : "well_model" , "value_type" : "STRING" , "default" : "STD"},
{"name" : "POLYMER_TABLE" , "value_type" : "INT" , "default" : 0}]}

View File

@ -4,7 +4,7 @@ START
SCHEDULE
DATES
DATES -- Bananskrell
10 'JUN' 2007 /
/

View File

@ -0,0 +1,26 @@
START
10 MAI 2007 /
SCHEDULE
DATES -- Bananskrell
10 'JUN' 2007 /
/
DATES
10 JLY 2007 /
10 AUG 2007 /
/
TSTEP -- Fiskepudding
10 2*10 /
DATES
10 JLY 2008 /
10 AUG 2008 /
/

View File

@ -0,0 +1,70 @@
START -- 0
10 MAI 2007 /
SCHEDULE
DATES -- 1
10 'JUN' 2007 /
/
DATES -- 2,3
10 JLY 2007 /
10 AUG 2007 /
/
WELSPECS
'W_1' 'OP' 30 37 1* 'OIL' 7* / Crap1
'W_2' 'INJ' 20 51 1* 'OIL' 7* / Crap2 Crap3
/
GCONINJE
'INJ' 'WATER' 'VREP' 10 20 0.75 0.95 6* /
/
GCONPROD
'OP' 'ORAT' 10 20 30 40 +CON /
/
TSTEP -- 4,5,6
10 2*10 /
GCONINJE
'INJ' 'OIL' 'RATE' 1000 2* 0.95 6* /
/
TSTEP - 7
3 /
TSTEP -- 8
4 /
DATES -- 9
10 JLY 2008 /
/
GCONINJE
'INJ' 'GAS' 'NONE' 1000 2* 0.95 6* /
/
DATES -- 10
10 AUG 2008 /
/
DATES -- 11
10 SEP 2008 /
/