My Project
Loading...
Searching...
No Matches
ERst.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_ERST_HPP
20#define OPM_IO_ERST_HPP
21
22#include <opm/io/eclipse/EclFile.hpp>
23
24#include <ios>
25#include <map>
26#include <string>
27#include <unordered_map>
28#include <vector>
29
30
31namespace Opm { namespace EclIO { namespace OutputStream {
32 class Restart;
33}}}
34
35namespace Opm { namespace EclIO {
36
37class ERst : public EclFile
38{
39public:
40 explicit ERst(const std::string& filename);
41
42 bool hasReportStepNumber(int number) const;
43 bool hasArray(const std::string& name, int number) const;
44 bool hasLGR(const std::string& gridname, int reportStepNumber) const;
45
46 void loadReportStepNumber(int number);
47
48 template <typename T>
49 const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber)
50 {
51 return getRestartData<T>(name,reportStepNumber, 0);
52 }
53
54 template <typename T>
55 const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber, int occurrence);
56
57 template <typename T>
58 const std::vector<T>& getRestartData(int index, int reportStepNumber)
59 {
60 auto indRange = this->getIndexRange(reportStepNumber);
61 return this->get<T>(index + std::get<0>(indRange));
62 }
63
64 template <typename T>
65 const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber, const std::string& lgr_name);
66
67 template <typename T>
68 const std::vector<T>& getRestartData(int index, int reportStepNumber, const std::string& lgr_name);
69
70 int occurrence_count(const std::string& name, int reportStepNumber) const;
71 size_t numberOfReportSteps() const { return seqnum.size(); };
72
73 const std::vector<int>& listOfReportStepNumbers() const { return seqnum; }
74
75 std::vector<EclEntry> listOfRstArrays(int reportStepNumber);
76 std::vector<EclEntry> listOfRstArrays(int reportStepNumber, const std::string& lgr_name);
77
78 friend class OutputStream::Restart;
79
80private:
81 int nReports;
82 std::vector<int> seqnum; // report step numbers, from SEQNUM array in restart file
83 mutable std::unordered_map<int,bool> reportLoaded;
84 std::map<int, std::pair<int,int>> arrIndexRange; // mapping report step number to array indeces (start and end)
85 std::vector<std::vector<std::string>> lgr_names; // report step numbers, from SEQNUM array in restart file
86
87 void initUnified();
88 void initSeparate(const int number);
89
90 int get_start_index_lgrname(int number, const std::string& lgr_name);
91
92 int getArrayIndex(const std::string& name, int seqnum, int occurrence);
93 int getArrayIndex(const std::string& name, int number, const std::string& lgr_name);
94
95 std::tuple<int,int> getIndexRange(int reportStepNumber) const;
96
97 std::streampos
98 restartStepWritePosition(const int seqnumValue) const;
99
100};
101
102}} // namespace Opm::EclIO
103
104#endif // OPM_IO_ERST_HPP
Definition ERst.hpp:38
Definition EclFile.hpp:36
File manager for restart output streams.
Definition OutputStream.hpp:136
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30