phaseUsageFromDeck.hpp
Go to the documentation of this file.
1 /*
2  Copyright 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_PHASEUSAGEFROMDECK_HEADER_INCLUDED
21 #define OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
22 
24 #include <opm/common/ErrorMacros.hpp>
25 
26 #include <opm/parser/eclipse/Deck/Deck.hpp>
27 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
28 
29 
30 namespace Opm
31 {
32 
35  inline PhaseUsage phaseUsageFromDeck(Opm::EclipseStateConstPtr eclipseState)
36  {
37  PhaseUsage pu;
38  std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0);
39 
40  // Discover phase usage.
41  if (eclipseState->hasPhase(Phase::PhaseEnum::WATER)) {
43  }
44  if (eclipseState->hasPhase(Phase::PhaseEnum::OIL)) {
46  }
47  if (eclipseState->hasPhase(Phase::PhaseEnum::GAS)) {
49  }
50  pu.num_phases = 0;
51  for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) {
52  pu.phase_pos[i] = pu.num_phases;
53  pu.num_phases += pu.phase_used[i];
54  }
55 
56  // Only 2 or 3 phase systems handled.
57  if (pu.num_phases < 2 || pu.num_phases > 3) {
58  OPM_THROW(std::runtime_error, "Cannot handle cases with " << pu.num_phases << " phases.");
59  }
60 
61  // We need oil systems, since we do not support the keywords needed for
62  // water-gas systems.
64  OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
65  }
66 
67  return pu;
68  }
69 
72  inline PhaseUsage phaseUsageFromDeck(Opm::DeckConstPtr deck)
73  {
74  PhaseUsage pu;
75  std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0);
76 
77  // Discover phase usage.
78  if (deck->hasKeyword("WATER")) {
80  }
81  if (deck->hasKeyword("OIL")) {
83  }
84  if (deck->hasKeyword("GAS")) {
86  }
87  pu.num_phases = 0;
88  for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) {
89  pu.phase_pos[i] = pu.num_phases;
90  pu.num_phases += pu.phase_used[i];
91  }
92 
93  // Only 2 or 3 phase systems handled.
94  if (pu.num_phases < 2 || pu.num_phases > 3) {
95  OPM_THROW(std::runtime_error, "Cannot handle cases with " << pu.num_phases << " phases.");
96  }
97 
98  // We need oil systems, since we do not support the keywords needed for
99  // water-gas systems.
101  OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems.");
102  }
103 
104  return pu;
105  }
106 
107 }
108 
109 #endif // OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
Definition: AnisotropicEikonal.hpp:43
Definition: BlackoilPhases.hpp:32
Definition: legacy_well.h:47
Definition: legacy_well.h:47
int phase_used[MaxNumPhases]
Definition: BlackoilPhases.hpp:39
int phase_pos[MaxNumPhases]
Definition: BlackoilPhases.hpp:40
int num_phases
Definition: BlackoilPhases.hpp:38
Definition: legacy_well.h:47
Definition: BlackoilPhases.hpp:32
static const int MaxNumPhases
Definition: BlackoilPhases.hpp:30
PhaseUsage phaseUsageFromDeck(Opm::EclipseStateConstPtr eclipseState)
Definition: phaseUsageFromDeck.hpp:35
Definition: BlackoilPhases.hpp:32
Definition: BlackoilPhases.hpp:36