2015-02-12 16:51:04 +01:00
|
|
|
/*
|
|
|
|
|
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 SimulationConfigTests
|
|
|
|
|
|
2015-10-06 11:30:43 +02:00
|
|
|
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
2015-02-12 16:51:04 +01:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2015-10-06 11:30:43 +02:00
|
|
|
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
2015-02-12 16:51:04 +01:00
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
2015-09-24 21:51:48 +02:00
|
|
|
#include <opm/parser/eclipse/Deck/Section.hpp>
|
2015-07-24 15:38:22 +02:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
|
2016-01-18 17:51:15 +01:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
|
2015-02-12 16:51:04 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2016-01-15 08:42:57 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
|
2015-02-12 16:51:04 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Opm;
|
|
|
|
|
|
|
|
|
|
const std::string& inputStr = "RUNSPEC\n"
|
|
|
|
|
"EQLOPTS\n"
|
2015-12-15 13:50:41 +01:00
|
|
|
"THPRES /\n"
|
2015-02-12 16:51:04 +01:00
|
|
|
"DIMENS\n"
|
|
|
|
|
"10 3 4 /\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"GRID\n"
|
|
|
|
|
"REGIONS\n"
|
|
|
|
|
"EQLNUM\n"
|
|
|
|
|
"10*1 10*2 100*3 /\n "
|
|
|
|
|
"\n"
|
|
|
|
|
|
|
|
|
|
"SOLUTION\n"
|
|
|
|
|
"THPRES\n"
|
|
|
|
|
"1 2 12.0/\n"
|
|
|
|
|
"1 3 5.0/\n"
|
|
|
|
|
"2 3 7.0/\n"
|
|
|
|
|
"/\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
2015-08-25 11:45:04 +02:00
|
|
|
const std::string& inputStr_noTHPRES = "RUNSPEC\n"
|
|
|
|
|
"EQLOPTS\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
"10 3 4 /\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"GRID\n"
|
|
|
|
|
"REGIONS\n"
|
|
|
|
|
"EQLNUM\n"
|
|
|
|
|
"10*1 10*2 100*3 /\n "
|
|
|
|
|
"\n"
|
|
|
|
|
"SOLUTION\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
2015-09-15 16:37:29 +02:00
|
|
|
const std::string& inputStr_cpr = "RUNSPEC\n"
|
2015-09-24 21:51:48 +02:00
|
|
|
"CPR\n"
|
|
|
|
|
"/\n"
|
|
|
|
|
"SUMMARY\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& inputStr_INVALID = "RUNSPEC\n"
|
|
|
|
|
"CPR\n"
|
|
|
|
|
"WEll 10 10 17/"
|
|
|
|
|
"/\n"
|
|
|
|
|
"SUMMARY\n";
|
2015-08-25 11:45:04 +02:00
|
|
|
|
2015-09-24 21:51:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& inputStr_cpr_in_SUMMARY = "SUMMARY\n"
|
2015-09-15 16:37:29 +02:00
|
|
|
"CPR\n"
|
2015-09-24 21:51:48 +02:00
|
|
|
"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";
|
2015-02-12 16:51:04 +01:00
|
|
|
|
2015-12-15 13:50:41 +01:00
|
|
|
const std::string& inputStr_vap_dis = "RUNSPEC\n"
|
|
|
|
|
"VAPOIL\n"
|
|
|
|
|
"DISGAS\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
"10 3 4 /\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"GRID\n"
|
|
|
|
|
"REGIONS\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
2015-08-07 16:30:38 +02:00
|
|
|
static DeckPtr createDeck(const ParseMode& parseMode , const std::string& input) {
|
2015-02-12 16:51:04 +01:00
|
|
|
Opm::Parser parser;
|
2015-08-10 12:50:49 +02:00
|
|
|
return parser.parseString(input, parseMode);
|
2015-02-12 16:51:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static std::shared_ptr<GridProperties<int>> getGridProperties() {
|
|
|
|
|
GridPropertySupportedKeywordInfo<int> kwInfo = GridPropertySupportedKeywordInfo<int>("EQLNUM", 3, "");
|
2016-02-26 23:41:33 +01:00
|
|
|
std::vector<GridPropertySupportedKeywordInfo<int>> supportedKeywordsVec;
|
|
|
|
|
supportedKeywordsVec.push_back(kwInfo);
|
2015-02-12 16:51:04 +01:00
|
|
|
EclipseGridConstPtr eclipseGrid = std::make_shared<const EclipseGrid>(3, 3, 3);
|
2016-02-26 23:41:33 +01:00
|
|
|
std::shared_ptr<GridProperties<int>> gridProperties = std::make_shared<GridProperties<int>>(eclipseGrid, std::move(supportedKeywordsVec));
|
2015-02-12 16:51:04 +01:00
|
|
|
gridProperties->addKeyword("EQLNUM");
|
|
|
|
|
return gridProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigGetThresholdPressureTableTest) {
|
2015-08-07 16:30:38 +02:00
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr);
|
2015-02-12 16:51:04 +01:00
|
|
|
SimulationConfigConstPtr simulationConfigPtr;
|
2015-08-07 16:30:38 +02:00
|
|
|
BOOST_CHECK_NO_THROW(simulationConfigPtr = std::make_shared<const SimulationConfig>(parseMode , deck, getGridProperties()));
|
2015-02-12 16:51:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-08-25 11:45:04 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigNOTHPRES) {
|
|
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr_noTHPRES);
|
|
|
|
|
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
|
|
|
|
BOOST_CHECK_EQUAL( false , simulationConfig.hasThresholdPressure());
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 16:37:29 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigCPRNotUsed) {
|
|
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr_noTHPRES);
|
|
|
|
|
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
2015-09-24 20:37:34 +02:00
|
|
|
BOOST_CHECK_EQUAL( false , simulationConfig.useCPR());
|
2015-09-15 16:37:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsed) {
|
2015-09-24 21:51:48 +02:00
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr_cpr);
|
2016-02-09 12:09:40 +01:00
|
|
|
SUMMARYSection summary(*deck);
|
2015-09-24 21:51:48 +02:00
|
|
|
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
|
|
|
|
BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
|
|
|
|
|
BOOST_CHECK_EQUAL( false , summary.hasKeyword("CPR"));
|
2015-09-15 16:37:29 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-24 21:51:48 +02:00
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigCPRInSUMMARYSection) {
|
|
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr_cpr_in_SUMMARY);
|
2016-02-09 12:09:40 +01:00
|
|
|
SUMMARYSection summary(*deck);
|
2015-09-24 21:51:48 +02:00
|
|
|
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
|
|
|
|
BOOST_CHECK_EQUAL( false , simulationConfig.useCPR());
|
|
|
|
|
BOOST_CHECK_EQUAL( true , summary.hasKeyword("CPR"));
|
2015-09-15 16:37:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-09-24 21:51:48 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigCPRBoth) {
|
|
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr_cpr_BOTH);
|
2016-02-09 12:09:40 +01:00
|
|
|
SUMMARYSection summary(*deck);
|
2015-09-24 21:51:48 +02:00
|
|
|
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
|
|
|
|
BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
|
|
|
|
|
BOOST_CHECK_EQUAL( true , summary.hasKeyword("CPR"));
|
|
|
|
|
|
2016-02-09 12:09:40 +01:00
|
|
|
const auto& cpr = summary.getKeyword<ParserKeywords::CPR>();
|
|
|
|
|
const auto& record = cpr.getRecord(0);
|
|
|
|
|
BOOST_CHECK_EQUAL( 1 , cpr.size());
|
|
|
|
|
BOOST_CHECK_EQUAL( record.getItem<ParserKeywords::CPR::WELL>().get< std::string >(0) , "well1");
|
|
|
|
|
BOOST_CHECK_EQUAL( record.getItem<ParserKeywords::CPR::I>().get< int >(0) , 10);
|
|
|
|
|
BOOST_CHECK_EQUAL( record.getItem<ParserKeywords::CPR::J>().get< int >(0) , 20);
|
|
|
|
|
BOOST_CHECK_EQUAL( record.getItem<ParserKeywords::CPR::K>().get< int >(0) , 30);
|
2015-09-24 21:51:48 +02:00
|
|
|
}
|
2015-02-12 16:51:04 +01:00
|
|
|
|
2015-09-24 21:51:48 +02:00
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfigCPRRUnspecWithData) {
|
|
|
|
|
ParseMode parseMode;
|
|
|
|
|
BOOST_CHECK_THROW( createDeck(parseMode , inputStr_INVALID) , std::invalid_argument );
|
|
|
|
|
}
|
2015-12-15 13:50:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(SimulationConfig_VAPOIL_DISGAS) {
|
|
|
|
|
ParseMode parseMode;
|
|
|
|
|
DeckPtr deck = createDeck(parseMode , inputStr);
|
|
|
|
|
SimulationConfig simulationConfig(parseMode , deck, getGridProperties());
|
|
|
|
|
BOOST_CHECK_EQUAL( false , simulationConfig.hasDISGAS());
|
|
|
|
|
BOOST_CHECK_EQUAL( false , simulationConfig.hasVAPOIL());
|
|
|
|
|
|
|
|
|
|
DeckPtr deck_vd = createDeck(parseMode, inputStr_vap_dis);
|
|
|
|
|
SimulationConfig simulationConfig_vd(parseMode , deck_vd, getGridProperties());
|
|
|
|
|
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasDISGAS());
|
|
|
|
|
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasVAPOIL());
|
|
|
|
|
}
|