CompositionalContainer.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 Consult the COPYING file in the top-level source directory of this
19 module for the precise wording of the license and the list of
20 copyright holders.
21*/
26#ifndef OPM_COMPOSITIONAL_CONTAINER_HPP
27#define OPM_COMPOSITIONAL_CONTAINER_HPP
28
29#include <opm/input/eclipse/EclipseState/Compositional/CompositionalConfig.hpp>
30
31#include <array>
32#include <functional>
33#include <map>
34#include <optional>
35#include <string>
36#include <vector>
37
38namespace Opm {
39
40namespace data { class Solution; }
41
42template<class FluidSystem>
44{
45 using Scalar = typename FluidSystem::Scalar;
46 using ScalarBuffer = std::vector<Scalar>;
47
48 static constexpr int numComponents = FluidSystem::numComponents;
49
50 static constexpr int numPhases = FluidSystem::numPhases;
51 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
52 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
53 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
54
55public:
56 enum class RestartOutput { Disabled, Enabled };
57
62 void allocate(const unsigned bufferSize,
63 std::map<std::string, int>& rstKeywords,
64 RestartOutput restartOutput);
65
66 using AssignFunction = std::function<Scalar(const unsigned)>;
67
68 void assignGasFractions(const unsigned globalDofIdx,
69 const AssignFunction& fractions);
70
71 void assignMoleFractions(const unsigned globalDofIdx,
72 const AssignFunction& fractions);
73
74 void assignOilFractions(const unsigned globalDofIdx,
75 const AssignFunction& fractions);
76
77 void assignPhasePressures(const unsigned globalDofIdx,
78 const Scalar oilPressure,
79 const Scalar gasPressure);
80
81 void assignSaturationPressure(const unsigned globalDofIdx,
82 const Scalar psat);
83
92 [[nodiscard]] static std::optional<Scalar>
93 cellSaturationPressure(const Scalar liquidFraction,
94 const Scalar oilPressure,
95 const std::array<Scalar, numComponents>& moleFractions,
96 const Scalar temperature,
97 const CompositionalConfig::EOSType eosType);
98
99 void assignVaporFraction(const unsigned globalDofIdx,
100 const Scalar vmf);
101
102 void outputRestart(data::Solution& sol,
103 ScalarBuffer& oil_saturation);
104
106 { return !moleFractions_[0].empty(); }
107
109 { return !phaseMoleFractions_[gasPhaseIdx][0].empty(); }
110
112 { return !phaseMoleFractions_[oilPhaseIdx][0].empty(); }
113
115 { return !oilPressure_.empty() || !gasPressure_.empty(); }
116
118 { return !vaporFraction_.empty(); }
119
121 { return !saturationPressure_.empty(); }
122
126 { return saturationPressureRequested_; }
127
128 bool allocated() const
129 { return allocated_; }
130
131private:
132 bool allocated_ = false;
133 // total mole fractions for each component
134 std::array<ScalarBuffer, numComponents> moleFractions_;
135 // mole fractions for each component in each phase
136 std::array<std::array<ScalarBuffer, numComponents>, numPhases> phaseMoleFractions_;
137 // phase pressures (POIL, PGAS)
138 ScalarBuffer oilPressure_;
139 ScalarBuffer gasPressure_;
140 // saturation pressure (PSAT)
141 ScalarBuffer saturationPressure_;
142 bool saturationPressureRequested_ = false;
143 // vapour mole fraction of the total mixture (VMF)
144 ScalarBuffer vaporFraction_;
145};
146
147} // namespace Opm
148
149#endif // OPM_COMPOSITIONAL_CONTAINER_HPP
Definition: CompositionalContainer.hpp:44
void assignGasFractions(const unsigned globalDofIdx, const AssignFunction &fractions)
bool saturationPressureAllocated() const
Definition: CompositionalContainer.hpp:120
RestartOutput
Definition: CompositionalContainer.hpp:56
std::function< Scalar(const unsigned)> AssignFunction
Definition: CompositionalContainer.hpp:66
bool oilFractionsAllocated() const
Definition: CompositionalContainer.hpp:111
bool moleFractionsAllocated() const
Definition: CompositionalContainer.hpp:105
void assignSaturationPressure(const unsigned globalDofIdx, const Scalar psat)
void allocate(const unsigned bufferSize, std::map< std::string, int > &rstKeywords, RestartOutput restartOutput)
bool saturationPressureRequested() const
Definition: CompositionalContainer.hpp:125
bool vaporFractionAllocated() const
Definition: CompositionalContainer.hpp:117
static std::optional< Scalar > cellSaturationPressure(const Scalar liquidFraction, const Scalar oilPressure, const std::array< Scalar, numComponents > &moleFractions, const Scalar temperature, const CompositionalConfig::EOSType eosType)
bool gasFractionsAllocated() const
Definition: CompositionalContainer.hpp:108
bool allocated() const
Definition: CompositionalContainer.hpp:128
void outputRestart(data::Solution &sol, ScalarBuffer &oil_saturation)
void assignMoleFractions(const unsigned globalDofIdx, const AssignFunction &fractions)
bool phasePressuresAllocated() const
Definition: CompositionalContainer.hpp:114
void assignOilFractions(const unsigned globalDofIdx, const AssignFunction &fractions)
void assignPhasePressures(const unsigned globalDofIdx, const Scalar oilPressure, const Scalar gasPressure)
void assignVaporFraction(const unsigned globalDofIdx, const Scalar vmf)
Definition: blackoilbioeffectsmodules.hh:45