Redesign cmake
Tune the makefile according to new principles, which adds a few bells
and whistles and for clarity.
Synopsis:
* The dependency on opm-common is completely gone. This is reflected in
travis and appveyor as well. No non-kitware cmake modules are used.
* Directories are flattened, quite a bit - source code is located in the
lib/ directory if it belongs to opm-parser, and external/ if third
party.
* The sibling build feature is implemented through cmake's
export(PACKAGE) rather than implicitly looking through source files.
* Targets explicitly set required public and private include
directories, compile options and definitions, which cmake will handle
and propagate
* opm-parser-config.cmake for downstream users is now provided.
* Dependencies are set up using targets. In the future, when cmake 3.x+
can be used, these should be either targets from newer Find modules,
or interface libraries.
* Fewer system specific assumptions are coded in, instead we assume
cmake or users set up system specific details.
* All module wide configuration and looking up libraries is handled in
the root makefile - all sub directories only set up libraries and
compile options for the module in question.
* Targets are defined and links handled transitively because cmake now
is told about them. ${module_LIBRARIES} variables are gone.
This is largely guided by the principles outlined in
https://rix0r.nl/blog/2015/08/13/cmake-guide/
Most source files are just moved - if they have some content change then
it's nothing more than include fixes or similar in order to make them
compile.
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
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/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Section.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/D.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/V.hpp>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The internalization of the CPR keyword has been temporarily
|
||||
disabled, suddenly decks with 'CPR' in the summary section turned
|
||||
up. Keywords with section aware keyword semantics is currently not
|
||||
handled by the parser.
|
||||
|
||||
When the CPR is added again the following keyword configuration must
|
||||
be added:
|
||||
|
||||
{"name" : "CPR" , "sections" : ["RUNSPEC"], "size": 1 }
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace Opm {
|
||||
|
||||
SimulationConfig::SimulationConfig(const Deck& deck,
|
||||
const Eclipse3DProperties& eclipseProperties) :
|
||||
m_ThresholdPressure( deck, eclipseProperties ),
|
||||
m_useCPR(false),
|
||||
m_DISGAS(false),
|
||||
m_VAPOIL(false)
|
||||
{
|
||||
if (Section::hasRUNSPEC(deck)) {
|
||||
const RUNSPECSection runspec(deck);
|
||||
if (runspec.hasKeyword<ParserKeywords::CPR>()) {
|
||||
const auto& cpr = runspec.getKeyword<ParserKeywords::CPR>();
|
||||
if (cpr.size() > 0)
|
||||
throw std::invalid_argument("ERROR: In the RUNSPEC section the CPR keyword should EXACTLY one empty record.");
|
||||
|
||||
m_useCPR = true;
|
||||
}
|
||||
if (runspec.hasKeyword<ParserKeywords::DISGAS>()) {
|
||||
m_DISGAS = true;
|
||||
}
|
||||
if (runspec.hasKeyword<ParserKeywords::VAPOIL>()) {
|
||||
m_VAPOIL = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ThresholdPressure& SimulationConfig::getThresholdPressure() const {
|
||||
return m_ThresholdPressure;
|
||||
}
|
||||
|
||||
bool SimulationConfig::hasThresholdPressure() const {
|
||||
return m_ThresholdPressure.size() > 0;
|
||||
}
|
||||
|
||||
bool SimulationConfig::useCPR() const {
|
||||
return m_useCPR;
|
||||
}
|
||||
|
||||
bool SimulationConfig::hasDISGAS() const {
|
||||
return m_DISGAS;
|
||||
}
|
||||
|
||||
bool SimulationConfig::hasVAPOIL() const {
|
||||
return m_VAPOIL;
|
||||
}
|
||||
|
||||
} //namespace Opm
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
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/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Section.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/R.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/V.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
ThresholdPressure::ThresholdPressure(const Deck& deck,
|
||||
const Eclipse3DProperties& eclipseProperties)
|
||||
{
|
||||
|
||||
if( !Section::hasRUNSPEC( deck ) || !Section::hasSOLUTION( deck ) )
|
||||
return;
|
||||
|
||||
RUNSPECSection runspecSection( deck );
|
||||
SOLUTIONSection solutionSection( deck );
|
||||
|
||||
bool thpresOption = false;
|
||||
const bool thpresKeyword = solutionSection.hasKeyword<ParserKeywords::THPRES>();
|
||||
const bool hasEqlnumKeyword = eclipseProperties.hasDeckIntGridProperty( "EQLNUM" );
|
||||
int maxEqlnum = 0;
|
||||
|
||||
//Is THPRES option set?
|
||||
if( runspecSection.hasKeyword<ParserKeywords::EQLOPTS>() ) {
|
||||
const auto& eqlopts = runspecSection.getKeyword<ParserKeywords::EQLOPTS>( );
|
||||
const auto& rec = eqlopts.getRecord(0);
|
||||
for( const auto& item : rec ) {
|
||||
if( !item.hasValue( 0 ) ) continue;
|
||||
|
||||
const auto& opt = item.get< std::string >( 0 );
|
||||
if( opt == "IRREVERS" )
|
||||
throw std::runtime_error("Cannot use IRREVERS version of THPRES option, not implemented");
|
||||
|
||||
if( opt == "THPRES" )
|
||||
thpresOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( thpresOption && !thpresKeyword ) {
|
||||
throw std::runtime_error("Invalid solution section; "
|
||||
"the EQLOPTS THPRES option is set in RUNSPEC, "
|
||||
"but no THPRES keyword is found in SOLUTION." );
|
||||
}
|
||||
|
||||
|
||||
//Option is set and keyword is found
|
||||
if( thpresOption && thpresKeyword ) {
|
||||
if( !hasEqlnumKeyword )
|
||||
throw std::runtime_error("Error when internalizing THPRES: EQLNUM keyword not found in deck");
|
||||
|
||||
//Find max of eqlnum
|
||||
const auto& eqlnumKeyword = eclipseProperties.getIntGridProperty( "EQLNUM" );
|
||||
const auto& eqlnum = eqlnumKeyword.getData();
|
||||
maxEqlnum = *std::max_element(eqlnum.begin(), eqlnum.end());
|
||||
|
||||
if (0 == maxEqlnum) {
|
||||
throw std::runtime_error("Error in EQLNUM data: all values are 0");
|
||||
}
|
||||
|
||||
|
||||
// Fill threshold pressure table.
|
||||
const auto& thpres = solutionSection.getKeyword<ParserKeywords::THPRES>( );
|
||||
|
||||
for( const auto& rec : thpres ) {
|
||||
const auto& region1Item = rec.getItem<ParserKeywords::THPRES::REGION1>();
|
||||
const auto& region2Item = rec.getItem<ParserKeywords::THPRES::REGION2>();
|
||||
const auto& thpressItem = rec.getItem<ParserKeywords::THPRES::VALUE>();
|
||||
|
||||
if( !region1Item.hasValue( 0 ) || !region2Item.hasValue( 0 ) )
|
||||
throw std::runtime_error("Missing region data for use of the THPRES keyword");
|
||||
|
||||
const int r1 = region1Item.get< int >(0);
|
||||
const int r2 = region2Item.get< int >(0);
|
||||
if (r1 > maxEqlnum || r2 > maxEqlnum) {
|
||||
throw std::runtime_error("Too high region numbers in THPRES keyword");
|
||||
}
|
||||
|
||||
if (thpressItem.hasValue(0)) {
|
||||
addBarrier( r1 , r2 , thpressItem.getSIDouble( 0 ) );
|
||||
} else
|
||||
addBarrier( r1 , r2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ThresholdPressure::hasRegionBarrier(int r1 , int r2) const {
|
||||
std::pair<int,int> indexPair = makeIndex(r1,r2);
|
||||
if (m_pressureTable.find( indexPair ) == m_pressureTable.end())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
double ThresholdPressure::getThresholdPressure(int r1 , int r2) const {
|
||||
std::pair<int,int> indexPair = makeIndex(r1,r2);
|
||||
auto iter = m_pressureTable.find( indexPair );
|
||||
if (iter == m_pressureTable.end())
|
||||
return 0.0;
|
||||
else {
|
||||
auto pair_pair = *iter;
|
||||
auto value_pair = pair_pair.second;
|
||||
bool valid = value_pair.first;
|
||||
double value = value_pair.second;
|
||||
if (valid)
|
||||
return value;
|
||||
else {
|
||||
std::string msg = "The THPRES value for regions " + std::to_string(r1) + " and " + std::to_string(r2) + " has not been initialized. Using 0.0";
|
||||
throw std::invalid_argument(msg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::pair<int,int> ThresholdPressure::makeIndex(int r1 , int r2) {
|
||||
if (r1 < r2)
|
||||
return std::make_pair(r1,r2);
|
||||
else
|
||||
return std::make_pair(r2,r1);
|
||||
}
|
||||
|
||||
void ThresholdPressure::addPair(int r1 , int r2 , const std::pair<bool , double>& valuePair) {
|
||||
std::pair<int,int> indexPair = makeIndex(r1,r2);
|
||||
m_pressureTable[indexPair] = valuePair;
|
||||
}
|
||||
|
||||
void ThresholdPressure::addBarrier(int r1 , int r2 , double p) {
|
||||
std::pair<bool,double> valuePair = std::make_pair(true , p);
|
||||
addPair( r1,r2, valuePair );
|
||||
}
|
||||
|
||||
void ThresholdPressure::addBarrier(int r1 , int r2) {
|
||||
std::pair<bool,double> valuePair = std::make_pair(false , 0);
|
||||
addPair( r1,r2, valuePair );
|
||||
}
|
||||
|
||||
size_t ThresholdPressure::size() const {
|
||||
return m_pressureTable.size();
|
||||
}
|
||||
|
||||
|
||||
bool ThresholdPressure::hasThresholdPressure(int r1 , int r2) const {
|
||||
std::pair<int,int> indexPair = makeIndex(r1,r2);
|
||||
auto iter = m_pressureTable.find( indexPair );
|
||||
if (iter == m_pressureTable.end())
|
||||
return false;
|
||||
else {
|
||||
auto pair_pair = *iter;
|
||||
auto value_pair = pair_pair.second;
|
||||
return value_pair.first;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} //namespace Opm
|
||||
@@ -1,4 +0,0 @@
|
||||
foreach(tapp ThresholdPressureTest SimulationConfigTest)
|
||||
opm_add_test(run${tapp} SOURCES ${tapp}.cpp
|
||||
LIBRARIES opmparser ${Boost_LIBRARIES})
|
||||
endforeach()
|
||||
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Section.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
const std::string& inputStr = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n"
|
||||
"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";
|
||||
|
||||
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";
|
||||
|
||||
const std::string& inputStr_cpr = "RUNSPEC\n"
|
||||
"CPR\n"
|
||||
"/\n"
|
||||
"SUMMARY\n";
|
||||
|
||||
|
||||
const std::string& inputStr_INVALID = "RUNSPEC\n"
|
||||
"CPR\n"
|
||||
"WEll 10 10 17/"
|
||||
"/\n"
|
||||
"SUMMARY\n";
|
||||
|
||||
|
||||
|
||||
const std::string& inputStr_cpr_in_SUMMARY = "SUMMARY\n"
|
||||
"CPR\n"
|
||||
"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";
|
||||
|
||||
const std::string& inputStr_vap_dis = "RUNSPEC\n"
|
||||
"VAPOIL\n"
|
||||
"DISGAS\n"
|
||||
"DIMENS\n"
|
||||
"10 3 4 /\n"
|
||||
"\n"
|
||||
"GRID\n"
|
||||
"REGIONS\n"
|
||||
"\n";
|
||||
|
||||
static Deck createDeck(const ParseContext& parseContext , const std::string& input) {
|
||||
Opm::Parser parser;
|
||||
return parser.parseString(input, parseContext);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigGetThresholdPressureTableTest) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext , inputStr);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
BOOST_CHECK_NO_THROW( SimulationConfig( deck, ep ) );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigNOTHPRES) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext, inputStr_noTHPRES);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
SimulationConfig simulationConfig(deck, ep);
|
||||
BOOST_CHECK( !simulationConfig.hasThresholdPressure() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRNotUsed) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext, inputStr_noTHPRES);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
SimulationConfig simulationConfig(deck, ep);
|
||||
BOOST_CHECK( ! simulationConfig.useCPR());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsed) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext, inputStr_cpr);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
SUMMARYSection summary(deck);
|
||||
SimulationConfig simulationConfig(deck, ep);
|
||||
BOOST_CHECK( simulationConfig.useCPR() );
|
||||
BOOST_CHECK( ! summary.hasKeyword("CPR") );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRInSUMMARYSection) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext, inputStr_cpr_in_SUMMARY);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
SUMMARYSection summary(deck);
|
||||
SimulationConfig simulationConfig(deck, ep);
|
||||
BOOST_CHECK( ! simulationConfig.useCPR());
|
||||
BOOST_CHECK( summary.hasKeyword("CPR"));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRBoth) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext, inputStr_cpr_BOTH);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
SUMMARYSection summary(deck);
|
||||
SimulationConfig simulationConfig(deck, ep);
|
||||
BOOST_CHECK( simulationConfig.useCPR());
|
||||
BOOST_CHECK( summary.hasKeyword("CPR"));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfigCPRRUnspecWithData) {
|
||||
ParseContext parseContext;
|
||||
BOOST_CHECK_THROW( createDeck(parseContext , inputStr_INVALID) , std::invalid_argument );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SimulationConfig_VAPOIL_DISGAS) {
|
||||
ParseContext parseContext;
|
||||
auto deck = createDeck(parseContext, inputStr);
|
||||
TableManager tm(deck);
|
||||
EclipseGrid eg(10, 3, 4);
|
||||
Eclipse3DProperties ep(deck, tm, eg);
|
||||
SimulationConfig simulationConfig(deck, ep);
|
||||
BOOST_CHECK_EQUAL( false , simulationConfig.hasDISGAS());
|
||||
BOOST_CHECK_EQUAL( false , simulationConfig.hasVAPOIL());
|
||||
|
||||
auto deck_vd = createDeck(parseContext, inputStr_vap_dis);
|
||||
TableManager tm_vd(deck_vd);
|
||||
EclipseGrid eg_vd(10, 3, 4);
|
||||
Eclipse3DProperties ep_vd(deck_vd, tm, eg);
|
||||
SimulationConfig simulationConfig_vd(deck_vd, ep_vd);
|
||||
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasDISGAS());
|
||||
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasVAPOIL());
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
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 <algorithm>
|
||||
|
||||
#define BOOST_TEST_MODULE ThresholdPressureTests
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
const std::string& inputStr = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"1 2 12.0/\n"
|
||||
"1 3 5.0/\n"
|
||||
"2 3 33.0 /\n"
|
||||
"2 3 7.0/\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
const std::string& inputStrWithEqlNum =
|
||||
"RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
"REGIONS\n"
|
||||
"EQLNUM\n"
|
||||
" 27*3 /\n"
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"1 2 12.0/\n"
|
||||
"1 3 5.0/\n"
|
||||
"2 3 33.0 /\n"
|
||||
"2 3 7.0/\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
|
||||
const std::string& inputStrWithEqlNumall0 =
|
||||
"RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
"REGIONS\n"
|
||||
"EQLNUM\n"
|
||||
" 27*0 /\n"
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"1 2 12.0/\n"
|
||||
"1 3 5.0/\n"
|
||||
"2 3 33.0 /\n"
|
||||
"2 3 7.0/\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
|
||||
const std::string& inputStrNoSolutionSection = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n";
|
||||
|
||||
|
||||
const std::string& inputStrNoTHPRESinSolutionNorRUNSPEC = "RUNSPEC\n"
|
||||
"\n"
|
||||
"SOLUTION\n"
|
||||
"\n"
|
||||
"SCHEDULE\n";
|
||||
|
||||
const std::string& inputStrTHPRESinRUNSPECnotSoultion = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"ss /\n "
|
||||
"\n"
|
||||
"SOLUTION\n"
|
||||
"\n";
|
||||
|
||||
|
||||
const std::string& inputStrIrrevers = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES IRREVERS/\n "
|
||||
"\n"
|
||||
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
const std::string& inputStrInconsistency = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
|
||||
"SOLUTION\n"
|
||||
"\n";
|
||||
|
||||
const std::string& inputStrTooHighRegionNumbers = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"1 2 12.0/\n"
|
||||
"4 3 5.0/\n"
|
||||
"2 3 7.0/\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
|
||||
const std::string& inputStrMissingData = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"1 2 12.0/\n"
|
||||
"2 3 5.0/\n"
|
||||
"1 /\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
|
||||
const std::string& inputStrMissingPressure = "RUNSPEC\n"
|
||||
"EQLOPTS\n"
|
||||
"THPRES /\n "
|
||||
"\n"
|
||||
"REGIONS\n"
|
||||
"EQLNUM\n"
|
||||
" 27*3 /\n"
|
||||
"SOLUTION\n"
|
||||
"THPRES\n"
|
||||
"1 2 12.0/\n"
|
||||
"2 3 5.0/\n"
|
||||
"2 3 /\n"
|
||||
"/\n"
|
||||
"\n";
|
||||
|
||||
static Deck createDeck(const ParseContext& parseContext, const std::string& input) {
|
||||
Opm::Parser parser;
|
||||
return parser.parseString(input, parseContext);
|
||||
}
|
||||
|
||||
/// Setup fixture
|
||||
struct Setup
|
||||
{
|
||||
ParseContext parseContext;
|
||||
Deck deck;
|
||||
TableManager tablemanager;
|
||||
EclipseGrid grid;
|
||||
Eclipse3DProperties props;
|
||||
ThresholdPressure threshPres;
|
||||
|
||||
explicit Setup(const std::string& input) :
|
||||
parseContext(),
|
||||
deck(createDeck(parseContext, input)),
|
||||
tablemanager(deck),
|
||||
grid(10, 3, 4),
|
||||
props(deck, tablemanager, grid),
|
||||
threshPres(deck, props)
|
||||
{
|
||||
}
|
||||
explicit Setup(const std::string& input, ParseContext& parseContextArg) :
|
||||
parseContext(), // not used
|
||||
deck(createDeck(parseContextArg, input)),
|
||||
tablemanager(deck),
|
||||
grid(10, 3, 4),
|
||||
props(deck, tablemanager, grid),
|
||||
threshPres(deck, props)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ThresholdPressureDeckHasEqlnum) {
|
||||
Setup s(inputStrWithEqlNum);
|
||||
|
||||
BOOST_CHECK(s.props.hasDeckIntGridProperty("EQLNUM"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ThresholdPressureTest) {
|
||||
Setup s(inputStrWithEqlNum);
|
||||
auto thp = s.threshPres;
|
||||
|
||||
BOOST_CHECK_EQUAL(thp.getThresholdPressure(1, 2), 1200000.0);
|
||||
BOOST_CHECK_EQUAL(thp.getThresholdPressure(2, 1), 1200000.0);
|
||||
BOOST_CHECK_EQUAL(thp.getThresholdPressure(1, 3), 500000.0);
|
||||
BOOST_CHECK_EQUAL(thp.getThresholdPressure(3, 1), 500000.0);
|
||||
BOOST_CHECK_EQUAL(thp.getThresholdPressure(2, 3), 700000.0);
|
||||
BOOST_CHECK_EQUAL(thp.getThresholdPressure(3, 2), 700000.0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ThresholdPressureEmptyTest) {
|
||||
Setup s(inputStrNoSolutionSection);
|
||||
BOOST_CHECK_EQUAL(0, s.threshPres.size());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ThresholdPressureNoTHPREStest) {
|
||||
Setup s(inputStrNoTHPRESinSolutionNorRUNSPEC);
|
||||
Setup s2(inputStrTHPRESinRUNSPECnotSoultion);
|
||||
|
||||
BOOST_CHECK_EQUAL(0, s.threshPres.size());
|
||||
BOOST_CHECK_EQUAL(0, s.threshPres.size());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ThresholdPressureThrowTest) {
|
||||
BOOST_CHECK_THROW(Setup sx(inputStrIrrevers), std::runtime_error);
|
||||
BOOST_CHECK_THROW(Setup sx(inputStrInconsistency), std::runtime_error);
|
||||
BOOST_CHECK_THROW(Setup sx(inputStrTooHighRegionNumbers), std::runtime_error);
|
||||
BOOST_CHECK_THROW(Setup sx(inputStrMissingData), std::runtime_error);
|
||||
BOOST_CHECK_THROW(Setup sx(inputStr), std::runtime_error);
|
||||
BOOST_CHECK_THROW(Setup sx(inputStrWithEqlNumall0), std::runtime_error);
|
||||
|
||||
BOOST_CHECK_THROW(Setup sx(inputStr), std::runtime_error);
|
||||
ParseContext pc;
|
||||
pc.update(ParseContext::UNSUPPORTED_INITIAL_THPRES, InputError::IGNORE);
|
||||
BOOST_CHECK_NO_THROW(Setup sx(inputStrMissingPressure, pc));
|
||||
|
||||
Setup s(inputStrMissingPressure, pc);
|
||||
BOOST_CHECK( s.threshPres.hasRegionBarrier(2, 3));
|
||||
BOOST_CHECK(!s.threshPres.hasThresholdPressure(2, 3));
|
||||
|
||||
pc.update(ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES, InputError::THROW_EXCEPTION);
|
||||
BOOST_CHECK_THROW(s.threshPres.getThresholdPressure(2, 3), std::invalid_argument);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(HasPair) {
|
||||
Setup s(inputStrWithEqlNum);
|
||||
|
||||
BOOST_CHECK( s.threshPres.hasRegionBarrier(1, 2));
|
||||
BOOST_CHECK(!s.threshPres.hasRegionBarrier(1, 7));
|
||||
BOOST_CHECK( s.threshPres.hasThresholdPressure(1, 2));
|
||||
BOOST_CHECK(!s.threshPres.hasThresholdPressure(1, 7));
|
||||
BOOST_CHECK_EQUAL(1200000.0, s.threshPres.getThresholdPressure(1, 2));
|
||||
}
|
||||
Reference in New Issue
Block a user