My Project
ERsm.hpp
1 /*
2  Copyright 2020 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_ERSM_HPP
20 #define OPM_IO_ERSM_HPP
21 
22 #include <deque>
23 #include <string>
24 #include <unordered_map>
25 #include <variant>
26 #include <vector>
27 
28 #include <opm/io/eclipse/SummaryNode.hpp>
29 #include <opm/common/utility/TimeService.hpp>
30 
31 namespace Opm { namespace EclIO {
32 
33 /*
34  Small class to load RSM files. The RSM file is a text based version of the
35  information found in the summary file. The format seems quite fragile - with
36  significant whitespace all over the place.The ambition of this ERsm clas is to
37  be able to do regression testing of the RSM files we export from the ESmry
38  class - it is not meant to be a rock-solid-works-in-every-lunar phase RSM
39  loader.
40 */
41 class ESmry;
42 
43 class ERsm
44 {
45 
46 struct Vector{
47  SummaryNode header;
48  std::vector<double> data;
49 
50  Vector(SummaryNode header_, std::size_t size_advice) :
51  header(std::move(header_))
52  {
53  this->data.reserve(size_advice);
54  }
55 };
56 
57 
58 public:
59  ERsm(const std::string& fname);
60 
61  const std::vector<TimeStampUTC>& dates() const;
62  const std::vector<double>& days() const;
63  bool has_dates() const;
64 
65  const std::vector<double>& get(const std::string& key) const;
66  bool has(const std::string& key) const;
67 private:
68  void load_block(std::deque<std::string>& lines , std::size_t& vector_length);
69 
70  std::unordered_map<std::string, Vector> vectors;
71  std::variant<std::vector<double>, std::vector<TimeStampUTC>> time;
72 };
73 
74 bool cmp(const ESmry& esmr, const ERsm& ersm);
75 
76 }
77 }
78 
79 #endif
Definition: ERsm.hpp:44
Definition: ESmry.hpp:41
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: SummaryNode.hpp:37