PressureOverlayFluidState.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_PRESSURE_OVERLAY_FLUID_STATE_HPP
26 #define OPM_PRESSURE_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  PressureOverlayFluidState(const FluidState &fs)
56  : fs_(&fs)
57  {
58  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
59  pressure_[phaseIdx] = fs.pressure(phaseIdx);
60  }
61 
62  // copy constructor
64  : fs_(fs.fs_)
65  , pressure_(fs.pressure_)
66  {
67  }
68 
69  // assignment operator
71  {
72  fs_ = fs.fs_;
73  pressure_ = fs.pressure_;
74  return *this;
75  }
76 
77  /*****************************************************
78  * Generic access to fluid properties (No assumptions
79  * on thermodynamic equilibrium required)
80  *****************************************************/
84  Scalar saturation(unsigned phaseIdx) const
85  { return fs_->saturation(phaseIdx); }
86 
90  Scalar moleFraction(unsigned phaseIdx, unsigned compIdx) const
91  { return fs_->moleFraction(phaseIdx, compIdx); }
92 
96  Scalar massFraction(unsigned phaseIdx, unsigned compIdx) const
97  { return fs_->massFraction(phaseIdx, compIdx); }
98 
107  Scalar averageMolarMass(unsigned phaseIdx) const
108  { return fs_->averageMolarMass(phaseIdx); }
109 
119  Scalar molarity(unsigned phaseIdx, unsigned compIdx) const
120  { return fs_->molarity(phaseIdx, compIdx); }
121 
125  Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
126  { return fs_->fugacity(phaseIdx, compIdx); }
127 
131  Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
132  { return fs_->fugacityCoefficient(phaseIdx, compIdx); }
133 
137  Scalar molarVolume(unsigned phaseIdx) const
138  { return fs_->molarVolume(phaseIdx); }
139 
143  Scalar density(unsigned phaseIdx) const
144  { return fs_->density(phaseIdx); }
145 
149  Scalar molarDensity(unsigned phaseIdx) const
150  { return fs_->molarDensity(phaseIdx); }
151 
155  Scalar temperature(unsigned phaseIdx) const
156  { return fs_->temperature(phaseIdx); }
157 
161  Scalar pressure(unsigned phaseIdx) const
162  { return pressure_[phaseIdx]; }
163 
167  Scalar enthalpy(unsigned phaseIdx) const
168  { return fs_->enthalpy(phaseIdx); }
169 
173  Scalar internalEnergy(unsigned phaseIdx) const
174  { return fs_->internalEnergy(phaseIdx); }
175 
179  Scalar viscosity(unsigned phaseIdx) const
180  { return fs_->viscosity(phaseIdx); }
181 
182 
183  /*****************************************************
184  * Setter methods. Note that these are not part of the
185  * generic FluidState interface but specific for each
186  * implementation...
187  *****************************************************/
191  void setPressure(unsigned phaseIdx, Scalar value)
192  { pressure_[phaseIdx] = value; }
193 
202  void checkDefined() const
203  {
205  }
206 
207 protected:
208  const FluidState *fs_;
209  std::array<Scalar, numPhases> pressure_;
210 };
211 
212 } // namespace Opm
213 
214 #endif
Scalar massFraction(unsigned phaseIdx, unsigned compIdx) const
The mass fraction of a component in a phase [].
Definition: PressureOverlayFluidState.hpp:96
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition: PressureOverlayFluidState.hpp:125
Definition: PressureOverlayFluidState.hpp:46
This is a fluid state which allows to set the fluid pressures and takes all other quantities from an ...
Definition: PressureOverlayFluidState.hpp:40
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
PressureOverlayFluidState(const FluidState &fs)
Constructor.
Definition: PressureOverlayFluidState.hpp:55
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: PressureOverlayFluidState.hpp:119
Definition: PressureOverlayFluidState.hpp:45
Scalar saturation(unsigned phaseIdx) const
Returns the saturation of a phase [].
Definition: PressureOverlayFluidState.hpp:84
Some templates to wrap the valgrind client request macros.
Scalar averageMolarMass(unsigned phaseIdx) const
The average molar mass of a fluid phase [kg/mol].
Definition: PressureOverlayFluidState.hpp:107
Scalar molarVolume(unsigned phaseIdx) const
The molar volume of a fluid phase [m^3/mol].
Definition: PressureOverlayFluidState.hpp:137
Scalar pressure(unsigned phaseIdx) const
The pressure of a fluid phase [Pa].
Definition: PressureOverlayFluidState.hpp:161
const FluidState * fs_
Definition: PressureOverlayFluidState.hpp:208
std::array< Scalar, numPhases > pressure_
Definition: PressureOverlayFluidState.hpp:209
void checkDefined() const
Make sure that all attributes are defined.
Definition: PressureOverlayFluidState.hpp:202
FluidState::Scalar Scalar
Definition: PressureOverlayFluidState.hpp:43
Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [-].
Definition: PressureOverlayFluidState.hpp:131
void setPressure(unsigned phaseIdx, Scalar value)
Set the pressure [Pa] of a fluid phase.
Definition: PressureOverlayFluidState.hpp:191
Scalar density(unsigned phaseIdx) const
The mass density of a fluid phase [kg/m^3].
Definition: PressureOverlayFluidState.hpp:143
Scalar molarDensity(unsigned phaseIdx) const
The molar density of a fluid phase [mol/m^3].
Definition: PressureOverlayFluidState.hpp:149
Scalar enthalpy(unsigned phaseIdx) const
The specific enthalpy of a fluid phase [J/kg].
Definition: PressureOverlayFluidState.hpp:167
Scalar temperature(unsigned phaseIdx) const
The temperature of a fluid phase [K].
Definition: PressureOverlayFluidState.hpp:155
PressureOverlayFluidState(const PressureOverlayFluidState &fs)
Definition: PressureOverlayFluidState.hpp:63
Scalar viscosity(unsigned phaseIdx) const
The dynamic viscosity of a fluid phase [Pa s].
Definition: PressureOverlayFluidState.hpp:179
PressureOverlayFluidState & operator=(const PressureOverlayFluidState &fs)
Definition: PressureOverlayFluidState.hpp:70
Scalar internalEnergy(unsigned phaseIdx) const
The specific internal energy of a fluid phase [J/kg].
Definition: PressureOverlayFluidState.hpp:173
Scalar moleFraction(unsigned phaseIdx, unsigned compIdx) const
The mole fraction of a component in a phase [].
Definition: PressureOverlayFluidState.hpp:90