My Project
RestartValue.hpp
1 /*
2  Copyright (c) 2017 Statoil ASA
3  This file is part of the Open Porous Media project (OPM).
4 
5  OPM is free software: you can redistribute it and/or modify
6  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 #ifndef RESTART_VALUE_HPP
19 #define RESTART_VALUE_HPP
20 
21 #include <map>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 
26 #include <opm/input/eclipse/Units/UnitSystem.hpp>
27 
28 #include <opm/output/data/Aquifer.hpp>
29 #include <opm/output/data/Solution.hpp>
30 #include <opm/output/data/Wells.hpp>
31 #include <opm/output/data/Groups.hpp>
32 
33 namespace Opm {
34 
35  class RestartKey {
36  public:
37 
38  std::string key;
39  UnitSystem::measure dim;
40  bool required = false;
41 
42  RestartKey() = default;
43 
44  RestartKey( const std::string& _key, UnitSystem::measure _dim)
45  : key(_key),
46  dim(_dim),
47  required(true)
48  {}
49 
50 
51  RestartKey( const std::string& _key, UnitSystem::measure _dim, bool _required)
52  : key(_key),
53  dim(_dim),
54  required(_required)
55  {}
56 
57  bool operator==(const RestartKey& key2) const
58  {
59  return key == key2.key &&
60  dim == key2.dim &&
61  required == key2.required;
62  }
63  };
64 
65  /*
66  A simple class used to communicate values between the simulator and
67  the RestartIO functions.
68  */
69  class RestartValue {
70  public:
71  using ExtraVector = std::vector<std::pair<RestartKey, std::vector<double>>>;
72 
73  data::Solution solution{};
74  data::Wells wells{};
75  data::GroupAndNetworkValues grp_nwrk{};
76  data::Aquifers aquifer{};
77  ExtraVector extra{};
78 
80  data::Wells wells_arg,
81  data::GroupAndNetworkValues grpn_nwrk_arg,
82  data::Aquifers aquifer_arg);
83 
84  RestartValue() = default;
85 
86  bool hasExtra(const std::string& key) const;
87  void addExtra(const std::string& key, UnitSystem::measure dimension, std::vector<double> data);
88  void addExtra(const std::string& key, std::vector<double> data);
89  const std::vector<double>& getExtra(const std::string& key) const;
90 
91  void convertFromSI(const UnitSystem& units);
92  void convertToSI(const UnitSystem& units);
93 
94  bool operator==(const RestartValue& val2) const
95  {
96  return (this->solution == val2.solution)
97  && (this->wells == val2.wells)
98  && (this->grp_nwrk == val2.grp_nwrk)
99  && (this->aquifer == val2.aquifer)
100  && (this->extra == val2.extra);
101  }
102  };
103 
104 }
105 
106 #endif // RESTART_VALUE_HPP
Definition: RestartValue.hpp:35
Definition: RestartValue.hpp:69
Definition: UnitSystem.hpp:34
Definition: Groups.hpp:157
Definition: Solution.hpp:32
Definition: Wells.hpp:337
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29