2015-07-24 22:43:00 +02:00
|
|
|
/*
|
|
|
|
|
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>
|
2017-12-03 08:30:04 +01:00
|
|
|
#include <stdlib.h>
|
2015-07-24 22:43:00 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2016-03-17 08:42:46 +08:00
|
|
|
#define BOOST_TEST_MODULE ParseContextTests
|
2015-07-24 22:43:00 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
2016-01-18 17:51:15 +01:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/D.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
|
2018-01-12 15:04:25 +01:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/G.hpp>
|
2016-06-14 12:29:31 +02:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/O.hpp>
|
2017-03-29 15:59:01 +02:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/R.hpp>
|
2016-01-18 17:51:15 +01:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
|
2015-07-24 22:43:00 +02:00
|
|
|
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
2016-03-17 08:42:46 +08:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
2015-07-24 22:43:00 +02:00
|
|
|
|
2015-07-26 23:13:49 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
|
|
|
|
|
2015-07-24 22:43:00 +02:00
|
|
|
using namespace Opm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestUnkownKeyword) {
|
|
|
|
|
const char * deck1 =
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 10 /n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
const char * deck2 =
|
|
|
|
|
"1rdomTX\n"
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 10 /n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-07-24 22:43:00 +02:00
|
|
|
Parser parser(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser.addKeyword<ParserKeywords::DIMENS>();
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext ) , std::invalid_argument);
|
2015-07-24 22:43:00 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext ) );
|
2015-07-24 22:43:00 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::THROW_EXCEPTION );
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext ) , std::invalid_argument);
|
2015-07-24 22:43:00 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_NO_THROW( parser.parseString( deck2 , parseContext ) );
|
2015-07-24 22:43:00 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION );
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext ) , std::invalid_argument);
|
2015-07-24 22:43:00 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_NO_THROW( parser.parseString( deck2 , parseContext ) );
|
2015-07-24 22:43:00 +02:00
|
|
|
}
|
2015-07-25 10:34:06 +02:00
|
|
|
|
|
|
|
|
|
2018-01-12 15:04:25 +01:00
|
|
|
BOOST_AUTO_TEST_CASE(Handle_extra_records) {
|
|
|
|
|
const char * deck_string =
|
|
|
|
|
"EQLDIMS\n"
|
|
|
|
|
" 2 100 20 1 1 /\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"EQUIL\n"
|
|
|
|
|
" 2469 382.4 1705.0 0.0 500 0.0 1 1 20 /\n"
|
|
|
|
|
" 2469 382.4 1705.0 0.0 500 0.0 1 1 20 /\n"
|
|
|
|
|
" 2470 382.4 1705.0 0.0 500 0.0 1 1 20 /\n"
|
|
|
|
|
"GRID\n";
|
|
|
|
|
|
|
|
|
|
ParseContext parseContext;
|
|
|
|
|
Parser parser(false);
|
|
|
|
|
|
|
|
|
|
parser.addKeyword<ParserKeywords::EQLDIMS>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::EQUIL>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::GRID>();
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext ) , std::invalid_argument );
|
|
|
|
|
|
2018-01-15 13:50:56 +01:00
|
|
|
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::IGNORE );
|
2018-01-12 15:04:25 +01:00
|
|
|
parser.parseString( deck_string , parseContext );
|
|
|
|
|
BOOST_CHECK( parser.hasKeyword( "GRID" ) );
|
|
|
|
|
|
2018-01-15 13:50:56 +01:00
|
|
|
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::THROW_EXCEPTION );
|
2018-01-12 15:04:25 +01:00
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext ) , std::invalid_argument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-01-16 17:15:37 +01:00
|
|
|
BOOST_AUTO_TEST_CASE(Handle_extra_records_2) {
|
|
|
|
|
const char * deck_string =
|
|
|
|
|
"EQLDIMS\n"
|
|
|
|
|
" 2 100 20 1 1 /\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"EQUIL\n"
|
|
|
|
|
" 2469 382.4 1705.0 0.0 500 0.0 1 1 20 /\n"
|
|
|
|
|
" 2469 382.4 1705.0 0.0 500 0.0 1 1 20 /\n"
|
|
|
|
|
"GRID\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 3 /\n"
|
|
|
|
|
" 5 3 2 /\n";
|
|
|
|
|
|
|
|
|
|
ParseContext parseContext;
|
|
|
|
|
Parser parser(false);
|
|
|
|
|
|
|
|
|
|
parser.addKeyword<ParserKeywords::EQLDIMS>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::EQUIL>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::GRID>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::DIMENS>();
|
|
|
|
|
|
|
|
|
|
parseContext.update(ParseContext::PARSE_EXTRA_RECORDS , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck_string , parseContext ), std::invalid_argument );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-03-29 15:59:01 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(TestUnkownKeyword_DATA) {
|
|
|
|
|
const char * deck_string1 =
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"UNKNOWN1\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"UNKNOWN2\n"
|
|
|
|
|
" 10 10 10 /n"
|
|
|
|
|
"\n"
|
|
|
|
|
"UNKNOWN3\n"
|
|
|
|
|
" 11 11 11 /n"
|
|
|
|
|
"/\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 12 12 12 /n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * deck_string2 =
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"UNKNOWN1\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"UNKNOWN2\n"
|
|
|
|
|
" 10 10 10 /n"
|
|
|
|
|
"\n"
|
|
|
|
|
"UNKNOWN3\n"
|
|
|
|
|
" 11 11 11 /n"
|
|
|
|
|
"/\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 12 12 12 /\n"
|
|
|
|
|
"Ran/dom Noise; \n"
|
|
|
|
|
"with 0 0 0 Data /\n"
|
|
|
|
|
"/\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParseContext parseContext;
|
|
|
|
|
Parser parser(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser.addKeyword<ParserKeywords::RUNSPEC>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::DIMENS>();
|
|
|
|
|
parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD , InputError::IGNORE );
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION );
|
|
|
|
|
{
|
|
|
|
|
Deck deck = parser.parseString( deck_string1 , parseContext );
|
|
|
|
|
BOOST_CHECK( deck.hasKeyword( "RUNSPEC") );
|
|
|
|
|
BOOST_CHECK( deck.hasKeyword( "DIMENS") );
|
|
|
|
|
}
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck_string2 , parseContext ) , std::invalid_argument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-14 12:29:31 +02:00
|
|
|
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 ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-25 10:34:06 +02:00
|
|
|
BOOST_AUTO_TEST_CASE( CheckMissingSizeKeyword) {
|
|
|
|
|
const char * deck =
|
|
|
|
|
"SOLUTION\n"
|
|
|
|
|
"EQUIL\n"
|
|
|
|
|
" 10 10 10 10 / \n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-07-25 10:34:06 +02:00
|
|
|
Parser parser(false);
|
|
|
|
|
|
|
|
|
|
parser.addKeyword<ParserKeywords::EQUIL>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::EQLDIMS>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::SOLUTION>();
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputError::THROW_EXCEPTION );
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck , parseContext ) , std::invalid_argument);
|
2015-07-25 10:34:06 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( ParseContext::PARSE_MISSING_DIMS_KEYWORD , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseContext ) );
|
2015-07-25 10:34:06 +02:00
|
|
|
}
|
2015-07-26 23:13:49 +02:00
|
|
|
|
|
|
|
|
|
2016-02-09 12:09:40 +01:00
|
|
|
BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) {
|
2015-10-30 15:33:53 +01:00
|
|
|
const char * deckStringUnSupported =
|
|
|
|
|
"START\n"
|
|
|
|
|
" 10 'JAN' 2000 /\n"
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 10 / \n"
|
2016-06-21 15:55:04 +02:00
|
|
|
"GRID\n"
|
|
|
|
|
"DX\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"DY\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"DZ\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"TOPS\n"
|
|
|
|
|
"100*0.25 /\n"
|
2015-10-30 15:33:53 +01:00
|
|
|
"SCHEDULE\n"
|
|
|
|
|
"MULTZ\n"
|
|
|
|
|
" 1000*0.10 /\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
const char * deckStringSupported =
|
2015-07-26 23:13:49 +02:00
|
|
|
"START\n"
|
|
|
|
|
" 10 'JAN' 2000 /\n"
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 10 / \n"
|
2016-06-21 15:55:04 +02:00
|
|
|
"GRID\n"
|
|
|
|
|
"DX\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"DY\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"DZ\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"TOPS\n"
|
|
|
|
|
"100*0.25 /\n"
|
2015-07-26 23:13:49 +02:00
|
|
|
"SCHEDULE\n"
|
|
|
|
|
"MULTFLT\n"
|
2015-10-30 15:33:53 +01:00
|
|
|
" 'F1' 0.10 /\n"
|
2015-07-26 23:13:49 +02:00
|
|
|
"/\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
2015-10-30 15:33:53 +01:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-07-26 23:13:49 +02:00
|
|
|
Parser parser(true);
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
auto deckSupported = parser.parseString( deckStringSupported , parseContext );
|
|
|
|
|
auto deckUnSupported = parser.parseString( deckStringUnSupported , parseContext );
|
2016-10-13 10:13:32 +02:00
|
|
|
EclipseGrid grid( deckSupported );
|
2017-02-15 11:13:29 +01:00
|
|
|
TableManager table ( deckSupported );
|
|
|
|
|
Eclipse3DProperties eclipseProperties ( deckSupported , table, grid);
|
2015-07-26 23:13:49 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::IGNORE );
|
2017-09-27 16:34:38 +02:00
|
|
|
BOOST_CHECK_NO_THROW( Schedule( deckSupported , grid , eclipseProperties, Phases(true, true, true), parseContext ));
|
|
|
|
|
BOOST_CHECK_NO_THROW( Schedule( deckUnSupported, grid , eclipseProperties, Phases(true, true, true), parseContext ));
|
2015-07-26 23:13:49 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::THROW_EXCEPTION );
|
2017-09-27 16:34:38 +02:00
|
|
|
BOOST_CHECK_THROW( Schedule( deckUnSupported , grid , eclipseProperties, Phases(true, true, true) , parseContext), std::invalid_argument );
|
|
|
|
|
BOOST_CHECK_NO_THROW( Schedule( deckSupported , grid , eclipseProperties, Phases(true, true, true) , parseContext));
|
2015-07-26 23:13:49 +02:00
|
|
|
}
|
2015-08-04 18:02:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestRandomSlash) {
|
2015-08-07 10:22:00 +02:00
|
|
|
const char * deck1 =
|
2015-08-04 18:02:26 +02:00
|
|
|
"SCHEDULE\n"
|
|
|
|
|
"TSTEP\n"
|
|
|
|
|
" 10 10 10 /\n"
|
|
|
|
|
"/\n";
|
|
|
|
|
|
2015-08-07 10:22:00 +02:00
|
|
|
const char * deck2 =
|
|
|
|
|
"SCHEDULE\n"
|
|
|
|
|
"TSTEP\n"
|
|
|
|
|
" 10 10 10 /\n"
|
|
|
|
|
" /\n";
|
|
|
|
|
|
|
|
|
|
|
2015-08-04 18:02:26 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-08-04 18:02:26 +02:00
|
|
|
Parser parser(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser.addKeyword<ParserKeywords::TSTEP>();
|
|
|
|
|
parser.addKeyword<ParserKeywords::SCHEDULE>();
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::THROW_EXCEPTION);
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::IGNORE);
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck1 , parseContext ) , std::invalid_argument);
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deck2 , parseContext ) , std::invalid_argument);
|
2015-08-04 18:02:26 +02:00
|
|
|
|
2015-08-07 10:22:00 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE);
|
|
|
|
|
parseContext.update(ParseContext::PARSE_RANDOM_TEXT , InputError::THROW_EXCEPTION);
|
|
|
|
|
BOOST_CHECK_NO_THROW( parser.parseString( deck1 , parseContext ) );
|
|
|
|
|
BOOST_CHECK_NO_THROW( parser.parseString( deck2 , parseContext ) );
|
2015-08-04 18:02:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 15:13:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestCOMPORD) {
|
|
|
|
|
const char * deckString =
|
|
|
|
|
"START\n"
|
|
|
|
|
" 10 'JAN' 2000 /\n"
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 10 / \n"
|
2016-06-21 15:55:04 +02:00
|
|
|
"GRID\n"
|
|
|
|
|
"DX\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"DY\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"DZ\n"
|
|
|
|
|
"1000*0.25 /\n"
|
|
|
|
|
"TOPS\n"
|
|
|
|
|
"100*0.25 /\n"
|
2015-08-07 15:13:52 +02:00
|
|
|
"SCHEDULE\n"
|
|
|
|
|
"COMPORD\n"
|
2015-08-28 16:22:06 +02:00
|
|
|
" '*' 'DEPTH' /\n"
|
2015-08-07 15:13:52 +02:00
|
|
|
"/\n";
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-08-07 15:13:52 +02:00
|
|
|
Parser parser(true);
|
2016-03-16 16:34:58 +08:00
|
|
|
auto deck = parser.parseString( deckString , parseContext );
|
2015-08-07 15:13:52 +02:00
|
|
|
|
2016-10-13 10:13:32 +02:00
|
|
|
EclipseGrid grid( deck );
|
2017-02-15 11:13:29 +01:00
|
|
|
TableManager table ( deck );
|
|
|
|
|
Eclipse3DProperties eclipseProperties ( deck , table, grid);
|
2015-08-07 15:13:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( ParseContext::UNSUPPORTED_COMPORD_TYPE , InputError::IGNORE);
|
2017-09-27 16:34:38 +02:00
|
|
|
BOOST_CHECK_NO_THROW( Schedule( deck , grid , eclipseProperties, Phases(true, true, true), parseContext ));
|
2015-08-07 15:13:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( ParseContext::UNSUPPORTED_COMPORD_TYPE , InputError::THROW_EXCEPTION);
|
2017-09-27 16:34:38 +02:00
|
|
|
BOOST_CHECK_THROW( Schedule( deck, grid , eclipseProperties, Phases(true, true, true) , parseContext), std::invalid_argument );
|
2015-08-07 15:13:52 +02:00
|
|
|
}
|
2015-08-08 12:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestInvalidKey) {
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2018-02-19 14:47:15 +01:00
|
|
|
BOOST_CHECK_THROW( parseContext.addKey("KEY*", InputError::THROW_EXCEPTION) , std::invalid_argument );
|
|
|
|
|
BOOST_CHECK_THROW( parseContext.addKey("KEY:", InputError::THROW_EXCEPTION) , std::invalid_argument );
|
2015-08-08 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(TestNew) {
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
BOOST_CHECK_EQUAL( false , parseContext.hasKey("NO"));
|
2018-02-19 14:47:15 +01:00
|
|
|
parseContext.addKey("NEW_KEY", InputError::THROW_EXCEPTION);
|
2016-03-16 16:34:58 +08:00
|
|
|
BOOST_CHECK_EQUAL( true , parseContext.hasKey("NEW_KEY"));
|
|
|
|
|
BOOST_CHECK_THROW( parseContext.get("NO") , std::invalid_argument );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::THROW_EXCEPTION );
|
2018-02-19 14:47:15 +01:00
|
|
|
parseContext.addKey("KEY2", InputError::THROW_EXCEPTION);
|
2016-03-16 16:34:58 +08:00
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::THROW_EXCEPTION );
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
BOOST_CHECK_THROW( parseContext.updateKey("NO" , InputError::IGNORE) , std::invalid_argument);
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.updateKey("NEW_KEY" , InputError::WARN);
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::WARN );
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
BOOST_CHECK_NO_THROW( parseContext.update("KEY2:NEW_KEY" , InputError::IGNORE));
|
|
|
|
|
BOOST_CHECK_NO_THROW( parseContext.update("UnknownKey" , InputError::IGNORE));
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("KEY2") , InputError::IGNORE );
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2018-02-19 14:47:15 +01:00
|
|
|
parseContext.addKey("SECRET_KEY", InputError::THROW_EXCEPTION);
|
|
|
|
|
parseContext.addKey("NEW_KEY2", InputError::THROW_EXCEPTION);
|
|
|
|
|
parseContext.addKey("NEW_KEY3", InputError::THROW_EXCEPTION);
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update("NEW_KEY*" , InputError::WARN);
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY") , InputError::WARN );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY2") , InputError::WARN );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY3") , InputError::WARN );
|
2015-08-08 12:36:52 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update( InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("NEW_KEY3") , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get("SECRET_KEY") , InputError::IGNORE );
|
2015-08-08 12:36:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( test_constructor_with_values) {
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext( {{ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE},
|
2015-08-08 12:36:52 +02:00
|
|
|
{"UNSUPPORTED_*" , InputError::WARN},
|
|
|
|
|
{"UNKNWON-IGNORED" , InputError::WARN}});
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::PARSE_RANDOM_SLASH) , InputError::IGNORE );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::PARSE_RANDOM_TEXT) , InputError::THROW_EXCEPTION );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::UNSUPPORTED_INITIAL_THPRES) , InputError::WARN );
|
|
|
|
|
BOOST_CHECK_EQUAL( parseContext.get(ParseContext::UNSUPPORTED_COMPORD_TYPE) , InputError::WARN );
|
2015-08-08 12:36:52 +02:00
|
|
|
}
|
2015-09-28 13:43:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( test_too_much_data ) {
|
|
|
|
|
const char * deckString =
|
|
|
|
|
"RUNSPEC\n"
|
|
|
|
|
"DIMENS\n"
|
|
|
|
|
" 10 10 10 10 /n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
ParseContext parseContext;
|
2015-09-28 13:43:22 +02:00
|
|
|
Parser parser;
|
|
|
|
|
|
|
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::THROW_EXCEPTION );
|
|
|
|
|
BOOST_CHECK_THROW( parser.parseString( deckString , parseContext ) , std::invalid_argument);
|
2015-09-28 13:43:22 +02:00
|
|
|
|
2016-03-16 16:34:58 +08:00
|
|
|
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::IGNORE );
|
|
|
|
|
auto deck = parser.parseString( deckString , parseContext );
|
2015-09-28 13:43:22 +02:00
|
|
|
}
|
2017-12-03 08:30:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_1arg_constructor) {
|
|
|
|
|
setenv("OPM_ERRORS_IGNORE", "PARSE_RANDOM_SLASH", 1);
|
|
|
|
|
{
|
|
|
|
|
ParseContext ctx(InputError::WARN);
|
|
|
|
|
BOOST_CHECK_EQUAL(ctx.get(ParseContext::UNSUPPORTED_COMPORD_TYPE), InputError::WARN);
|
|
|
|
|
BOOST_CHECK_EQUAL(ctx.get(ParseContext::PARSE_RANDOM_SLASH), InputError::IGNORE);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-22 10:25:17 +02:00
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) {
|
2018-05-02 11:01:21 +02:00
|
|
|
const std::string defDeckString = R"(
|
2018-04-22 10:25:17 +02:00
|
|
|
START -- 0
|
|
|
|
|
10 'JAN' 2000 /
|
|
|
|
|
RUNSPEC
|
|
|
|
|
DIMENS
|
|
|
|
|
10 10 10 /
|
|
|
|
|
GRID
|
|
|
|
|
DX
|
|
|
|
|
1000*0.25 /
|
|
|
|
|
DY
|
|
|
|
|
1000*0.25 /
|
|
|
|
|
DZ
|
|
|
|
|
1000*0.25 /
|
|
|
|
|
TOPS
|
|
|
|
|
100*0.25 /
|
|
|
|
|
SCHEDULE
|
|
|
|
|
DATES -- 1
|
|
|
|
|
10 OKT 2008 /
|
|
|
|
|
/
|
|
|
|
|
WELSPECS
|
|
|
|
|
'PROD' 'G1' 10 10 100 'OIL' /
|
|
|
|
|
'INJ' 'G1' 3 3 100 'WATER' /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
|
|
|
|
|
ParseContext parseContext;
|
|
|
|
|
Parser parser;
|
|
|
|
|
|
2018-05-03 13:20:04 +02:00
|
|
|
parseContext.update(ParseContext::SCHEDULE_INVALID_NAME , InputError::THROW_EXCEPTION );
|
2018-04-22 10:25:17 +02:00
|
|
|
|
|
|
|
|
std::vector < std::string > testSamples;
|
|
|
|
|
std::string testSample;
|
|
|
|
|
|
|
|
|
|
// Invalid well name in COMPDAT
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'SOMETHINGELSE' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
2018-04-23 12:45:57 +02:00
|
|
|
// Invalid well name in WCONPROD
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONPROD
|
|
|
|
|
'SOMETHINGELSE' 'OPEN' 'ORAT' 20000 4* 1000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
2018-04-26 10:39:54 +02:00
|
|
|
// Invalid well name in WCONINJE
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJE
|
|
|
|
|
'SOMETHINGELSE' 'WATER' 'OPEN' 'RATE' 20000 4* 1000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid well name in WCONINJH
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJH
|
|
|
|
|
'SOMETHINGELSE' 'WAT' 'OPEN' 20000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
2018-04-26 14:41:39 +02:00
|
|
|
// Invalid well name in WTEMP
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJE
|
|
|
|
|
'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* /
|
|
|
|
|
/
|
|
|
|
|
DATES
|
|
|
|
|
15 OKT 2008 /
|
|
|
|
|
/
|
|
|
|
|
WTEMP
|
|
|
|
|
'SOMETHINGELSE' 40.0 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid well name in WINJTEMP
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJE
|
|
|
|
|
'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* /
|
|
|
|
|
/
|
|
|
|
|
DATES
|
|
|
|
|
15 OKT 2008 /
|
|
|
|
|
/
|
|
|
|
|
WINJTEMP
|
|
|
|
|
'SOMETHINGELSE' 1* 40.0 1* /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
2018-05-02 11:01:21 +02:00
|
|
|
// Invalid well name in WSOLVENT
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJE
|
|
|
|
|
'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* /
|
|
|
|
|
/
|
|
|
|
|
DATES
|
|
|
|
|
15 OKT 2008 /
|
|
|
|
|
/
|
|
|
|
|
WSOLVENT
|
|
|
|
|
'SOMETHINGELSE' 1.0 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid well name in WPOLYMER
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJE
|
|
|
|
|
'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* /
|
|
|
|
|
/
|
|
|
|
|
DATES
|
|
|
|
|
15 OKT 2008 /
|
|
|
|
|
/
|
|
|
|
|
WPOLYMER
|
|
|
|
|
'SOMETHINGELSE' 1.0 0.0 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
2018-05-03 09:18:53 +02:00
|
|
|
// Invalid well name in WELOPEN
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONINJE
|
|
|
|
|
'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* /
|
|
|
|
|
/
|
|
|
|
|
DATES
|
|
|
|
|
15 OKT 2008 /
|
|
|
|
|
/
|
|
|
|
|
WELOPEN
|
|
|
|
|
'SOMETHINGELSE' /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid well name in WELTARG
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONHIST
|
|
|
|
|
'PROD' 'OPEN' 'ORAT' 20000 4* 1000 /
|
|
|
|
|
/
|
|
|
|
|
WELTARG
|
|
|
|
|
'SOMETHINGELSE' 'ORAT' 15000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
2018-05-02 11:01:21 +02:00
|
|
|
|
2018-05-03 09:34:54 +02:00
|
|
|
// Invalid well name in WECON
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONPROD
|
|
|
|
|
'PROD' 'OPEN' 'ORAT' 20000 4* 1000 /
|
|
|
|
|
/
|
|
|
|
|
WECON
|
|
|
|
|
'SOMETHINGELSE' 15000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid well name in WEFAC
|
|
|
|
|
testSample = R"(
|
|
|
|
|
COMPDAT
|
|
|
|
|
'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 /
|
|
|
|
|
/
|
|
|
|
|
WCONPROD
|
|
|
|
|
'PROD' 'OPEN' 'ORAT' 20000 4* 1000 /
|
|
|
|
|
/
|
|
|
|
|
WEFAC
|
|
|
|
|
'SOMETHINGELSE' 0.5 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
2018-05-03 14:04:19 +02:00
|
|
|
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
// Invalid group name in GCONPROD
|
|
|
|
|
testSample = R"(
|
|
|
|
|
GCONPROD
|
|
|
|
|
'SOMETHINGELSE' 'ORAT' 20000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid group name in GEFAC
|
|
|
|
|
testSample = R"(
|
|
|
|
|
GEFAC
|
|
|
|
|
'SOMETHINGELSE' 0.5 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
|
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
|
|
|
|
// Invalid group name in GCONINJE
|
|
|
|
|
testSample = R"(
|
|
|
|
|
GCONINJE
|
|
|
|
|
'SOMETHINGELSE' 'WAT' 'RATE' 20000 /
|
|
|
|
|
/
|
|
|
|
|
)";
|
2018-05-03 09:34:54 +02:00
|
|
|
testSamples.push_back(testSample);
|
|
|
|
|
|
2018-04-22 10:25:17 +02:00
|
|
|
std::string deckinput;
|
|
|
|
|
|
|
|
|
|
for (std::string sample : testSamples) {
|
|
|
|
|
|
|
|
|
|
deckinput = defDeckString + sample;
|
|
|
|
|
auto deckUnSupported = parser.parseString( deckinput , parseContext );
|
|
|
|
|
|
|
|
|
|
EclipseGrid grid( deckUnSupported );
|
|
|
|
|
TableManager table ( deckUnSupported );
|
|
|
|
|
Eclipse3DProperties eclipseProperties ( deckUnSupported , table, grid);
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK_THROW( Schedule( deckUnSupported , grid , eclipseProperties, Phases(true, true, true) , parseContext), std::invalid_argument );
|
|
|
|
|
}
|
2018-05-15 12:38:04 +02:00
|
|
|
}
|