My Project
Loading...
Searching...
No Matches
flashprimaryvariables.hh
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*/
28#ifndef OPM_PTFLASH_PRIMARY_VARIABLES_HH
29#define OPM_PTFLASH_PRIMARY_VARIABLES_HH
30
34
35#include <opm/material/common/Valgrind.hpp>
36
37#include <iostream>
38
39namespace Opm {
40
50template <class TypeTag>
51class FlashPrimaryVariables : public FvBasePrimaryVariables<TypeTag>
52{
53 using ParentType = FvBasePrimaryVariables<TypeTag>;
54
60
61 // primary variable indices
62 enum { z0Idx = Indices::z0Idx };
63 enum { pressure0Idx = Indices::pressure0Idx };
64 enum { water0Idx = Indices::water0Idx };
65
66 static constexpr bool waterEnabled = Indices::waterEnabled;
67
68 // phase indices
69 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
70 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
71 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
72
74 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
75
76 using Toolbox = typename Opm::MathToolbox<Evaluation>;
78
79public:
80 FlashPrimaryVariables() : ParentType()
81 { Opm::Valgrind::SetDefined(*this); }
82
88 FlashPrimaryVariables& operator=(const FlashPrimaryVariables& value) = default;
89
90 using ParentType::operator=;
91
95 template <class FluidState>
96 void assignMassConservative(const FluidState& fluidState,
97 const MaterialLawParams&,
98 bool = false)
99 {
100 // there is no difference between naive and mass conservative
101 // assignment in the flash model. (we only need the total
102 // concentrations.)
103 assignNaive(fluidState);
104 }
105
109 template <class FluidState>
110 void assignNaive(const FluidState& fluidState)
111 {
112 // reset everything
113 (*this) = 0.0;
114
115 // assign the phase temperatures. this is out-sourced to
116 // the energy module
117 EnergyModule::setPriVarTemperatures(*this, fluidState);
118
119 // assign components total fraction
120 for (int i = 0; i < numComponents - 1; ++i)
121 (*this)[z0Idx + i] = getValue(fluidState.moleFraction(i));
122
123 // assign pressure
124 (*this)[pressure0Idx] = getValue(fluidState.pressure(oilPhaseIdx));
125
126 // assign water saturation
127 if constexpr (waterEnabled) {
128 (*this)[water0Idx] = getValue(fluidState.saturation(waterPhaseIdx));
129 }
130 }
131
137 void print(std::ostream& os = std::cout) const
138 {
139 os << "(p_" << FluidSystem::phaseName(FluidSystem::oilPhaseIdx) << " = "
140 << this->operator[](pressure0Idx);
141 for (unsigned compIdx = 0; compIdx < numComponents - 2; ++compIdx) {
142 os << ", z_" << FluidSystem::componentName(compIdx) << " = "
143 << this->operator[](z0Idx + compIdx);
144 }
145 if constexpr (waterEnabled) {
146 os << ", S_w = " << this->operator[](water0Idx);
147 }
148 os << ")" << std::flush;
149 }
150};
151
152} // namespace Opm
153
154#endif
Represents the primary variables used by the compositional flow model based on flash calculations.
Definition flashprimaryvariables.hh:51
void print(std::ostream &os=std::cout) const
Prints the names of the primary variables and their values.
Definition flashprimaryvariables.hh:137
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition flashprimaryvariables.hh:104
FlashPrimaryVariables(const FlashPrimaryVariables &value)=default
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &, bool=false)
< Import base class assignment operators.
Definition flashprimaryvariables.hh:96
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
Represents the primary variables used by the a model.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...