InjectedPhase.hpp
Go to the documentation of this file.
1/*
2 Copyright 2026 Equinor 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_INJECTED_PHASE_HPP_INCLUDED
21#define OPM_INJECTED_PHASE_HPP_INCLUDED
22
23#include <opm/input/eclipse/Schedule/ScheduleTypes.hpp>
24#include <opm/material/fluidsystems/PhaseUsageInfo.hpp>
25
26#include <optional>
27
28namespace Opm {
29
33template <class IndexTraits>
34std::optional<unsigned> injectedCanonicalPhaseIdx(const InjectorType type)
35{
36 switch (type) {
37 case InjectorType::WATER: return IndexTraits::waterPhaseIdx;
38 case InjectorType::OIL: return IndexTraits::oilPhaseIdx;
39 case InjectorType::GAS: return IndexTraits::gasPhaseIdx;
40 case InjectorType::MULTI: return std::nullopt;
41 }
42 return std::nullopt;
43}
44
49template <class IndexTraits>
51 const InjectorType type)
52{
53 const auto canonical = injectedCanonicalPhaseIdx<IndexTraits>(type);
54 if (!canonical.has_value() || !pu.phaseIsActive(*canonical)) {
55 return std::nullopt;
56 }
57 return pu.canonicalToActivePhaseIdx(*canonical);
58}
59
60} // namespace Opm
61
62#endif // OPM_INJECTED_PHASE_HPP_INCLUDED
Definition: GasLiftGroupInfo.hpp:40
Definition: blackoilbioeffectsmodules.hh:45
std::optional< unsigned > injectedCanonicalPhaseIdx(const InjectorType type)
Definition: InjectedPhase.hpp:34
std::optional< int > injectedActivePhaseIdx(const PhaseUsageInfo< IndexTraits > &pu, const InjectorType type)
Definition: InjectedPhase.hpp:50