Loading...
Searching...
No Matches
immisciblemodel.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_IMMISCIBLE_MODEL_HH
#define EWOMS_IMMISCIBLE_MODEL_HH
#include <opm/material/densead/Math.hpp>
#include "immiscibleproperties.hh"
#include "immiscibleindices.hh"
#include "immiscibleextensivequantities.hh"
#include "immiscibleprimaryvariables.hh"
#include "immiscibleintensivequantities.hh"
#include "immiscibleratevector.hh"
#include "immiscibleboundaryratevector.hh"
#include "immisciblelocalresidual.hh"
#include <opm/models/common/multiphasebasemodel.hh>
#include <opm/models/common/energymodule.hh>
#include <opm/models/io/vtkenergymodule.hpp>
#include <opm/material/components/NullComponent.hpp>
#include <opm/material/fluidsystems/GasPhase.hpp>
#include <opm/material/fluidsystems/LiquidPhase.hpp>
#include <opm/material/fluidsystems/SinglePhaseFluidSystem.hpp>
#include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
#include <sstream>
#include <string>
namespace Opm {
template <class TypeTag>
class ImmiscibleModel;
}
namespace Opm::Properties {
// Create new type tags
namespace TTag {
struct ImmiscibleModel { using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
struct ImmiscibleSinglePhaseModel { using InheritsFrom = std::tuple<ImmiscibleModel>; };
struct ImmiscibleTwoPhaseModel { using InheritsFrom = std::tuple<ImmiscibleModel>; };
} // end namespace TTag
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleLocalResidual<TypeTag>; };
template<class TypeTag>
struct Model<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleModel<TypeTag>; };
template<class TypeTag>
struct RateVector<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleRateVector<TypeTag>; };
template<class TypeTag>
struct BoundaryRateVector<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleBoundaryRateVector<TypeTag>; };
template<class TypeTag>
struct PrimaryVariables<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmisciblePrimaryVariables<TypeTag>; };
template<class TypeTag>
struct IntensiveQuantities<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleIntensiveQuantities<TypeTag>; };
template<class TypeTag>
struct ExtensiveQuantities<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleExtensiveQuantities<TypeTag>; };
template<class TypeTag>
struct Indices<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleIndices<TypeTag, /*PVOffset=*/0>; };
template<class TypeTag>
struct EnableEnergy<TypeTag, TTag::ImmiscibleModel> { static constexpr bool value = false; };
// set slightly different properties for the single-phase case
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ImmiscibleSinglePhaseModel>
{ private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Fluid = GetPropType<TypeTag, Properties::Fluid>;
public:
using type = Opm::SinglePhaseFluidSystem<Scalar , Fluid>;
};
template<class TypeTag>
struct Fluid<TypeTag, TTag::ImmiscibleSinglePhaseModel>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
};
// set slightly different properties for the two-phase case
template<class TypeTag>
struct WettingPhase<TypeTag, TTag::ImmiscibleTwoPhaseModel>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
};
template<class TypeTag>
struct NonwettingPhase<TypeTag, TTag::ImmiscibleTwoPhaseModel>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
};
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ImmiscibleTwoPhaseModel>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using WettingPhase = GetPropType<TypeTag, Properties::WettingPhase>;
using NonwettingPhase = GetPropType<TypeTag, Properties::NonwettingPhase>;
public:
using type = Opm::TwoPhaseImmiscibleFluidSystem<Scalar, WettingPhase, NonwettingPhase>;
};
} // namespace Opm::Properties
namespace Opm {
template <class TypeTag>
class ImmiscibleModel
: public Opm::MultiPhaseBaseModel<TypeTag>
{
using ParentType = Opm::MultiPhaseBaseModel<TypeTag>;
using Implementation = GetPropType<TypeTag, Properties::Model>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
enum { numComponents = FluidSystem::numComponents };
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
using EnergyModule = Opm::EnergyModule<TypeTag, enableEnergy>;
public:
explicit ImmiscibleModel(Simulator& simulator)
: ParentType(simulator)
{}
static void registerParameters()
{
ParentType::registerParameters();
if (enableEnergy)
Opm::VtkEnergyModule<TypeTag>::registerParameters();
Parameters::SetDefault<Parameters::VtkWriteSaturations>(false);
Parameters::SetDefault<Parameters::VtkWriteMobilities>(false);
Parameters::SetDefault<Parameters::VtkWriteRelativePermeabilities>(false);
}
static std::string name()
{ return "immiscible"; }
std::string primaryVarName(unsigned pvIdx) const
{
std::string s;
if (!(s = EnergyModule::primaryVarName(pvIdx)).empty())
return s;
std::ostringstream oss;
if (pvIdx == Indices::pressure0Idx) {
oss << "pressure_" << FluidSystem::phaseName(/*phaseIdx=*/0);
}
else if (Indices::saturation0Idx <= pvIdx
&& pvIdx < Indices::saturation0Idx + numPhases - 1) {
unsigned phaseIdx = pvIdx - Indices::saturation0Idx;
oss << "saturation_" << FluidSystem::phaseName(phaseIdx);
}
else
assert(false);
return oss.str();
}
std::string eqName(unsigned eqIdx) const
{
std::string s;
if (!(s = EnergyModule::eqName(eqIdx)).empty())
return s;
std::ostringstream oss;
if (Indices::conti0EqIdx <= eqIdx && eqIdx < Indices::conti0EqIdx + numComponents)
oss << "conti_" << FluidSystem::phaseName(eqIdx - Indices::conti0EqIdx);
else
assert(false);
return oss.str();
}
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...
size_t nDof = this->numTotalDof();
for (unsigned dofIdx = 0; dofIdx < nDof; ++ dofIdx) {
if (this->isLocalDof(dofIdx)) {
referencePressure_ =
this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressure0Idx];
break;
}
}
}
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
{
assert(referencePressure_ > 0);
Scalar tmp = EnergyModule::primaryVarWeight(asImp_(), globalDofIdx, pvIdx);
if (tmp > 0)
// energy related quantity
return tmp;
if (Indices::pressure0Idx == pvIdx) {
return 10 / referencePressure_;
}
return 1.0;
}
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
{
Scalar tmp = EnergyModule::eqWeight(asImp_(), globalDofIdx, eqIdx);
if (tmp > 0)
// energy related equation
return tmp;
#ifndef NDEBUG
unsigned compIdx = eqIdx - Indices::conti0EqIdx;
assert(compIdx <= numPhases);
#endif
// make all kg equal
return 1.0;
}
void registerOutputModules_()
{
ParentType::registerOutputModules_();
if (enableEnergy)
this->addOutputModule(std::make_unique<VtkEnergyModule<TypeTag>>(this->simulator_));
}
private:
const Implementation& asImp_() const
{ return *static_cast<const Implementation *>(this); }
mutable Scalar referencePressure_;
};
} // namespace Opm
#endif
Opm::EnergyModule
Provides the auxiliary methods required for consideration of the energy equation.
Definition energymodule.hh:54
Opm::ImmiscibleBoundaryRateVector
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility.
Definition immiscibleboundaryratevector.hh:50
Opm::ImmiscibleExtensiveQuantities
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
Definition immiscibleextensivequantities.hh:53
Opm::ImmiscibleIntensiveQuantities
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
Definition immiscibleintensivequantities.hh:54
Opm::ImmiscibleLocalResidual
Calculates the local residual of the immiscible multi-phase model.
Definition immisciblelocalresidual.hh:46
Opm::ImmiscibleModel
A fully-implicit multi-phase flow model which assumes immiscibility of the phases.
Definition immisciblemodel.hh:211
Opm::ImmiscibleModel::name
static std::string name()
Definition immisciblemodel.hh:251
Opm::ImmiscibleModel::primaryVarName
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition immisciblemodel.hh:257
Opm::ImmiscibleModel::primaryVarWeight
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Definition immisciblemodel.hh:321
Opm::ImmiscibleModel::updateBegin
void updateBegin()
Called by the update() method before it tries to apply the newton method.
Definition immisciblemodel.hh:301
Opm::ImmiscibleModel::eqName
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition immisciblemodel.hh:282
Opm::ImmiscibleModel::registerParameters
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition immisciblemodel.hh:236
Opm::ImmiscibleModel::eqWeight
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Definition immisciblemodel.hh:341
Opm::ImmisciblePrimaryVariables
Represents the primary variables used by the immiscible multi-phase, model.
Definition immiscibleprimaryvariables.hh:54
Opm::ImmiscibleRateVector
Implements a vector representing rates of conserved quantities.
Definition immiscibleratevector.hh:51
Opm::MultiPhaseBaseModel
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition multiphasebasemodel.hh:168
Opm::MultiPhaseBaseModel::registerParameters
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition multiphasebasemodel.hh:190
Opm::VtkEnergyModule
VTK output module for quantities which make sense for models which assume thermal equilibrium.
Definition vtkenergymodule.hpp:58
Opm::VtkEnergyModule::registerParameters
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkenergymodule.hpp:87
energymodule.hh
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
immiscibleboundaryratevector.hh
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility.
immiscibleextensivequantities.hh
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
immiscibleindices.hh
The indices for the isothermal multi-phase model.
immiscibleintensivequantities.hh
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
immisciblelocalresidual.hh
Calculates the local residual of the immiscible multi-phase model.
immiscibleprimaryvariables.hh
Represents the primary variables used by the immiscible multi-phase, model.
immiscibleproperties.hh
Defines the properties required for the immiscible multi-phase model.
immiscibleratevector.hh
Implements a vector representing rates of conserved quantities.
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::Parameters::SetDefault
void SetDefault(decltype(Param::value) new_value)
Set a runtime parameter.
Definition parametersystem.hpp:212
Opm::ImmiscibleIndices
The indices for the isothermal multi-phase model.
Definition immiscibleindices.hh:45
Opm::Properties::BoundaryRateVector
Type of object for specifying boundary conditions.
Definition fvbaseproperties.hh:119
Opm::Properties::EnableEnergy
Specify whether energy should be considered as a conservation quantity or not.
Definition multiphasebaseproperties.hh:87
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::Fluid
The fluid used by the model.
Definition immiscibleproperties.hh:49
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::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::NonwettingPhase
The non-wetting phase for two-phase models.
Definition immiscibleproperties.hh:44
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::ImmiscibleModel
The generic type tag for problems using the immiscible multi-phase model.
Definition immisciblemodel.hh:63
Opm::Properties::TTag::ImmiscibleSinglePhaseModel
The type tag for single-phase immiscible problems.
Definition immisciblemodel.hh:66
Opm::Properties::TTag::ImmiscibleTwoPhaseModel
The type tag for two-phase immiscible problems.
Definition immisciblemodel.hh:69
Opm::Properties::WettingPhase
The wetting phase for two-phase models.
Definition immiscibleproperties.hh:41
vtkenergymodule.hpp
VTK output module for quantities which make sense for models which assume thermal equilibrium.