Added logging class. Changed bin output, added test DATA file, with 18 keywords.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
add_library(Parser Parser.cpp EclipseDeck.cpp)
|
||||
add_library(Logger Logger.cpp)
|
||||
|
||||
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
/*
|
||||
* File: EclipseDeck.cpp
|
||||
* Author: kflik
|
||||
*
|
||||
* Created on March 11, 2013, 3:42 PM
|
||||
/*
|
||||
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 "EclipseDeck.hpp"
|
||||
|
||||
EclipseDeck::EclipseDeck() {
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
/*
|
||||
* File: EclipseDeck.h
|
||||
* Author: kflik
|
||||
*
|
||||
* Created on March 11, 2013, 3:42 PM
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ECLIPSEDECK_H
|
||||
|
||||
47
eclipse/src/Logger.cpp
Normal file
47
eclipse/src/Logger.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
using namespace boost::posix_time;
|
||||
#include "Logger.hpp"
|
||||
|
||||
Logger::Logger() {
|
||||
m_logFile = "log.log";
|
||||
initLogger();
|
||||
}
|
||||
|
||||
Logger::Logger(const std::string& path) {
|
||||
m_logFile = path;
|
||||
initLogger();
|
||||
}
|
||||
|
||||
void Logger::debug(const std::string& message) {
|
||||
ptime now = second_clock::universal_time();
|
||||
m_logStream << to_simple_string(now) << " (DEBUG) " << message << "\n";
|
||||
}
|
||||
|
||||
void Logger::initLogger() {
|
||||
m_logStream.open(m_logFile.c_str());
|
||||
}
|
||||
|
||||
Logger::~Logger() {
|
||||
m_logStream.close();
|
||||
}
|
||||
|
||||
39
eclipse/src/Logger.hpp
Normal file
39
eclipse/src/Logger.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LOGGER_HPP
|
||||
#define LOGGER_HPP
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
Logger();
|
||||
Logger(const std::string& path);
|
||||
void debug(const std::string& message);
|
||||
virtual ~Logger();
|
||||
private:
|
||||
void initLogger();
|
||||
std::string m_logFile;
|
||||
std::ofstream m_logStream;
|
||||
};
|
||||
|
||||
#endif /* LOGGER_HPP */
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
/*
|
||||
* File: Parser.cpp
|
||||
* Author: kflik
|
||||
*
|
||||
* Created on March 11, 2013, 3:40 PM
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using std::ifstream;
|
||||
|
||||
@@ -21,13 +34,13 @@ Parser::Parser(const std::string &path) {
|
||||
|
||||
EclipseDeck Parser::parse() {
|
||||
EclipseDeck deck;
|
||||
m_log.append("Initializing inputstream from file: " + m_dataFilePath + "\n");
|
||||
m_logger.debug("Initializing inputstream from file: " + m_dataFilePath);
|
||||
|
||||
ifstream inputstream;
|
||||
inputstream.open(m_dataFilePath.c_str());
|
||||
|
||||
if (!inputstream.is_open()) {
|
||||
m_log.append("ERROR: unable to open file");
|
||||
m_logger.debug("ERROR: unable to open file");
|
||||
return deck;
|
||||
}
|
||||
|
||||
@@ -35,31 +48,23 @@ EclipseDeck Parser::parse() {
|
||||
while (!inputstream.eof()) {
|
||||
std::getline(inputstream, line);
|
||||
if (line.substr(0, 2) == "--") {
|
||||
m_log.append("COMMENT LINE < " + line + ">\n");
|
||||
m_logger.debug("COMMENT LINE < " + line + ">");
|
||||
}
|
||||
else if (boost::algorithm::trim_copy(line).length() == 0) {
|
||||
m_log.append("EMPTY LINE <" + line + ">\n");
|
||||
m_logger.debug("EMPTY LINE <" + line + ">");
|
||||
}
|
||||
else if (line.substr(0, 1) != " " && boost::algorithm::to_upper_copy(line) == line) {
|
||||
deck.addKeyword(line);
|
||||
m_log.append("KEYWORD LINE <" + line + ">\n");
|
||||
m_logger.debug("KEYWORD LINE <" + line + ">");
|
||||
}
|
||||
else {
|
||||
m_log.append("SOMETHING ELSE <" + line + ">\n");
|
||||
m_logger.debug("SOMETHING ELSE <" + line + ">");
|
||||
}
|
||||
}
|
||||
writeLogToFile();
|
||||
inputstream.close();
|
||||
return deck;
|
||||
}
|
||||
|
||||
void Parser::writeLogToFile() {
|
||||
std::ofstream logfile;
|
||||
logfile.open("log.txt");
|
||||
logfile << m_log;
|
||||
logfile.close();
|
||||
}
|
||||
|
||||
Parser::~Parser() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,27 @@
|
||||
/*
|
||||
* File: Parser.h
|
||||
* Author: kflik
|
||||
*
|
||||
* Created on March 11, 2013, 3:40 PM
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include "EclipseDeck.hpp"
|
||||
#include "Logger.hpp"
|
||||
#include <string>
|
||||
|
||||
class Parser {
|
||||
@@ -20,8 +34,7 @@ public:
|
||||
private:
|
||||
//EclipseDeck deck;
|
||||
std::string m_dataFilePath;
|
||||
std::string m_log;
|
||||
void writeLogToFile();
|
||||
Logger m_logger;
|
||||
};
|
||||
|
||||
#endif /* PARSER_H */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Add test executable
|
||||
add_executable(runUnitTests ParserTests.cpp)
|
||||
|
||||
target_link_libraries(runUnitTests Parser ${Boost_LIBRARIES} gtest gtest_main)
|
||||
target_link_libraries(runUnitTests Parser Logger ${Boost_LIBRARIES} gtest gtest_main)
|
||||
|
||||
add_test(runUnitTests ${EXECUTABLE_OUTPUT_PATH}/runUnitTests)
|
||||
add_test(NAME runUnitTests WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runUnitTests )
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
Copyright 2013 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
@@ -9,41 +29,35 @@
|
||||
|
||||
|
||||
TEST(ParserTest, Initializing) {
|
||||
Parser * parser = new Parser();
|
||||
ASSERT_TRUE(parser != NULL);
|
||||
delete parser;
|
||||
Parser parser;
|
||||
ASSERT_TRUE(&parser != NULL);
|
||||
}
|
||||
|
||||
TEST(ParserTest, ParseEmptyFileKeywordVectorEmpty) {
|
||||
Parser * parser = new Parser();
|
||||
EclipseDeck deck = parser->parse();
|
||||
Parser parser;
|
||||
EclipseDeck deck = parser.parse();
|
||||
ASSERT_EQ(0, deck.getNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)0, deck.getKeywords().size());
|
||||
delete parser;
|
||||
}
|
||||
|
||||
TEST(ParserTest, ParseFileWithOneKeyword) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/single.data");
|
||||
|
||||
Parser * parser = new Parser(singleKeywordFile.string());
|
||||
EclipseDeck deck = parser->parse();
|
||||
Parser parser(singleKeywordFile.string());
|
||||
EclipseDeck deck = parser.parse();
|
||||
|
||||
ASSERT_EQ(1, deck.getNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)1, deck.getKeywords().size());
|
||||
|
||||
delete parser;
|
||||
}
|
||||
|
||||
TEST(ParserTest, ParseFileWithManyKeywords) {
|
||||
boost::filesystem::path multipleKeywordFile("testdata/ECLIPSE.DATA");
|
||||
boost::filesystem::path multipleKeywordFile("testdata/gurbat_trimmed.DATA");
|
||||
|
||||
Parser * parser = new Parser(multipleKeywordFile.string());
|
||||
EclipseDeck deck = parser->parse();
|
||||
Parser parser(multipleKeywordFile.string());
|
||||
EclipseDeck deck = parser.parse();
|
||||
|
||||
ASSERT_EQ(1, deck.getNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)1, deck.getKeywords().size());
|
||||
|
||||
delete parser;
|
||||
ASSERT_EQ(18, deck.getNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)18, deck.getKeywords().size());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
160
eclipse/testdata/gurbat_trimmed.DATA
vendored
Normal file
160
eclipse/testdata/gurbat_trimmed.DATA
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
-- AUTO-SMOOTHER
|
||||
|
||||
-----------------------------------------------------------------
|
||||
-----------------------------------------------------------------
|
||||
-- This is the DATA file used by EnKF to run ECLIPSE. It is nearly a 100%
|
||||
-- normal ECLIPSE DATA file, but there have been som modifications to use
|
||||
-- it with EnkF. There are essentially three types of modifications:
|
||||
--
|
||||
-- * The parameters we want to update/estimate with EnKF are separated
|
||||
-- out in separate files, which are included into this file.
|
||||
--
|
||||
-- * There are som 'magic strings' looking like this: <xxxx>. These are
|
||||
-- replaced withother content by EnKF before the simulations starts -
|
||||
-- observe that the 'magic strings' never represent parameters to
|
||||
-- update.
|
||||
--
|
||||
-- * There are some special ECLIPSE keywords which must/must not be
|
||||
-- present in the DATA file.
|
||||
--
|
||||
-- All the places[1] where the DATA file has been update for EnKF are marked
|
||||
-- with EnKF.
|
||||
--
|
||||
-- [1]: There are many places with the string /private/joaho/ERT/git/ert/Gurbat - that is
|
||||
-- not essential EnKF - just convenience to get EnKF to insert the
|
||||
-- include path. The value of INCLUDE_PATH must be set with DATA_KW in
|
||||
-- the main configuration file.
|
||||
-----------------------------------------------------------------
|
||||
-----------------------------------------------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------
|
||||
-- Reservoir Simulation Model Building Basic Principles: Generic Reservoir
|
||||
-- by Gurbat S. Agaev, 26.06.2006
|
||||
--
|
||||
-- Objective: Explain simulation modelling steps
|
||||
-- 3-phase model
|
||||
-- Geological Grid - 120 x 200 x 42
|
||||
-----------------------------------------------------------------------------------------
|
||||
--
|
||||
--
|
||||
-- **************************************************************************************
|
||||
-- In this section simulation run specification is given
|
||||
-- **************************************************************************************
|
||||
--
|
||||
-----------------------------------------------------------------------------------------
|
||||
-- **************************************************************************************
|
||||
RUNSPEC
|
||||
-- **************************************************************************************
|
||||
-- Simulation run title
|
||||
TITLE
|
||||
Reservoir Simulation Model Building Basic Principles
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Simulation grid dimension (Imax, Jmax, Kmax)
|
||||
DIMENS
|
||||
40 64 14 /
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Big Model
|
||||
--BIGMODEL
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Simulation run start
|
||||
START
|
||||
----
|
||||
1 JAN 2000 /
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Fluid phases present
|
||||
OIL
|
||||
GAS
|
||||
WATER
|
||||
DISGAS
|
||||
VAPOIL
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Measurement unit used
|
||||
METRIC
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
--Options to process grid data
|
||||
--If MULTX-, MULTY- and MULTZ- are used, set first parameter= 'YES'
|
||||
GRIDOPTS
|
||||
-- MULTNUM? NRMULT
|
||||
'YES' 1* /
|
||||
INCLUDE
|
||||
'include/example_summary.txt' /
|
||||
|
||||
-- Tracer data to be written to SUMMARY file
|
||||
--FTPRSK1
|
||||
--FTPRSK2
|
||||
--FTPRSK3
|
||||
|
||||
--FTPTSK1
|
||||
--FTPTSK2
|
||||
--FTPTSK3
|
||||
|
||||
--WTPRSK1
|
||||
--/
|
||||
--WTPRSK2
|
||||
--/
|
||||
--WTPRSK3
|
||||
--/
|
||||
|
||||
--WTPTSK1
|
||||
--/
|
||||
--WTPTSK2
|
||||
--/
|
||||
--WTPTSK3
|
||||
--/
|
||||
--
|
||||
--
|
||||
-- **************************************************************************************
|
||||
-- In this section data required to describe history and prediction is given
|
||||
-- - well completions, well production/injection, well constraints
|
||||
-- - platform/production unit constraints, etc.
|
||||
-- **************************************************************************************
|
||||
--
|
||||
-----------------------------------------------------------------------------------------
|
||||
-- **************************************************************************************
|
||||
SCHEDULE
|
||||
-- **************************************************************************************
|
||||
-----------------------------------------------------------------------------------------
|
||||
-- EnKF: RPTSCHED must have RESTART=2 for EnKF to work.
|
||||
RPTSCHED
|
||||
RESTART=2 /
|
||||
|
||||
-- EnKF: The keyword 'SKIPREST' in the SCHEDULE section is essential
|
||||
-- EnKF: for EnKF to work.
|
||||
SKIPREST
|
||||
NOECHO
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Schedule file (well comptetions, well constraints, well groups, rates, etc.)
|
||||
-- Generated by SCHEDULE software
|
||||
-- Input data required and input data formats are given in directory
|
||||
--
|
||||
INCLUDE
|
||||
'target.SCH' /
|
||||
|
||||
--INCLUDE
|
||||
-- 'include/target.SCH' /
|
||||
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Production well VFP table (used for predictions)
|
||||
--INCLUDE
|
||||
-- 'include/example_vfp.vfp' /
|
||||
|
||||
--
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- If injection well VFP tables are required, include them in this section
|
||||
--
|
||||
|
||||
--INCLUDE
|
||||
-- 'prediction.sch' /
|
||||
|
||||
END
|
||||
Reference in New Issue
Block a user