Loading...
Searching...
No Matches
BaseFluidSystem.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_BASE_FLUID_SYSTEM_HPP
#define OPM_BASE_FLUID_SYSTEM_HPP
#include <opm/common/utility/DemangledType.hpp>
#include <stdexcept>
#include <string_view>
namespace Opm {
template <class ScalarT, class Implementation>
class BaseFluidSystem
{
public:
typedef ScalarT Scalar;
template <class Evaluation>
struct ParameterCache {
ParameterCache() = delete; // derived fluid systems must specify this class!
};
static const int numComponents = -1000;
static const int numPhases = -2000;
static std::string_view phaseName(unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("phaseName"));
}
static bool isLiquid(unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("isLiquid"));
}
static bool isIdealMixture(unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("isIdealMixture"));
}
static bool isCompressible(unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("isCompressible"));
}
static bool isIdealGas(unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("isIdealGas"));
}
static std::string_view componentName(unsigned /*compIdx*/)
{
throw std::runtime_error(not_implemented("componentName"));
}
static Scalar molarMass(unsigned /*compIdx*/)
{
throw std::runtime_error(not_implemented("molarMass"));
}
static Scalar acentricFactor(unsigned /*compIdx*/)
{
throw std::runtime_error(not_implemented("acentricFactor"));
}
static void init()
{ }
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval density(const FluidState& /*fluidState*/,
const ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("density"));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval fugacityCoefficient(const FluidState& /*fluidState*/,
ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/,
unsigned /*compIdx*/)
{
throw std::runtime_error(not_implemented("fugacityCoefficient"));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval viscosity(const FluidState& /*fluidState*/,
ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("viscosity"));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval diffusionCoefficient(const FluidState& /*fluidState*/,
ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/,
unsigned /*compIdx*/)
{
throw std::runtime_error(not_implemented("diffusionCoefficient"));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval enthalpy(const FluidState& /*fluidState*/,
ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("enthalpy"));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval thermalConductivity(const FluidState& /*fluidState*/,
ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("thermalConductivity"));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
static LhsEval heatCapacity(const FluidState& /*fluidState*/,
ParamCache& /*paramCache*/,
unsigned /*phaseIdx*/)
{
throw std::runtime_error(not_implemented("heatCapacity"));
}
static bool phaseIsActive(unsigned /*phaseIdx*/)
{
return true;
}
private:
static std::string not_implemented(const std::string_view method)
{
return "Not implemented: The fluid system '" +
getDemangledType<Implementation>() +
"' does not provide a " + method.data() + "() method!";
}
};
} // namespace Opm
#endif
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem::phaseIsActive
static bool phaseIsActive(unsigned)
Returns whether a fluid phase is active.
Definition BaseFluidSystem.hpp:290
Opm::BaseFluidSystem::heatCapacity
static LhsEval heatCapacity(const FluidState &, ParamCache &, unsigned)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition BaseFluidSystem.hpp:281
Opm::BaseFluidSystem::phaseName
static std::string_view phaseName(unsigned)
Return the human readable name of a fluid phase.
Definition BaseFluidSystem.hpp:73
Opm::BaseFluidSystem::enthalpy
static LhsEval enthalpy(const FluidState &, ParamCache &, unsigned)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition BaseFluidSystem.hpp:253
Opm::BaseFluidSystem::numPhases
static const int numPhases
Number of fluid phases in the fluid system.
Definition BaseFluidSystem.hpp:66
Opm::BaseFluidSystem::isIdealGas
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition BaseFluidSystem.hpp:127
Opm::BaseFluidSystem::isCompressible
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition BaseFluidSystem.hpp:116
Opm::BaseFluidSystem::molarMass
static Scalar molarMass(unsigned)
Return the molar mass of a component in [kg/mol].
Definition BaseFluidSystem.hpp:147
Opm::BaseFluidSystem::isIdealMixture
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition BaseFluidSystem.hpp:102
Opm::BaseFluidSystem::diffusionCoefficient
static LhsEval diffusionCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition BaseFluidSystem.hpp:237
Opm::BaseFluidSystem::isLiquid
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition BaseFluidSystem.hpp:83
Opm::BaseFluidSystem::init
static void init()
Initialize the fluid system's static parameters.
Definition BaseFluidSystem.hpp:165
Opm::BaseFluidSystem::Scalar
ScalarT Scalar
The type used for scalar quantities.
Definition BaseFluidSystem.hpp:48
Opm::BaseFluidSystem::numComponents
static const int numComponents
Number of chemical species in the fluid system.
Definition BaseFluidSystem.hpp:63
Opm::BaseFluidSystem::density
static LhsEval density(const FluidState &, const ParamCache &, unsigned)
Calculate the density [kg/m^3] of a fluid phase.
Definition BaseFluidSystem.hpp:175
Opm::BaseFluidSystem::acentricFactor
static Scalar acentricFactor(unsigned)
Return the acetntric factor of a component.
Definition BaseFluidSystem.hpp:157
Opm::BaseFluidSystem::fugacityCoefficient
static LhsEval fugacityCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition BaseFluidSystem.hpp:197
Opm::BaseFluidSystem::viscosity
static LhsEval viscosity(const FluidState &, ParamCache &, unsigned)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition BaseFluidSystem.hpp:212
Opm::BaseFluidSystem::componentName
static std::string_view componentName(unsigned)
Return the human readable name of a component.
Definition BaseFluidSystem.hpp:137
Opm::BaseFluidSystem::thermalConductivity
static LhsEval thermalConductivity(const FluidState &, ParamCache &, unsigned)
Thermal conductivity of a fluid phase [W/(m K)].
Definition BaseFluidSystem.hpp:267
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::BaseFluidSystem::ParameterCache
The type of the fluid system's parameter cache.
Definition BaseFluidSystem.hpp:58