SaturationOverlayFluidState.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  Copyright (C) 2011-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef OPM_SATURATION_OVERLAY_FLUID_STATE_HPP
26 #define OPM_SATURATION_OVERLAY_FLUID_STATE_HPP
27 
29 
30 #include <array>
31 
32 namespace Opm {
33 
39 template <class FluidState>
41 {
42 public:
43  typedef typename FluidState::Scalar Scalar;
44 
45  enum { numPhases = FluidState::numPhases };
46  enum { numComponents = FluidState::numComponents };
47 
55  SaturationOverlayFluidState(const FluidState &fs)
56  : fs_(&fs)
57  {
58  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
59  saturation_[phaseIdx] = fs.saturation(phaseIdx);
60  }
61 
62  // copy constructor
64  : fs_(fs.fs_)
66  {}
67 
68  // assignment operator
70  {
71  fs_ = fs.fs_;
73  return *this;
74  }
75 
76  /*****************************************************
77  * Generic access to fluid properties (No assumptions
78  * on thermodynamic equilibrium required)
79  *****************************************************/
83  Scalar saturation(unsigned phaseIdx) const
84  { return saturation_[phaseIdx]; }
85 
89  Scalar moleFraction(unsigned phaseIdx, unsigned compIdx) const
90  { return fs_->moleFraction(phaseIdx, compIdx); }
91 
95  Scalar massFraction(unsigned phaseIdx, unsigned compIdx) const
96  { return fs_->massFraction(phaseIdx, compIdx); }
97 
106  Scalar averageMolarMass(unsigned phaseIdx) const
107  { return fs_->averageMolarMass(phaseIdx); }
108 
118  Scalar molarity(unsigned phaseIdx, unsigned compIdx) const
119  { return fs_->molarity(phaseIdx, compIdx); }
120 
124  Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
125  { return fs_->fugacity(phaseIdx, compIdx); }
126 
130  Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
131  { return fs_->fugacityCoefficient(phaseIdx, compIdx); }
132 
136  Scalar molarVolume(unsigned phaseIdx) const
137  { return fs_->molarVolume(phaseIdx); }
138 
142  Scalar density(unsigned phaseIdx) const
143  { return fs_->density(phaseIdx); }
144 
148  Scalar molarDensity(unsigned phaseIdx) const
149  { return fs_->molarDensity(phaseIdx); }
150 
154  Scalar temperature(unsigned phaseIdx) const
155  { return fs_->temperature(phaseIdx); }
156 
160  Scalar pressure(unsigned phaseIdx) const
161  { return fs_->pressure(phaseIdx); }
162 
166  Scalar enthalpy(unsigned phaseIdx) const
167  { return fs_->enthalpy(phaseIdx); }
168 
172  Scalar internalEnergy(unsigned phaseIdx) const
173  { return fs_->internalEnergy(phaseIdx); }
174 
178  Scalar viscosity(unsigned phaseIdx) const
179  { return fs_->viscosity(phaseIdx); }
180 
181 
182  /*****************************************************
183  * Setter methods. Note that these are not part of the
184  * generic FluidState interface but specific for each
185  * implementation...
186  *****************************************************/
190  void setSaturation(unsigned phaseIdx, Scalar value)
191  { saturation_[phaseIdx] = value; }
192 
201  void checkDefined() const
202  {
204  }
205 
206 protected:
207  const FluidState *fs_;
208  std::array<Scalar, numPhases> saturation_;
209 };
210 
211 } // namespace Opm
212 
213 #endif
Scalar massFraction(unsigned phaseIdx, unsigned compIdx) const
The mass fraction of a component in a phase [].
Definition: SaturationOverlayFluidState.hpp:95
Scalar molarVolume(unsigned phaseIdx) const
The molar volume of a fluid phase [m^3/mol].
Definition: SaturationOverlayFluidState.hpp:136
bool CheckDefined(const T &value OPM_UNUSED)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
Definition: Air_Mesitylene.hpp:31
Scalar molarity(unsigned phaseIdx, unsigned compIdx) const
The molar concentration of a component in a phase [mol/m^3].
Definition: SaturationOverlayFluidState.hpp:118
Scalar internalEnergy(unsigned phaseIdx) const
The specific internal energy of a fluid phase [J/kg].
Definition: SaturationOverlayFluidState.hpp:172
void setSaturation(unsigned phaseIdx, Scalar value)
Set the saturation [-] of a fluid phase.
Definition: SaturationOverlayFluidState.hpp:190
Some templates to wrap the valgrind client request macros.
Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [-].
Definition: SaturationOverlayFluidState.hpp:130
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition: SaturationOverlayFluidState.hpp:124
FluidState::Scalar Scalar
Definition: SaturationOverlayFluidState.hpp:43
Scalar temperature(unsigned phaseIdx) const
The temperature of a fluid phase [K].
Definition: SaturationOverlayFluidState.hpp:154
SaturationOverlayFluidState & operator=(const SaturationOverlayFluidState &fs)
Definition: SaturationOverlayFluidState.hpp:69
void checkDefined() const
Make sure that all attributes are defined.
Definition: SaturationOverlayFluidState.hpp:201
Scalar saturation(unsigned phaseIdx) const
Returns the saturation of a phase [].
Definition: SaturationOverlayFluidState.hpp:83
Scalar density(unsigned phaseIdx) const
The mass density of a fluid phase [kg/m^3].
Definition: SaturationOverlayFluidState.hpp:142
Scalar enthalpy(unsigned phaseIdx) const
The specific enthalpy of a fluid phase [J/kg].
Definition: SaturationOverlayFluidState.hpp:166
const FluidState * fs_
Definition: SaturationOverlayFluidState.hpp:207
Scalar moleFraction(unsigned phaseIdx, unsigned compIdx) const
The mole fraction of a component in a phase [].
Definition: SaturationOverlayFluidState.hpp:89
Scalar viscosity(unsigned phaseIdx) const
The dynamic viscosity of a fluid phase [Pa s].
Definition: SaturationOverlayFluidState.hpp:178
Scalar averageMolarMass(unsigned phaseIdx) const
The average molar mass of a fluid phase [kg/mol].
Definition: SaturationOverlayFluidState.hpp:106
SaturationOverlayFluidState(const SaturationOverlayFluidState &fs)
Definition: SaturationOverlayFluidState.hpp:63
This is a fluid state which allows to set the fluid saturations and takes all other quantities from a...
Definition: SaturationOverlayFluidState.hpp:40
Definition: SaturationOverlayFluidState.hpp:46
Scalar molarDensity(unsigned phaseIdx) const
The molar density of a fluid phase [mol/m^3].
Definition: SaturationOverlayFluidState.hpp:148
Scalar pressure(unsigned phaseIdx) const
The pressure of a fluid phase [Pa].
Definition: SaturationOverlayFluidState.hpp:160
std::array< Scalar, numPhases > saturation_
Definition: SaturationOverlayFluidState.hpp:208
SaturationOverlayFluidState(const FluidState &fs)
Constructor.
Definition: SaturationOverlayFluidState.hpp:55
Definition: SaturationOverlayFluidState.hpp:45