Loading...
Searching...
No Matches
SaturationOverlayFluidState.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_SATURATION_OVERLAY_FLUID_STATE_HPP
#define OPM_SATURATION_OVERLAY_FLUID_STATE_HPP
#include <opm/material/common/Valgrind.hpp>
#include <array>
#include <utility>
namespace Opm {
template <class FluidState>
class SaturationOverlayFluidState
{
public:
typedef typename FluidState::Scalar Scalar;
enum { numPhases = FluidState::numPhases };
enum { numComponents = FluidState::numComponents };
explicit SaturationOverlayFluidState(const FluidState& fs)
: fs_(&fs)
{
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
saturation_[phaseIdx] = fs.saturation(phaseIdx);
}
// copy constructor
SaturationOverlayFluidState(const SaturationOverlayFluidState& fs)
: fs_(fs.fs_)
, saturation_(fs.saturation_)
{}
// assignment operator
SaturationOverlayFluidState& operator=(const SaturationOverlayFluidState& fs)
{
fs_ = fs.fs_;
saturation_ = fs.saturation_;
return *this;
}
/*****************************************************
* Generic access to fluid properties (No assumptions
* on thermodynamic equilibrium required)
*****************************************************/
auto saturation(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().saturation(phaseIdx))
{ return saturation_[phaseIdx]; }
auto moleFraction(unsigned phaseIdx, unsigned compIdx) const
-> decltype(std::declval<FluidState>().moleFraction(phaseIdx, compIdx))
{ return fs_->moleFraction(phaseIdx, compIdx); }
auto massFraction(unsigned phaseIdx, unsigned compIdx) const
-> decltype(std::declval<FluidState>().massFraction(phaseIdx, compIdx))
{ return fs_->massFraction(phaseIdx, compIdx); }
auto averageMolarMass(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().averageMolarMass(phaseIdx))
{ return fs_->averageMolarMass(phaseIdx); }
auto molarity(unsigned phaseIdx, unsigned compIdx) const
-> decltype(std::declval<FluidState>().molarity(phaseIdx, compIdx))
{ return fs_->molarity(phaseIdx, compIdx); }
auto fugacity(unsigned phaseIdx, unsigned compIdx) const
-> decltype(std::declval<FluidState>().fugacity(phaseIdx, compIdx))
{ return fs_->fugacity(phaseIdx, compIdx); }
auto fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
-> decltype(std::declval<FluidState>().fugacityCoefficient(phaseIdx, compIdx))
{ return fs_->fugacityCoefficient(phaseIdx, compIdx); }
auto molarVolume(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().molarVolume(phaseIdx))
{ return fs_->molarVolume(phaseIdx); }
auto density(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().density(phaseIdx))
{ return fs_->density(phaseIdx); }
auto molarDensity(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().molarDensity(phaseIdx))
{ return fs_->molarDensity(phaseIdx); }
auto temperature(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().temperature(phaseIdx))
{ return fs_->temperature(phaseIdx); }
auto pressure(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().pressure(phaseIdx))
{ return fs_->pressure(phaseIdx); }
auto enthalpy(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().enthalpy(phaseIdx))
{ return fs_->enthalpy(phaseIdx); }
auto internalEnergy(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().internalEnergy(phaseIdx))
{ return fs_->internalEnergy(phaseIdx); }
auto viscosity(unsigned phaseIdx) const
-> decltype(std::declval<FluidState>().viscosity(phaseIdx))
{ return fs_->viscosity(phaseIdx); }
/*****************************************************
* Setter methods. Note that these are not part of the
* generic FluidState interface but specific for each
* implementation...
*****************************************************/
void setSaturation(unsigned phaseIdx, const Scalar& value)
{ saturation_[phaseIdx] = value; }
void checkDefined() const
{
Valgrind::CheckDefined(saturation_);
}
protected:
const FluidState* fs_;
std::array<Scalar, numPhases> saturation_;
};
} // namespace Opm
#endif
Valgrind.hpp
Some templates to wrap the valgrind client request macros.
Opm::Valgrind::CheckDefined
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
Opm::SaturationOverlayFluidState
This is a fluid state which allows to set the fluid saturations and takes all other quantities from a...
Definition SaturationOverlayFluidState.hpp:44
Opm::SaturationOverlayFluidState::setSaturation
void setSaturation(unsigned phaseIdx, const Scalar &value)
Set the saturation [-] of a fluid phase.
Definition SaturationOverlayFluidState.hpp:208
Opm::SaturationOverlayFluidState::moleFraction
auto moleFraction(unsigned phaseIdx, unsigned compIdx) const -> decltype(std::declval< FluidState >().moleFraction(phaseIdx, compIdx))
The mole fraction of a component in a phase [].
Definition SaturationOverlayFluidState.hpp:93
Opm::SaturationOverlayFluidState::internalEnergy
auto internalEnergy(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().internalEnergy(phaseIdx))
The specific internal energy of a fluid phase [J/kg].
Definition SaturationOverlayFluidState.hpp:188
Opm::SaturationOverlayFluidState::fugacityCoefficient
auto fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const -> decltype(std::declval< FluidState >().fugacityCoefficient(phaseIdx, compIdx))
The fugacity coefficient of a component in a phase [-].
Definition SaturationOverlayFluidState.hpp:139
Opm::SaturationOverlayFluidState::enthalpy
auto enthalpy(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().enthalpy(phaseIdx))
The specific enthalpy of a fluid phase [J/kg].
Definition SaturationOverlayFluidState.hpp:181
Opm::SaturationOverlayFluidState::saturation
auto saturation(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().saturation(phaseIdx))
Returns the saturation of a phase [].
Definition SaturationOverlayFluidState.hpp:86
Opm::SaturationOverlayFluidState::temperature
auto temperature(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().temperature(phaseIdx))
The temperature of a fluid phase [K].
Definition SaturationOverlayFluidState.hpp:167
Opm::SaturationOverlayFluidState::pressure
auto pressure(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().pressure(phaseIdx))
The pressure of a fluid phase [Pa].
Definition SaturationOverlayFluidState.hpp:174
Opm::SaturationOverlayFluidState::density
auto density(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().density(phaseIdx))
The mass density of a fluid phase [kg/m^3].
Definition SaturationOverlayFluidState.hpp:153
Opm::SaturationOverlayFluidState::checkDefined
void checkDefined() const
Make sure that all attributes are defined.
Definition SaturationOverlayFluidState.hpp:219
Opm::SaturationOverlayFluidState::averageMolarMass
auto averageMolarMass(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().averageMolarMass(phaseIdx))
The average molar mass of a fluid phase [kg/mol].
Definition SaturationOverlayFluidState.hpp:112
Opm::SaturationOverlayFluidState::molarVolume
auto molarVolume(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().molarVolume(phaseIdx))
The molar volume of a fluid phase [m^3/mol].
Definition SaturationOverlayFluidState.hpp:146
Opm::SaturationOverlayFluidState::viscosity
auto viscosity(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().viscosity(phaseIdx))
The dynamic viscosity of a fluid phase [Pa s].
Definition SaturationOverlayFluidState.hpp:195
Opm::SaturationOverlayFluidState::massFraction
auto massFraction(unsigned phaseIdx, unsigned compIdx) const -> decltype(std::declval< FluidState >().massFraction(phaseIdx, compIdx))
The mass fraction of a component in a phase [].
Definition SaturationOverlayFluidState.hpp:100
Opm::SaturationOverlayFluidState::fugacity
auto fugacity(unsigned phaseIdx, unsigned compIdx) const -> decltype(std::declval< FluidState >().fugacity(phaseIdx, compIdx))
The fugacity of a component in a phase [Pa].
Definition SaturationOverlayFluidState.hpp:132
Opm::SaturationOverlayFluidState::molarDensity
auto molarDensity(unsigned phaseIdx) const -> decltype(std::declval< FluidState >().molarDensity(phaseIdx))
The molar density of a fluid phase [mol/m^3].
Definition SaturationOverlayFluidState.hpp:160
Opm::SaturationOverlayFluidState::molarity
auto molarity(unsigned phaseIdx, unsigned compIdx) const -> decltype(std::declval< FluidState >().molarity(phaseIdx, compIdx))
The molar concentration of a component in a phase [mol/m^3].
Definition SaturationOverlayFluidState.hpp:125
Opm::SaturationOverlayFluidState::SaturationOverlayFluidState
SaturationOverlayFluidState(const FluidState &fs)
Constructor.
Definition SaturationOverlayFluidState.hpp:58
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30