Move ECLIPSE I/O Into Main OPM Common Library

This makes the facility usable for the restart read/write code.

Specifically, import the I/O classes into namespace Opm::ecl, and
place the files in physical location opm/io/eclipse, and move the
test utilities to new top-level directory 'test_util/'.  While here,
discontinue the 'testutil' static library since most of its features
are now available in the main 'opmcommon' library.  This does entail
compiling a few of the test_util/ CPP files multiple times, and
adding the objects to each executable independently.
This commit is contained in:
Bård Skaflestad
2019-05-02 15:01:20 +02:00
parent 464bc4b795
commit e654915069
31 changed files with 532 additions and 427 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -16,10 +16,10 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EGRID_HPP
#define EGRID_HPP
#ifndef OPM_IO_EGRID_HPP
#define OPM_IO_EGRID_HPP
#include "EclFile.hpp"
#include <opm/io/eclipse/EclFile.hpp>
#include <array>
#include <iostream>
@@ -29,6 +29,7 @@
#include <ctime>
#include <map>
namespace Opm { namespace ecl {
class EGrid : public EclFile
{
@@ -59,4 +60,6 @@ private:
std::vector<float> zcorn_array;
};
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_EGRID_HPP

View File

@@ -16,20 +16,20 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ERFT_HPP
#define ERFT_HPP
#ifndef OPM_IO_ERFT_HPP
#define OPM_IO_ERFT_HPP
#include <opm/io/eclipse/EclFile.hpp>
#include "EclFile.hpp"
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
namespace Opm { namespace ecl {
class ERft : public EclFile
{
@@ -79,5 +79,6 @@ private:
const RftDate& date) const;
};
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_ERFT_HPP

View File

@@ -16,19 +16,17 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ERST_HPP
#define ERST_HPP
#ifndef OPM_IO_ERST_HPP
#define OPM_IO_ERST_HPP
#include <opm/io/eclipse/EclFile.hpp>
#include "EclFile.hpp"
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <ctime>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
namespace Opm { namespace ecl {
class ERst : public EclFile
{
@@ -54,4 +52,6 @@ private:
int getArrayIndex(const std::string& name, int seqnum) const;
};
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_ERST_HPP

View File

@@ -16,15 +16,13 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ESMRY_HPP
#define ESMRY_HPP
#ifndef OPM_IO_ESMRY_HPP
#define OPM_IO_ESMRY_HPP
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <ctime>
#include <map>
namespace Opm { namespace ecl {
class ESmry
{
@@ -55,6 +53,6 @@ private:
std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num);
};
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_ESMRY_HPP

View File

@@ -16,22 +16,20 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECLFILE_HPP
#define ECLFILE_HPP
#ifndef OPM_IO_ECLFILE_HPP
#define OPM_IO_ECLFILE_HPP
#include <opm/common/ErrorMacros.hpp>
#include <examples/test_util/data/EclIOdata.hpp>
#include <iostream>
#include <string>
#include <opm/io/eclipse/EclIOdata.hpp>
#include <fstream>
#include <vector>
#include <ctime>
#include <map>
#include <string>
#include <stdexcept>
#include <unordered_map>
#include <stdio.h>
#include <vector>
namespace EIOD = Opm::ecl;
namespace Opm { namespace ecl {
class EclFile
{
@@ -53,7 +51,7 @@ public:
char_array.clear();
}
using EclEntry = std::tuple<std::string, EIOD::eclArrType, int>;
using EclEntry = std::tuple<std::string, eclArrType, int>;
std::vector<EclEntry> getList() const;
template <typename T>
@@ -77,7 +75,7 @@ protected:
std::unordered_map<int, std::vector<std::string>> char_array;
std::vector<std::string> array_name;
std::vector<EIOD::eclArrType> array_type;
std::vector<eclArrType> array_type;
std::vector<int> array_size;
std::vector<unsigned long int> ifStreamPos;
@@ -85,7 +83,7 @@ protected:
std::map<std::string, int> array_index;
template<class T>
const std::vector<T>& getImpl(int arrIndex, EIOD::eclArrType type,
const std::vector<T>& getImpl(int arrIndex, eclArrType type,
const std::unordered_map<int, std::vector<T>>& array,
const std::string& typeStr)
{
@@ -98,7 +96,7 @@ protected:
loadData(arrIndex);
}
return array.find(arrIndex)->second;
return array.at(arrIndex);
}
private:
@@ -107,4 +105,6 @@ private:
void loadArray(std::fstream& fileH, int arrIndex);
};
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_ECLFILE_HPP

View File

@@ -17,24 +17,19 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_ECLIO_DATA_HPP
#define OPM_ECLIO_DATA_HPP
#ifndef OPM_IO_ECLIODATA_HPP
#define OPM_IO_ECLIODATA_HPP
#include <tuple>
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

View File

@@ -15,19 +15,19 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECL_OUTPUT_HPP
#define ECL_OUTPUT_HPP
#ifndef OPM_IO_ECLOUTPUT_HPP
#define OPM_IO_ECLOUTPUT_HPP
#include <iostream>
#include <ios>
#include <fstream>
#include <vector>
#include <iomanip>
#include <typeinfo>
#include <examples/test_util/data/EclIOdata.hpp>
namespace EIOD = Opm::ecl;
#include <opm/io/eclipse/EclIOdata.hpp>
namespace Opm { namespace ecl {
class EclOutput
{
@@ -38,41 +38,41 @@ public:
void write(const std::string& name,
const std::vector<T>& 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 <typename T>
void writeBinaryArray(const std::vector<T>& data);
void writeBinaryCharArray(const std::vector<std::string>& data);
void writeFormattedHeader(const std::string& arrName, int size, EIOD::eclArrType arrType);
void writeFormattedHeader(const std::string& arrName, int size, eclArrType arrType);
template <typename T>
void writeFormattedArray(const std::vector<T>& data);
@@ -91,4 +91,6 @@ template<>
void EclOutput::write<std::string>(const std::string& name,
const std::vector<std::string>& data);
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_ECLOUTPUT_HPP

View File

@@ -16,25 +16,25 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECL_UTIL_HPP
#define ECL_UTIL_HPP
#ifndef OPM_IO_ECLUTIL_HPP
#define OPM_IO_ECLUTIL_HPP
#include <opm/io/eclipse/EclIOdata.hpp>
#include <string>
#include <tuple>
#include <examples/test_util/data/EclIOdata.hpp>
namespace Opm { namespace ecl {
namespace Opm {
namespace ecl {
int flipEndianInt(int num);
float flipEndianFloat(float num);
double flipEndianDouble(double num);
int flipEndianInt(int num);
float flipEndianFloat(float num);
double flipEndianDouble(double num);
std::tuple<int, int> block_size_data_binary(eclArrType arrType);
std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
std::tuple<int, int> block_size_data_binary(eclArrType arrType);
std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
std::string trimr(const std::string &str1);
}
}
std::string trimr(const std::string &str1);
#endif
}} // namespace Opm::ecl
#endif // OPM_IO_ECLUTIL_HPP

View File

@@ -16,17 +16,19 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "EGrid.hpp"
#include <opm/io/eclipse/EGrid.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <string>
#include <string.h>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <iterator>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
namespace Opm { namespace ecl {
EGrid::EGrid(const std::string &filename) : EclFile(filename)
{
@@ -184,3 +186,5 @@ void EGrid::getCellCorners(int globindex, std::vector<double>& X,
{
return getCellCorners(ijk_from_global_index(globindex),X,Y,Z);
}
}} // namespace Opm::ecl

View File

@@ -16,16 +16,18 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ERft.hpp"
#include <opm/io/eclipse/ERft.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <string>
#include <string.h>
#include <sstream>
#include <iterator>
#include <iomanip>
#include <algorithm>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <string>
#include <sstream>
namespace Opm { namespace ecl {
ERft::ERft(const std::string &filename) : EclFile(filename)
{
@@ -162,7 +164,7 @@ ERft::getRft<float>(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<double>(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<int>(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<bool>(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<std::string>(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::RftDate> ERft::listOfdates() const
{
return { this->dateList.begin(), this->dateList.end() };
}
}} // namespace Opm::ecl

View File

@@ -16,17 +16,19 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ERst.hpp"
#include <opm/io/eclipse/ERst.hpp>
#include <string>
#include <string.h>
#include <sstream>
#include <iterator>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <string>
#include <sstream>
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<int>& ERst::getRst<int>(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<float>& ERst::getRst<float>(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<double>& ERst::getRst<double>(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<bool>& ERst::getRst<bool>(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<std::string>& ERst::getRst<std::string>(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

View File

@@ -16,6 +16,7 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/io/eclipse/ESmry.hpp>
#include <string>
#include <string.h>
@@ -27,8 +28,7 @@
#include <limits>
#include <set>
#include "EclFile.hpp"
#include "ESmry.hpp"
#include <opm/io/eclipse/EclFile.hpp>
/*
@@ -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<std::string>& restartArray, std::string& pathRst, std::string& rootN) const {
@@ -429,3 +431,5 @@ const std::vector<float>& ESmry::get(const std::string& name) const
return param[ind];
}
}} // namespace Opm::ecl

View File

@@ -16,11 +16,14 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "EclFile.hpp"
#include "EclUtil.hpp"
#include <opm/io/eclipse/EclFile.hpp>
#include <opm/io/eclipse/EclUtil.hpp>
#include <array>
#include <exception>
#include <functional>
#include <fstream>
#include <stdexcept>
#include <string>
#include <string.h>
#include <sstream>
@@ -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<char*>(&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<char*>(&size), sizeof(size));
size = EIOD::flipEndianInt(size);
size = Opm::ecl::flipEndianInt(size);
fileH.read(&tmpStrType[0], 4);
fileH.read(reinterpret_cast<char*>(&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<typename T, typename T2>
std::vector<T> readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArrType type,
std::vector<T> readBinaryArray(std::fstream& fileH, const int size, Opm::ecl::eclArrType type,
std::function<T(T2)>& flip)
{
std::vector<T> arr;
@@ -201,7 +204,7 @@ std::vector<T> readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArr
while (rest > 0) {
int dhead;
fileH.read(reinterpret_cast<char*>(&dhead), sizeof(dhead));
dhead = EIOD::flipEndianInt(dhead);
dhead = Opm::ecl::flipEndianInt(dhead);
int num = dhead / sizeOfElement;
@@ -225,7 +228,7 @@ std::vector<T> readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArr
int dtail;
fileH.read(reinterpret_cast<char*>(&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<T> readBinaryArray(std::fstream& fileH, const int size, EIOD::eclArr
std::vector<int> readBinaryInteArray(std::fstream &fileH, const int size)
{
std::function<int(int)> f = EIOD::flipEndianInt;
return readBinaryArray<int,int>(fileH, size, EIOD::INTE, f);
std::function<int(int)> f = Opm::ecl::flipEndianInt;
return readBinaryArray<int,int>(fileH, size, Opm::ecl::INTE, f);
}
std::vector<float> readBinaryRealArray(std::fstream& fileH, const int size)
{
std::function<float(float)> f = EIOD::flipEndianFloat;
return readBinaryArray<float,float>(fileH, size, EIOD::REAL, f);
std::function<float(float)> f = Opm::ecl::flipEndianFloat;
return readBinaryArray<float,float>(fileH, size, Opm::ecl::REAL, f);
}
std::vector<double> readBinaryDoubArray(std::fstream& fileH, const int size)
{
std::function<double(double)> f = EIOD::flipEndianDouble;
return readBinaryArray<double,double>(fileH, size, EIOD::DOUB, f);
std::function<double(double)> f = Opm::ecl::flipEndianDouble;
return readBinaryArray<double,double>(fileH, size, Opm::ecl::DOUB, f);
}
std::vector<bool> readBinaryLogiArray(std::fstream &fileH, const int size)
@@ -261,9 +264,9 @@ std::vector<bool> readBinaryLogiArray(std::fstream &fileH, const int size)
std::function<bool(unsigned int)> 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<bool> readBinaryLogiArray(std::fstream &fileH, const int size)
return value;
};
return readBinaryArray<bool,unsigned int>(fileH, size, EIOD::LOGI, f);
return readBinaryArray<bool,unsigned int>(fileH, size, Opm::ecl::LOGI, f);
}
@@ -281,9 +284,9 @@ std::vector<std::string> readBinaryCharArray(std::fstream& fileH, const int size
std::function<std::string(Char8)> f = [](const Char8& val)
{
std::string res(val.begin(), val.end());
return EIOD::trimr(res);
return Opm::ecl::trimr(res);
};
return readBinaryArray<std::string,Char8>(fileH, size, EIOD::CHAR, f);
return readBinaryArray<std::string,Char8>(fileH, size, Opm::ecl::CHAR, f);
}
@@ -300,10 +303,10 @@ std::vector<std::string> 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<std::string> 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<double> 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::EclEntry> EclFile::getList() const
template<>
const std::vector<int>& EclFile::get<int>(int arrIndex)
{
return getImpl(arrIndex, EIOD::INTE, inte_array, "integer");
return getImpl(arrIndex, INTE, inte_array, "integer");
}
template<>
const std::vector<float>&
EclFile::get<float>(int arrIndex)
{
return getImpl(arrIndex, EIOD::REAL, real_array, "float");
return getImpl(arrIndex, REAL, real_array, "float");
}
template<>
const std::vector<double> &EclFile::get<double>(int arrIndex)
{
return getImpl(arrIndex, EIOD::DOUB, doub_array, "double");
return getImpl(arrIndex, DOUB, doub_array, "double");
}
template<>
const std::vector<bool>& EclFile::get<bool>(int arrIndex)
{
return getImpl(arrIndex, EIOD::LOGI, logi_array, "bool");
return getImpl(arrIndex, LOGI, logi_array, "bool");
}
template<>
const std::vector<std::string>& EclFile::get<std::string>(int arrIndex)
{
return getImpl(arrIndex, EIOD::CHAR, char_array, "string");
return getImpl(arrIndex, CHAR, char_array, "string");
}
@@ -765,7 +771,7 @@ const std::vector<int>& EclFile::get<int>(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<float>& EclFile::get<float>(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<double>& EclFile::get<double>(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<bool>& EclFile::get<bool>(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<std::string>& EclFile::get<std::string>(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

View File

@@ -16,18 +16,19 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "EclOutput.hpp"
#include "EclUtil.hpp"
#include <opm/io/eclipse/EclOutput.hpp>
#include <opm/io/eclipse/EclUtil.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <stdexcept>
#include <typeinfo>
#include <sstream>
#include <stdio.h>
namespace Opm { namespace ecl {
EclOutput::EclOutput(const std::string& inputFile, bool formatted) :
isFormatted(formatted)
@@ -42,23 +43,23 @@ void EclOutput::write<std::string>(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<char*>(&bhead), sizeof(bhead));
@@ -66,22 +67,22 @@ void EclOutput::writeBinaryHeader(const std::string&arrName, int size, EIOD::ecl
ofileH.write(reinterpret_cast<char*>(&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<T>& data)
int n = 0;
int size = data.size();
EIOD::eclArrType arrType = EIOD::MESS;
eclArrType arrType = MESS;
if (typeid(std::vector<T>) == typeid(std::vector<int>)) {
arrType = EIOD::INTE;
arrType = INTE;
} else if (typeid(std::vector<T>) == typeid(std::vector<float>)) {
arrType = EIOD::REAL;
arrType = REAL;
} else if (typeid(std::vector<T>) == typeid(std::vector<double>)) {
arrType = EIOD::DOUB;
arrType = DOUB;
} else if (typeid(std::vector<T>) == typeid(std::vector<bool>)) {
arrType = EIOD::LOGI;
arrType = LOGI;
}
auto sizeData = block_size_data_binary(arrType);
@@ -134,22 +135,22 @@ void EclOutput::writeBinaryArray(const std::vector<T>& data)
rest = 0;
}
dhead = EIOD::flipEndianInt(num * sizeOfElement);
dhead = flipEndianInt(num * sizeOfElement);
ofileH.write(reinterpret_cast<char*>(&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<char*>(&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<char*>(&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<char*>(&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<char*>(&intVal), sizeOfElement);
} else {
std::cout << "type not supported in write binaryarray" << std::endl;
@@ -178,7 +179,7 @@ void EclOutput::writeBinaryCharArray(const std::vector<std::string>& 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<std::string>& data)
rest = 0;
}
dhead = EIOD::flipEndianInt(num * sizeOfElement);
dhead = flipEndianInt(num * sizeOfElement);
ofileH.write(reinterpret_cast<char*>(&dhead), sizeof(dhead));
@@ -214,29 +215,29 @@ void EclOutput::writeBinaryCharArray(const std::vector<std::string>& 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<T>& 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<T>& 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<char>(const std::vector<char>& data
void EclOutput::writeFormattedCharArray(const std::vector<std::string>& 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<std::string>& data)
ofileH << std::endl;
}
}
}} // namespace Opm::ecl

View File

@@ -16,16 +16,14 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "EclUtil.hpp"
#include <opm/io/eclipse/EclUtil.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <algorithm>
#include <stdexcept>
namespace EIOD = Opm::ecl;
int Opm::ecl::flipEndianInt(int num)
{
unsigned int tmp = __builtin_bswap32(num);
@@ -60,22 +58,22 @@ std::tuple<int, int> Opm::ecl::block_size_data_binary(eclArrType arrType)
using BlockSizeTuple = std::tuple<int, int>;
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<int, int> Opm::ecl::block_size_data_binary(eclArrType arrType)
}
std::tuple<int, int, int> Opm::ecl::block_size_data_formatted(EIOD::eclArrType arrType)
std::tuple<int, int, int> Opm::ecl::block_size_data_formatted(eclArrType arrType)
{
using BlockSizeTuple = std::tuple<int, int, int>;
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:

View File

@@ -17,18 +17,20 @@
*/
#include "EclFilesComparator.hpp"
#include <opm/common/ErrorMacros.hpp>
#include <opm/io/eclipse/EGrid.hpp>
#include <stdio.h>
#include <set>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <set>
#include <type_traits>
#include <vector>
// helper macro to handle error throws or not
#define HANDLE_ERROR(type, message) \
@@ -41,9 +43,10 @@
} \
}
using Opm::ecl::EGrid;
template <typename T>
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<bool> (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<int> (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<double> (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<std::string>(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<bool> (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<int> (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<double> (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<std::string>(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<bool>::const_reference is not a bool. If it is we will initialize printValuesForCell<char> otherwise printValuesForCell<std::vector<bool>::const_reference>
using boolConstReference = typename std::vector<bool>::const_reference;
using boolTypeHelper = typename std::remove_const<typename std::remove_reference<boolConstReference>::type>::type;
using boolType = typename std::conditional<std::is_same<boolTypeHelper, bool>::value, char, boolTypeHelper>::type;
template void ECLFilesComparator::printValuesForCell<boolType> (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<boolType> (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<double> 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<double>& vec) {
double sum = std::accumulate(vec.begin(), vec.end(), 0.0);
return sum/vec.size();
}

View File

@@ -21,12 +21,15 @@
#define ECLFILESCOMPARATOR_HPP
#include "Deviation.hpp"
#include <map>
#include <vector>
#include <stddef.h>
#include <string>
#include <vector>
#include <examples/test_util/EGrid.hpp>
namespace Opm { namespace ecl {
class EGrid;
}} // namespace Opm::ecl
class ECLFilesComparator {
public:
@@ -75,7 +78,13 @@ protected:
std::string rootName1, rootName2;
template <typename T>
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;

View File

@@ -17,23 +17,24 @@
*/
#include "EclRegressionTest.hpp"
#include <opm/io/eclipse/EGrid.hpp>
#include <opm/io/eclipse/ERft.hpp>
#include <opm/io/eclipse/ERst.hpp>
#include <opm/io/eclipse/ESmry.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <algorithm>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <iomanip>
#include <typeinfo>
#include <type_traits>
#include <typeinfo>
#include <vector>
#include <examples/test_util/ERst.hpp>
#include <examples/test_util/ESmry.hpp>
#include <examples/test_util/ERft.hpp>
#include <chrono>
// 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<std::string> &keywords
void ECLRegressionTest::checkSpesificKeyword(std::vector<std::string>& keywords1,
std::vector<std::string>& keywords2,
std::vector<EIOD::eclArrType>& arrayType1,
std::vector<EIOD::eclArrType>& arrayType2,
std::vector<eclArrType>& arrayType1,
std::vector<eclArrType>& arrayType2,
const std::string& reference)
{
auto search1 = std::find(keywords1.begin(), keywords1.end(), spesificKeyword);
@@ -276,7 +278,7 @@ void ECLRegressionTest::checkSpesificKeyword(std::vector<std::string>& 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<std::string> keywords1;
std::vector<EIOD::eclArrType> arrayType1;
std::vector<eclArrType> arrayType1;
for (auto& array : arrayList1) {
keywords1.push_back(std::get<0>(array));
@@ -368,7 +370,7 @@ void ECLRegressionTest::gridCompare()
}
std::vector<std::string> keywords2;
std::vector<EIOD::eclArrType> arrayType2;
std::vector<eclArrType> 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<std::string> keywords1;
std::vector<EIOD::eclArrType> arrayType1;
std::vector<eclArrType> arrayType1;
for (const auto& array : arrayList1) {
keywords1.push_back(std::get<0>(array));
@@ -549,7 +551,7 @@ void ECLRegressionTest::results_init()
}
std::vector<std::string> keywords2;
std::vector<EIOD::eclArrType> arrayType2;
std::vector<eclArrType> 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<int>(keywords1[i]);
auto vect2 = init2.get<int>(keywords2[ind2]);
compareVectors(vect1, vect2, keywords1[i],reference);
} else if (arrayType1[i] == EIOD::REAL) {
} else if (arrayType1[i] == REAL) {
auto vect1 = init1.get<float>(keywords1[i]);
auto vect2 = init2.get<float>(keywords2[ind2]);
compareFloatingPointVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::DOUB) {
} else if (arrayType1[i] == DOUB) {
auto vect1 = init1.get<double>(keywords1[i]);
auto vect2 = init2.get<double>(keywords2[ind2]);
compareFloatingPointVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::LOGI) {
} else if (arrayType1[i] == LOGI) {
auto vect1 = init1.get<bool>(keywords1[i]);
auto vect2 = init2.get<bool>(keywords2[ind2]);
compareVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::CHAR) {
} else if (arrayType1[i] == CHAR) {
auto vect1 = init1.get<std::string>(keywords1[i]);
auto vect2 = init2.get<std::string>(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<std::string> keywords1;
std::vector<EIOD::eclArrType> arrayType1;
std::vector<eclArrType> arrayType1;
for (const auto& array : arrays1) {
keywords1.push_back(std::get<0>(array));
arrayType1.push_back(std::get<1>(array));
}
std::vector<std::string> keywords2;
std::vector<EIOD::eclArrType> arrayType2;
std::vector<eclArrType> 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<int>(keywords1[i], seqn);
if (arrayType1[i] == INTE) {
auto vect1 = rst1.getRst<int>(keywords1[i], seqn);
auto vect2 = rst2.getRst<int>(keywords2[ind2], seqn);
compareVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::REAL) {
} else if (arrayType1[i] == REAL) {
auto vect1 = rst1.getRst<float>(keywords1[i], seqn);
auto vect2 = rst2.getRst<float>(keywords2[ind2], seqn);
compareFloatingPointVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::DOUB) {
} else if (arrayType1[i] == DOUB) {
auto vect1 = rst1.getRst<double>(keywords1[i], seqn);
auto vect2 = rst2.getRst<double>(keywords2[ind2], seqn);
compareFloatingPointVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::LOGI) {
} else if (arrayType1[i] == LOGI) {
auto vect1 = rst1.getRst<bool>(keywords1[i], seqn);
auto vect2 = rst2.getRst<bool>(keywords2[ind2], seqn);
compareVectors(vect1, vect2, keywords1[i], reference);
} else if (arrayType1[i] == EIOD::CHAR) {
} else if (arrayType1[i] == CHAR) {
auto vect1 = rst1.getRst<std::string>(keywords1[i], seqn);
auto vect2 = rst2.getRst<std::string>(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<std::string> keywords1 = smry1.keywordList();
std::vector<std::string> keywords2 = smry2.keywordList();
std::vector<EIOD::eclArrType> arrayType1(keywords1.size(), EIOD::REAL);
std::vector<EIOD::eclArrType> arrayType2 (keywords1.size(), EIOD::REAL);
std::vector<eclArrType> arrayType1(keywords1.size(), REAL);
std::vector<eclArrType> arrayType2 (keywords1.size(), REAL);
if (integrationTest) {
std::vector<std::string> 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<std::string> keywords1;
std::vector<EIOD::eclArrType> arrayType1;
std::vector<eclArrType> arrayType1;
for (auto& array : vectList1 ) {
keywords1.push_back(std::get<0>(array)) ;
arrayType1.push_back(std::get<1>(array)) ;
}
std::vector<std::string> keywords2;
std::vector<EIOD::eclArrType> arrayType2;
std::vector<eclArrType> 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<int>(keywords, well, date);
auto vect2 = rft2.getRft<int>(keywords, well, date);
compareVectors(vect1, vect2, keywords, reference);
} else if (arrayType == EIOD::REAL) {
} else if (arrayType == REAL) {
auto vect1 = rft1.getRft<float>(keywords, well, date);
auto vect2 = rft2.getRft<float>(keywords, well, date);
compareFloatingPointVectors(vect1, vect2, keywords, reference);
} else if (arrayType == EIOD::DOUB) {
} else if (arrayType == DOUB) {
auto vect1 = rft1.getRft<double>(keywords, well, date);
auto vect2 = rft2.getRft<double>(keywords, well, date);
compareFloatingPointVectors(vect1, vect2, keywords, reference);
} else if (arrayType == EIOD::LOGI) {
} else if (arrayType == LOGI) {
auto vect1 = rft1.getRft<bool>(keywords, well, date);
auto vect2 = rft2.getRft<bool>(keywords, well, date);
compareVectors(vect1, vect2, keywords, reference);
} else if (arrayType == EIOD::CHAR) {
} else if (arrayType == CHAR) {
auto vect1 = rft1.getRft<std::string>(keywords, well, date);
auto vect2 = rft2.getRft<std::string>(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<std::string>& arrayList1,
const std::vector<std::string>& arrayList2,
const std::vector<EIOD::eclArrType>& arrayType1,
const std::vector<EIOD::eclArrType>& arrayType2) const
const std::vector<eclArrType>& arrayType1,
const std::vector<eclArrType>& arrayType2) const
{
unsigned int maxLen = 0;

View File

@@ -21,8 +21,12 @@
#define ECLREGRESSIONTEST_HPP
#include "EclFilesComparator.hpp"
#include "data/EclIOdata.hpp"
#include <opm/io/eclipse/EclIOdata.hpp>
namespace Opm { namespace ecl {
class EGrid;
}}
namespace EIOD = Opm::ecl;
@@ -172,8 +176,8 @@ private:
// 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

View File

@@ -17,6 +17,7 @@
*/
#include "EclRegressionTest.hpp"
#include <opm/common/ErrorMacros.hpp>
#include <iostream>

View File

@@ -1,11 +1,12 @@
#include <iostream>
#include <chrono>
#include <tuple>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <examples/test_util/EclFile.hpp>
#include <examples/test_util/EclOutput.hpp>
#include <opm/io/eclipse/EclFile.hpp>
#include <opm/io/eclipse/EclOutput.hpp>
using namespace Opm::ecl;
template<typename T>
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<int>(outFile, file1, name, index);
} else if (arrType == EIOD::REAL) {
} else if (arrType == REAL) {
write<float>(outFile, file1, name,index);
} else if (arrType == EIOD::DOUB) {
} else if (arrType == DOUB) {
write<double>(outFile, file1, name, index);
} else if (arrType == EIOD::LOGI) {
} else if (arrType == LOGI) {
write<bool>(outFile, file1, name, index);
} else if (arrType == EIOD::CHAR) {
} else if (arrType == CHAR) {
write<std::string>(outFile, file1, name, index);
} else if (arrType == EIOD::MESS) {
} else if (arrType == MESS) {
// shold not be any associated data
outFile.write(name,std::vector<char>());
} else {

View File

@@ -18,18 +18,24 @@
#include "config.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <examples/test_util/EGrid.hpp>
#include <opm/io/eclipse/EGrid.hpp>
#define BOOST_TEST_MODULE Test EGrid
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <array>
#include <fstream>
#include <initializer_list>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <tuple>
using Opm::ecl::EGrid;
template<typename InputIterator1, typename InputIterator2>
bool
range_equal(InputIterator1 first1, InputIterator1 last1,

View File

@@ -16,22 +16,27 @@
+ along with OPM. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <stdexcept>
#include <tuple>
#include <examples/test_util/ERft.hpp>
#include <examples/test_util/EclOutput.hpp>
#include <opm/io/eclipse/ERft.hpp>
#define BOOST_TEST_MODULE Test EGrid
#include <boost/test/unit_test.hpp>
#include <opm/io/eclipse/EclIOdata.hpp>
#include <opm/io/eclipse/EclOutput.hpp>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdexcept>
#include <stdio.h>
#include <tuple>
using namespace Opm::ecl;
template<typename InputIterator1, typename InputIterator2>
bool
range_equal(InputIterator1 first1, InputIterator1 last1,
@@ -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<int> vect = rft1.getRft<int>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == EIOD::REAL) {
} else if (arrType == REAL) {
std::vector<float> vect = rft1.getRft<float>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == EIOD::DOUB) {
} else if (arrType == DOUB) {
std::vector<double> vect = rft1.getRft<double>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == EIOD::LOGI) {
} else if (arrType == LOGI) {
std::vector<bool> vect = rft1.getRft<bool>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == EIOD::CHAR) {
} else if (arrType == CHAR) {
std::vector<std::string> vect = rft1.getRft<std::string>(arrName, wellName, date);
eclTest.write(arrName, vect);
} else if (arrType == EIOD::MESS) {
} else if (arrType == MESS) {
eclTest.write(arrName, std::vector<char>());
} else {
std::cout << "unknown type " << std::endl;

View File

@@ -16,21 +16,25 @@
+ along with OPM. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <examples/test_util/ERst.hpp>
#include <examples/test_util/EclOutput.hpp>
#include <opm/io/eclipse/ERst.hpp>
#define BOOST_TEST_MODULE Test EclIO
#include <boost/test/unit_test.hpp>
#include <opm/io/eclipse/EclOutput.hpp>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <tuple>
using namespace Opm::ecl;
template<typename InputIterator1, typename InputIterator2>
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<std::tuple<std::string, EIOD::eclArrType, int>> rstArrays; // = rst1.listOfRstArrays(4);
std::vector<std::tuple<std::string, eclArrType, int>> 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<int> vect = rst1.getRst<int>(name, seqnum);
eclTest.write(name, vect);
} else if (arrType == EIOD::REAL) {
} else if (arrType == REAL) {
std::vector<float> vect = rst1.getRst<float>(name, seqnum);
eclTest.write(name, vect);
} else if (arrType == EIOD::DOUB) {
} else if (arrType == DOUB) {
std::vector<double> vect = rst1.getRst<double>(name, seqnum);
eclTest.write(name, vect);
} else if (arrType == EIOD::LOGI) {
} else if (arrType == LOGI) {
std::vector<bool> vect = rst1.getRst<bool>(name, seqnum);
eclTest.write(name, vect);
} else if (arrType == EIOD::CHAR) {
} else if (arrType == CHAR) {
std::vector<std::string> vect = rst1.getRst<std::string>(name, seqnum);
eclTest.write(name, vect);
} else if (arrType == EIOD::MESS) {
} else if (arrType == MESS) {
eclTest.write(name, std::vector<char>());
} 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);
}
}

View File

@@ -16,21 +16,25 @@
+ along with OPM. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <examples/test_util/EclFile.hpp>
#include <examples/test_util/ESmry.hpp>
#include <opm/io/eclipse/ESmry.hpp>
#define BOOST_TEST_MODULE Test EclIO
#include <boost/test/unit_test.hpp>
#include <opm/io/eclipse/EclFile.hpp>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <tuple>
using Opm::ecl::ESmry;
template<typename InputIterator1, typename InputIterator2>
bool
range_equal(InputIterator1 first1, InputIterator1 last1,

View File

@@ -21,7 +21,8 @@
#define BOOST_TEST_MODULE EclFilesComparatorTest
#include <boost/test/unit_test.hpp>
#include <examples/test_util/EclFilesComparator.hpp>
#include <test_util/EclFilesComparator.hpp>
BOOST_AUTO_TEST_CASE(deviation) {
double a = 1;

View File

@@ -16,21 +16,23 @@
+ along with OPM. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "config.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <examples/test_util/EclFile.hpp>
#include <examples/test_util/EclOutput.hpp>
#include <opm/io/eclipse/EclFile.hpp>
#include <opm/io/eclipse/EclOutput.hpp>
#define BOOST_TEST_MODULE Test EclIO
#include <boost/test/unit_test.hpp>
using namespace Opm::ecl;
template<typename InputIterator1, typename InputIterator2>
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<int> vect = file1.get<int>(n);
eclTest.write(name, vect);
} else if (arrType == EIOD::REAL) {
} else if (arrType == REAL) {
std::vector<float> vect = file1.get<float>(n);
eclTest.write(name, vect);
} else if (arrType == EIOD::DOUB) {
} else if (arrType == DOUB) {
std::vector<double> vect = file1.get<double>(n);
eclTest.write(name, vect);
} else if (arrType == EIOD::LOGI) {
} else if (arrType == LOGI) {
std::vector<bool> vect = file1.get<bool>(n);
eclTest.write(name, vect);
} else if (arrType == EIOD::CHAR) {
} else if (arrType == CHAR) {
std::vector<std::string> vect = file1.get<std::string>(n);
eclTest.write(name, vect);
} else if (arrType == EIOD::MESS) {
} else if (arrType == MESS) {
eclTest.write(name, std::vector<char>());
} else {
std::cout << "unknown type " << std::endl;

View File

@@ -21,14 +21,18 @@
#define BOOST_TEST_MODULE EclRegressionTest
#include <boost/test/unit_test.hpp>
#include <examples/test_util/EclRegressionTest.hpp>
#include <examples/test_util/EGrid.hpp>
#include <examples/test_util/ESmry.hpp>
#include <examples/test_util/EclOutput.hpp>
#include <test_util/EclRegressionTest.hpp>
#include <opm/io/eclipse/EGrid.hpp>
#include <opm/io/eclipse/ESmry.hpp>
#include <opm/io/eclipse/EclOutput.hpp>
#include <iomanip>
using Opm::ecl::EGrid;
using Opm::ecl::ESmry;
using Opm::ecl::EclOutput;
void makeEgridFile(const std::string &fileName, const std::vector<float> &coord,
const std::vector<float> &zcorn, const std::vector<int> &gridhead,