opm-common
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 <cstddef>
24 #include <map>
25 #include <vector>
26 
27 namespace Opm {
28 
29 
30  class Deck;
31  class FaultCollection;
32  class FieldPropsManager;
33 
35 
36  public:
37  using ThresholdPressureTable = std::vector<std::pair<bool,double>>;
38  using PressureTable = std::map<std::pair<int,int>,std::pair<bool,double>>;
39 
40  ThresholdPressure(bool restart,
41  const Deck& deck,
42  const FieldPropsManager& fp);
43 
45  : m_active(false)
46  , m_restart(false)
47  , m_irreversible(false)
48  {}
49 
50 
52  void readFaults(const Deck& deck,
53  const FaultCollection& faults);
54 
57 
58  /*
59  The hasRegionBarrier() method checks if a threshold pressure
60  has been configured between the equilibration regions r1 and
61  r2; i.e. if the deck contains a THPRES record with regions
62  r1 and r2.
63  */
64  bool hasRegionBarrier(int r1 , int r2) const;
65 
66  /*
67  Checks if a threshold presssure has been configured between
68  the equilibration regions r1 and r2; the function will
69  return false either if no THPRES record with r1 and r2 has
70  been configured - or if THPRES record with ra and r2 has
71  defaulted pressure.
72  */
73  bool hasThresholdPressure(int r1 , int r2) const;
74 
75  /*
76  Will return the threshold pressure between equilibration
77  regions r1 and r2; if the pressure has been defaulted the
78  function will raise the error
79  INTERNAL_ERROR_UNINITIALIZED_THPRES - check with
80  hasThresholdPressure(r1,r2) first to be safe.
81  */
82  double getThresholdPressure(int r1 , int r2) const;
83 
85  double getThresholdPressureFault(int idx) const;
86 
87  size_t ftSize() const;
88  size_t size() const;
89  bool active() const;
90  bool restart() const;
91  bool irreversible() const;
92 
93  bool operator==(const ThresholdPressure& data) const;
94  static bool rst_cmp(const ThresholdPressure& full_arg, const ThresholdPressure& rst_arg);
95 
96 
97  template<class Serializer>
98  void serializeOp(Serializer& serializer)
99  {
100  serializer(m_active);
101  serializer(m_restart);
102  serializer(m_irreversible);
103  serializer(m_thresholdPressureTable);
104  serializer(m_pressureTable);
105  serializer(m_thresholdFaultTable);
106  }
107 
108  private:
109  bool m_active;
110  bool m_restart;
111  bool m_irreversible;
112  std::pair<int,int> makeIndex(int r1 , int r2) const;
113  void addPair(int r1 , int r2 , const std::pair<bool , double>& valuePair);
114  void addBarrier(int r1 , int r2);
115  void addBarrier(int r1 , int r2 , double p);
116 
117  std::vector<std::pair<bool,double>> m_thresholdPressureTable;
118  std::map<std::pair<int,int> , std::pair<bool , double> > m_pressureTable;
119  std::vector<double> m_thresholdFaultTable;
120  };
121 } //namespace Opm
122 
123 #endif
Definition: ThresholdPressure.hpp:34
Definition: FieldPropsManager.hpp:42
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
double getThresholdPressureFault(int idx) const
Returns threshold pressure for a fault.
Definition: ThresholdPressure.cpp:205
void readFaults(const Deck &deck, const FaultCollection &faults)
Reads the THPRESFT keyword if present.
Definition: ThresholdPressure.cpp:135
Definition: FaultCollection.hpp:35
static ThresholdPressure serializationTestObject()
Returns an instance for serialization tests.
Definition: ThresholdPressure.cpp:167
Definition: Deck.hpp:46
Class for (de-)serializing.
Definition: Serializer.hpp:94