All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
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 
24 namespace Opm
25 {
26 
28  {
29  public:
30  static const int MaxNumPhases = 3;
31  // enum ComponentIndex { Water = 0, Oil = 1, Gas = 2 };
32  enum PhaseIndex { Aqua = 0, Liquid = 1, Vapour = 2 };
33 
34  };
35 
36  struct PhaseUsage : public BlackoilPhases
37  {
38  int num_phases;
39  int phase_used[MaxNumPhases];
40  int phase_pos[MaxNumPhases];
41  bool has_solvent;
42  bool has_polymer;
43  };
44 
51  {
52  public:
54  : present_(0)
55  {}
56 
57  bool hasFreeWater() const { return present(BlackoilPhases::Aqua ); }
58  bool hasFreeOil () const { return present(BlackoilPhases::Liquid); }
59  bool hasFreeGas () const { return present(BlackoilPhases::Vapour); }
60 
61  void setFreeWater() { insert(BlackoilPhases::Aqua ); }
62  void setFreeOil () { insert(BlackoilPhases::Liquid); }
63  void setFreeGas () { insert(BlackoilPhases::Vapour); }
64 
65  bool operator==(const PhasePresence& other) const { return present_ == other.present_; }
66  bool operator!=(const PhasePresence& other) const { return !this->operator==(other); }
67 
68  private:
69  unsigned char present_;
70 
71  bool present(const BlackoilPhases::PhaseIndex i) const
72  {
73  return present_ & (1 << i);
74  }
75 
76  void insert(const BlackoilPhases::PhaseIndex i)
77  {
78  present_ |= (1 << i);
79  }
80  };
81 
82 } // namespace Opm
83 
84 #endif // OPM_BLACKOILPHASES_HEADER_INCLUDED
Check or assign presence of a formed, free phase.
Definition: BlackoilPhases.hpp:50
Definition: BlackoilPhases.hpp:27
Definition: BlackoilPhases.hpp:36