3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1padapter.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_FLUIDSYTEMS_ONEP_ADAPTER_HH
25#define DUMUX_FLUIDSYTEMS_ONEP_ADAPTER_HH
26
27#include <cassert>
28
29#include <dune/common/exceptions.hh>
30
33
34namespace Dumux {
35namespace FluidSystems {
36
43template <class MPFluidSystem, int phase = 0>
45: public Base<typename MPFluidSystem::Scalar, OnePAdapter<MPFluidSystem, phase>>
46{
49
50 static_assert(phase < MPFluidSystem::numPhases, "Phase does not exist in multi-phase fluidsystem!");
51
52 struct AdapterPolicy
53 {
54 using FluidSystem = MPFluidSystem;
55
56 // the phase index is always zero, other phases than the chosen phase should never be called
57 static int phaseIdx(int mpFluidPhaseIdx)
58 { return 0; }
59
60 // the main component is currently excepted to have the same index as it's phase
61 // (see Fluidsystems::Base::getMainComponent for more information)
62 // so we swap the main component with the first component
63 // this mapping works in both ways since we are only swapping components
64 static constexpr int compIdx(int compIdx)
65 {
66 if (compIdx == 0)
67 return phase;
68 else if (compIdx == phase)
69 return 0;
70 else
71 return compIdx;
72 }
73 };
74
75 template<class FluidState>
76 static auto adaptFluidState(const FluidState& fluidState)
78
79public:
80 using Scalar = typename Base::Scalar;
82
84 using MultiPhaseFluidSystem = MPFluidSystem;
86 static constexpr int multiphaseFluidsystemPhaseIdx = phase;
87
89 static constexpr int numPhases = 1;
92 static constexpr int numComponents = MultiPhaseFluidSystem::isMiscible() ? MultiPhaseFluidSystem::numComponents : numPhases;
94 static constexpr int phase0Idx = 0;
95
97 static constexpr int compIdx(int multiPhaseFluidSystemCompIdx)
98 { return AdapterPolicy::compIdx(multiPhaseFluidSystemCompIdx); }
99
103 template<class ...Args>
104 static void init(Args&&... args)
105 { MultiPhaseFluidSystem::init(std::forward<Args>(args)...); }
106
107 /****************************************
108 * Fluid phase related static parameters
109 ****************************************/
115 static std::string phaseName(int phaseIdx = 0)
116 { return MultiPhaseFluidSystem::phaseName(phase); }
117
123 static std::string componentName(int compIdx)
124 { return MultiPhaseFluidSystem::componentName(AdapterPolicy::compIdx(compIdx)); }
125
129 static std::string name()
130 { return MultiPhaseFluidSystem::phaseName(phase); }
131
135 static constexpr bool isMiscible()
136 { return false; }
137
141 static constexpr bool isGas(int phaseIdx = 0)
142 { return MultiPhaseFluidSystem::isGas(phase); }
143
158 static constexpr bool isIdealMixture(int phaseIdx = 0)
159 { return MultiPhaseFluidSystem::isIdealMixture(phase); }
160
164 static constexpr bool isCompressible(int phaseIdx = 0)
165 { return MultiPhaseFluidSystem::isCompressible(phase); }
166
170 static constexpr bool viscosityIsConstant(int phaseIdx = 0)
171 { return MultiPhaseFluidSystem::viscosityIsConstant(phase); }
172
176 static constexpr bool isIdealGas(int phaseIdx = 0)
177 { return MultiPhaseFluidSystem::isIdealGas(phase); }
178
183 { return MultiPhaseFluidSystem::molarMass(AdapterPolicy::compIdx(compIdx)); }
184
185 using Base::density;
189 template <class FluidState>
190 static Scalar density(const FluidState &fluidState, int phaseIdx = 0)
191 {
192 assert(phaseIdx == 0);
193 return MultiPhaseFluidSystem::density(adaptFluidState(fluidState), phase);
194 }
195
196 using Base::molarDensity;
206 template <class FluidState>
207 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx = 0)
208 {
209 assert(phaseIdx == 0);
210 return MultiPhaseFluidSystem::molarDensity(adaptFluidState(fluidState), phase);
211 }
212
213 using Base::enthalpy;
217 template <class FluidState>
218 static Scalar enthalpy(const FluidState &fluidState, int phaseIdx = 0)
219 {
220 assert(phaseIdx == 0);
221 return MultiPhaseFluidSystem::enthalpy(adaptFluidState(fluidState), phase);
222 }
223
231 template <class FluidState>
232 static Scalar componentEnthalpy(const FluidState &fluidState,
233 int phaseIdx,
234 int compIdx)
235 {
236 assert(phaseIdx == 0);
237 return MultiPhaseFluidSystem::componentEnthalpy(adaptFluidState(fluidState), phase,
238 AdapterPolicy::compIdx(compIdx));
239 }
240
241 using Base::viscosity;
245 template <class FluidState>
246 static Scalar viscosity(const FluidState &fluidState, int phaseIdx = 0)
247 {
248 assert(phaseIdx == 0);
249 return MultiPhaseFluidSystem::viscosity(adaptFluidState(fluidState), phase);
250 }
251
260 template <class FluidState>
261 static Scalar fugacityCoefficient(const FluidState &fluidState,
262 int phaseIdx,
263 int compIdx)
264 {
265 assert(phaseIdx == 0);
266 return MultiPhaseFluidSystem::fugacityCoefficient(adaptFluidState(fluidState), phase,
267 AdapterPolicy::compIdx(compIdx));
268 }
269
278 template <class FluidState>
279 static Scalar diffusionCoefficient(const FluidState &fluidState,
280 int phaseIdx,
281 int compIdx)
282 {
283 assert(phaseIdx == 0);
284 return MultiPhaseFluidSystem::diffusionCoefficient(adaptFluidState(fluidState), phase,
285 AdapterPolicy::compIdx(compIdx));
286 }
287
297 template <class FluidState>
298 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
299 int phaseIdx,
300 int compIIdx,
301 int compJIdx)
302 {
303 assert(phaseIdx == 0);
304 return MultiPhaseFluidSystem::binaryDiffusionCoefficient(adaptFluidState(fluidState), phase,
305 AdapterPolicy::compIdx(compIIdx),
306 AdapterPolicy::compIdx(compJIdx));
307 }
308
313 template <class FluidState>
314 static Scalar thermalConductivity(const FluidState &fluidState,
315 int phaseIdx = 0)
316 {
317 assert(phaseIdx == 0);
318 return MultiPhaseFluidSystem::thermalConductivity(adaptFluidState(fluidState), phase);
319 }
320
321 using Base::heatCapacity;
325 template <class FluidState>
326 static Scalar heatCapacity(const FluidState &fluidState,
327 int phaseIdx = 0)
328 {
329 assert(phaseIdx == 0);
330 return MultiPhaseFluidSystem::heatCapacity(adaptFluidState(fluidState), phase);
331 }
332};
333
334} // namespace FluidSystems
335} // namespace
336
337#endif
Adapter class for fluid states with different indices.
Definition: adapt.hh:29
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Adapter class for fluid states with different indices.
Definition: adapter.hh:44
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
Definition: 1padapter.hh:46
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int compIdx)
Returns the specific enthalpy of a component in a specific phase.
Definition: 1padapter.hh:232
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx=0)
Thermal conductivity of the fluid .
Definition: 1padapter.hh:314
static Scalar viscosity(const FluidState &fluidState, int phaseIdx=0)
The dynamic liquid viscosity of the pure component.
Definition: 1padapter.hh:246
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: 1padapter.hh:115
static void init(Args &&... args)
Initialize the fluid system's static parameters generically.
Definition: 1padapter.hh:104
static Scalar density(const FluidState &fluidState, int phaseIdx=0)
The density of the component at a given pressure and temperature.
Definition: 1padapter.hh:190
static constexpr int multiphaseFluidsystemPhaseIdx
the index of the phase we choose from the multi-phase fluid system
Definition: 1padapter.hh:86
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx=0)
The molar density of a fluid phase in .
Definition: 1padapter.hh:207
typename Base::Scalar Scalar
Definition: 1padapter.hh:80
static constexpr int numPhases
number of phases in the fluid system
Definition: 1padapter.hh:89
static constexpr int phase0Idx
number of components has to be the same as in the multi-phase fluid system as the composition needs t...
Definition: 1padapter.hh:94
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: 1padapter.hh:298
static constexpr int compIdx(int multiPhaseFluidSystemCompIdx)
convert a component index of the multi-phase component index to the actual component index
Definition: 1padapter.hh:97
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx=0)
Specific enthalpy the pure component as a liquid.
Definition: 1padapter.hh:218
MPFluidSystem MultiPhaseFluidSystem
export the wrapped MultiPhaseFluidSystem type
Definition: 1padapter.hh:84
static Scalar molarMass(int compIdx)
The mass in of one mole of the component.
Definition: 1padapter.hh:182
static std::string componentName(int compIdx)
A human readable name for the component.
Definition: 1padapter.hh:123
static std::string name()
A human readable name for the component.
Definition: 1padapter.hh:129
static constexpr bool viscosityIsConstant(int phaseIdx=0)
Returns true if the fluid viscosity is constant.
Definition: 1padapter.hh:170
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is gaseous.
Definition: 1padapter.hh:141
static constexpr bool isMiscible()
There is only one phase, so not mass transfer between phases can occur.
Definition: 1padapter.hh:135
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: 1padapter.hh:261
static constexpr bool isIdealMixture(int phaseIdx=0)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: 1padapter.hh:158
static constexpr bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: 1padapter.hh:176
static constexpr int numComponents
Definition: 1padapter.hh:92
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx=0)
Specific isobaric heat capacity of the fluid .
Definition: 1padapter.hh:326
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: 1padapter.hh:164
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: 1padapter.hh:279
Fluid system base class.
Definition: fluidsystems/base.hh:45
ScalarType Scalar
export the scalar type
Definition: fluidsystems/base.hh:48
static Scalar density(const FluidState &fluidState, int phaseIdx)
Calculate the density of a fluid phase.
Definition: fluidsystems/base.hh:134
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: fluidsystems/base.hh:390
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: fluidsystems/base.hh:197
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: fluidsystems/base.hh:278
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: fluidsystems/base.hh:326
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: fluidsystems/base.hh:363
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: fluidsystems/base.hh:160
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: fluidsystems/base.hh:236
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: fluidsystems/base.hh:424
The a parameter cache which does nothing.
Definition: nullparametercache.hh:34
Fluid system base class.