diff --git a/eclipse/src/CMakeLists.txt b/eclipse/src/CMakeLists.txt
index 61811f373..73e6d5150 100644
--- a/eclipse/src/CMakeLists.txt
+++ b/eclipse/src/CMakeLists.txt
@@ -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})
diff --git a/eclipse/src/EclipseDeck.cpp b/eclipse/src/EclipseDeck.cpp
index 8661f88a8..e390f9732 100644
--- a/eclipse/src/EclipseDeck.cpp
+++ b/eclipse/src/EclipseDeck.cpp
@@ -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 .
*/
+
#include "EclipseDeck.hpp"
EclipseDeck::EclipseDeck() {
diff --git a/eclipse/src/EclipseDeck.hpp b/eclipse/src/EclipseDeck.hpp
index 07ca73a32..7e9473356 100644
--- a/eclipse/src/EclipseDeck.hpp
+++ b/eclipse/src/EclipseDeck.hpp
@@ -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 .
*/
#ifndef ECLIPSEDECK_H
diff --git a/eclipse/src/Logger.cpp b/eclipse/src/Logger.cpp
new file mode 100644
index 000000000..aa1b4bd58
--- /dev/null
+++ b/eclipse/src/Logger.cpp
@@ -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 .
+ */
+
+
+#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();
+}
+
diff --git a/eclipse/src/Logger.hpp b/eclipse/src/Logger.hpp
new file mode 100644
index 000000000..0b0fcc972
--- /dev/null
+++ b/eclipse/src/Logger.hpp
@@ -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 .
+ */
+
+
+#ifndef LOGGER_HPP
+#define LOGGER_HPP
+#include
+#include
+
+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 */
+
diff --git a/eclipse/src/Parser.cpp b/eclipse/src/Parser.cpp
index 35e0efcde..18f192879 100644
--- a/eclipse/src/Parser.cpp
+++ b/eclipse/src/Parser.cpp
@@ -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 .
*/
+
+
#include
#include
-#include
#include
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() {
}
diff --git a/eclipse/src/Parser.hpp b/eclipse/src/Parser.hpp
index 4ce72cd9f..ed3ed0cac 100644
--- a/eclipse/src/Parser.hpp
+++ b/eclipse/src/Parser.hpp
@@ -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 .
*/
+
#ifndef PARSER_H
#define PARSER_H
#include "EclipseDeck.hpp"
+#include "Logger.hpp"
#include
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 */
diff --git a/eclipse/src/tests/CMakeLists.txt b/eclipse/src/tests/CMakeLists.txt
index d727debd2..7a648eec2 100644
--- a/eclipse/src/tests/CMakeLists.txt
+++ b/eclipse/src/tests/CMakeLists.txt
@@ -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 )
diff --git a/eclipse/src/tests/ParserTests.cpp b/eclipse/src/tests/ParserTests.cpp
index 1482830f2..7e7462614 100644
--- a/eclipse/src/tests/ParserTests.cpp
+++ b/eclipse/src/tests/ParserTests.cpp
@@ -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 .
+ */
+
+
#include
#include
#include
@@ -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) {
diff --git a/eclipse/testdata/gurbat_trimmed.DATA b/eclipse/testdata/gurbat_trimmed.DATA
new file mode 100644
index 000000000..63d8adcc1
--- /dev/null
+++ b/eclipse/testdata/gurbat_trimmed.DATA
@@ -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: . 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