My Project
BlackoilPhases.hpp
1 /*
2  Copyright 2010, 2011, 2012 SINTEF ICT, Applied Mathematics.
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_BLACKOILPHASES_HEADER_INCLUDED
21 #define OPM_BLACKOILPHASES_HEADER_INCLUDED
22 
23 #include <array>
24 
25 namespace Opm
26 {
27 
29  {
30  public:
31  static const int MaxNumPhases = 3;
32 
33  // "Crypto phases" are "phases" (or rather "conservation quantities") in the
34  // sense that they can be active or not and canonical indices can be translated
35  // to and from active ones. That said, they are not considered by num_phases or
36  // MaxNumPhases. The crypto phases which are currently implemented are solvent,
37  // polymer, energy, polymer molecular weight, foam and brine.
38  static const int NumCryptoPhases = 7;
39 
40  // enum ComponentIndex { Water = 0, Oil = 1, Gas = 2 };
41  enum PhaseIndex { Aqua = 0, Liquid = 1, Vapour = 2, Solvent = 3, Polymer = 4, Energy = 5, PolymerMW = 6, Foam = 7, Brine = 8, ZFraction = 9 };
42  };
43 
44  struct PhaseUsage : public BlackoilPhases
45  {
46  std::array<int, MaxNumPhases + NumCryptoPhases> phase_used;
47  std::array<int, MaxNumPhases + NumCryptoPhases> phase_pos;
48 
49  int num_phases;
50  bool has_solvent;
51  bool has_polymer;
52  bool has_energy;
53  // polymer molecular weight
54  bool has_polymermw;
55  bool has_foam;
56  bool has_brine;
57  bool has_zFraction;
58 
59  };
60 
67  {
68  public:
70  : present_(0)
71  {}
72 
73  bool hasFreeWater() const { return present(BlackoilPhases::Aqua ); }
74  bool hasFreeOil () const { return present(BlackoilPhases::Liquid); }
75  bool hasFreeGas () const { return present(BlackoilPhases::Vapour); }
76 
77  void setFreeWater() { insert(BlackoilPhases::Aqua ); }
78  void setFreeOil () { insert(BlackoilPhases::Liquid); }
79  void setFreeGas () { insert(BlackoilPhases::Vapour); }
80 
81  bool operator==(const PhasePresence& other) const { return present_ == other.present_; }
82  bool operator!=(const PhasePresence& other) const { return !this->operator==(other); }
83 
84  private:
85  unsigned char present_;
86 
87  bool present(const BlackoilPhases::PhaseIndex i) const
88  {
89  return present_ & (1 << i);
90  }
91 
92  void insert(const BlackoilPhases::PhaseIndex i)
93  {
94  present_ |= (1 << i);
95  }
96  };
97 
98 } // namespace Opm
99 
100 #endif // OPM_BLACKOILPHASES_HEADER_INCLUDED
Definition: BlackoilPhases.hpp:29
Check or assign presence of a formed, free phase.
Definition: BlackoilPhases.hpp:67
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:26
Definition: BlackoilPhases.hpp:45