opm-common
BlackOilDefaultFluidSystemIndices.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
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 2 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  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef OPM_BLACK_OIL_DEFAULT_FLUID_SYSTEM_INDICES_HPP
28 #define OPM_BLACK_OIL_DEFAULT_FLUID_SYSTEM_INDICES_HPP
29 
30 #include <cassert>
31 
32 namespace Opm {
33 
39 {
40 public:
42  static constexpr unsigned numPhases = 3;
43 
45  static constexpr unsigned waterPhaseIdx = 0;
47  static constexpr unsigned oilPhaseIdx = 1;
49  static constexpr unsigned gasPhaseIdx = 2;
50 
52  static constexpr unsigned numComponents = 3;
53 
55  static constexpr int oilCompIdx = 0;
57  static constexpr int waterCompIdx = 1;
59  static constexpr int gasCompIdx = 2;
60 
61  // TODO: the following two functions are for black oil only
62  // it remains to be formulated to be more generic
63  // it is likely moved out of the Indices class
65  static constexpr int componentToPhaseIdx(int compIdx) {
66  assert(compIdx >= 0 && compIdx < static_cast<int>(numComponents));
67  switch (compIdx) {
68  case oilCompIdx: return oilPhaseIdx;
69  case waterCompIdx: return waterPhaseIdx;
70  case gasCompIdx: return gasPhaseIdx;
71  default: return -1; // invalid index
72  }
73  }
74 
76  static constexpr int phaseToComponentIdx(int phaseIdx) {
77  assert(phaseIdx >= 0 && phaseIdx < static_cast<int>(numPhases));
78  switch (phaseIdx) {
79  case waterPhaseIdx: return waterCompIdx;
80  case oilPhaseIdx: return oilCompIdx;
81  case gasPhaseIdx: return gasCompIdx;
82  default: return -1; // invalid index
83  }
84  }
85 };
86 
87 } // namespace Opm
88 
89 #endif
The class which specifies the default phase and component indices for the black-oil fluid system...
Definition: BlackOilDefaultFluidSystemIndices.hpp:38
static constexpr int componentToPhaseIdx(int compIdx)
Map component index to phase index.
Definition: BlackOilDefaultFluidSystemIndices.hpp:65
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static constexpr unsigned numPhases
Total number of phases.
Definition: BlackOilDefaultFluidSystemIndices.hpp:42
static constexpr int gasCompIdx
Index of the gas component.
Definition: BlackOilDefaultFluidSystemIndices.hpp:59
static constexpr int oilCompIdx
Index of the oil component.
Definition: BlackOilDefaultFluidSystemIndices.hpp:55
static constexpr unsigned gasPhaseIdx
Index of the gas phase.
Definition: BlackOilDefaultFluidSystemIndices.hpp:49
static constexpr unsigned oilPhaseIdx
Index of the oil phase.
Definition: BlackOilDefaultFluidSystemIndices.hpp:47
static constexpr int waterCompIdx
Index of the water component.
Definition: BlackOilDefaultFluidSystemIndices.hpp:57
static constexpr unsigned waterPhaseIdx
Index of the water phase.
Definition: BlackOilDefaultFluidSystemIndices.hpp:45
static constexpr int phaseToComponentIdx(int phaseIdx)
Map phase index to component index.
Definition: BlackOilDefaultFluidSystemIndices.hpp:76
static constexpr unsigned numComponents
Total number of components.
Definition: BlackOilDefaultFluidSystemIndices.hpp:52