From 9a9e268391f76f7959d19cea5f34456514d03b2a Mon Sep 17 00:00:00 2001 From: Markus Wolff <markus.wolff@twt-gmbh.de> Date: Fri, 23 Dec 2011 10:40:21 +0000 Subject: [PATCH] added new fluid state for isothermal incompressible models - used from decoupled models git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7251 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- .../fluidstates/isoimmisciblefluidstate.hh | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 dumux/material/fluidstates/isoimmisciblefluidstate.hh diff --git a/dumux/material/fluidstates/isoimmisciblefluidstate.hh b/dumux/material/fluidstates/isoimmisciblefluidstate.hh new file mode 100644 index 0000000000..0f6327f2d2 --- /dev/null +++ b/dumux/material/fluidstates/isoimmisciblefluidstate.hh @@ -0,0 +1,179 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * Copyright (C) 2011 by Markus Wolff * + * Institute of Hydraulic Engineering * + * University of Stuttgart, Germany * + * email: <givenname>.<name>@iws.uni-stuttgart.de * + * * + * This program 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. * + * * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * + * \brief Represents all relevant thermodynamic quantities of a isothermal immiscible + * multi-phase fluid system + */ +#ifndef DUMUX_ISOIMMISCIBLE_FLUID_STATE_HH +#define DUMUX_ISOIMMISCIBLE_FLUID_STATE_HH + +#include <dumux/common/valgrind.hh> + +#include <limits> + +namespace Dumux +{ +/*! + * \brief Represents all relevant thermodynamic quantities of a + * multi-phase fluid system assuming immiscibility and + * thermodynamic equilibrium. + */ +template <class Scalar, class FluidSystem> +class IsothermalImmiscibleFluidState +{ +public: + static constexpr int numPhases = FluidSystem::numPhases; + + IsothermalImmiscibleFluidState() + { Valgrind::SetUndefined(*this); } + + template <class FluidState> + IsothermalImmiscibleFluidState(FluidState &fs) + { assign(fs); } + + /***************************************************** + * Generic access to fluid properties + *****************************************************/ + /*! + * \brief Returns the saturation of a phase [] + */ + Scalar saturation(int phaseIdx) const + { return saturation_[phaseIdx]; } + + /*! + * \brief The mass density of a fluid phase [kg/m^3] + */ + Scalar density(int phaseIdx) const + { return density_[phaseIdx]; } + + /*! + * \brief The pressure of a fluid phase [Pa] + */ + Scalar pressure(int phaseIdx) const + { return pressure_[phaseIdx]; } + + /*! + * \brief The dynamic viscosity of a fluid phase [Pa s] + */ + Scalar viscosity(int phaseIdx) const + { return viscosity_[phaseIdx]; } + + /*! + * \brief The temperature of a fluid phase [K] + */ + Scalar temperature(int phaseIdx) const + { return temperature_; } + + /*! + * \brief The temperature within the domain [K] + */ + Scalar temperature() const + { return temperature_; } + + + /***************************************************** + * Setter methods. Note that these are not part of the + * generic FluidState interface but specific for each + * implementation... + *****************************************************/ + + /*! + * \brief Retrieve all parameters from an arbitrary fluid + * state. + */ + template <class FluidState> + void assign(const FluidState &fs) + { + for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { + pressure_[phaseIdx] = fs.pressure(phaseIdx); + saturation_[phaseIdx] = fs.saturation(phaseIdx); + density_[phaseIdx] = fs.density(phaseIdx); + viscosity_[phaseIdx] = fs.viscosity(phaseIdx); + } + temperature_ = fs.temperature(0); + }; + + /*! + * \brief Set the temperature [K] of a fluid phase + */ + void setTemperature(Scalar value) + { temperature_ = value; } + + /*! + * \brief Set the fluid pressure of a phase [Pa] + */ + void setPressure(int phaseIdx, Scalar value) + { pressure_[phaseIdx] = value; } + + /*! + * \brief Set the saturation of a phase [] + */ + void setSaturation(int phaseIdx, Scalar value) + { saturation_[phaseIdx] = value; } + + /*! + * \brief Set the density of a phase [kg / m^3] + */ + void setDensity(int phaseIdx, Scalar value) + { density_[phaseIdx] = value; } + + /*! + * \brief Set the dynamic viscosity of a phase [Pa s] + */ + void setViscosity(int phaseIdx, Scalar value) + { viscosity_[phaseIdx] = value; } + + /*! + * \brief Make sure that all attributes are defined. + * + * This method does not do anything if the program is not run + * under valgrind. If it is, then valgrind will print an error + * message if some attributes of the object have not been properly + * defined. + */ + void checkDefined() const + { +#if HAVE_VALGRIND && ! defined NDEBUG + for (int i = 0; i < numPhases; ++i) { + Valgrind::CheckDefined(pressure_[i]); + Valgrind::CheckDefined(saturation_[i]); + Valgrind::CheckDefined(density_[i]); + Valgrind::CheckDefined(viscosity_[i]); + } + + Valgrind::CheckDefined(temperature_); +#endif // HAVE_VALGRIND + } + +protected: + Scalar pressure_[numPhases]; + Scalar saturation_[numPhases]; + Scalar density_[numPhases]; + Scalar viscosity_[numPhases]; + Scalar temperature_; +}; + +} // end namepace Dumux + +#endif -- GitLab