EclUtil.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 OPM is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with OPM. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef OPM_IO_ECLUTIL_HPP
20#define OPM_IO_ECLUTIL_HPP
21
24
25#include <string>
26#include <tuple>
27#include <vector>
28#include <functional>
29
30namespace Opm { namespace EclIO {
31
32 int flipEndianInt(int num);
33 int64_t flipEndianLongInt(int64_t num);
34 float flipEndianFloat(float num);
35 double flipEndianDouble(double num);
36 bool isEOF(std::fstream* fileH);
37 bool fileExists(const std::string& filename);
38 bool isFormatted(const std::string& filename);
39 bool is_number(const std::string& numstr);
40
41 bool isEqualCaseInsensitive(const std::string& string1, const std::string& string2);
42 Opm::filesystem::path findFileCaseInsensitive(const Opm::filesystem::path& folder, const std::string& filename);
43
44 std::tuple<int, int> block_size_data_binary(eclArrType arrType);
45 std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
46
48
49 uint64_t sizeOnDiskBinary(int64_t num, Opm::EclIO::eclArrType arrType, int elementSize);
50 uint64_t sizeOnDiskFormatted(const int64_t num, Opm::EclIO::eclArrType arrType, int elementSize);
51
52 void readBinaryHeader(std::fstream& fileH, std::string& tmpStrName,
53 int& tmpSize, std::string& tmpStrType);
54
55 void readBinaryHeader(std::fstream& fileH, std::string& arrName,
56 int64_t& size, Opm::EclIO::eclArrType &arrType, int& elementSize);
57
58 void readFormattedHeader(std::fstream& fileH, std::string& arrName,
59 int64_t &num, Opm::EclIO::eclArrType &arrType, int& elementSize);
60
61 template<typename T, typename T2>
62 std::vector<T> readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type,
63 std::function<T(T2)>& flip, int elementSize);
64
65 std::vector<int> readBinaryInteArray(std::fstream &fileH, const int64_t size);
66 std::vector<float> readBinaryRealArray(std::fstream& fileH, const int64_t size);
67 std::vector<double> readBinaryDoubArray(std::fstream& fileH, const int64_t size);
68 std::vector<bool> readBinaryLogiArray(std::fstream &fileH, const int64_t size);
69 std::vector<unsigned int> readBinaryRawLogiArray(std::fstream &fileH, const int64_t size);
70 std::vector<std::string> readBinaryCharArray(std::fstream& fileH, const int64_t size);
71 std::vector<std::string> readBinaryC0nnArray(std::fstream& fileH, const int64_t size, int elementSize);
72
73 template<typename T>
74 std::vector<T> readFormattedArray(const std::string& file_str, const int size, int64_t fromPos,
76
77 std::vector<int> readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos);
78
79 std::vector<std::string> readFormattedCharArray(const std::string& file_str, const int64_t size,
80 int64_t fromPos, int elementSize);
81
82 std::vector<float> readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos);
83 std::vector<std::string> readFormattedRealRawStrings(const std::string& file_str, const int64_t size, int64_t fromPos);
84
85 std::vector<bool> readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos);
86 std::vector<double> readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos);
87
88}} // namespace Opm::EclIO
89
90#endif // OPM_IO_ECLUTIL_HPP
const char *const string
Definition: cJSON.h:170
bool is_number(const std::string &numstr)
float flipEndianFloat(float num)
int64_t flipEndianLongInt(int64_t num)
std::vector< float > readBinaryRealArray(std::fstream &fileH, const int64_t size)
std::vector< std::string > readBinaryCharArray(std::fstream &fileH, const int64_t size)
std::vector< unsigned int > readBinaryRawLogiArray(std::fstream &fileH, const int64_t size)
std::string trimr(const std::string &str1)
bool isEqualCaseInsensitive(const std::string &string1, const std::string &string2)
std::tuple< int, int > block_size_data_binary(eclArrType arrType)
uint64_t sizeOnDiskFormatted(const int64_t num, Opm::EclIO::eclArrType arrType, int elementSize)
uint64_t sizeOnDiskBinary(int64_t num, Opm::EclIO::eclArrType arrType, int elementSize)
std::vector< T > readBinaryArray(std::fstream &fileH, const int64_t size, Opm::EclIO::eclArrType type, std::function< T(T2)> &flip, int elementSize)
double flipEndianDouble(double num)
void readBinaryHeader(std::fstream &fileH, std::string &tmpStrName, int &tmpSize, std::string &tmpStrType)
void readFormattedHeader(std::fstream &fileH, std::string &arrName, int64_t &num, Opm::EclIO::eclArrType &arrType, int &elementSize)
bool fileExists(const std::string &filename)
int flipEndianInt(int num)
std::vector< T > readFormattedArray(const std::string &file_str, const int size, int64_t fromPos, std::function< T(const std::string &)> &process)
std::vector< std::string > readFormattedCharArray(const std::string &file_str, const int64_t size, int64_t fromPos, int elementSize)
std::vector< int > readBinaryInteArray(std::fstream &fileH, const int64_t size)
eclArrType
Definition: EclIOdata.hpp:28
bool isFormatted(const std::string &filename)
bool isEOF(std::fstream *fileH)
std::vector< std::string > readBinaryC0nnArray(std::fstream &fileH, const int64_t size, int elementSize)
std::vector< int > readFormattedInteArray(const std::string &file_str, const int64_t size, int64_t fromPos)
Opm::filesystem::path findFileCaseInsensitive(const Opm::filesystem::path &folder, const std::string &filename)
std::vector< float > readFormattedRealArray(const std::string &file_str, const int64_t size, int64_t fromPos)
std::vector< double > readFormattedDoubArray(const std::string &file_str, const int64_t size, int64_t fromPos)
std::vector< bool > readFormattedLogiArray(const std::string &file_str, const int64_t size, int64_t fromPos)
std::vector< std::string > readFormattedRealRawStrings(const std::string &file_str, const int64_t size, int64_t fromPos)
std::tuple< int, int, int > block_size_data_formatted(eclArrType arrType)
std::vector< bool > readBinaryLogiArray(std::fstream &fileH, const int64_t size)
std::vector< double > readBinaryDoubArray(std::fstream &fileH, const int64_t size)
std::function< double(double, double)> function
Definition: Operate.hpp:28
Definition: A.hpp:4
T process(const operator_type operation, const T arg)
Definition: exprtk.hpp:5101
const T1 const T2
Definition: exprtk.hpp:14402