My Project
ThresholdPressure.hpp
1 /*
2  Copyright 2015 Statoil 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
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OPM_TRESHOLD_PRESSURES_HPP
21 #define OPM_TRESHOLD_PRESSURES_HPP
22 
23 #include <map>
24 #include <vector>
25 
26 namespace Opm {
27 
28 
29  class Deck;
30  class FieldPropsManager;
31 
33 
34  public:
35  using ThresholdPressureTable = std::vector<std::pair<bool,double>>;
36  using PressureTable = std::map<std::pair<int,int>,std::pair<bool,double>>;
37 
38  ThresholdPressure(bool restart,
39  const Deck& deck,
40  const FieldPropsManager& fp);
41 
43  : m_active(false)
44  , m_restart(false)
45  , m_irreversible(false)
46  {}
47 
50 
51  /*
52  The hasRegionBarrier() method checks if a threshold pressure
53  has been configured between the equilibration regions r1 and
54  r2; i.e. if the deck contains a THPRES record with regions
55  r1 and r2.
56  */
57  bool hasRegionBarrier(int r1 , int r2) const;
58 
59  /*
60  Checks if a threshold presssure has been configured between
61  the equilibration regions r1 and r2; the function will
62  return false either if no THPRES record with r1 and r2 has
63  been configured - or if THPRES record with ra and r2 has
64  defaulted pressure.
65  */
66  bool hasThresholdPressure(int r1 , int r2) const;
67 
68  /*
69  Will return the threshold pressure between equilibration
70  regions r1 and r2; if the pressure has been defaulted the
71  function will raise the error
72  INTERNAL_ERROR_UNINITIALIZED_THPRES - check with
73  hasThresholdPressure(r1,r2) first to be safe.
74  */
75  double getThresholdPressure(int r1 , int r2) const;
76  size_t size() const;
77  bool active() const;
78  bool restart() const;
79 
80  bool operator==(const ThresholdPressure& data) const;
81  static bool rst_cmp(const ThresholdPressure& full_arg, const ThresholdPressure& rst_arg);
82 
83 
84  template<class Serializer>
85  void serializeOp(Serializer& serializer)
86  {
87  serializer(m_active);
88  serializer(m_restart);
89  serializer(m_irreversible);
90  serializer(m_thresholdPressureTable);
91  serializer(m_pressureTable);
92  }
93 
94  private:
95  bool m_active;
96  bool m_restart;
97  bool m_irreversible;
98  std::pair<int,int> makeIndex(int r1 , int r2) const;
99  void addPair(int r1 , int r2 , const std::pair<bool , double>& valuePair);
100  void addBarrier(int r1 , int r2);
101  void addBarrier(int r1 , int r2 , double p);
102 
103  std::vector<std::pair<bool,double>> m_thresholdPressureTable;
104  std::map<std::pair<int,int> , std::pair<bool , double> > m_pressureTable;
105  };
106 } //namespace Opm
107 
108 #endif
Definition: Deck.hpp:63
Definition: FieldPropsManager.hpp:38
Definition: Serializer.hpp:38
Definition: ThresholdPressure.hpp:32
static ThresholdPressure serializeObject()
Returns an instance for serialization tests.
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29