diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b116b5b59..ef829c2a07a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,27 +157,51 @@ endif() # Build the compare utilities if(ENABLE_ECL_INPUT) - add_library(testutil STATIC - examples/test_util/EclFile.cpp - examples/test_util/EclFilesComparator.cpp - examples/test_util/EclOutput.cpp - examples/test_util/EclRegressionTest.cpp - examples/test_util/EclUtil.cpp - examples/test_util/EGrid.cpp - examples/test_util/ERft.cpp - examples/test_util/ERst.cpp - examples/test_util/ESmry.cpp) + add_executable(compareECL + test_util/EclFilesComparator.cpp + test_util/EclRegressionTest.cpp + test_util/compareECL.cpp + ) + + add_executable(convertECL + test_util/convertECL.cpp + ) + foreach(target compareECL convertECL) - add_executable(${target} examples/test_util/${target}.cpp) - target_link_libraries(${target} testutil opmcommon) + target_link_libraries(${target} opmcommon) install(TARGETS ${target} DESTINATION bin) endforeach() # Add the tests - set(_libs testutil opmcommon + set(_libs opmcommon ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - foreach(test test_EclFilesComparator test_EclIO test_EclRegressionTest - test_EGrid test_ERft test_ERst test_ESmry) + + opm_add_test(test_EclFilesComparator + CONDITION + ENABLE_ECL_INPUT + SOURCES + tests/test_EclFilesComparator.cpp + test_util/EclFilesComparator.cpp + LIBRARIES + ${_libs} + WORKING_DIRECTORY + ${PROJECT_BINARY_DIR}/tests + ) + + opm_add_test(test_EclRegressionTest + CONDITION + ENABLE_ECL_INPUT + SOURCES + tests/test_EclRegressionTest.cpp + test_util/EclFilesComparator.cpp + test_util/EclRegressionTest.cpp + LIBRARIES + ${_libs} + WORKING_DIRECTORY + ${PROJECT_BINARY_DIR}/tests + ) + + foreach(test test_EclIO test_EGrid test_ERft test_ERst test_ESmry) opm_add_test(${test} CONDITION ENABLE_ECL_INPUT LIBRARIES ${_libs} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index e9fb36d5bb7..18a44f1b7ad 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -164,6 +164,13 @@ if(ENABLE_ECL_INPUT) endif() if(ENABLE_ECL_OUTPUT) list( APPEND MAIN_SOURCE_FILES + src/opm/io/eclipse/EclFile.cpp + src/opm/io/eclipse/EclOutput.cpp + src/opm/io/eclipse/EclUtil.cpp + src/opm/io/eclipse/EGrid.cpp + src/opm/io/eclipse/ERft.cpp + src/opm/io/eclipse/ERst.cpp + src/opm/io/eclipse/ESmry.cpp src/opm/output/eclipse/AggregateConnectionData.cpp src/opm/output/eclipse/AggregateGroupData.cpp src/opm/output/eclipse/AggregateMSWData.cpp @@ -562,6 +569,14 @@ if(ENABLE_ECL_INPUT) endif() if(ENABLE_ECL_OUTPUT) list(APPEND PUBLIC_HEADER_FILES + opm/io/eclipse/EclFile.hpp + opm/io/eclipse/EclIOdata.hpp + opm/io/eclipse/EclOutput.hpp + opm/io/eclipse/EclUtil.hpp + opm/io/eclipse/EGrid.hpp + opm/io/eclipse/ERft.hpp + opm/io/eclipse/ERst.hpp + opm/io/eclipse/ESmry.hpp opm/output/data/Cells.hpp opm/output/data/Solution.hpp opm/output/data/Wells.hpp diff --git a/examples/test_util/EGrid.hpp b/opm/io/eclipse/EGrid.hpp similarity index 91% rename from examples/test_util/EGrid.hpp rename to opm/io/eclipse/EGrid.hpp index 7cb570565ed..cada6c31c44 100644 --- a/examples/test_util/EGrid.hpp +++ b/opm/io/eclipse/EGrid.hpp @@ -16,10 +16,10 @@ along with OPM. If not, see . */ -#ifndef EGRID_HPP -#define EGRID_HPP +#ifndef OPM_IO_EGRID_HPP +#define OPM_IO_EGRID_HPP -#include "EclFile.hpp" +#include #include #include @@ -29,6 +29,7 @@ #include #include +namespace Opm { namespace ecl { class EGrid : public EclFile { @@ -59,4 +60,6 @@ class EGrid : public EclFile std::vector zcorn_array; }; -#endif +}} // namespace Opm::ecl + +#endif // OPM_IO_EGRID_HPP diff --git a/examples/test_util/ERft.hpp b/opm/io/eclipse/ERft.hpp similarity index 92% rename from examples/test_util/ERft.hpp rename to opm/io/eclipse/ERft.hpp index 2c0144fe5cf..0d8a327f55f 100644 --- a/examples/test_util/ERft.hpp +++ b/opm/io/eclipse/ERft.hpp @@ -16,20 +16,20 @@ along with OPM. If not, see . */ -#ifndef ERFT_HPP -#define ERFT_HPP +#ifndef OPM_IO_ERFT_HPP +#define OPM_IO_ERFT_HPP +#include -#include "EclFile.hpp" - -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +namespace Opm { namespace ecl { class ERft : public EclFile { @@ -79,5 +79,6 @@ class ERft : public EclFile const RftDate& date) const; }; -#endif +}} // namespace Opm::ecl +#endif // OPM_IO_ERFT_HPP diff --git a/examples/test_util/ERst.hpp b/opm/io/eclipse/ERst.hpp similarity index 89% rename from examples/test_util/ERst.hpp rename to opm/io/eclipse/ERst.hpp index 20e82cb64ee..2ba9ac2bfd1 100644 --- a/examples/test_util/ERst.hpp +++ b/opm/io/eclipse/ERst.hpp @@ -16,19 +16,17 @@ along with OPM. If not, see . */ -#ifndef ERST_HPP -#define ERST_HPP +#ifndef OPM_IO_ERST_HPP +#define OPM_IO_ERST_HPP +#include -#include "EclFile.hpp" - -#include +#include #include -#include +#include #include -#include -#include +namespace Opm { namespace ecl { class ERst : public EclFile { @@ -54,4 +52,6 @@ class ERst : public EclFile int getArrayIndex(const std::string& name, int seqnum) const; }; -#endif +}} // namespace Opm::ecl + +#endif // OPM_IO_ERST_HPP diff --git a/examples/test_util/ESmry.hpp b/opm/io/eclipse/ESmry.hpp similarity index 92% rename from examples/test_util/ESmry.hpp rename to opm/io/eclipse/ESmry.hpp index 0e86f4431e0..6d94d986071 100644 --- a/examples/test_util/ESmry.hpp +++ b/opm/io/eclipse/ESmry.hpp @@ -16,15 +16,13 @@ along with OPM. If not, see . */ -#ifndef ESMRY_HPP -#define ESMRY_HPP +#ifndef OPM_IO_ESMRY_HPP +#define OPM_IO_ESMRY_HPP -#include #include -#include #include -#include -#include + +namespace Opm { namespace ecl { class ESmry { @@ -55,6 +53,6 @@ class ESmry std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num); }; -#endif - +}} // namespace Opm::ecl +#endif // OPM_IO_ESMRY_HPP diff --git a/examples/test_util/EclFile.hpp b/opm/io/eclipse/EclFile.hpp similarity index 87% rename from examples/test_util/EclFile.hpp rename to opm/io/eclipse/EclFile.hpp index a7e46849572..968f93c83e1 100644 --- a/examples/test_util/EclFile.hpp +++ b/opm/io/eclipse/EclFile.hpp @@ -16,22 +16,20 @@ along with OPM. If not, see . */ -#ifndef ECLFILE_HPP -#define ECLFILE_HPP +#ifndef OPM_IO_ECLFILE_HPP +#define OPM_IO_ECLFILE_HPP #include -#include -#include -#include +#include + #include -#include -#include -#include +#include +#include #include -#include +#include -namespace EIOD = Opm::ecl; +namespace Opm { namespace ecl { class EclFile { @@ -53,7 +51,7 @@ class EclFile char_array.clear(); } - using EclEntry = std::tuple; + using EclEntry = std::tuple; std::vector getList() const; template @@ -77,7 +75,7 @@ class EclFile std::unordered_map> char_array; std::vector array_name; - std::vector array_type; + std::vector array_type; std::vector array_size; std::vector ifStreamPos; @@ -85,7 +83,7 @@ class EclFile std::map array_index; template - const std::vector& getImpl(int arrIndex, EIOD::eclArrType type, + const std::vector& getImpl(int arrIndex, eclArrType type, const std::unordered_map>& array, const std::string& typeStr) { @@ -98,7 +96,7 @@ class EclFile loadData(arrIndex); } - return array.find(arrIndex)->second; + return array.at(arrIndex); } private: @@ -107,4 +105,6 @@ class EclFile void loadArray(std::fstream& fileH, int arrIndex); }; -#endif +}} // namespace Opm::ecl + +#endif // OPM_IO_ECLFILE_HPP diff --git a/examples/test_util/data/EclIOdata.hpp b/opm/io/eclipse/EclIOdata.hpp similarity index 95% rename from examples/test_util/data/EclIOdata.hpp rename to opm/io/eclipse/EclIOdata.hpp index 63f265dd02e..a2ed0c2a826 100644 --- a/examples/test_util/data/EclIOdata.hpp +++ b/opm/io/eclipse/EclIOdata.hpp @@ -17,24 +17,19 @@ along with OPM. If not, see . */ -#ifndef OPM_ECLIO_DATA_HPP -#define OPM_ECLIO_DATA_HPP +#ifndef OPM_IO_ECLIODATA_HPP +#define OPM_IO_ECLIODATA_HPP #include - -namespace Opm { - - namespace ecl { +namespace Opm { namespace ecl { // type MESS have no assisiated data - enum eclArrType { INTE, REAL, DOUB, CHAR, LOGI, MESS }; // named constants related to binary file format - const unsigned int true_value = 0xffffffff; const unsigned int false_value = 0x00000000; @@ -51,7 +46,6 @@ namespace Opm { const int MaxBlockSizeChar = 840; // Maximum block size for CHAR arrays in binary files // named constants related to formatted file file format - const int MaxNumBlockInte = 1000; // maximum number of Inte values in block => hard line shift const int MaxNumBlockReal = 1000; // maximum number of Real values in block => hard line shift const int MaxNumBlockDoub = 1000; // maximum number of Doub values in block => hard line shift @@ -69,8 +63,7 @@ namespace Opm { const int columnWidthDoub = 23; // number of characters fore each Inte Element const int columnWidthLogi = 3; // number of characters fore each Inte Element const int columnWidthChar = 11; // number of characters fore each Inte Element - - } // ecl -} // Opm -#endif // OPM_ECLIO_DATA_HPP +}} // namespace Opm::ecl + +#endif // OPM_IO_ECLIODATA_HPP diff --git a/examples/test_util/EclOutput.hpp b/opm/io/eclipse/EclOutput.hpp similarity index 82% rename from examples/test_util/EclOutput.hpp rename to opm/io/eclipse/EclOutput.hpp index 1d1825eb221..776bf2a8dcf 100644 --- a/examples/test_util/EclOutput.hpp +++ b/opm/io/eclipse/EclOutput.hpp @@ -15,19 +15,19 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#ifndef ECL_OUTPUT_HPP -#define ECL_OUTPUT_HPP +#ifndef OPM_IO_ECLOUTPUT_HPP +#define OPM_IO_ECLOUTPUT_HPP #include +#include #include #include #include #include -#include - -namespace EIOD = Opm::ecl; +#include +namespace Opm { namespace ecl { class EclOutput { @@ -38,41 +38,41 @@ class EclOutput void write(const std::string& name, const std::vector& data) { - EIOD::eclArrType arrType = EIOD::MESS; + eclArrType arrType = MESS; if (typeid(T) == typeid(int)) - arrType = EIOD::INTE; + arrType = INTE; else if (typeid(T) == typeid(float)) - arrType = EIOD::REAL; + arrType = REAL; else if (typeid(T) == typeid(double)) - arrType = EIOD::DOUB; + arrType = DOUB; else if (typeid(T) == typeid(bool)) - arrType = EIOD::LOGI; + arrType = LOGI; else if (typeid(T) == typeid(char)) - arrType = EIOD::MESS; + arrType = MESS; if (isFormatted) { writeFormattedHeader(name, data.size(), arrType); - if (arrType != EIOD::MESS) + if (arrType != MESS) writeFormattedArray(data); } else { writeBinaryHeader(name, data.size(), arrType); - if (arrType != EIOD::MESS) + if (arrType != MESS) writeBinaryArray(data); } } private: - void writeBinaryHeader(const std::string& arrName, int size, EIOD::eclArrType arrType); + void writeBinaryHeader(const std::string& arrName, int size, eclArrType arrType); template void writeBinaryArray(const std::vector& data); void writeBinaryCharArray(const std::vector& data); - void writeFormattedHeader(const std::string& arrName, int size, EIOD::eclArrType arrType); + void writeFormattedHeader(const std::string& arrName, int size, eclArrType arrType); template void writeFormattedArray(const std::vector& data); @@ -91,4 +91,6 @@ template<> void EclOutput::write(const std::string& name, const std::vector& data); -#endif +}} // namespace Opm::ecl + +#endif // OPM_IO_ECLOUTPUT_HPP diff --git a/examples/test_util/EclUtil.hpp b/opm/io/eclipse/EclUtil.hpp similarity index 60% rename from examples/test_util/EclUtil.hpp rename to opm/io/eclipse/EclUtil.hpp index 36aaa394949..7ea61a7c306 100644 --- a/examples/test_util/EclUtil.hpp +++ b/opm/io/eclipse/EclUtil.hpp @@ -16,25 +16,25 @@ along with OPM. If not, see . */ -#ifndef ECL_UTIL_HPP -#define ECL_UTIL_HPP +#ifndef OPM_IO_ECLUTIL_HPP +#define OPM_IO_ECLUTIL_HPP + +#include #include #include -#include +namespace Opm { namespace ecl { + + int flipEndianInt(int num); + float flipEndianFloat(float num); + double flipEndianDouble(double num); -namespace Opm { - namespace ecl { - int flipEndianInt(int num); - float flipEndianFloat(float num); - double flipEndianDouble(double num); + std::tuple block_size_data_binary(eclArrType arrType); + std::tuple block_size_data_formatted(eclArrType arrType); - std::tuple block_size_data_binary(eclArrType arrType); - std::tuple block_size_data_formatted(eclArrType arrType); + std::string trimr(const std::string &str1); - std::string trimr(const std::string &str1); - } -} +}} // namespace Opm::ecl -#endif +#endif // OPM_IO_ECLUTIL_HPP diff --git a/examples/test_util/EGrid.cpp b/src/opm/io/eclipse/EGrid.cpp similarity index 97% rename from examples/test_util/EGrid.cpp rename to src/opm/io/eclipse/EGrid.cpp index 2ff6aa8a8b2..f7fe8e8894d 100644 --- a/examples/test_util/EGrid.cpp +++ b/src/opm/io/eclipse/EGrid.cpp @@ -16,17 +16,19 @@ along with OPM. If not, see . */ -#include "EGrid.hpp" +#include #include -#include -#include -#include + +#include +#include #include #include -#include #include +#include +#include +namespace Opm { namespace ecl { EGrid::EGrid(const std::string &filename) : EclFile(filename) { @@ -184,3 +186,5 @@ void EGrid::getCellCorners(int globindex, std::vector& X, { return getCellCorners(ijk_from_global_index(globindex),X,Y,Z); } + +}} // namespace Opm::ecl diff --git a/examples/test_util/ERft.cpp b/src/opm/io/eclipse/ERft.cpp similarity index 96% rename from examples/test_util/ERft.cpp rename to src/opm/io/eclipse/ERft.cpp index 342de035fe3..fb1decc6917 100644 --- a/examples/test_util/ERft.cpp +++ b/src/opm/io/eclipse/ERft.cpp @@ -16,16 +16,18 @@ along with OPM. If not, see . */ -#include "ERft.hpp" +#include #include + +#include +#include +#include +#include #include -#include #include -#include -#include -#include +namespace Opm { namespace ecl { ERft::ERft(const std::string &filename) : EclFile(filename) { @@ -162,7 +164,7 @@ ERft::getRft(const std::string& name, const std::string &wellName, { int arrInd = getArrayIndex(name, wellName, date); - if (array_type[arrInd] != EIOD::REAL) { + if (array_type[arrInd] != REAL) { std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type"; OPM_THROW(std::runtime_error, message); } @@ -178,7 +180,7 @@ ERft::getRft(const std::string& name, const std::string& wellName, { int arrInd = getArrayIndex(name, wellName, date); - if (array_type[arrInd] != EIOD::DOUB) { + if (array_type[arrInd] != DOUB) { std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type"; OPM_THROW(std::runtime_error, message); } @@ -194,7 +196,7 @@ ERft::getRft(const std::string& name, const std::string& wellName, { int arrInd = getArrayIndex(name, wellName, date); - if (array_type[arrInd] != EIOD::INTE) { + if (array_type[arrInd] != INTE) { std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type"; OPM_THROW(std::runtime_error, message); } @@ -210,7 +212,7 @@ ERft::getRft(const std::string& name, const std::string& wellName, { int arrInd = getArrayIndex(name, wellName, date); - if (array_type[arrInd] != EIOD::LOGI) { + if (array_type[arrInd] != LOGI) { std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type"; OPM_THROW(std::runtime_error, message); } @@ -226,7 +228,7 @@ ERft::getRft(const std::string& name, const std::string& wellName, { int arrInd = getArrayIndex(name, wellName, date); - if (array_type[arrInd] != EIOD::CHAR) { + if (array_type[arrInd] != CHAR) { std::string message = "Array " + name + " found in RFT file for selected date and well, but called with wrong type"; OPM_THROW(std::runtime_error, message); } @@ -308,3 +310,5 @@ std::vector ERft::listOfdates() const { return { this->dateList.begin(), this->dateList.end() }; } + +}} // namespace Opm::ecl diff --git a/examples/test_util/ERst.cpp b/src/opm/io/eclipse/ERst.cpp similarity index 91% rename from examples/test_util/ERst.cpp rename to src/opm/io/eclipse/ERst.cpp index 5d809041efa..8b5cf8b9347 100644 --- a/examples/test_util/ERst.cpp +++ b/src/opm/io/eclipse/ERst.cpp @@ -16,17 +16,19 @@ along with OPM. If not, see . */ -#include "ERst.hpp" +#include +#include +#include +#include +#include #include -#include #include -#include -#include -#include +namespace Opm { namespace ecl { -ERst::ERst(const std::string& filename) : EclFile(filename) +ERst::ERst(const std::string& filename) + : EclFile(filename) { loadData("SEQNUM"); @@ -143,7 +145,7 @@ template<> const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) { int ind = getArrayIndex(name, reportStepNumber); - return getImpl(ind, EIOD::INTE, inte_array, "integer"); + return getImpl(ind, INTE, inte_array, "integer"); } @@ -151,7 +153,7 @@ template<> const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) { int ind = getArrayIndex(name, reportStepNumber); - return getImpl(ind, EIOD::REAL, real_array, "float"); + return getImpl(ind, REAL, real_array, "float"); } @@ -159,7 +161,7 @@ template<> const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) { int ind = getArrayIndex(name, reportStepNumber); - return getImpl(ind, EIOD::DOUB, doub_array, "double"); + return getImpl(ind, DOUB, doub_array, "double"); } @@ -167,12 +169,14 @@ template<> const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) { int ind = getArrayIndex(name, reportStepNumber); - return getImpl(ind, EIOD::LOGI, logi_array, "bool"); + return getImpl(ind, LOGI, logi_array, "bool"); } template<> const std::vector& ERst::getRst(const std::string& name, int reportStepNumber) { int ind = getArrayIndex(name, reportStepNumber); - return getImpl(ind, EIOD::CHAR, char_array, "string"); + return getImpl(ind, CHAR, char_array, "string"); } + +}} // namespace Opm::ecl diff --git a/examples/test_util/ESmry.cpp b/src/opm/io/eclipse/ESmry.cpp similarity index 99% rename from examples/test_util/ESmry.cpp rename to src/opm/io/eclipse/ESmry.cpp index e9e6db2a877..b4478a2e2a3 100644 --- a/examples/test_util/ESmry.cpp +++ b/src/opm/io/eclipse/ESmry.cpp @@ -16,6 +16,7 @@ along with OPM. If not, see . */ +#include #include #include @@ -27,8 +28,7 @@ #include #include -#include "EclFile.hpp" -#include "ESmry.hpp" +#include /* @@ -50,6 +50,8 @@ */ +namespace Opm { namespace ecl { + ESmry::ESmry(const std::string &filename, bool loadBaseRunData) { std::string rootN; @@ -308,7 +310,7 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) for (auto keyw : keywList){ keyword.push_back(keyw); } -}; +} void ESmry::getRstString(const std::vector& restartArray, std::string& pathRst, std::string& rootN) const { @@ -429,3 +431,5 @@ const std::vector& ESmry::get(const std::string& name) const return param[ind]; } + +}} // namespace Opm::ecl diff --git a/examples/test_util/EclFile.cpp b/src/opm/io/eclipse/EclFile.cpp similarity index 86% rename from examples/test_util/EclFile.cpp rename to src/opm/io/eclipse/EclFile.cpp index 6d3c91feeaf..c9778cace5c 100644 --- a/examples/test_util/EclFile.cpp +++ b/src/opm/io/eclipse/EclFile.cpp @@ -16,11 +16,14 @@ along with OPM. If not, see . */ -#include "EclFile.hpp" -#include "EclUtil.hpp" +#include +#include #include +#include #include +#include +#include #include #include #include @@ -64,14 +67,14 @@ bool isEOF(std::fstream* fileH) void readBinaryHeader(std::fstream& fileH, std::string& arrName, - int& size, EIOD::eclArrType &arrType) + int& size, Opm::ecl::eclArrType &arrType) { int bhead; std::string tmpStrName(8,' '); std::string tmpStrType(4,' '); fileH.read(reinterpret_cast(&bhead), sizeof(bhead)); - bhead = EIOD::flipEndianInt(bhead); + bhead = Opm::ecl::flipEndianInt(bhead); if (bhead != 16) { std::string message="Error reading binary header. Expected 16 bytes of header data, found " + std::to_string(bhead); @@ -81,12 +84,12 @@ void readBinaryHeader(std::fstream& fileH, std::string& arrName, fileH.read(&tmpStrName[0], 8); fileH.read(reinterpret_cast(&size), sizeof(size)); - size = EIOD::flipEndianInt(size); + size = Opm::ecl::flipEndianInt(size); fileH.read(&tmpStrType[0], 4); fileH.read(reinterpret_cast(&bhead), sizeof(bhead)); - bhead = EIOD::flipEndianInt(bhead); + bhead = Opm::ecl::flipEndianInt(bhead); if (bhead != 16) { std::string message="Error reading binary header. Expected 16 bytes of header data, found " + std::to_string(bhead); @@ -95,54 +98,54 @@ void readBinaryHeader(std::fstream& fileH, std::string& arrName, arrName = tmpStrName; if (tmpStrType == "INTE") - arrType = EIOD::INTE; + arrType = Opm::ecl::INTE; else if (tmpStrType == "REAL") - arrType = EIOD::REAL; + arrType = Opm::ecl::REAL; else if (tmpStrType == "DOUB") - arrType = EIOD::DOUB; + arrType = Opm::ecl::DOUB; else if (tmpStrType == "CHAR") - arrType = EIOD::CHAR; + arrType = Opm::ecl::CHAR; else if (tmpStrType =="LOGI") - arrType = EIOD::LOGI; + arrType = Opm::ecl::LOGI; else if (tmpStrType == "MESS") - arrType = EIOD::MESS; + arrType = Opm::ecl::MESS; else OPM_THROW(std::runtime_error, "Error, unknown array type '" + tmpStrType +"'"); } -unsigned long int sizeOnDiskBinary(int num, EIOD::eclArrType arrType) +unsigned long int sizeOnDiskBinary(int num, Opm::ecl::eclArrType arrType) { unsigned long int size = 0; - if (arrType == EIOD::MESS) { + if (arrType == Opm::ecl::MESS) { if (num > 0) { std::string message = "In routine calcSizeOfArray, type MESS can not have size > 0"; OPM_THROW(std::invalid_argument, message); } } else { - auto sizeData = EIOD::block_size_data_binary(arrType); + auto sizeData = Opm::ecl::block_size_data_binary(arrType); int sizeOfElement = std::get<0>(sizeData); int maxBlockSize = std::get<1>(sizeData); int maxNumberOfElements = maxBlockSize / sizeOfElement; size = num * sizeOfElement; - size = size + ((num-1) / maxNumberOfElements) * 2 * EIOD::sizeOfInte; // 8 byte (two integers) every 1000 element + size = size + ((num-1) / maxNumberOfElements) * 2 * Opm::ecl::sizeOfInte; // 8 byte (two integers) every 1000 element if (num > 0) { - size = size + 2 * EIOD::sizeOfInte; + size = size + 2 * Opm::ecl::sizeOfInte; } } return size; } -unsigned long int sizeOnDiskFormatted(const int num, EIOD::eclArrType arrType) +unsigned long int sizeOnDiskFormatted(const int num, Opm::ecl::eclArrType arrType) { unsigned long int size = 0; - if (arrType == EIOD::MESS) { + if (arrType == Opm::ecl::MESS) { if (num > 0) { OPM_THROW(std::invalid_argument, "In routine calcSizeOfArray, type MESS can not have size > 0"); } @@ -185,7 +188,7 @@ unsigned long int sizeOnDiskFormatted(const int num, EIOD::eclArrType arrType) template -std::vector readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArrType type, +std::vector readBinaryArray(std::fstream& fileH, const int size, Opm::ecl::eclArrType type, std::function& flip) { std::vector arr; @@ -201,7 +204,7 @@ std::vector readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArr while (rest > 0) { int dhead; fileH.read(reinterpret_cast(&dhead), sizeof(dhead)); - dhead = EIOD::flipEndianInt(dhead); + dhead = Opm::ecl::flipEndianInt(dhead); int num = dhead / sizeOfElement; @@ -225,7 +228,7 @@ std::vector readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArr int dtail; fileH.read(reinterpret_cast(&dtail), sizeof(dtail)); - dtail = EIOD::flipEndianInt(dtail); + dtail = Opm::ecl::flipEndianInt(dtail); if (dhead != dtail) { OPM_THROW(std::runtime_error, "Error reading binary data, tail not matching header."); @@ -238,22 +241,22 @@ std::vector readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArr std::vector readBinaryInteArray(std::fstream &fileH, const int size) { - std::function f = EIOD::flipEndianInt; - return readBinaryArray(fileH, size, EIOD::INTE, f); + std::function f = Opm::ecl::flipEndianInt; + return readBinaryArray(fileH, size, Opm::ecl::INTE, f); } std::vector readBinaryRealArray(std::fstream& fileH, const int size) { - std::function f = EIOD::flipEndianFloat; - return readBinaryArray(fileH, size, EIOD::REAL, f); + std::function f = Opm::ecl::flipEndianFloat; + return readBinaryArray(fileH, size, Opm::ecl::REAL, f); } std::vector readBinaryDoubArray(std::fstream& fileH, const int size) { - std::function f = EIOD::flipEndianDouble; - return readBinaryArray(fileH, size, EIOD::DOUB, f); + std::function f = Opm::ecl::flipEndianDouble; + return readBinaryArray(fileH, size, Opm::ecl::DOUB, f); } std::vector readBinaryLogiArray(std::fstream &fileH, const int size) @@ -261,9 +264,9 @@ std::vector readBinaryLogiArray(std::fstream &fileH, const int size) std::function f = [](unsigned int intVal) { bool value; - if (intVal == EIOD::true_value) { + if (intVal == Opm::ecl::true_value) { value = true; - } else if (intVal == EIOD::false_value) { + } else if (intVal == Opm::ecl::false_value) { value = false; } else { OPM_THROW(std::runtime_error, "Error reading logi value"); @@ -271,7 +274,7 @@ std::vector readBinaryLogiArray(std::fstream &fileH, const int size) return value; }; - return readBinaryArray(fileH, size, EIOD::LOGI, f); + return readBinaryArray(fileH, size, Opm::ecl::LOGI, f); } @@ -281,9 +284,9 @@ std::vector readBinaryCharArray(std::fstream& fileH, const int size std::function f = [](const Char8& val) { std::string res(val.begin(), val.end()); - return EIOD::trimr(res); + return Opm::ecl::trimr(res); }; - return readBinaryArray(fileH, size, EIOD::CHAR, f); + return readBinaryArray(fileH, size, Opm::ecl::CHAR, f); } @@ -300,10 +303,10 @@ std::vector split_string(const std::string& inputStr) void readFormattedHeader(std::fstream& fileH, std::string& arrName, - int &num, EIOD::eclArrType &arrType) + int &num, Opm::ecl::eclArrType &arrType) { std::string line; - getline(fileH,line); + std::getline(fileH,line); int p1 = line.find_first_of("'"); int p2 = line.find_first_of("'",p1+1); @@ -321,17 +324,17 @@ void readFormattedHeader(std::fstream& fileH, std::string& arrName, num = std::stoi(antStr); if (arrTypeStr == "INTE") - arrType = EIOD::INTE; + arrType = Opm::ecl::INTE; else if (arrTypeStr == "REAL") - arrType = EIOD::REAL; + arrType = Opm::ecl::REAL; else if (arrTypeStr == "DOUB") - arrType = EIOD::DOUB; + arrType = Opm::ecl::DOUB; else if (arrTypeStr == "CHAR") - arrType = EIOD::CHAR; + arrType = Opm::ecl::CHAR; else if (arrTypeStr == "LOGI") - arrType = EIOD::LOGI; + arrType = Opm::ecl::LOGI; else if (arrTypeStr == "MESS") - arrType = EIOD::MESS; + arrType = Opm::ecl::MESS; else OPM_THROW(std::runtime_error, "Error, unknown array type '" + arrTypeStr +"'"); @@ -421,7 +424,7 @@ std::vector readFormattedCharArray(std::fstream& fileH, const int s if (value == " ") { arr.push_back(""); } else { - arr.push_back(EIOD::trimr(value)); + arr.push_back(Opm::ecl::trimr(value)); } num++; @@ -495,6 +498,9 @@ std::vector readFormattedDoubArray(std::fstream& fileH, const int size) } // anonymous namespace +// ========================================================================== + +namespace Opm { namespace ecl { EclFile::EclFile(const std::string& filename) : inputFilename(filename) { @@ -516,7 +522,7 @@ EclFile::EclFile(const std::string& filename) : inputFilename(filename) int n = 0; while (!isEOF(&fileH)) { std::string arrName(8,' '); - EIOD::eclArrType arrType; + eclArrType arrType; int num; if (formatted) { @@ -528,7 +534,7 @@ EclFile::EclFile(const std::string& filename) : inputFilename(filename) array_size.push_back(num); array_type.push_back(arrType); - array_name.push_back(EIOD::trimr(arrName)); + array_name.push_back(trimr(arrName)); array_index[array_name[n]] = n; unsigned long int pos = fileH.tellg(); @@ -557,22 +563,22 @@ void EclFile::loadArray(std::fstream& fileH, int arrIndex) if (formatted) { switch (array_type[arrIndex]) { - case EIOD::INTE: + case INTE: inte_array[arrIndex] = readFormattedInteArray(fileH, array_size[arrIndex]); break; - case EIOD::REAL: + case REAL: real_array[arrIndex] = readFormattedRealArray(fileH, array_size[arrIndex]); break; - case EIOD::DOUB: + case DOUB: doub_array[arrIndex] = readFormattedDoubArray(fileH, array_size[arrIndex]); break; - case EIOD::LOGI: + case LOGI: logi_array[arrIndex] = readFormattedLogiArray(fileH, array_size[arrIndex]); break; - case EIOD::CHAR: + case CHAR: char_array[arrIndex] = readFormattedCharArray(fileH, array_size[arrIndex]); break; - case EIOD::MESS: + case MESS: break; default: OPM_THROW(std::runtime_error, "Asked to read unexpected array type"); @@ -581,22 +587,22 @@ void EclFile::loadArray(std::fstream& fileH, int arrIndex) } else { switch (array_type[arrIndex]) { - case EIOD::INTE: + case INTE: inte_array[arrIndex] = readBinaryInteArray(fileH, array_size[arrIndex]); break; - case EIOD::REAL: + case REAL: real_array[arrIndex] = readBinaryRealArray(fileH, array_size[arrIndex]); break; - case EIOD::DOUB: + case DOUB: doub_array[arrIndex] = readBinaryDoubArray(fileH, array_size[arrIndex]); break; - case EIOD::LOGI: + case LOGI: logi_array[arrIndex] = readBinaryLogiArray(fileH, array_size[arrIndex]); break; - case EIOD::CHAR: + case CHAR: char_array[arrIndex] = readBinaryCharArray(fileH, array_size[arrIndex]); break; - case EIOD::MESS: + case MESS: break; default: OPM_THROW(std::runtime_error, "Asked to read unexpected array type"); @@ -716,35 +722,35 @@ std::vector EclFile::getList() const template<> const std::vector& EclFile::get(int arrIndex) { - return getImpl(arrIndex, EIOD::INTE, inte_array, "integer"); + return getImpl(arrIndex, INTE, inte_array, "integer"); } template<> const std::vector& EclFile::get(int arrIndex) { - return getImpl(arrIndex, EIOD::REAL, real_array, "float"); + return getImpl(arrIndex, REAL, real_array, "float"); } template<> const std::vector &EclFile::get(int arrIndex) { - return getImpl(arrIndex, EIOD::DOUB, doub_array, "double"); + return getImpl(arrIndex, DOUB, doub_array, "double"); } template<> const std::vector& EclFile::get(int arrIndex) { - return getImpl(arrIndex, EIOD::LOGI, logi_array, "bool"); + return getImpl(arrIndex, LOGI, logi_array, "bool"); } template<> const std::vector& EclFile::get(int arrIndex) { - return getImpl(arrIndex, EIOD::CHAR, char_array, "string"); + return getImpl(arrIndex, CHAR, char_array, "string"); } @@ -765,7 +771,7 @@ const std::vector& EclFile::get(const std::string& name) OPM_THROW(std::invalid_argument, message); } - return getImpl(search->second, EIOD::INTE, inte_array, "integer"); + return getImpl(search->second, INTE, inte_array, "integer"); } template<> @@ -778,7 +784,7 @@ const std::vector& EclFile::get(const std::string& name) OPM_THROW(std::invalid_argument, message); } - return getImpl(search->second, EIOD::REAL, real_array, "float"); + return getImpl(search->second, REAL, real_array, "float"); } @@ -792,7 +798,7 @@ const std::vector& EclFile::get(const std::string &name) OPM_THROW(std::invalid_argument, message); } - return getImpl(search->second, EIOD::DOUB, doub_array, "double"); + return getImpl(search->second, DOUB, doub_array, "double"); } @@ -806,7 +812,7 @@ const std::vector& EclFile::get(const std::string &name) OPM_THROW(std::invalid_argument, message); } - return getImpl(search->second, EIOD::LOGI, logi_array, "bool"); + return getImpl(search->second, LOGI, logi_array, "bool"); } @@ -820,5 +826,7 @@ const std::vector& EclFile::get(const std::string &nam OPM_THROW(std::invalid_argument, message); } - return getImpl(search->second, EIOD::CHAR, char_array, "string"); + return getImpl(search->second, CHAR, char_array, "string"); } + +}} // namespace Opm::ecl diff --git a/examples/test_util/EclOutput.cpp b/src/opm/io/eclipse/EclOutput.cpp similarity index 84% rename from examples/test_util/EclOutput.cpp rename to src/opm/io/eclipse/EclOutput.cpp index ccd2a2c531b..d3c666934dd 100644 --- a/examples/test_util/EclOutput.cpp +++ b/src/opm/io/eclipse/EclOutput.cpp @@ -16,18 +16,19 @@ along with OPM. If not, see . */ -#include "EclOutput.hpp" -#include "EclUtil.hpp" +#include +#include + #include #include #include #include #include -#include #include #include +namespace Opm { namespace ecl { EclOutput::EclOutput(const std::string& inputFile, bool formatted) : isFormatted(formatted) @@ -42,23 +43,23 @@ void EclOutput::write(const std::string& name, { if (isFormatted) { - writeFormattedHeader(name, data.size(), EIOD::CHAR); + writeFormattedHeader(name, data.size(), CHAR); writeFormattedCharArray(data); } else { - writeBinaryHeader(name, data.size(), EIOD::CHAR); + writeBinaryHeader(name, data.size(), CHAR); writeBinaryCharArray(data); } } -void EclOutput::writeBinaryHeader(const std::string&arrName, int size, EIOD::eclArrType arrType) +void EclOutput::writeBinaryHeader(const std::string&arrName, int size, eclArrType arrType) { std::string name = arrName + std::string(8 - arrName.size(),' '); - int flippedSize = EIOD::flipEndianInt(size); - int bhead = EIOD::flipEndianInt(16); + int flippedSize = flipEndianInt(size); + int bhead = flipEndianInt(16); ofileH.write(reinterpret_cast(&bhead), sizeof(bhead)); @@ -66,22 +67,22 @@ void EclOutput::writeBinaryHeader(const std::string&arrName, int size, EIOD::ecl ofileH.write(reinterpret_cast(&flippedSize), sizeof(flippedSize)); switch(arrType) { - case EIOD::INTE: + case INTE: ofileH.write("INTE", 4); break; - case EIOD::REAL: + case REAL: ofileH.write("REAL", 4); break; - case EIOD::DOUB: + case DOUB: ofileH.write("DOUB", 4); break; - case EIOD::LOGI: + case LOGI: ofileH.write("LOGI", 4); break; - case EIOD::CHAR: + case CHAR: ofileH.write("CHAR", 4); break; - case EIOD::MESS: + case MESS: ofileH.write("MESS", 4); break; } @@ -102,16 +103,16 @@ void EclOutput::writeBinaryArray(const std::vector& data) int n = 0; int size = data.size(); - EIOD::eclArrType arrType = EIOD::MESS; + eclArrType arrType = MESS; if (typeid(std::vector) == typeid(std::vector)) { - arrType = EIOD::INTE; + arrType = INTE; } else if (typeid(std::vector) == typeid(std::vector)) { - arrType = EIOD::REAL; + arrType = REAL; } else if (typeid(std::vector) == typeid(std::vector)) { - arrType = EIOD::DOUB; + arrType = DOUB; } else if (typeid(std::vector) == typeid(std::vector)) { - arrType = EIOD::LOGI; + arrType = LOGI; } auto sizeData = block_size_data_binary(arrType); @@ -134,22 +135,22 @@ void EclOutput::writeBinaryArray(const std::vector& data) rest = 0; } - dhead = EIOD::flipEndianInt(num * sizeOfElement); + dhead = flipEndianInt(num * sizeOfElement); ofileH.write(reinterpret_cast(&dhead), sizeof(dhead)); for (int i = 0; i < num; i++) { - if (arrType == EIOD::INTE) { - rval = EIOD::flipEndianInt(data[n]); + if (arrType == INTE) { + rval = flipEndianInt(data[n]); ofileH.write(reinterpret_cast(&rval), sizeof(rval)); - } else if (arrType == EIOD::REAL) { - value_f = EIOD::flipEndianFloat(data[n]); + } else if (arrType == REAL) { + value_f = flipEndianFloat(data[n]); ofileH.write(reinterpret_cast(&value_f), sizeof(value_f)); - } else if (arrType == EIOD::DOUB) { - value_d = EIOD::flipEndianDouble(data[n]); + } else if (arrType == DOUB) { + value_d = flipEndianDouble(data[n]); ofileH.write(reinterpret_cast(&value_d), sizeof(value_d)); - } else if (arrType == EIOD::LOGI) { - intVal = data[n] ? EIOD::true_value : EIOD::false_value; + } else if (arrType == LOGI) { + intVal = data[n] ? true_value : false_value; ofileH.write(reinterpret_cast(&intVal), sizeOfElement); } else { std::cout << "type not supported in write binaryarray" << std::endl; @@ -178,7 +179,7 @@ void EclOutput::writeBinaryCharArray(const std::vector& data) int n = 0; int size = data.size(); - auto sizeData = EIOD::block_size_data_binary(EIOD::CHAR); + auto sizeData = block_size_data_binary(CHAR); int sizeOfElement = std::get<0>(sizeData); int maxBlockSize = std::get<1>(sizeData); @@ -199,7 +200,7 @@ void EclOutput::writeBinaryCharArray(const std::vector& data) rest = 0; } - dhead = EIOD::flipEndianInt(num * sizeOfElement); + dhead = flipEndianInt(num * sizeOfElement); ofileH.write(reinterpret_cast(&dhead), sizeof(dhead)); @@ -214,29 +215,29 @@ void EclOutput::writeBinaryCharArray(const std::vector& data) } -void EclOutput::writeFormattedHeader(const std::string& arrName, int size, EIOD::eclArrType arrType) +void EclOutput::writeFormattedHeader(const std::string& arrName, int size, eclArrType arrType) { std::string name = arrName + std::string(8 - arrName.size(),' '); ofileH << " '" << name << "' " << std::setw(11) << size; switch (arrType) { - case EIOD::INTE: + case INTE: ofileH << " 'INTE'" << std::endl; break; - case EIOD::REAL: + case REAL: ofileH << " 'REAL'" << std::endl; break; - case EIOD::DOUB: + case DOUB: ofileH << " 'DOUB'" << std::endl; break; - case EIOD::LOGI: + case LOGI: ofileH << " 'LOGI'" << std::endl; break; - case EIOD::CHAR: + case CHAR: ofileH << " 'CHAR'" << std::endl; break; - case EIOD::MESS: + case MESS: ofileH << " 'MESS'" << std::endl; break; } @@ -309,18 +310,18 @@ void EclOutput::writeFormattedArray(const std::vector& data) int size = data.size(); int n = 0; - EIOD::eclArrType arrType = EIOD::MESS; + eclArrType arrType = MESS; if (typeid(T) == typeid(int)) { - arrType = EIOD::INTE; + arrType = INTE; } else if (typeid(T) == typeid(float)) { - arrType = EIOD::REAL; + arrType = REAL; } else if (typeid(T) == typeid(double)) { - arrType = EIOD::DOUB; + arrType = DOUB; } else if (typeid(T) == typeid(bool)) { - arrType = EIOD::LOGI; + arrType = LOGI; } - auto sizeData = EIOD::block_size_data_formatted(arrType); + auto sizeData = block_size_data_formatted(arrType); int maxBlockSize = std::get<0>(sizeData); int nColumns = std::get<1>(sizeData); @@ -330,16 +331,16 @@ void EclOutput::writeFormattedArray(const std::vector& data) n++; switch (arrType) { - case EIOD::INTE: + case INTE: ofileH << std::setw(columnWidth) << data[i]; break; - case EIOD::REAL: + case REAL: ofileH << std::setw(columnWidth) << make_real_string(data[i]); break; - case EIOD::DOUB: + case DOUB: ofileH << std::setw(columnWidth) << make_doub_string(data[i]); break; - case EIOD::LOGI: + case LOGI: if (data[i]) { ofileH << " T"; } else { @@ -374,7 +375,7 @@ template void EclOutput::writeFormattedArray(const std::vector& data void EclOutput::writeFormattedCharArray(const std::vector& data) { - auto sizeData = EIOD::block_size_data_formatted(EIOD::CHAR); + auto sizeData = block_size_data_formatted(CHAR); int nColumns = std::get<1>(sizeData); @@ -395,3 +396,5 @@ void EclOutput::writeFormattedCharArray(const std::vector& data) ofileH << std::endl; } } + +}} // namespace Opm::ecl diff --git a/examples/test_util/EclUtil.cpp b/src/opm/io/eclipse/EclUtil.cpp similarity index 65% rename from examples/test_util/EclUtil.cpp rename to src/opm/io/eclipse/EclUtil.cpp index b0f6962b5cd..ac5606f33dc 100644 --- a/examples/test_util/EclUtil.cpp +++ b/src/opm/io/eclipse/EclUtil.cpp @@ -16,16 +16,14 @@ along with OPM. If not, see . */ -#include "EclUtil.hpp" +#include + #include #include #include -namespace EIOD = Opm::ecl; - - int Opm::ecl::flipEndianInt(int num) { unsigned int tmp = __builtin_bswap32(num); @@ -60,22 +58,22 @@ std::tuple Opm::ecl::block_size_data_binary(eclArrType arrType) using BlockSizeTuple = std::tuple; switch (arrType) { - case EIOD::INTE: - return BlockSizeTuple{EIOD::sizeOfInte, EIOD::MaxBlockSizeInte}; + case INTE: + return BlockSizeTuple{sizeOfInte, MaxBlockSizeInte}; break; - case EIOD::REAL: - return BlockSizeTuple{EIOD::sizeOfReal, EIOD::MaxBlockSizeReal}; + case REAL: + return BlockSizeTuple{sizeOfReal, MaxBlockSizeReal}; break; - case EIOD::DOUB: - return BlockSizeTuple{EIOD::sizeOfDoub, EIOD::MaxBlockSizeDoub}; + case DOUB: + return BlockSizeTuple{sizeOfDoub, MaxBlockSizeDoub}; break; - case EIOD::LOGI: - return BlockSizeTuple{EIOD::sizeOfLogi, EIOD::MaxBlockSizeLogi}; + case LOGI: + return BlockSizeTuple{sizeOfLogi, MaxBlockSizeLogi}; break; - case EIOD::CHAR: - return BlockSizeTuple{EIOD::sizeOfChar, EIOD::MaxBlockSizeChar}; + case CHAR: + return BlockSizeTuple{sizeOfChar, MaxBlockSizeChar}; break; - case EIOD::MESS: + case MESS: OPM_THROW(std::invalid_argument, "Type 'MESS' have no associated data"); break; default: @@ -85,27 +83,27 @@ std::tuple Opm::ecl::block_size_data_binary(eclArrType arrType) } -std::tuple Opm::ecl::block_size_data_formatted(EIOD::eclArrType arrType) +std::tuple Opm::ecl::block_size_data_formatted(eclArrType arrType) { using BlockSizeTuple = std::tuple; switch (arrType) { - case EIOD::INTE: - return BlockSizeTuple{EIOD::MaxNumBlockInte, EIOD::numColumnsInte, EIOD::columnWidthInte}; + case INTE: + return BlockSizeTuple{MaxNumBlockInte, numColumnsInte, columnWidthInte}; break; - case EIOD::REAL: - return BlockSizeTuple{EIOD::MaxNumBlockReal,EIOD::numColumnsReal, EIOD::columnWidthReal}; + case REAL: + return BlockSizeTuple{MaxNumBlockReal,numColumnsReal, columnWidthReal}; break; - case EIOD::DOUB: - return BlockSizeTuple{EIOD::MaxNumBlockDoub,EIOD::numColumnsDoub, EIOD::columnWidthDoub}; + case DOUB: + return BlockSizeTuple{MaxNumBlockDoub,numColumnsDoub, columnWidthDoub}; break; - case EIOD::LOGI: - return BlockSizeTuple{EIOD::MaxNumBlockLogi,EIOD::numColumnsLogi, EIOD::columnWidthLogi}; + case LOGI: + return BlockSizeTuple{MaxNumBlockLogi,numColumnsLogi, columnWidthLogi}; break; - case EIOD::CHAR: - return BlockSizeTuple{EIOD::MaxNumBlockChar,EIOD::numColumnsChar, EIOD::columnWidthChar}; + case CHAR: + return BlockSizeTuple{MaxNumBlockChar,numColumnsChar, columnWidthChar}; break; - case EIOD::MESS: + case MESS: OPM_THROW(std::invalid_argument, "Type 'MESS' have no associated data") ; break; default: diff --git a/examples/test_util/Deviation.hpp b/test_util/Deviation.hpp similarity index 100% rename from examples/test_util/Deviation.hpp rename to test_util/Deviation.hpp diff --git a/examples/test_util/EclFilesComparator.cpp b/test_util/EclFilesComparator.cpp similarity index 82% rename from examples/test_util/EclFilesComparator.cpp rename to test_util/EclFilesComparator.cpp index 90f3dc8eb0b..b5693af06a7 100644 --- a/examples/test_util/EclFilesComparator.cpp +++ b/test_util/EclFilesComparator.cpp @@ -17,18 +17,20 @@ */ #include "EclFilesComparator.hpp" + #include +#include #include -#include -#include -#include #include #include +#include +#include #include -#include +#include #include +#include // helper macro to handle error throws or not #define HANDLE_ERROR(type, message) \ @@ -41,9 +43,10 @@ } \ } +using Opm::ecl::EGrid; template -void ECLFilesComparator::printValuesForCell(const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const T& value1, const T& value2) const { +void ECLFilesComparator::printValuesForCell(const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const T& value1, const T& value2) const { int nActive = -1; int nTot = -1; @@ -86,15 +89,15 @@ void ECLFilesComparator::printValuesForCell(const std::string& keyword, const st << "(first value, second value) = (" << value1 << ", " << value2 << ")\n\n"; } -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const bool& value1, const bool& value2) const; -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const int& value1, const int& value2) const; -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const double& value1, const double& value2) const; -template void ECLFilesComparator::printValuesForCell(const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const std::string& value1, const std::string& value2) const; +template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const bool& value1, const bool& value2) const; +template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const int& value1, const int& value2) const; +template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const double& value1, const double& value2) const; +template void ECLFilesComparator::printValuesForCell(const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const std::string& value1, const std::string& value2) const; // Hack to work around case where std::vector::const_reference is not a bool. If it is we will initialize printValuesForCell otherwise printValuesForCell::const_reference> using boolConstReference = typename std::vector::const_reference; using boolTypeHelper = typename std::remove_const::type>::type; using boolType = typename std::conditional::value, char, boolTypeHelper>::type; -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const boolType& value1, const boolType& value2) const; +template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const boolType& value1, const boolType& value2) const; ECLFilesComparator::ECLFilesComparator(const std::string& basename1, const std::string& basename2, @@ -126,7 +129,7 @@ double ECLFilesComparator::median(std::vector vec) { } else { size_t n = vec.size() / 2; - nth_element(vec.begin(), vec.begin() + n, vec.end()); + std::nth_element(vec.begin(), vec.begin() + n, vec.end()); if (vec.size() % 2 == 0) { return 0.5 * (vec[n-1] + vec[n]); } @@ -144,5 +147,3 @@ double ECLFilesComparator::average(const std::vector& vec) { double sum = std::accumulate(vec.begin(), vec.end(), 0.0); return sum/vec.size(); } - - diff --git a/examples/test_util/EclFilesComparator.hpp b/test_util/EclFilesComparator.hpp similarity index 87% rename from examples/test_util/EclFilesComparator.hpp rename to test_util/EclFilesComparator.hpp index c9ce93995b6..5c4fdf9ab9b 100644 --- a/examples/test_util/EclFilesComparator.hpp +++ b/test_util/EclFilesComparator.hpp @@ -21,12 +21,15 @@ #define ECLFILESCOMPARATOR_HPP #include "Deviation.hpp" + #include -#include +#include #include +#include -#include - +namespace Opm { namespace ecl { + class EGrid; +}} // namespace Opm::ecl class ECLFilesComparator { public: @@ -75,7 +78,13 @@ class ECLFilesComparator { std::string rootName1, rootName2; template - void printValuesForCell(const std::string& keyword, const std::string reference, size_t kw_size, size_t cell, EGrid *grid, const T& value1, const T& value2) const; + void printValuesForCell(const std::string& keyword, + const std::string& reference, + size_t kw_size, + size_t cell, + Opm::ecl::EGrid *grid, + const T& value1, + const T& value2) const; private: double absTolerance = 0; diff --git a/examples/test_util/EclRegressionTest.cpp b/test_util/EclRegressionTest.cpp similarity index 94% rename from examples/test_util/EclRegressionTest.cpp rename to test_util/EclRegressionTest.cpp index 4f40d3c63c9..b577c6a272a 100644 --- a/examples/test_util/EclRegressionTest.cpp +++ b/test_util/EclRegressionTest.cpp @@ -17,23 +17,24 @@ */ #include "EclRegressionTest.hpp" + +#include +#include +#include +#include + #include + #include +#include #include +#include #include #include -#include -#include #include +#include #include -#include -#include -#include - -#include - - // helper macro to handle error throws or not #define HANDLE_ERROR(type, message) \ { \ @@ -45,6 +46,7 @@ } \ } +using namespace Opm::ecl; ECLRegressionTest::~ECLRegressionTest() { @@ -264,8 +266,8 @@ void ECLRegressionTest::compareKeywords(const std::vector &keywords void ECLRegressionTest::checkSpesificKeyword(std::vector& keywords1, std::vector& keywords2, - std::vector& arrayType1, - std::vector& arrayType2, + std::vector& arrayType1, + std::vector& arrayType2, const std::string& reference) { auto search1 = std::find(keywords1.begin(), keywords1.end(), spesificKeyword); @@ -276,7 +278,7 @@ void ECLRegressionTest::checkSpesificKeyword(std::vector& keywords1 OPM_THROW(std::runtime_error, "\nTesting spesific kewyword in " << reference << ". Keyword not found in any of the cases ."); } - EIOD::eclArrType arrType; + eclArrType arrType; if (search1 != keywords1.end()) { int ind = std::distance(keywords1.begin(), search1); arrType = arrayType1[ind]; @@ -360,7 +362,7 @@ void ECLRegressionTest::gridCompare() auto arrayList2 = grid2->getList(); std::vector keywords1; - std::vector arrayType1; + std::vector arrayType1; for (auto& array : arrayList1) { keywords1.push_back(std::get<0>(array)); @@ -368,7 +370,7 @@ void ECLRegressionTest::gridCompare() } std::vector keywords2; - std::vector arrayType2; + std::vector arrayType2; for (auto& array : arrayList2) { keywords2.push_back(std::get<0>(array)); @@ -541,7 +543,7 @@ void ECLRegressionTest::results_init() auto arrayList2 = init2.getList(); std::vector keywords1; - std::vector arrayType1; + std::vector arrayType1; for (const auto& array : arrayList1) { keywords1.push_back(std::get<0>(array)); @@ -549,7 +551,7 @@ void ECLRegressionTest::results_init() } std::vector keywords2; - std::vector arrayType2; + std::vector arrayType2; for (const auto& array : arrayList2) { keywords2.push_back(std::get<0>(array)); @@ -578,27 +580,27 @@ void ECLRegressionTest::results_init() std::cout << "Comparing " << keywords1[i] << " ... "; - if (arrayType1[i] == EIOD::INTE) { + if (arrayType1[i] == INTE) { auto vect1 = init1.get(keywords1[i]); auto vect2 = init2.get(keywords2[ind2]); compareVectors(vect1, vect2, keywords1[i],reference); - } else if (arrayType1[i] == EIOD::REAL) { + } else if (arrayType1[i] == REAL) { auto vect1 = init1.get(keywords1[i]); auto vect2 = init2.get(keywords2[ind2]); compareFloatingPointVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::DOUB) { + } else if (arrayType1[i] == DOUB) { auto vect1 = init1.get(keywords1[i]); auto vect2 = init2.get(keywords2[ind2]); compareFloatingPointVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::LOGI) { + } else if (arrayType1[i] == LOGI) { auto vect1 = init1.get(keywords1[i]); auto vect2 = init2.get(keywords2[ind2]); compareVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::CHAR) { + } else if (arrayType1[i] == CHAR) { auto vect1 = init1.get(keywords1[i]); auto vect2 = init2.get(keywords2[ind2]); compareVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::MESS) { + } else if (arrayType1[i] == MESS) { // shold not be any associated data } else { std::cout << "unknown array type " << std::endl; @@ -701,14 +703,14 @@ void ECLRegressionTest::results_rst() auto arrays2 = rst2.listOfRstArrays(seqn); std::vector keywords1; - std::vector arrayType1; + std::vector arrayType1; for (const auto& array : arrays1) { keywords1.push_back(std::get<0>(array)); arrayType1.push_back(std::get<1>(array)); } std::vector keywords2; - std::vector arrayType2; + std::vector arrayType2; for (const auto& array : arrays2) { keywords2.push_back(std::get<0>(array)); arrayType2.push_back(std::get<1>(array)); @@ -731,8 +733,8 @@ void ECLRegressionTest::results_rst() keywords1 = keywords2 = keywords; int nKeys = keywords.size(); - arrayType1.assign(nKeys, EIOD::REAL); - arrayType2.assign(nKeys, EIOD::REAL); + arrayType1.assign(nKeys, REAL); + arrayType2.assign(nKeys, REAL); } if (printKeywordOnly) { @@ -756,27 +758,27 @@ void ECLRegressionTest::results_rst() std::cout << "Comparing " << keywords1[i] << " ... "; - if (arrayType1[i] == EIOD::INTE) { - auto vect1 = rst1.getRst(keywords1[i], seqn); + if (arrayType1[i] == INTE) { + auto vect1 = rst1.getRst(keywords1[i], seqn); auto vect2 = rst2.getRst(keywords2[ind2], seqn); compareVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::REAL) { + } else if (arrayType1[i] == REAL) { auto vect1 = rst1.getRst(keywords1[i], seqn); auto vect2 = rst2.getRst(keywords2[ind2], seqn); compareFloatingPointVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::DOUB) { + } else if (arrayType1[i] == DOUB) { auto vect1 = rst1.getRst(keywords1[i], seqn); auto vect2 = rst2.getRst(keywords2[ind2], seqn); compareFloatingPointVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::LOGI) { + } else if (arrayType1[i] == LOGI) { auto vect1 = rst1.getRst(keywords1[i], seqn); auto vect2 = rst2.getRst(keywords2[ind2], seqn); compareVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::CHAR) { + } else if (arrayType1[i] == CHAR) { auto vect1 = rst1.getRst(keywords1[i], seqn); auto vect2 = rst2.getRst(keywords2[ind2], seqn); compareVectors(vect1, vect2, keywords1[i], reference); - } else if (arrayType1[i] == EIOD::MESS) { + } else if (arrayType1[i] == MESS) { // shold not be any associated data } else { std::cout << "unknown array type " << std::endl; @@ -826,8 +828,8 @@ void ECLRegressionTest::results_smry() std::vector keywords1 = smry1.keywordList(); std::vector keywords2 = smry2.keywordList(); - std::vector arrayType1(keywords1.size(), EIOD::REAL); - std::vector arrayType2 (keywords1.size(), EIOD::REAL); + std::vector arrayType1(keywords1.size(), REAL); + std::vector arrayType2 (keywords1.size(), REAL); if (integrationTest) { std::vector keywords; @@ -848,8 +850,8 @@ void ECLRegressionTest::results_smry() int nKeys = keywords.size(); - arrayType1.assign(nKeys, EIOD::REAL); - arrayType2.assign(nKeys ,EIOD::REAL); + arrayType1.assign(nKeys, REAL); + arrayType2.assign(nKeys, REAL); } if (printKeywordOnly) { @@ -951,14 +953,14 @@ void ECLRegressionTest::results_rft() auto vectList2 = rft2.listOfRftArrays(well, date); std::vector keywords1; - std::vector arrayType1; + std::vector arrayType1; for (auto& array : vectList1 ) { keywords1.push_back(std::get<0>(array)) ; arrayType1.push_back(std::get<1>(array)) ; } std::vector keywords2; - std::vector arrayType2; + std::vector arrayType2; for (auto& array : vectList2 ) { keywords2.push_back(std::get<0>(array)) ; arrayType2.push_back(std::get<1>(array)) ; @@ -975,31 +977,31 @@ void ECLRegressionTest::results_rft() for (auto& array : vectList1 ) { std::string keywords = std::get<0>(array); - EIOD::eclArrType arrayType = std::get<1>(array); + eclArrType arrayType = std::get<1>(array); std::cout << "Comparing: " << keywords << " ... "; - if (arrayType == EIOD::INTE) { + if (arrayType == INTE) { auto vect1 = rft1.getRft(keywords, well, date); auto vect2 = rft2.getRft(keywords, well, date); compareVectors(vect1, vect2, keywords, reference); - } else if (arrayType == EIOD::REAL) { + } else if (arrayType == REAL) { auto vect1 = rft1.getRft(keywords, well, date); auto vect2 = rft2.getRft(keywords, well, date); compareFloatingPointVectors(vect1, vect2, keywords, reference); - } else if (arrayType == EIOD::DOUB) { + } else if (arrayType == DOUB) { auto vect1 = rft1.getRft(keywords, well, date); auto vect2 = rft2.getRft(keywords, well, date); compareFloatingPointVectors(vect1, vect2, keywords, reference); - } else if (arrayType == EIOD::LOGI) { + } else if (arrayType == LOGI) { auto vect1 = rft1.getRft(keywords, well, date); auto vect2 = rft2.getRft(keywords, well, date); compareVectors(vect1, vect2, keywords, reference); - } else if (arrayType == EIOD::CHAR) { + } else if (arrayType == CHAR) { auto vect1 = rft1.getRft(keywords, well, date); auto vect2 = rft2.getRft(keywords, well, date); compareVectors(vect1, vect2, keywords, reference); - } else if (arrayType == EIOD::MESS) { + } else if (arrayType == MESS) { // shold not be any associated data } else { std::cout << "unknown array type " << std::endl; @@ -1023,8 +1025,8 @@ void ECLRegressionTest::results_rft() void ECLRegressionTest::printComparisonForKeywordLists(const std::vector& arrayList1, const std::vector& arrayList2, - const std::vector& arrayType1, - const std::vector& arrayType2) const + const std::vector& arrayType1, + const std::vector& arrayType2) const { unsigned int maxLen = 0; diff --git a/examples/test_util/EclRegressionTest.hpp b/test_util/EclRegressionTest.hpp similarity index 97% rename from examples/test_util/EclRegressionTest.hpp rename to test_util/EclRegressionTest.hpp index 557068bef6c..e2b9060b8d6 100644 --- a/examples/test_util/EclRegressionTest.hpp +++ b/test_util/EclRegressionTest.hpp @@ -21,8 +21,12 @@ #define ECLREGRESSIONTEST_HPP #include "EclFilesComparator.hpp" -#include "data/EclIOdata.hpp" +#include + +namespace Opm { namespace ecl { + class EGrid; +}} namespace EIOD = Opm::ecl; @@ -172,8 +176,8 @@ class ECLRegressionTest: public ECLFilesComparator { // Accept extra keywords in the restart file of the 'new' simulation. bool acceptExtraKeywords = false; - EGrid* grid1 = nullptr; - EGrid* grid2 = nullptr; + Opm::ecl::EGrid* grid1 = nullptr; + Opm::ecl::EGrid* grid2 = nullptr; }; #endif diff --git a/examples/test_util/compareECL.cpp b/test_util/compareECL.cpp similarity index 99% rename from examples/test_util/compareECL.cpp rename to test_util/compareECL.cpp index 401a28b03b3..20d649800aa 100644 --- a/examples/test_util/compareECL.cpp +++ b/test_util/compareECL.cpp @@ -17,6 +17,7 @@ */ #include "EclRegressionTest.hpp" + #include #include diff --git a/examples/test_util/convertECL.cpp b/test_util/convertECL.cpp similarity index 85% rename from examples/test_util/convertECL.cpp rename to test_util/convertECL.cpp index 118eb1aacca..3ebdeb2340f 100644 --- a/examples/test_util/convertECL.cpp +++ b/test_util/convertECL.cpp @@ -1,11 +1,12 @@ -#include #include -#include #include +#include +#include -#include -#include +#include +#include +using namespace Opm::ecl; template void write(EclOutput& outFile, EclFile& file1, @@ -57,19 +58,19 @@ int main(int argc, char **argv) { for (size_t index = 0; index < arrayList.size(); index++) { std::string name = std::get<0>(arrayList[index]); - EIOD::eclArrType arrType = std::get<1>(arrayList[index]); + eclArrType arrType = std::get<1>(arrayList[index]); - if (arrType == EIOD::INTE) { + if (arrType == INTE) { write(outFile, file1, name, index); - } else if (arrType == EIOD::REAL) { + } else if (arrType == REAL) { write(outFile, file1, name,index); - } else if (arrType == EIOD::DOUB) { + } else if (arrType == DOUB) { write(outFile, file1, name, index); - } else if (arrType == EIOD::LOGI) { + } else if (arrType == LOGI) { write(outFile, file1, name, index); - } else if (arrType == EIOD::CHAR) { + } else if (arrType == CHAR) { write(outFile, file1, name, index); - } else if (arrType == EIOD::MESS) { + } else if (arrType == MESS) { // shold not be any associated data outFile.write(name,std::vector()); } else { diff --git a/tests/test_EGrid.cpp b/tests/test_EGrid.cpp index 0e71a7d76d6..d1b196b225e 100644 --- a/tests/test_EGrid.cpp +++ b/tests/test_EGrid.cpp @@ -18,17 +18,23 @@ #include "config.h" + +#include + +#define BOOST_TEST_MODULE Test EGrid +#include + +#include +#include +#include +#include #include -#include #include #include -#include +#include #include -#include - -#define BOOST_TEST_MODULE Test EGrid -#include +using Opm::ecl::EGrid; template bool diff --git a/tests/test_ERft.cpp b/tests/test_ERft.cpp index 0a82852c08f..3d04ba02790 100644 --- a/tests/test_ERft.cpp +++ b/tests/test_ERft.cpp @@ -16,21 +16,26 @@ + along with OPM. If not, see . + */ - #include "config.h" -#include -#include + +#include + +#define BOOST_TEST_MODULE Test EGrid +#include + +#include +#include + +#include +#include #include +#include #include -#include #include +#include #include -#include -#include - -#define BOOST_TEST_MODULE Test EGrid -#include +using namespace Opm::ecl; template bool @@ -167,24 +172,24 @@ BOOST_AUTO_TEST_CASE(TestERft_2) { for (auto& array : arrayList) { std::string arrName = std::get<0>(array); - EIOD::eclArrType arrType = std::get<1>(array); + eclArrType arrType = std::get<1>(array); - if (arrType == EIOD::INTE) { + if (arrType == INTE) { std::vector vect = rft1.getRft(arrName, wellName, date); eclTest.write(arrName, vect); - } else if (arrType == EIOD::REAL) { + } else if (arrType == REAL) { std::vector vect = rft1.getRft(arrName, wellName, date); eclTest.write(arrName, vect); - } else if (arrType == EIOD::DOUB) { + } else if (arrType == DOUB) { std::vector vect = rft1.getRft(arrName, wellName, date); eclTest.write(arrName, vect); - } else if (arrType == EIOD::LOGI) { + } else if (arrType == LOGI) { std::vector vect = rft1.getRft(arrName, wellName, date); eclTest.write(arrName, vect); - } else if (arrType == EIOD::CHAR) { + } else if (arrType == CHAR) { std::vector vect = rft1.getRft(arrName, wellName, date); eclTest.write(arrName, vect); - } else if (arrType == EIOD::MESS) { + } else if (arrType == MESS) { eclTest.write(arrName, std::vector()); } else { std::cout << "unknown type " << std::endl; diff --git a/tests/test_ERst.cpp b/tests/test_ERst.cpp index cb5b949d34d..746ea2776d6 100644 --- a/tests/test_ERst.cpp +++ b/tests/test_ERst.cpp @@ -16,21 +16,25 @@ + along with OPM. If not, see . + */ - #include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include #define BOOST_TEST_MODULE Test EclIO #include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace Opm::ecl; + template bool range_equal(InputIterator1 first1, InputIterator1 last1, @@ -86,7 +90,7 @@ BOOST_AUTO_TEST_CASE(TestERst_1) { // try to get a list of vectors from non-existing report step, should throw exception - std::vector> rstArrays; // = rst1.listOfRstArrays(4); + std::vector> rstArrays; // = rst1.listOfRstArrays(4); BOOST_CHECK_THROW(rstArrays = rst1.listOfRstArrays(4), std::invalid_argument); // non exising report step number, should throw exception @@ -124,24 +128,24 @@ BOOST_AUTO_TEST_CASE(TestERst_1) { static void readAndWrite(EclOutput& eclTest, ERst& rst1, const std::string& name, int seqnum, - EIOD::eclArrType arrType) + eclArrType arrType) { - if (arrType == EIOD::INTE) { + if (arrType == INTE) { std::vector vect = rst1.getRst(name, seqnum); eclTest.write(name, vect); - } else if (arrType == EIOD::REAL) { + } else if (arrType == REAL) { std::vector vect = rst1.getRst(name, seqnum); eclTest.write(name, vect); - } else if (arrType == EIOD::DOUB) { + } else if (arrType == DOUB) { std::vector vect = rst1.getRst(name, seqnum); eclTest.write(name, vect); - } else if (arrType == EIOD::LOGI) { + } else if (arrType == LOGI) { std::vector vect = rst1.getRst(name, seqnum); eclTest.write(name, vect); - } else if (arrType == EIOD::CHAR) { + } else if (arrType == CHAR) { std::vector vect = rst1.getRst(name, seqnum); eclTest.write(name, vect); - } else if (arrType == EIOD::MESS) { + } else if (arrType == MESS) { eclTest.write(name, std::vector()); } else { std::cout << "unknown type " << std::endl; @@ -172,7 +176,7 @@ BOOST_AUTO_TEST_CASE(TestERst_2) { for (auto& array : rstArrays) { std::string name = std::get<0>(array); - EIOD::eclArrType arrType = std::get<1>(array); + eclArrType arrType = std::get<1>(array); readAndWrite(eclTest, rst1, name, seqnums[i], arrType); } } @@ -205,7 +209,7 @@ BOOST_AUTO_TEST_CASE(TestERst_3) { for (auto& array : rstArrays) { std::string name = std::get<0>(array); - EIOD::eclArrType arrType = std::get<1>(array); + eclArrType arrType = std::get<1>(array); readAndWrite(eclTest, rst1, name, seqnums[i], arrType); } } diff --git a/tests/test_ESmry.cpp b/tests/test_ESmry.cpp index 21cfd400524..effa57c90c7 100644 --- a/tests/test_ESmry.cpp +++ b/tests/test_ESmry.cpp @@ -16,21 +16,25 @@ + along with OPM. If not, see . + */ - #include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include #define BOOST_TEST_MODULE Test EclIO #include +#include + +#include +#include +#include +#include +#include +#include +#include + +using Opm::ecl::ESmry; + template bool range_equal(InputIterator1 first1, InputIterator1 last1, diff --git a/tests/test_EclFilesComparator.cpp b/tests/test_EclFilesComparator.cpp index 075b0dd28c4..81ea493d845 100644 --- a/tests/test_EclFilesComparator.cpp +++ b/tests/test_EclFilesComparator.cpp @@ -21,7 +21,8 @@ #define BOOST_TEST_MODULE EclFilesComparatorTest #include -#include + +#include BOOST_AUTO_TEST_CASE(deviation) { double a = 1; diff --git a/tests/test_EclIO.cpp b/tests/test_EclIO.cpp index 562e1ad18e2..2ce76729f0b 100644 --- a/tests/test_EclIO.cpp +++ b/tests/test_EclIO.cpp @@ -16,21 +16,23 @@ + along with OPM. If not, see . + */ - #include "config.h" -#include -#include + +#include +#include #include +#include #include -#include +#include #include -#include -#include +#include +#include #define BOOST_TEST_MODULE Test EclIO #include +using namespace Opm::ecl; template bool @@ -270,24 +272,24 @@ BOOST_AUTO_TEST_CASE(TestEcl_getList) { int n=0; for (auto array : arrayList) { std::string name = std::get<0>(array); - EIOD::eclArrType arrType = std::get<1>(array); + eclArrType arrType = std::get<1>(array); - if (arrType == EIOD::INTE) { + if (arrType == INTE) { std::vector vect = file1.get(n); eclTest.write(name, vect); - } else if (arrType == EIOD::REAL) { + } else if (arrType == REAL) { std::vector vect = file1.get(n); eclTest.write(name, vect); - } else if (arrType == EIOD::DOUB) { + } else if (arrType == DOUB) { std::vector vect = file1.get(n); eclTest.write(name, vect); - } else if (arrType == EIOD::LOGI) { + } else if (arrType == LOGI) { std::vector vect = file1.get(n); eclTest.write(name, vect); - } else if (arrType == EIOD::CHAR) { + } else if (arrType == CHAR) { std::vector vect = file1.get(n); eclTest.write(name, vect); - } else if (arrType == EIOD::MESS) { + } else if (arrType == MESS) { eclTest.write(name, std::vector()); } else { std::cout << "unknown type " << std::endl; diff --git a/tests/test_EclRegressionTest.cpp b/tests/test_EclRegressionTest.cpp index 5f2251b1b1c..a18abe8cb7e 100644 --- a/tests/test_EclRegressionTest.cpp +++ b/tests/test_EclRegressionTest.cpp @@ -21,14 +21,18 @@ #define BOOST_TEST_MODULE EclRegressionTest #include -#include -#include -#include -#include +#include + +#include +#include +#include #include +using Opm::ecl::EGrid; +using Opm::ecl::ESmry; +using Opm::ecl::EclOutput; void makeEgridFile(const std::string &fileName, const std::vector &coord, const std::vector &zcorn, const std::vector &gridhead,