Loading...
Searching...
No Matches
richardsmodel.hh
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 EWOMS_RICHARDS_MODEL_HH
#define EWOMS_RICHARDS_MODEL_HH
#include <opm/material/components/NullComponent.hpp>
#include <opm/material/densead/Math.hpp>
#include <opm/material/fluidsystems/LiquidPhase.hpp>
#include <opm/material/fluidsystems/GasPhase.hpp>
#include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
#include <opm/models/common/multiphasebasemodel.hh>
#include <opm/models/richards/richardsproperties.hh>
#include <opm/models/richards/richardsindices.hh>
#include <opm/models/richards/richardslocalresidual.hh>
#include <opm/models/richards/richardsextensivequantities.hh>
#include <opm/models/richards/richardsratevector.hh>
#include <opm/models/richards/richardsboundaryratevector.hh>
#include <opm/models/richards/richardsprimaryvariables.hh>
#include <opm/models/richards/richardsintensivequantities.hh>
#include <opm/models/richards/richardsnewtonmethod.hh>
#include <cassert>
#include <sstream>
#include <string>
#include <tuple>
namespace Opm {
template <class TypeTag>
class RichardsModel;
}
namespace Opm::Properties {
// Create new type tags
namespace TTag {
struct Richards { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
} // end namespace TTag
template<class TypeTag>
struct LiquidPhaseIndex<TypeTag, TTag::Richards>
{ static constexpr int value = 0; };
template<class TypeTag>
struct GasPhaseIndex<TypeTag, TTag::Richards>
{ static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
template<class TypeTag>
struct LiquidComponentIndex<TypeTag, TTag::Richards>
{ static constexpr int value = getPropValue<TypeTag, Properties::LiquidPhaseIndex>(); };
template<class TypeTag>
struct GasComponentIndex<TypeTag, TTag::Richards>
{ static constexpr int value = 1 - getPropValue<TypeTag, Properties::LiquidComponentIndex>(); };
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::Richards>
{ using type = RichardsLocalResidual<TypeTag>; };
template<class TypeTag>
struct Model<TypeTag, TTag::Richards>
{ using type = RichardsModel<TypeTag>; };
template<class TypeTag>
struct RateVector<TypeTag, TTag::Richards>
{ using type = RichardsRateVector<TypeTag>; };
template<class TypeTag>
struct BoundaryRateVector<TypeTag, TTag::Richards>
{ using type = RichardsBoundaryRateVector<TypeTag>; };
template<class TypeTag>
struct PrimaryVariables<TypeTag, TTag::Richards>
{ using type = RichardsPrimaryVariables<TypeTag>; };
template<class TypeTag>
struct IntensiveQuantities<TypeTag, TTag::Richards>
{ using type = RichardsIntensiveQuantities<TypeTag>; };
template<class TypeTag>
struct ExtensiveQuantities<TypeTag, TTag::Richards>
{ using type = RichardsExtensiveQuantities<TypeTag>; };
template<class TypeTag>
struct NewtonMethod<TypeTag, TTag::Richards>
{ using type = RichardsNewtonMethod<TypeTag>; };
template<class TypeTag>
struct Indices<TypeTag, TTag::Richards>
{ using type = RichardsIndices; };
template<class TypeTag>
struct WettingFluid<TypeTag, TTag::Richards>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = LiquidPhase<Scalar, NullComponent<Scalar>>;
};
template<class TypeTag>
struct NonWettingFluid<TypeTag, TTag::Richards>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = GasPhase<Scalar, NullComponent<Scalar>>;
};
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::Richards>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using WettingFluid = GetPropType<TypeTag, Properties::WettingFluid>;
using NonWettingFluid = GetPropType<TypeTag, Properties::NonWettingFluid>;
public:
using type = TwoPhaseImmiscibleFluidSystem<Scalar, WettingFluid, NonWettingFluid>;
};
} // namespace Opm::Properties
namespace Opm {
template <class TypeTag>
class RichardsModel
: public MultiPhaseBaseModel<TypeTag>
{
using ParentType = MultiPhaseBaseModel<TypeTag>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
static const unsigned numPhases = FluidSystem::numPhases;
static const unsigned numComponents = FluidSystem::numComponents;
static const unsigned liquidPhaseIdx = getPropValue<TypeTag, Properties::LiquidPhaseIndex>();
static const unsigned gasPhaseIdx = getPropValue<TypeTag, Properties::GasPhaseIndex>();
static const unsigned liquidCompIdx = getPropValue<TypeTag, Properties::LiquidComponentIndex>();
static const unsigned gasCompIdx = getPropValue<TypeTag, Properties::GasComponentIndex>();
// some consistency checks
static_assert(numPhases == 2,
"Exactly two fluids are required for this model");
static_assert(numComponents == 2,
"Exactly two components are required for this model");
static_assert(liquidPhaseIdx != gasPhaseIdx,
"The liquid and the gas phases must be different");
static_assert(liquidCompIdx != gasCompIdx,
"The liquid and the gas components must be different");
public:
explicit RichardsModel(Simulator& simulator)
: ParentType(simulator)
{
// the liquid phase must be liquid, the gas phase must be
// gaseous. Think about it!
assert(FluidSystem::isLiquid(liquidPhaseIdx));
assert(!FluidSystem::isLiquid(gasPhaseIdx));
}
static void registerParameters()
{
ParentType::registerParameters();
}
static std::string name()
{ return "richards"; }
std::string primaryVarName(unsigned pvIdx) const
{
std::ostringstream oss;
if (pvIdx == Indices::pressureWIdx) {
oss << "pressure_" << FluidSystem::phaseName(liquidPhaseIdx);
}
else {
assert(0);
}
return oss.str();
}
std::string eqName(unsigned eqIdx) const
{
std::ostringstream oss;
if (eqIdx == Indices::contiEqIdx) {
oss << "continuity_" << FluidSystem::phaseName(liquidPhaseIdx);
}
else {
assert(0);
}
return oss.str();
}
Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
{
if (Indices::pressureWIdx == pvIdx) {
return 10 / referencePressure_;
}
return 1;
}
Scalar eqWeight(unsigned, [[maybe_unused]] unsigned eqIdx) const
{
assert((eqIdx - Indices::contiEqIdx) <= FluidSystem::numPhases);
// make all kg equal
return 1.0;
}
void updateBegin()
{
ParentType::updateBegin();
// find the a reference pressure. The first degree of freedom
// might correspond to non-interior entities which would lead
// to an undefined value, so we have to iterate...
for (unsigned dofIdx = 0; dofIdx < this->numGridDof(); ++ dofIdx) {
if (this->isLocalDof(dofIdx)) {
referencePressure_ =
this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressureWIdx];
break;
}
}
}
bool phaseIsConsidered(unsigned phaseIdx) const
{ return phaseIdx == liquidPhaseIdx; }
void registerOutputModules_()
{ ParentType::registerOutputModules_(); }
Scalar referencePressure_{};
};
} // namespace Opm
#endif
Opm::MultiPhaseBaseModel::registerParameters
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition multiphasebasemodel.hh:190
Opm::RichardsBoundaryRateVector
Implements a boundary vector for the fully implicit Richards model.
Definition richardsboundaryratevector.hh:49
Opm::RichardsIntensiveQuantities
Intensive quantities required by the Richards model.
Definition richardsintensivequantities.hh:54
Opm::RichardsLocalResidual
Element-wise calculation of the residual for the Richards model.
Definition richardslocalresidual.hh:47
Opm::RichardsModel
This model implements a variant of the Richards equation for quasi-twophase flow.
Definition richardsmodel.hh:267
Opm::RichardsModel::updateBegin
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition richardsmodel.hh:377
Opm::RichardsModel::phaseIsConsidered
bool phaseIsConsidered(unsigned phaseIdx) const
Definition richardsmodel.hh:396
Opm::RichardsModel::eqWeight
Scalar eqWeight(unsigned, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition richardsmodel.hh:366
Opm::RichardsModel::eqName
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition richardsmodel.hh:338
Opm::RichardsModel::primaryVarName
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition richardsmodel.hh:322
Opm::RichardsModel::registerParameters
static void registerParameters()
Register all run-time parameters for the model.
Definition richardsmodel.hh:308
Opm::RichardsModel::name
static std::string name()
Definition richardsmodel.hh:316
Opm::RichardsModel::primaryVarWeight
Scalar primaryVarWeight(unsigned, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition richardsmodel.hh:354
Opm::RichardsNewtonMethod
A Richards model specific Newton method.
Definition richardsnewtonmethod.hh:50
Opm::RichardsPrimaryVariables
Represents the primary variables used in the Richards model.
Definition richardsprimaryvariables.hh:53
Opm::RichardsRateVector
Implements a vector representing mass, molar or volumetric rates.
Definition richardsratevector.hh:54
multiphasebasemodel.hh
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Opm::Properties::TTag
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Opm::GetPropType
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
Opm::getPropValue
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
Opm::RichardsExtensiveQuantities
MultiPhaseBaseExtensiveQuantities< TypeTag > RichardsExtensiveQuantities
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
Definition richardsextensivequantities.hh:43
richardsboundaryratevector.hh
Implements a boundary vector for the fully implicit Richards model.
richardsextensivequantities.hh
Calculates and stores the data which is required to calculate the flux of fluid over a face of a fini...
richardsindices.hh
Indices for the primary variables/conservation equations of the Richards model.
richardsintensivequantities.hh
Intensive quantities required by the Richards model.
richardslocalresidual.hh
Element-wise calculation of the residual for the Richards model.
richardsnewtonmethod.hh
A Richards model specific Newton method.
richardsprimaryvariables.hh
Represents the primary variables used in the Richards model.
richardsproperties.hh
Contains the property declarations for the Richards model.
richardsratevector.hh
Implements a vector representing mass, molar or volumetric rates.
Opm::Properties::BoundaryRateVector
Type of object for specifying boundary conditions.
Definition fvbaseproperties.hh:119
Opm::Properties::ExtensiveQuantities
Data required to calculate a flux over a face.
Definition fvbaseproperties.hh:149
Opm::Properties::FluidSystem
The fluid systems including the information about the phases.
Definition multiphasebaseproperties.hh:79
Opm::Properties::GasComponentIndex
Index of the component which constitutes the gas.
Definition richardsproperties.hh:61
Opm::Properties::GasPhaseIndex
Index of the fluid which represents the non-wetting phase.
Definition richardsproperties.hh:53
Opm::Properties::Indices
Enumerations used by the model.
Definition multiphasebaseproperties.hh:51
Opm::Properties::IntensiveQuantities
The secondary variables within a sub-control volume.
Definition fvbaseproperties.hh:133
Opm::Properties::LiquidComponentIndex
Index of the component which constitutes the liquid.
Definition richardsproperties.hh:57
Opm::Properties::LiquidPhaseIndex
Index of the fluid which represents the wetting phase.
Definition richardsproperties.hh:49
Opm::Properties::LocalResidual
The type of the local residual function.
Definition fvbaseproperties.hh:94
Opm::Properties::Model
The type of the model.
Definition basicproperties.hh:88
Opm::Properties::NewtonMethod
Specifies the type of the actual Newton method.
Definition newtonmethodproperties.hh:32
Opm::Properties::NonWettingFluid
The fluid used as the non-wetting phase (by default, we set the fluid system to the immiscible one,...
Definition richardsproperties.hh:45
Opm::Properties::PrimaryVariables
A vector of primary variables within a sub-control volume.
Definition fvbaseproperties.hh:130
Opm::Properties::RateVector
Vector containing volumetric or areal rates of quantities.
Definition fvbaseproperties.hh:116
Opm::Properties::TTag::Richards
The type tag for problems discretized using the Richards model.
Definition richardsmodel.hh:66
Opm::Properties::WettingFluid
The fluid used as the wetting phase (by default, we set the fluid system to the immiscible one,...
Definition richardsproperties.hh:40
Opm::RichardsIndices
Indices for the primary variables/conservation equations of the Richards model.
Definition richardsindices.hh:39