mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#743) Updated opm-parser with support for missing include files
This commit is contained in:
parent
27f6b980fe
commit
eb6d3e0e8f
@ -20,10 +20,10 @@ TEST(OpmParserTest, ReadFromFile)
|
||||
/*
|
||||
std::string filename = "d:/Models/MRST/simple/SIMPLE.DATA";
|
||||
std::string filename = "d:/gitroot/opm-data/spe1/SPE1CASE1.DATA";
|
||||
std::string filename = "d:/Models/Statoil/Brillig/BRILLIG.DATA";
|
||||
std::string filename = "d:/gitroot-magnesj/opm-parser/testdata/cases_with_issues/testcase_juli_2011/TEST10K_FLT_LGR_NNC.DATA";
|
||||
std::string filename = "d:/gitroot-magnesj/opm-parser/testdata/cases_with_issues/testcase_juli_2011/TEST10K_FLT_LGR_NNC.DATA";
|
||||
*/
|
||||
std::string filename = "d:/gitroot-magnesj/opm-parser/testdata/cases_with_issues/testcase_juli_2011/TEST10K_FLT_LGR_NNC.DATA";
|
||||
std::string filename = "d:/Models/Statoil/Brillig/BRILLIG.DATA";
|
||||
|
||||
/*
|
||||
std::string filename = "d:/Models/Statoil/1.2.0_Osesyd_segfault/BASEPRED6.DATA";
|
||||
@ -66,27 +66,6 @@ TEST(OpmParserTest, ReadFromFile)
|
||||
// GRDECL files
|
||||
//std::string filename = "d:/Models/Statoil/no_map_axis/geocell.grdecl";
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
}
|
||||
catch (CException* e)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
const char * deck =
|
||||
"OPERATE\n"
|
||||
"SWL 6* MULTX PERMX 1.E10 / Temp: SWL=1.E10*PERMX\n"
|
||||
"SWL 6* MINLIM SWL 1.0 /\n"
|
||||
"SWL 6* LOG10 SWL / Temp: SWL=log(1.E10*PERMX)\n"
|
||||
"SWL 6* MULTA SWL -0.06 0.91 / Final: SWL=0.31-0.06*log(PERMX)\n"
|
||||
"--SWCR 6* COPY SWL / SWCR=SWL\n"
|
||||
"SWCR 6* MULTA SWL 1.0 0.0 / SWCR=SWL+0.0 (+0.3)\n"
|
||||
"SWCR 6* MAXLIM SWCR 0.7 / max(SWCR)=0.7\n"
|
||||
"SGU 6* MULTA SWL -1.0 1.0 / SGU=1-SWL\n"
|
||||
"/\n";
|
||||
|
||||
//ParseContext parseContext;
|
||||
//parseContext.update(InputError::WARN);
|
||||
@ -97,12 +76,13 @@ TEST(OpmParserTest, ReadFromFile)
|
||||
ParseContext parseContext;
|
||||
Parser parser;
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::THROW_EXCEPTION);
|
||||
//BOOST_CHECK_THROW(parser.parseString(deck, parseContext), std::invalid_argument);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH, InputError::IGNORE);
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE);
|
||||
parser.parseString(deck, parseContext);
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::WARN);
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH, InputError::WARN);
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT, InputError::WARN);
|
||||
parseContext.update(ParseContext::PARSE_MISSING_INCLUDE, InputError::WARN);
|
||||
|
||||
//parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE);
|
||||
//parser.parseString(deck, parseContext);
|
||||
//BOOST_CHECK_NO_THROW(parser.parseString(deck, parseContext));
|
||||
|
||||
/*
|
||||
@ -117,11 +97,8 @@ TEST(OpmParserTest, ReadFromFile)
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Parser parser;
|
||||
const auto deck = parser.newDeckFromFile(filename, Opm::ParseContext());
|
||||
const auto deck = parser.parseFile(filename, parseContext);
|
||||
const auto grid = Parser::parseGrid(*deck);
|
||||
*/
|
||||
|
||||
/*
|
||||
{
|
||||
@ -152,39 +129,4 @@ TEST(OpmParserTest, ReadFromFile)
|
||||
//BOOST_CHECK_EQUAL("untitled", deck->getKeyword("TITLE").getStringData().front());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
//std::string wellName = "C:/dev/projects/ResInsight/GitHub/NRWellProject/well_UnitTests/Bean_A.las";
|
||||
|
||||
std::string wellName = "d:/Models/LAS Files/D-D' LAS Files/Bean/Bean_A.las";
|
||||
|
||||
int wellFormat = NRLib::Well::LAS;
|
||||
NRLib::Well* well = NRLib::Well::ReadWell(wellName, wellFormat);
|
||||
|
||||
std::cout << "Well name : " << well->GetWellName() << "\n";
|
||||
|
||||
std::cout << "Total number of logs : " << well->GetNlog() << "\n";
|
||||
|
||||
const std::map<std::string, std::vector<double> >& continuousLogs = well->GetContLog();
|
||||
|
||||
std::cout << "Continuous log names : " << "\n";
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::map<std::string, std::vector<double> >::const_iterator it;
|
||||
for (it = continuousLogs.begin(); it != continuousLogs.end(); it++)
|
||||
{
|
||||
std::cout << " " << it->first << "data value count : " << it->second.size() << "\n";
|
||||
names.push_back(it->first);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 20; i++)
|
||||
{
|
||||
for (size_t n = 0; n < names.size(); n++)
|
||||
{
|
||||
std::cout << "\t" << continuousLogs.at(names[n])[i];
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -5936,6 +5936,91 @@ OLDTRAN::OLDTRAN( ) : ParserKeyword("OLDTRAN") {
|
||||
const std::string OLDTRAN::keywordName = "OLDTRAN";
|
||||
|
||||
|
||||
OPERATE::OPERATE( ) : ParserKeyword("OPERATE") {
|
||||
setSizeType(SLASH_TERMINATED);
|
||||
setDescription("");
|
||||
clearValidSectionNames();
|
||||
addValidSectionName("EDIT");
|
||||
addValidSectionName("GRID");
|
||||
addValidSectionName("PROPS");
|
||||
addValidSectionName("REGIONS");
|
||||
addValidSectionName("SOLUTION");
|
||||
clearDeckNames();
|
||||
addDeckName("OPERATE");
|
||||
{
|
||||
std::shared_ptr<ParserRecord> record = std::make_shared<ParserRecord>();
|
||||
{
|
||||
ParserItemPtr item(new ParserStringItem("RESULT_ARRAY",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserIntItem("I1",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserIntItem("I2",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserIntItem("J1",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserIntItem("J2",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserIntItem("K1",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserIntItem("K2",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserStringItem("OPERATION",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserStringItem("ARRAY_ARG",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserDoubleItem("PARAM1",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
{
|
||||
ParserItemPtr item(new ParserDoubleItem("PARAM2",Opm::SINGLE));
|
||||
item->setDescription("");
|
||||
record->addItem(item);
|
||||
}
|
||||
addRecord( record );
|
||||
}
|
||||
}
|
||||
const std::string OPERATE::keywordName = "OPERATE";
|
||||
const std::string OPERATE::RESULT_ARRAY::itemName = "RESULT_ARRAY";
|
||||
const std::string OPERATE::I1::itemName = "I1";
|
||||
const std::string OPERATE::I2::itemName = "I2";
|
||||
const std::string OPERATE::J1::itemName = "J1";
|
||||
const std::string OPERATE::J2::itemName = "J2";
|
||||
const std::string OPERATE::K1::itemName = "K1";
|
||||
const std::string OPERATE::K2::itemName = "K2";
|
||||
const std::string OPERATE::OPERATION::itemName = "OPERATION";
|
||||
const std::string OPERATE::ARRAY_ARG::itemName = "ARRAY_ARG";
|
||||
const std::string OPERATE::PARAM1::itemName = "PARAM1";
|
||||
const std::string OPERATE::PARAM2::itemName = "PARAM2";
|
||||
|
||||
|
||||
OPTIONS::OPTIONS( ) : ParserKeyword("OPTIONS") {
|
||||
setFixedSize( (size_t) 1);
|
||||
setDescription("");
|
||||
|
@ -96,4 +96,5 @@ p.addKeyword< ParserKeywords::GECON >();
|
||||
p.addKeyword< ParserKeywords::GEFAC >();
|
||||
p.addKeyword< ParserKeywords::GRID >();
|
||||
p.addKeyword< ParserKeywords::GRIDFILE >();
|
||||
p.addKeyword< ParserKeywords::GRIDOPTS >();
|
||||
}}}
|
||||
|
@ -13,7 +13,6 @@ namespace ParserKeywords {
|
||||
|
||||
|
||||
void addDefaultKeywords1(Parser& p) {
|
||||
p.addKeyword< ParserKeywords::GRIDOPTS >();
|
||||
p.addKeyword< ParserKeywords::GRIDUNIT >();
|
||||
p.addKeyword< ParserKeywords::GROUP_PROBE >();
|
||||
p.addKeyword< ParserKeywords::GRUPNET >();
|
||||
@ -82,6 +81,7 @@ p.addKeyword< ParserKeywords::OILMW >();
|
||||
p.addKeyword< ParserKeywords::OILVISCT >();
|
||||
p.addKeyword< ParserKeywords::OILVTIM >();
|
||||
p.addKeyword< ParserKeywords::OLDTRAN >();
|
||||
p.addKeyword< ParserKeywords::OPERATE >();
|
||||
p.addKeyword< ParserKeywords::OPTIONS >();
|
||||
p.addKeyword< ParserKeywords::PARALLEL >();
|
||||
p.addKeyword< ParserKeywords::PATHS >();
|
||||
@ -96,4 +96,5 @@ p.addKeyword< ParserKeywords::PERMZ >();
|
||||
p.addKeyword< ParserKeywords::PERMZX >();
|
||||
p.addKeyword< ParserKeywords::PIMTDIMS >();
|
||||
p.addKeyword< ParserKeywords::PIMULTAB >();
|
||||
p.addKeyword< ParserKeywords::PINCH >();
|
||||
}}}
|
||||
|
@ -13,7 +13,6 @@ namespace ParserKeywords {
|
||||
|
||||
|
||||
void addDefaultKeywords2(Parser& p) {
|
||||
p.addKeyword< ParserKeywords::PINCH >();
|
||||
p.addKeyword< ParserKeywords::PLMIXPAR >();
|
||||
p.addKeyword< ParserKeywords::PLYADS >();
|
||||
p.addKeyword< ParserKeywords::PLYADSS >();
|
||||
@ -96,4 +95,6 @@ p.addKeyword< ParserKeywords::SORWMIS >();
|
||||
p.addKeyword< ParserKeywords::SOWCR >();
|
||||
p.addKeyword< ParserKeywords::SPECGRID >();
|
||||
p.addKeyword< ParserKeywords::SPECHEAT >();
|
||||
p.addKeyword< ParserKeywords::SPECROCK >();
|
||||
p.addKeyword< ParserKeywords::SSFN >();
|
||||
}}}
|
||||
|
@ -13,8 +13,6 @@ namespace ParserKeywords {
|
||||
|
||||
|
||||
void addDefaultKeywords3(Parser& p) {
|
||||
p.addKeyword< ParserKeywords::SPECROCK >();
|
||||
p.addKeyword< ParserKeywords::SSFN >();
|
||||
p.addKeyword< ParserKeywords::SSOL >();
|
||||
p.addKeyword< ParserKeywords::START >();
|
||||
p.addKeyword< ParserKeywords::STCOND >();
|
||||
|
@ -98,6 +98,69 @@ namespace ParserKeywords {
|
||||
|
||||
|
||||
|
||||
class OPERATE : public ParserKeyword {
|
||||
public:
|
||||
OPERATE();
|
||||
static const std::string keywordName;
|
||||
|
||||
class RESULT_ARRAY {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class I1 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class I2 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class J1 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class J2 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class K1 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class K2 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class OPERATION {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class ARRAY_ARG {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class PARAM1 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
|
||||
class PARAM2 {
|
||||
public:
|
||||
static const std::string itemName;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
class OPTIONS : public ParserKeyword {
|
||||
public:
|
||||
OPTIONS();
|
||||
|
@ -2901,6 +2901,25 @@ BOOST_AUTO_TEST_CASE(TESTOLDTRANKeyword) {
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TESTOPERATEKeyword) {
|
||||
std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/O/OPERATE";
|
||||
boost::filesystem::path jsonPath( jsonFile );
|
||||
Json::JsonObject jsonConfig( jsonPath );
|
||||
ParserKeyword jsonKeyword(jsonConfig);
|
||||
ParserKeywords::OPERATE inlineKeyword;
|
||||
BOOST_CHECK( jsonKeyword.equal( inlineKeyword ));
|
||||
if (jsonKeyword.hasDimension()) {
|
||||
ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0);
|
||||
for (size_t i=0; i < parserRecord->size(); i++){
|
||||
ParserItemConstPtr item = parserRecord->get( i );
|
||||
for (size_t j=0; j < item->numDimensions(); j++) {
|
||||
std::string dimString = item->getDimension(j);
|
||||
BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TESTOPTIONSKeyword) {
|
||||
std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/O/OPTIONS";
|
||||
boost::filesystem::path jsonPath( jsonFile );
|
||||
|
@ -61,6 +61,7 @@ endif()
|
||||
include(UseMultiArch)
|
||||
include(OpmSatellites)
|
||||
include(UseWarnings)
|
||||
include(cmake/build_check.cmake)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# This is modified copy & paste from the OpmDefaults.cmake module.
|
||||
@ -113,6 +114,7 @@ find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_frame
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
include_directories(BEFORE ${PROJECT_SOURCE_DIR})
|
||||
include_directories(${PROJECT_BINARY_DIR})
|
||||
|
||||
# if we are using dynamic boost, the header file must generate a main() function
|
||||
if (NOT Boost_USE_STATIC_LIBS)
|
||||
|
13
ThirdParty/custom-opm-parser/opm-parser/cmake/build_check.cmake
vendored
Normal file
13
ThirdParty/custom-opm-parser/opm-parser/cmake/build_check.cmake
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# This file contains checks which are used to implement portable
|
||||
# utility functions. The results of these check are assembled in the
|
||||
# generated header "opm_parser_build_config.hpp" - that header is NOT part
|
||||
# of the public api and it should only be included from source files
|
||||
# as part of the compilation.
|
||||
|
||||
include( CheckFunctionExists )
|
||||
|
||||
|
||||
check_function_exists( symlink OPM_PARSER_BUILD_HAVE_SYMLINK )
|
||||
|
||||
|
||||
configure_file( ${PROJECT_SOURCE_DIR}/cmake/config/opm_parser_build_config.hpp.in ${PROJECT_BINARY_DIR}/opm_parser_build_config.hpp)
|
7
ThirdParty/custom-opm-parser/opm-parser/cmake/config/opm_parser_build_config.hpp.in
vendored
Normal file
7
ThirdParty/custom-opm-parser/opm-parser/cmake/config/opm_parser_build_config.hpp.in
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// This file contains #define symols which come from feature tests
|
||||
// during the configure phase. This file should not be part of the
|
||||
// public api of opm-parser, and it should *only* be included in .cpp
|
||||
// files.
|
||||
|
||||
#cmakedefine OPM_PARSER_BUILD_HAVE_SYMLINK
|
||||
|
@ -1,23 +1,23 @@
|
||||
include_directories(BEFORE ${PROJECT_BINARY_DIR}/generated-source/include)
|
||||
|
||||
add_subdirectory(Parser/tests)
|
||||
add_subdirectory(Generator/tests)
|
||||
add_subdirectory(RawDeck/tests)
|
||||
add_subdirectory(Deck/tests)
|
||||
add_subdirectory(Units/tests)
|
||||
add_subdirectory(EclipseState/tests)
|
||||
add_subdirectory(EclipseState/Schedule/tests)
|
||||
add_subdirectory(EclipseState/SimulationConfig/tests)
|
||||
add_subdirectory(EclipseState/Tables/tests)
|
||||
add_subdirectory(EclipseState/Grid/tests)
|
||||
add_subdirectory(EclipseState/Util/tests)
|
||||
add_subdirectory(EclipseState/IOConfig/tests)
|
||||
add_subdirectory(EclipseState/InitConfig/tests)
|
||||
add_subdirectory(EclipseState/SummaryConfig/tests)
|
||||
add_subdirectory(Utility/tests)
|
||||
#add_subdirectory(Generator/tests)
|
||||
#add_subdirectory(RawDeck/tests)
|
||||
#add_subdirectory(Deck/tests)
|
||||
#add_subdirectory(Units/tests)
|
||||
#add_subdirectory(EclipseState/tests)
|
||||
#add_subdirectory(EclipseState/Schedule/tests)
|
||||
#add_subdirectory(EclipseState/SimulationConfig/tests)
|
||||
#add_subdirectory(EclipseState/Tables/tests)
|
||||
#add_subdirectory(EclipseState/Grid/tests)
|
||||
#add_subdirectory(EclipseState/Util/tests)
|
||||
#add_subdirectory(EclipseState/IOConfig/tests)
|
||||
#add_subdirectory(EclipseState/InitConfig/tests)
|
||||
#add_subdirectory(EclipseState/SummaryConfig/tests)
|
||||
#add_subdirectory(Utility/tests)
|
||||
|
||||
add_subdirectory(Applications)
|
||||
add_subdirectory(IntegrationTests)
|
||||
#add_subdirectory(Applications)
|
||||
#add_subdirectory(IntegrationTests)
|
||||
|
||||
set( rawdeck_source
|
||||
RawDeck/StarToken.cpp
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
@ -34,10 +35,9 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
#include <opm/parser/eclipse/Units/Dimension.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Utility/String.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
namespace GridPropertyPostProcessor {
|
||||
|
||||
void distTopLayer( std::vector<double>& values,
|
||||
@ -107,7 +107,6 @@ namespace Opm {
|
||||
*/
|
||||
|
||||
void ACTNUMPostProcessor( std::vector<int>& values,
|
||||
const EclipseGrid* eclipseGrid,
|
||||
const GridProperties<double>* doubleGridProperties)
|
||||
{
|
||||
const bool hasPORV = doubleGridProperties->hasKeyword( "PORV" ) || doubleGridProperties->hasKeyword( "PORO");
|
||||
@ -411,7 +410,6 @@ namespace Opm {
|
||||
{
|
||||
auto actnumPP = std::bind(&GridPropertyPostProcessor::ACTNUMPostProcessor,
|
||||
std::placeholders::_1,
|
||||
&eclipseGrid,
|
||||
&m_doubleGridProperties);
|
||||
|
||||
m_intGridProperties.postAddKeyword( "ACTNUM",
|
||||
@ -424,28 +422,32 @@ namespace Opm {
|
||||
}
|
||||
|
||||
bool Eclipse3DProperties::supportsGridProperty(const std::string& keyword) const {
|
||||
return m_doubleGridProperties.supportsKeyword( keyword ) || m_intGridProperties.supportsKeyword( keyword );
|
||||
auto kw = uppercase(keyword);
|
||||
return m_doubleGridProperties.supportsKeyword( kw ) || m_intGridProperties.supportsKeyword( kw );
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Eclipse3DProperties::hasDeckIntGridProperty(const std::string& keyword) const {
|
||||
if (!m_intGridProperties.supportsKeyword( keyword ))
|
||||
throw std::logic_error("Integer grid property " + keyword + " is unsupported!");
|
||||
auto kw = uppercase(keyword);
|
||||
if (!m_intGridProperties.supportsKeyword( kw ))
|
||||
throw std::logic_error("Integer grid property " + kw + " is unsupported!");
|
||||
|
||||
return m_intGridProperties.hasKeyword( keyword );
|
||||
return m_intGridProperties.hasKeyword( kw );
|
||||
}
|
||||
|
||||
bool Eclipse3DProperties::hasDeckDoubleGridProperty(const std::string& keyword) const {
|
||||
if (!m_doubleGridProperties.supportsKeyword( keyword ))
|
||||
throw std::logic_error("Double grid property " + keyword + " is unsupported!");
|
||||
auto kw = uppercase(keyword);
|
||||
if (!m_doubleGridProperties.supportsKeyword( kw ))
|
||||
throw std::logic_error("Double grid property " + kw + " is unsupported!");
|
||||
|
||||
return m_doubleGridProperties.hasKeyword( keyword );
|
||||
return m_doubleGridProperties.hasKeyword( kw );
|
||||
}
|
||||
|
||||
|
||||
const GridProperty<int>& Eclipse3DProperties::getIntGridProperty( const std::string& keyword ) const {
|
||||
auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_intGridProperties.getKeyword( keyword );
|
||||
auto kw = uppercase(keyword);
|
||||
auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_intGridProperties.getKeyword( kw );
|
||||
gridProperty.runPostProcessor();
|
||||
return gridProperty;
|
||||
}
|
||||
@ -454,7 +456,8 @@ namespace Opm {
|
||||
|
||||
/// gets property from doubleGridProperty --- and calls the runPostProcessor
|
||||
const GridProperty<double>& Eclipse3DProperties::getDoubleGridProperty( const std::string& keyword ) const {
|
||||
auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_doubleGridProperties.getKeyword( keyword );
|
||||
auto kw = uppercase(keyword);
|
||||
auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_doubleGridProperties.getKeyword( kw );
|
||||
gridProperty.runPostProcessor();
|
||||
return gridProperty;
|
||||
}
|
||||
@ -472,7 +475,8 @@ namespace Opm {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector< int > Eclipse3DProperties::getRegions( const std::string& kw ) const {
|
||||
std::vector< int > Eclipse3DProperties::getRegions( const std::string& keyword ) const {
|
||||
auto kw = uppercase(keyword);
|
||||
if( !this->hasDeckIntGridProperty( kw ) ) return {};
|
||||
|
||||
const auto& property = this->getIntGridProperty( kw );
|
||||
@ -704,7 +708,7 @@ namespace Opm {
|
||||
|
||||
void Eclipse3DProperties::handleADDREGKeyword( const DeckKeyword& deckKeyword) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
|
||||
const std::string targetArray = uppercase(record.getItem("ARRAY").get< std::string >(0));
|
||||
const auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
|
||||
if (m_intGridProperties.hasKeyword( targetArray ))
|
||||
@ -720,7 +724,7 @@ namespace Opm {
|
||||
|
||||
void Eclipse3DProperties::handleMULTIREGKeyword( const DeckKeyword& deckKeyword) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
|
||||
const std::string targetArray = uppercase(record.getItem("ARRAY").get< std::string >(0));
|
||||
const auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
|
||||
if (m_intGridProperties.supportsKeyword( targetArray ))
|
||||
@ -735,7 +739,7 @@ namespace Opm {
|
||||
|
||||
void Eclipse3DProperties::handleCOPYREGKeyword( const DeckKeyword& deckKeyword) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& srcArray = record.getItem("ARRAY").get< std::string >(0);
|
||||
const std::string srcArray = uppercase(record.getItem("ARRAY").get< std::string >(0));
|
||||
const auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
|
||||
|
||||
if (m_intGridProperties.hasKeyword( srcArray ))
|
||||
@ -752,7 +756,7 @@ namespace Opm {
|
||||
|
||||
void Eclipse3DProperties::handleMULTIPLYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& field = record.getItem("field").get< std::string >(0);
|
||||
const std::string field = uppercase(record.getItem("field").get< std::string >(0));
|
||||
|
||||
if (m_doubleGridProperties.hasKeyword( field ))
|
||||
m_doubleGridProperties.handleMULTIPLYRecord( record , boxManager );
|
||||
@ -772,7 +776,7 @@ namespace Opm {
|
||||
*/
|
||||
void Eclipse3DProperties::handleADDKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& field = record.getItem("field").get< std::string >(0);
|
||||
const std::string field = uppercase(record.getItem("field").get< std::string >(0));
|
||||
|
||||
if (m_doubleGridProperties.hasKeyword( field ))
|
||||
m_doubleGridProperties.handleADDRecord( record , boxManager );
|
||||
@ -787,7 +791,7 @@ namespace Opm {
|
||||
|
||||
void Eclipse3DProperties::handleCOPYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& field = record.getItem("src").get< std::string >(0);
|
||||
const std::string field = uppercase(record.getItem("src").get< std::string >(0));
|
||||
|
||||
if (m_doubleGridProperties.hasKeyword( field ))
|
||||
m_doubleGridProperties.handleCOPYRecord( record , boxManager );
|
||||
@ -802,7 +806,7 @@ namespace Opm {
|
||||
|
||||
void Eclipse3DProperties::handleEQUALSKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) {
|
||||
for( const auto& record : deckKeyword ) {
|
||||
const std::string& field = record.getItem("field").get< std::string >(0);
|
||||
const std::string field = uppercase(record.getItem("field").get< std::string >(0));
|
||||
|
||||
if (m_doubleGridProperties.supportsKeyword( field ))
|
||||
m_doubleGridProperties.handleEQUALSRecord( record , boxManager );
|
||||
|
@ -29,12 +29,10 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
EclipseConfig::EclipseConfig(const Deck& deck,
|
||||
const ParseContext& parseContext,
|
||||
const Eclipse3DProperties& eclipse3DProperties,
|
||||
std::shared_ptr< EclipseGrid > inputGrid,
|
||||
const Schedule& schedule) :
|
||||
|
@ -30,7 +30,6 @@ namespace Opm {
|
||||
class Eclipse3DProperties;
|
||||
class IOConfig;
|
||||
class InitConfig;
|
||||
class ParseContext;
|
||||
class SimulationConfig;
|
||||
|
||||
|
||||
@ -38,7 +37,6 @@ namespace Opm {
|
||||
{
|
||||
public:
|
||||
EclipseConfig(const Deck& deck,
|
||||
const ParseContext& parseContext,
|
||||
const Eclipse3DProperties& eclipse3DProperties,
|
||||
std::shared_ptr< EclipseGrid > inputGrid,
|
||||
const Schedule& schedule);
|
||||
|
@ -59,7 +59,7 @@ namespace Opm {
|
||||
m_inputGrid( std::make_shared<EclipseGrid>(deck, nullptr) ),
|
||||
m_schedule( std::make_shared<Schedule>( m_parseContext, m_inputGrid, deck ) ),
|
||||
m_eclipseProperties( deck, m_tables, *m_inputGrid ),
|
||||
m_eclipseConfig( deck, m_parseContext, m_eclipseProperties, m_inputGrid, *m_schedule),
|
||||
m_eclipseConfig( deck, m_eclipseProperties, m_inputGrid, *m_schedule),
|
||||
m_inputNnc( deck, m_inputGrid ),
|
||||
m_deckUnitSystem( deck.getActiveUnitSystem() )
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
|
||||
#include <opm/parser/eclipse/Utility/String.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -59,6 +60,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
double GridProperties<double>::convertInputValue( double doubleValue) const {
|
||||
return doubleValue;
|
||||
@ -74,11 +76,12 @@ namespace Opm {
|
||||
}
|
||||
|
||||
template<>
|
||||
int GridProperties<int>::convertInputValue(const GridProperty<int>& property, double doubleValue) const {
|
||||
int GridProperties<int>::convertInputValue(const GridProperty<int>& /* property */, double doubleValue) const {
|
||||
return convertInputValue(doubleValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setKeywordBox( const DeckRecord& deckRecord,
|
||||
BoxManager& boxManager) {
|
||||
const auto& I1Item = deckRecord.getItem("I1");
|
||||
@ -143,10 +146,12 @@ namespace Opm {
|
||||
|
||||
template< typename T >
|
||||
bool GridProperties<T>::hasKeyword(const std::string& keyword) const {
|
||||
const auto cnt = m_properties.count( keyword );
|
||||
const std::string kw = uppercase(keyword);
|
||||
|
||||
const auto cnt = m_properties.count( kw );
|
||||
const bool positive = cnt > 0;
|
||||
|
||||
return positive && !isAutoGenerated_(keyword);
|
||||
return positive && !isAutoGenerated_(kw);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
@ -157,10 +162,12 @@ namespace Opm {
|
||||
|
||||
template< typename T >
|
||||
const GridProperty<T>& GridProperties<T>::getKeyword(const std::string& keyword) const {
|
||||
if (!hasKeyword(keyword))
|
||||
addAutoGeneratedKeyword_(keyword);
|
||||
const std::string kw = uppercase(keyword);
|
||||
|
||||
GridProperty<T>& property = (*m_properties.at( keyword ));
|
||||
if (!hasKeyword(kw))
|
||||
addAutoGeneratedKeyword_(kw);
|
||||
|
||||
GridProperty<T>& property = (*m_properties.at( kw ));
|
||||
property.runPostProcessor( );
|
||||
return property;
|
||||
}
|
||||
@ -169,43 +176,46 @@ namespace Opm {
|
||||
|
||||
template< typename T >
|
||||
const GridProperty<T>& GridProperties<T>::getInitializedKeyword(const std::string& keyword) const {
|
||||
if (hasKeyword(keyword))
|
||||
return *m_properties.at( keyword );
|
||||
const std::string kw = uppercase(keyword);
|
||||
if (hasKeyword(kw))
|
||||
return *m_properties.at( kw );
|
||||
else {
|
||||
if (supportsKeyword(keyword))
|
||||
throw std::invalid_argument("Keyword: " + keyword + " is supported - but not initialized.");
|
||||
if (supportsKeyword(kw))
|
||||
throw std::invalid_argument("Keyword: " + kw + " is supported - but not initialized.");
|
||||
else
|
||||
throw std::invalid_argument("Keyword: " + keyword + " is not supported.");
|
||||
throw std::invalid_argument("Keyword: " + kw + " is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< typename T >
|
||||
bool GridProperties<T>::addKeyword(const std::string& keywordName) {
|
||||
if (!supportsKeyword( keywordName ))
|
||||
throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container");
|
||||
const std::string kw = uppercase(keywordName);
|
||||
|
||||
if (hasKeyword(keywordName))
|
||||
if (!supportsKeyword( kw ))
|
||||
throw std::invalid_argument("The keyword: " + kw + " is not supported in this container");
|
||||
|
||||
if (hasKeyword(kw))
|
||||
return false;
|
||||
else {
|
||||
// if the property was already added auto generated, we just need to make it
|
||||
// non-auto generated
|
||||
if (m_autoGeneratedProperties.count(keywordName)) {
|
||||
m_messages.warning("The keyword "+keywordName+" has been used to calculate the "
|
||||
if (m_autoGeneratedProperties.count(kw)) {
|
||||
m_messages.warning("The keyword "+kw+" has been used to calculate the "
|
||||
"defaults of another keyword before the first time it was "
|
||||
"explicitly mentioned in the deck. Maybe you need to change "
|
||||
"the ordering of your keywords (move "+keywordName+" to the front?).");
|
||||
m_autoGeneratedProperties.erase(m_autoGeneratedProperties.find(keywordName));
|
||||
"the ordering of your keywords (move "+kw+" to the front?).");
|
||||
m_autoGeneratedProperties.erase(m_autoGeneratedProperties.find(kw));
|
||||
return true;
|
||||
}
|
||||
|
||||
auto supportedKeyword = m_supportedKeywords.at( keywordName );
|
||||
auto supportedKeyword = m_supportedKeywords.at( kw );
|
||||
int nx = m_eclipseGrid.getNX();
|
||||
int ny = m_eclipseGrid.getNY();
|
||||
int nz = m_eclipseGrid.getNZ();
|
||||
std::shared_ptr<GridProperty<T> > newProperty(new GridProperty<T>(nx , ny , nz , supportedKeyword));
|
||||
|
||||
m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<T> > > ( keywordName , newProperty ));
|
||||
m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<T> > > ( kw , newProperty ));
|
||||
m_property_list.push_back( newProperty );
|
||||
return true;
|
||||
}
|
||||
@ -227,10 +237,11 @@ namespace Opm {
|
||||
|
||||
template< typename T >
|
||||
GridProperty<T>& GridProperties<T>::getOrCreateProperty(const std::string name) {
|
||||
if (!hasKeyword(name)) {
|
||||
addKeyword(name);
|
||||
const std::string kw = uppercase(name);
|
||||
if (!hasKeyword(kw)) {
|
||||
addKeyword(kw);
|
||||
}
|
||||
return getKeyword(name);
|
||||
return getKeyword(kw);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -382,10 +393,12 @@ namespace Opm {
|
||||
|
||||
template< typename T >
|
||||
GridProperty<T>& GridProperties<T>::getKeyword(const std::string& keyword) {
|
||||
if (!hasKeyword(keyword))
|
||||
addAutoGeneratedKeyword_(keyword);
|
||||
const std::string kw = uppercase(keyword);
|
||||
|
||||
return *m_properties.at( keyword );
|
||||
if (!hasKeyword(kw))
|
||||
addAutoGeneratedKeyword_(kw);
|
||||
|
||||
return *m_properties.at( kw );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
|
@ -344,7 +344,7 @@ namespace Opm {
|
||||
for (size_t g=0; g < m_data.size(); g++) {
|
||||
T value = m_data[g];
|
||||
if ((value < min) || (value > max))
|
||||
throw std::invalid_argument("Property element outside valid limits");
|
||||
throw std::invalid_argument("Property element " + std::to_string( value) + " in " + getKeywordName() + " outside valid limits: [" + std::to_string(min) + ", " + std::to_string(max) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,12 +257,9 @@ namespace Opm {
|
||||
* this->keywords = fun::concat( fun::map( handler, section ) );
|
||||
* The following code is a workaround for this compiler bug */
|
||||
for (auto& x : section)
|
||||
{
|
||||
auto keywords = handler(x);
|
||||
for (auto& keyword : keywords)
|
||||
{
|
||||
for (auto& keyword : handler(x))
|
||||
this->keywords.push_back(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,9 +393,10 @@ void VFPProdTable::check(const DeckKeyword& keyword, const double table_scaling_
|
||||
+ std::string("monotonically increasing.\nThis may cause convergence ")
|
||||
+ "issues due to switching between BHP and THP control mode."
|
||||
+ std::string("\nIn keyword VFPPROD table number ")
|
||||
+ std::to_string(m_table_num)
|
||||
+ ", line " + std::to_string(keyword.getLineNumber())
|
||||
+ ", in file " + keyword.getFileName());
|
||||
+ std::to_string(m_table_num)
|
||||
+ ", file " + keyword.getFileName()
|
||||
+ ", line " + std::to_string(keyword.getLineNumber())
|
||||
+ "\n");
|
||||
m_messages.note(points);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ static Opm::DeckPtr createDeck() {
|
||||
"\n"
|
||||
"PROPS\n"
|
||||
"REGIONS\n"
|
||||
"SWAT\n"
|
||||
"swat\n"
|
||||
"1000*1 /\n"
|
||||
"SATNUM\n"
|
||||
"1000*2 /\n"
|
||||
@ -93,7 +93,7 @@ static Opm::DeckPtr createValidIntDeck() {
|
||||
" 25*1 \n"
|
||||
"/\n"
|
||||
"ADDREG\n"
|
||||
" SATNUM 11 1 M / \n"
|
||||
" satnum 11 1 M / \n"
|
||||
" SATNUM 20 2 / \n"
|
||||
"/\n"
|
||||
"EDIT\n"
|
||||
@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(SupportsProperty) {
|
||||
// int props
|
||||
"ACTNUM", "SATNUM", "IMBNUM", "PVTNUM", "EQLNUM", "ENDNUM", "FLUXNUM", "MULTNUM", "FIPNUM", "MISCNUM", "OPERNUM",
|
||||
// double props
|
||||
"TEMPI", "MULTPV", "PERMX", "PERMY", "PERMZ", "SWATINIT", "THCONR", "NTG"
|
||||
"TEMPI", "MULTPV", "PERMX", "permy", "PERMZ", "SWATINIT", "THCONR", "NTG"
|
||||
};
|
||||
|
||||
for (auto keyword : keywordList)
|
||||
@ -193,14 +193,14 @@ BOOST_AUTO_TEST_CASE(UnsupportedKeywordsThrows) {
|
||||
BOOST_CHECK_THROW(s.props.getIntGridProperty("NONO"), std::logic_error);
|
||||
BOOST_CHECK_THROW(s.props.getDoubleGridProperty("NONO"), std::logic_error);
|
||||
|
||||
BOOST_CHECK_NO_THROW(s.props.hasDeckIntGridProperty("FLUXNUM"));
|
||||
BOOST_CHECK_NO_THROW(s.props.hasDeckIntGridProperty("FluxNUM"));
|
||||
BOOST_CHECK_NO_THROW(s.props.supportsGridProperty("NONO"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(IntGridProperty) {
|
||||
Setup s(createDeck());
|
||||
int cnt = 0;
|
||||
for (auto x : s.props.getIntGridProperty("SATNUM").getData()) {
|
||||
for (auto x : s.props.getIntGridProperty("SaTNuM").getData()) {
|
||||
BOOST_CHECK_EQUAL(x, 2);
|
||||
cnt++;
|
||||
}
|
||||
@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE(AddregIntSetCorrectly) {
|
||||
BOOST_AUTO_TEST_CASE(PermxUnitAppliedCorrectly) {
|
||||
Opm::DeckPtr deck = createValidPERMXDeck();
|
||||
Setup s(deck);
|
||||
const auto& permx = s.props.getDoubleGridProperty("PERMX");
|
||||
const auto& permx = s.props.getDoubleGridProperty("PermX");
|
||||
|
||||
for (size_t j = 0; j < 5; j++)
|
||||
for (size_t i = 0; i < 5; i++) {
|
||||
|
@ -62,9 +62,12 @@ namespace Opm {
|
||||
addKey(PARSE_RANDOM_SLASH);
|
||||
addKey(PARSE_MISSING_DIMS_KEYWORD);
|
||||
addKey(PARSE_EXTRA_DATA);
|
||||
addKey(PARSE_MISSING_INCLUDE);
|
||||
|
||||
addKey(UNSUPPORTED_SCHEDULE_GEO_MODIFIER);
|
||||
addKey(UNSUPPORTED_COMPORD_TYPE);
|
||||
addKey(UNSUPPORTED_INITIAL_THPRES);
|
||||
|
||||
addKey(INTERNAL_ERROR_UNINITIALIZED_THPRES);
|
||||
}
|
||||
|
||||
@ -230,6 +233,7 @@ namespace Opm {
|
||||
const std::string ParseContext::PARSE_RANDOM_SLASH = "PARSE_RANDOM_SLASH";
|
||||
const std::string ParseContext::PARSE_MISSING_DIMS_KEYWORD = "PARSE_MISSING_DIMS_KEYWORD";
|
||||
const std::string ParseContext::PARSE_EXTRA_DATA = "PARSE_EXTRA_DATA";
|
||||
const std::string ParseContext::PARSE_MISSING_INCLUDE = "PARSE_MISSING_INCLUDE";
|
||||
|
||||
const std::string ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER = "UNSUPPORTED_SCHEDULE_GEO_MODIFIER";
|
||||
const std::string ParseContext::UNSUPPORTED_COMPORD_TYPE = "UNSUPPORTED_COMPORD_TYPE";
|
||||
|
@ -160,6 +160,14 @@ namespace Opm {
|
||||
*/
|
||||
const static std::string PARSE_EXTRA_DATA;
|
||||
|
||||
/*
|
||||
If an include file is not found we can configure the parser
|
||||
to contine reading; of course the resulting deck can
|
||||
obviously be quite broken.
|
||||
*/
|
||||
const static std::string PARSE_MISSING_INCLUDE;
|
||||
|
||||
|
||||
/*
|
||||
Some property modfiers can be modified in the Schedule
|
||||
section; this effectively means that Eclipse supports time
|
||||
|
@ -163,6 +163,29 @@ inline std::string clean( const std::string& str ) {
|
||||
dst.push_back( '\n' );
|
||||
}
|
||||
|
||||
struct f {
|
||||
bool inside_quotes = false;
|
||||
bool operator()( char c ) {
|
||||
if( c == ',' ) return true;
|
||||
if( RawConsts::is_quote( c ) ) inside_quotes = !inside_quotes;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/* some decks use commas for item separation in records, but commas add
|
||||
* nothing over whitespace. run over the deck and replace all non-quoted
|
||||
* commas with whitespace. commas withing quotes are read verbatim and not
|
||||
* to be touched.
|
||||
*
|
||||
* There's a known defect: considering the record
|
||||
* foo bar, , , baz, , /
|
||||
* baz will silently interpreted as item #3 instead of item #5. As of
|
||||
* writing we're not sure if this is even legal, nor have we seen it
|
||||
* happen, but the effort needed to support it is tremendous and will
|
||||
* require significant changes throughout.
|
||||
*/
|
||||
std::replace_if( dst.begin(), dst.end(), f(), ' ' );
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
@ -280,7 +303,9 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) {
|
||||
try {
|
||||
inputFileCanonical = boost::filesystem::canonical(inputFile);
|
||||
} catch (boost::filesystem::filesystem_error fs_error) {
|
||||
throw std::runtime_error(std::string("Parser::loadFile fails: ") + fs_error.what());
|
||||
std::string msg = "Could not open file: " + inputFile.string();
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , deck->getMessageContainer() , msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto closer = []( std::FILE* f ) { std::fclose( f ); };
|
||||
@ -291,9 +316,9 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) {
|
||||
|
||||
// make sure the file we'd like to parse is readable
|
||||
if( !ufp ) {
|
||||
throw std::runtime_error(std::string("Input file '") +
|
||||
inputFileCanonical.string() +
|
||||
std::string("' is not readable"));
|
||||
std::string msg = "Could not read from file: " + inputFile.string();
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , deck->getMessageContainer() , msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -527,11 +527,7 @@ namespace Opm {
|
||||
|
||||
void ParserKeyword::setMatchRegex(const std::string& deckNameRegexp) {
|
||||
try {
|
||||
#ifdef HAVE_REGEX
|
||||
m_matchRegex = std::regex(deckNameRegexp, std::regex::extended);
|
||||
#else
|
||||
m_matchRegex = boost::regex(deckNameRegexp);
|
||||
#endif
|
||||
m_matchRegexString = deckNameRegexp;
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
@ -551,11 +547,7 @@ namespace Opm {
|
||||
return true;
|
||||
|
||||
else if (hasMatchRegex()) {
|
||||
#ifdef HAVE_REGEX
|
||||
return std::regex_match( name.begin(), name.end(), m_matchRegex);
|
||||
#else
|
||||
return boost::regex_match( name.begin(), name.end(), m_matchRegex);
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -23,11 +23,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#ifdef HAVE_REGEX
|
||||
#include <regex>
|
||||
#else
|
||||
#include <boost/regex.hpp>
|
||||
#endif
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Util/RecordVector.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserEnums.hpp>
|
||||
@ -113,11 +109,7 @@ namespace Opm {
|
||||
DeckNameSet m_deckNames;
|
||||
DeckNameSet m_validSectionNames;
|
||||
std::string m_matchRegexString;
|
||||
#ifdef HAVE_REGEX
|
||||
std::regex m_matchRegex;
|
||||
#else
|
||||
boost::regex m_matchRegex;
|
||||
#endif
|
||||
RecordVector<std::shared_ptr< ParserRecord >> m_records;
|
||||
enum ParserKeywordSizeEnum m_keywordSizeType;
|
||||
size_t m_fixedSize;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/D.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/O.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
|
||||
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
||||
@ -82,6 +83,40 @@ BOOST_AUTO_TEST_CASE(TestUnkownKeyword) {
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TEST_UNKNOWN_OPERATE) {
|
||||
const char * deck =
|
||||
"OPERATE\n"
|
||||
"SWL 6* MULTX PERMX 1.E10 / Temp: SWL=1.E10*PERMX\n"
|
||||
"SWL 6* MINLIM SWL 1.0 /\n"
|
||||
"SWL 6* LOG10 SWL / Temp: SWL=log(1.E10*PERMX)\n"
|
||||
"SWL 6* MULTA SWL -0.06 0.91 / Final: SWL=0.31-0.06*log(PERMX)\n"
|
||||
"--SWCR 6* COPY SWL / SWCR=SWL\n"
|
||||
"SWCR 6* MULTA SWL 1.0 0.0 / SWCR=SWL+0.0 (+0.3)\n"
|
||||
"SWCR 6* MAXLIM SWCR 0.7 / max(SWCR)=0.7\n"
|
||||
"SGU 6* MULTA SWL -1.0 1.0 / SGU=1-SWL\n"
|
||||
"/\n";
|
||||
|
||||
ParseContext parseContext;
|
||||
Parser parser(false);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW( parser.parseString( deck , parseContext ) , std::invalid_argument);
|
||||
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE );
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
||||
parser.parseString( deck , parseContext );
|
||||
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext ) );
|
||||
|
||||
parser.addKeyword<ParserKeywords::OPERATE>();
|
||||
parser.parseString( deck , parseContext );
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::THROW_EXCEPTION );
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( CheckMissingSizeKeyword) {
|
||||
const char * deck =
|
||||
"SOLUTION\n"
|
||||
|
@ -27,6 +27,25 @@
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
#include "opm_parser_build_config.hpp"
|
||||
|
||||
|
||||
#ifdef OPM_PARSER_BUILD_HAVE_SYMLINK
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
|
||||
boost::filesystem::path inputFilePath("testdata/parser/includeInvalid.data");
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::ParseContext parseContext;
|
||||
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFilePath.string() , parseContext) , std::invalid_argument);
|
||||
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW(parser->parseFile(inputFilePath.string() , parseContext));
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_is_a_symlink) {
|
||||
boost::filesystem::path inputFilePath("testdata/parser/includeSymlinkTestdata/symlink1/case_symlink.data");
|
||||
@ -57,6 +76,7 @@ BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_has_include_file_that_again_
|
||||
BOOST_CHECK_EQUAL(false , deck->hasKeyword("WATER"));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeValid) {
|
||||
@ -70,12 +90,9 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeValid) {
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
|
||||
boost::filesystem::path inputFilePath("testdata/parser/includeInvalid.data");
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFilePath.string() , Opm::ParseContext()), std::runtime_error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
|
||||
boost::filesystem::path inputFile1Path("testdata/parser/includeWrongCase1.data");
|
||||
@ -89,9 +106,12 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
|
||||
// exactly the same spelling as their names on disk. Eclipse seems
|
||||
// to be a bit more relaxed when it comes to this, so we might
|
||||
// have to change the current behavior one not-so-fine day...
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile1Path.string(), Opm::ParseContext()), std::runtime_error);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile2Path.string(), Opm::ParseContext()), std::runtime_error);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile3Path.string(), Opm::ParseContext()), std::runtime_error);
|
||||
Opm::ParseContext parseContext;
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
|
||||
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile1Path.string(), parseContext), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile2Path.string(), parseContext), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile3Path.string(), parseContext), std::invalid_argument);
|
||||
#else
|
||||
// for case-insensitive filesystems, the include statement will
|
||||
// always work regardless of how the capitalization of the
|
||||
|
@ -292,8 +292,11 @@ BOOST_AUTO_TEST_CASE( quoted_comments ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PATHS_has_global_scope ) {
|
||||
Parser parser;
|
||||
parser.newDeckFromFile( "testdata/parser/PATHSInInclude.data", ParseContext() );
|
||||
BOOST_CHECK_THROW( parser.newDeckFromFile( "testdata/parser/PATHSInIncludeInvalid.data", ParseContext() ), std::runtime_error );
|
||||
ParseContext parseContext;
|
||||
|
||||
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
|
||||
parser.newDeckFromFile( "testdata/parser/PATHSInInclude.data", parseContext );
|
||||
BOOST_CHECK_THROW( parser.newDeckFromFile( "testdata/parser/PATHSInIncludeInvalid.data", ParseContext() ), std::invalid_argument );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( handle_empty_title ) {
|
||||
@ -307,3 +310,42 @@ BOOST_AUTO_TEST_CASE( handle_empty_title ) {
|
||||
BOOST_CHECK_EQUAL( "untitled", deck->getKeyword( "TITLE" ).getStringData().front() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( deck_comma_separated_fields ) {
|
||||
const char* deck = R"(
|
||||
TABDIMS
|
||||
2* 24 2* 20 20 1* 1 7* /
|
||||
|
||||
SWOF
|
||||
0.1000, 0.0000e+00, 8.0000e-01 0
|
||||
0.2000, 0, 8.0000e-01 0
|
||||
0.2500, 2.7310e-04, 5.8082e-01 0
|
||||
0.3000, 2.1848e-03, 4.1010e-01 0
|
||||
0.3500, 7.3737e-03, 2.8010e-01 0
|
||||
0.4000, 1.7478e-02, 1.8378e-01 0
|
||||
0.4500, 3.4138e-02, 1.1473e-01 0
|
||||
0.5000, 5.8990e-02, 6.7253e-02 0
|
||||
0.5500, 9.3673e-02, 3.6301e-02 0
|
||||
0.6000, 1.3983e-01, 1.7506e-02 0
|
||||
0.6500, 1.9909e-01, 7.1706e-03 0
|
||||
0.7000, 2.7310e-01, 2.2688e-03 0
|
||||
0.7500, 3.6350e-01, 4.4820e-04 0
|
||||
0.8000, 4.7192e-01, 2.8000e-05 0
|
||||
0.8500, 6.0000e-01, 0.0000e+00 0
|
||||
0.9000, 7.4939e-01, 0.0000e+00 0
|
||||
/
|
||||
)";
|
||||
|
||||
BOOST_CHECK_NO_THROW( Parser().newDeckFromString( deck, ParseContext() ) );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(BRILLIG_CASE) {
|
||||
ParseContext parseContext;
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_SLASH, InputError::IGNORE);
|
||||
parseContext.update(ParseContext::PARSE_RANDOM_TEXT, InputError::IGNORE);
|
||||
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE);
|
||||
Parser parser(true);
|
||||
parser.newDeckFromFile("d:/Models/Statoil/Brillig/BRILLIG.DATA", parseContext);
|
||||
//BOOST_CHECK_THROW(parser.newDeckFromFile("testdata/parser/PATHSInIncludeInvalid.data", ParseContext()), std::runtime_error);
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,7 @@
|
||||
#include <opm/parser/eclipse/RawDeck/RawConsts.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawKeyword.hpp>
|
||||
#include <opm/parser/eclipse/RawDeck/RawRecord.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#include <opm/parser/eclipse/Utility/String.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -132,12 +131,6 @@ namespace Opm {
|
||||
return *m_records.begin();
|
||||
}
|
||||
|
||||
static inline std::string uppercase( std::string&& str ) {
|
||||
std::transform( str.begin(), str.end(), str.begin(),
|
||||
[]( char c ) { return std::toupper( c ); } );
|
||||
return str;
|
||||
}
|
||||
|
||||
bool RawKeyword::isKeywordPrefix(const string_view& line, std::string& keyword ) {
|
||||
// make the keyword string ALL_UPPERCASE because Eclipse seems
|
||||
// to be case-insensitive (although this is one of its
|
||||
|
24
ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/String.hpp
vendored
Normal file
24
ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/String.hpp
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef OPM_UTILITY_STRING_HPP
|
||||
#define OPM_UTILITY_STRING_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template< typename T, typename U >
|
||||
U& uppercase( const T& src, U& dst ) {
|
||||
const auto up = []( char c ) { return std::toupper( c ); };
|
||||
std::transform( std::begin( src ), std::end( src ), std::begin( dst ), up );
|
||||
return dst;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
typename std::decay< T >::type uppercase( T&& x ) {
|
||||
typename std::decay< T >::type t( std::forward< T >( x ) );
|
||||
return std::move( uppercase( t, t ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //OPM_UTILITY_STRING_HPP
|
@ -1,4 +1,4 @@
|
||||
foreach(tapp FunctionalTests StringviewTests )
|
||||
foreach(tapp FunctionalTests StringviewTests StringTests )
|
||||
|
||||
opm_add_test(run${tapp} SOURCES ${tapp}.cpp
|
||||
LIBRARIES opmparser ${Boost_LIBRARIES})
|
||||
|
64
ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringTests.cpp
vendored
Normal file
64
ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringTests.cpp
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
#define BOOST_TEST_MODULE StringTests
|
||||
|
||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
||||
|
||||
#include <opm/parser/eclipse/Utility/String.hpp>
|
||||
#include <opm/parser/eclipse/Utility/Stringview.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
BOOST_AUTO_TEST_CASE( uppercase_copy ) {
|
||||
const std::string src = "string";
|
||||
const std::string dst = uppercase( src );
|
||||
|
||||
BOOST_CHECK_EQUAL( src, "string" );
|
||||
BOOST_CHECK_EQUAL( dst, "STRING" );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( uppercase_inplace ) {
|
||||
std::string src = "string";
|
||||
auto& ref = uppercase( src, src );
|
||||
|
||||
BOOST_CHECK_EQUAL( src, "STRING" );
|
||||
BOOST_CHECK_EQUAL( src, ref );
|
||||
BOOST_CHECK_EQUAL( std::addressof( src ), std::addressof( ref ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( nonconst_ref ) {
|
||||
std::string src = "string";
|
||||
auto dst = uppercase( src );
|
||||
|
||||
BOOST_CHECK_EQUAL( src, "string" );
|
||||
BOOST_CHECK_EQUAL( dst, "STRING" );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( uppercase_move ) {
|
||||
std::string src = "string";
|
||||
auto dst = uppercase( std::move( src ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( dst, "STRING" );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( uppercase_mixed_type ) {
|
||||
std::string src = "string";
|
||||
string_view view( src );
|
||||
|
||||
|
||||
std::string dst = "string";
|
||||
uppercase( view, dst );
|
||||
BOOST_CHECK_EQUAL( dst, "STRING" );
|
||||
BOOST_CHECK_EQUAL( view, "string" );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( write_parts_of_dst ) {
|
||||
std::string src = "string";
|
||||
string_view view( src );
|
||||
|
||||
|
||||
std::string dst = "stringmixed";
|
||||
uppercase( view, dst );
|
||||
BOOST_CHECK_EQUAL( dst, "STRINGmixed" );
|
||||
BOOST_CHECK_EQUAL( view, "string" );
|
||||
}
|
15
ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/O/OPERATE
vendored
Normal file
15
ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/O/OPERATE
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
{"name" : "OPERATE" , "sections" : ["GRID" , "EDIT" , "PROPS" , "REGIONS" , "SOLUTION"],
|
||||
"items" : [
|
||||
{"name" : "RESULT_ARRAY" , "value_type" : "STRING"},
|
||||
{"name" : "I1" , "value_type" : "INT"},
|
||||
{"name" : "I2" , "value_type" : "INT"},
|
||||
{"name" : "J1" , "value_type" : "INT"},
|
||||
{"name" : "J2" , "value_type" : "INT"},
|
||||
{"name" : "K1" , "value_type" : "INT"},
|
||||
{"name" : "K2" , "value_type" : "INT"},
|
||||
{"name" : "OPERATION" , "value_type" : "STRING"},
|
||||
{"name" : "ARRAY_ARG" , "value_type" : "STRING"},
|
||||
{"name" : "PARAM1" , "value_type" : "DOUBLE"},
|
||||
{"name" : "PARAM2" , "value_type" : "DOUBLE"}]}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user