My Project
Loading...
Searching...
No Matches
EclUtil.hpp
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
22#include <opm/io/eclipse/EclIOdata.hpp>
23
24#include <string>
25#include <tuple>
26#include <vector>
27#include <functional>
28#include <cstdint>
29
30namespace Opm { namespace EclIO {
31
32 int flipEndianInt(int num);
33 std::int64_t flipEndianLongInt(std::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
46 int combineSummaryNumbers(const int n1, const int n2);
47
50 std::tuple<int,int> splitSummaryNumber(const int n);
51
52 std::tuple<int, int> block_size_data_binary(eclArrType arrType);
53 std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
54
55 std::string trimr(const std::string &str1);
56
57 std::uint64_t sizeOnDiskBinary(std::int64_t num, Opm::EclIO::eclArrType arrType, int elementSize);
58 std::uint64_t sizeOnDiskFormatted(const std::int64_t num, Opm::EclIO::eclArrType arrType, int elementSize);
59
60 void readBinaryHeader(std::fstream& fileH, std::string& tmpStrName,
61 int& tmpSize, std::string& tmpStrType);
62
63 void readBinaryHeader(std::fstream& fileH, std::string& arrName,
64 std::int64_t& size, Opm::EclIO::eclArrType &arrType, int& elementSize);
65
66 void readFormattedHeader(std::fstream& fileH, std::string& arrName,
67 std::int64_t &num, Opm::EclIO::eclArrType &arrType, int& elementSize);
68
69 template<typename T, typename T2>
70 std::vector<T> readBinaryArray(std::fstream& fileH, const std::int64_t size, Opm::EclIO::eclArrType type,
71 std::function<T(T2)>& flip, int elementSize);
72
73 std::vector<int> readBinaryInteArray(std::fstream &fileH, const std::int64_t size);
74 std::vector<float> readBinaryRealArray(std::fstream& fileH, const std::int64_t size);
75 std::vector<double> readBinaryDoubArray(std::fstream& fileH, const std::int64_t size);
76 std::vector<bool> readBinaryLogiArray(std::fstream &fileH, const std::int64_t size);
77 std::vector<unsigned int> readBinaryRawLogiArray(std::fstream &fileH, const std::int64_t size);
78 std::vector<std::string> readBinaryCharArray(std::fstream& fileH, const std::int64_t size);
79 std::vector<std::string> readBinaryC0nnArray(std::fstream& fileH, const std::int64_t size, int elementSize);
80
81 template<typename T>
82 std::vector<T> readFormattedArray(const std::string& file_str, const int size, std::int64_t fromPos,
83 std::function<T(const std::string&)>& process);
84
85 std::vector<int> readFormattedInteArray(const std::string& file_str, const std::int64_t size, std::int64_t fromPos);
86
87 std::vector<std::string> readFormattedCharArray(const std::string& file_str, const std::int64_t size,
88 std::int64_t fromPos, int elementSize);
89
90 std::vector<float> readFormattedRealArray(const std::string& file_str, const std::int64_t size, std::int64_t fromPos);
91 std::vector<std::string> readFormattedRealRawStrings(const std::string& file_str, const std::int64_t size, std::int64_t fromPos);
92
93 std::vector<bool> readFormattedLogiArray(const std::string& file_str, const std::int64_t size, std::int64_t fromPos);
94 std::vector<double> readFormattedDoubArray(const std::string& file_str, const std::int64_t size, std::int64_t fromPos);
95
96}} // namespace Opm::EclIO
97
98#endif // OPM_IO_ECLUTIL_HPP
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30