immisciblemodel.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef EWOMS_IMMISCIBLE_MODEL_HH
29#define EWOMS_IMMISCIBLE_MODEL_HH
30
31#include <opm/material/densead/Math.hpp>
33#include "immiscibleindices.hh"
40
44#include <opm/material/components/NullComponent.hpp>
45#include <opm/material/fluidsystems/GasPhase.hpp>
46#include <opm/material/fluidsystems/LiquidPhase.hpp>
47#include <opm/material/fluidsystems/SinglePhaseFluidSystem.hpp>
48#include <opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp>
49
50#include <sstream>
51#include <string>
52
53namespace Opm {
54template <class TypeTag>
55class ImmiscibleModel;
56}
57
58namespace Opm::Properties {
59
60// Create new type tags
61namespace TTag {
63struct ImmiscibleModel { using InheritsFrom = std::tuple<VtkEnergy, MultiPhaseBaseModel>; };
64
66struct ImmiscibleSinglePhaseModel { using InheritsFrom = std::tuple<ImmiscibleModel>; };
67
69struct ImmiscibleTwoPhaseModel { using InheritsFrom = std::tuple<ImmiscibleModel>; };
70} // end namespace TTag
71
73template<class TypeTag>
75
77template<class TypeTag>
78struct Model<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleModel<TypeTag>; };
79
81template<class TypeTag>
83
85template<class TypeTag>
87
89template<class TypeTag>
91
93template<class TypeTag>
95
97template<class TypeTag>
99
101template<class TypeTag>
102struct Indices<TypeTag, TTag::ImmiscibleModel> { using type = Opm::ImmiscibleIndices<TypeTag, /*PVOffset=*/0>; };
103
105template<class TypeTag>
106struct EnableEnergy<TypeTag, TTag::ImmiscibleModel> { static constexpr bool value = false; };
107
109// set slightly different properties for the single-phase case
111
113template<class TypeTag>
114struct FluidSystem<TypeTag, TTag::ImmiscibleSinglePhaseModel>
115{ private:
118public:
119 using type = Opm::SinglePhaseFluidSystem<Scalar , Fluid>;
120};
121
122template<class TypeTag>
123struct Fluid<TypeTag, TTag::ImmiscibleSinglePhaseModel>
124{
125private:
127
128public:
129 using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
130};
131
132// disable output of a few quantities which make sense in a
133// multi-phase but not in a single-phase context
134template<class TypeTag>
135struct VtkWriteSaturations<TypeTag, TTag::ImmiscibleSinglePhaseModel> { static constexpr bool value = false; };
136template<class TypeTag>
137struct VtkWriteMobilities<TypeTag, TTag::ImmiscibleSinglePhaseModel> { static constexpr bool value = false; };
138template<class TypeTag>
139struct VtkWriteRelativePermeabilities<TypeTag, TTag::ImmiscibleSinglePhaseModel> { static constexpr bool value = false; };
140
142// set slightly different properties for the two-phase case
144template<class TypeTag>
145struct WettingPhase<TypeTag, TTag::ImmiscibleTwoPhaseModel>
146{
147private:
149
150public:
151 using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
152};
153
154template<class TypeTag>
155struct NonwettingPhase<TypeTag, TTag::ImmiscibleTwoPhaseModel>
156{
157private:
159
160public:
161 using type = Opm::LiquidPhase<Scalar, Opm::NullComponent<Scalar> >;
162};
163
164template<class TypeTag>
165struct FluidSystem<TypeTag, TTag::ImmiscibleTwoPhaseModel>
166{
167private:
171
172public:
173 using type = Opm::TwoPhaseImmiscibleFluidSystem<Scalar, WettingPhase, NonwettingPhase>;
174};
175
176
177} // namespace Opm::Properties
178
179namespace Opm {
180
218template <class TypeTag>
220 : public Opm::MultiPhaseBaseModel<TypeTag>
221{
222 using ParentType = Opm::MultiPhaseBaseModel<TypeTag>;
223 using Implementation = GetPropType<TypeTag, Properties::Model>;
225
229
230 enum { numComponents = FluidSystem::numComponents };
231
232
233
234 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
235 enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
237
238public:
239 ImmiscibleModel(Simulator& simulator)
240 : ParentType(simulator)
241 {}
242
246 static void registerParameters()
247 {
249
250 if (enableEnergy)
252 }
253
257 static std::string name()
258 { return "immiscible"; }
259
263 std::string primaryVarName(unsigned pvIdx) const
264 {
265 std::string s;
266 if (!(s = EnergyModule::primaryVarName(pvIdx)).empty())
267 return s;
268
269 std::ostringstream oss;
270
271 if (pvIdx == Indices::pressure0Idx) {
272 oss << "pressure_" << FluidSystem::phaseName(/*phaseIdx=*/0);
273 }
274 else if (Indices::saturation0Idx <= pvIdx
275 && pvIdx < Indices::saturation0Idx + numPhases - 1) {
276 unsigned phaseIdx = pvIdx - Indices::saturation0Idx;
277 oss << "saturation_" << FluidSystem::phaseName(phaseIdx);
278 }
279 else
280 assert(false);
281
282 return oss.str();
283 }
284
288 std::string eqName(unsigned eqIdx) const
289 {
290 std::string s;
291 if (!(s = EnergyModule::eqName(eqIdx)).empty())
292 return s;
293
294 std::ostringstream oss;
295
296 if (Indices::conti0EqIdx <= eqIdx && eqIdx < Indices::conti0EqIdx + numComponents)
297 oss << "conti_" << FluidSystem::phaseName(eqIdx - Indices::conti0EqIdx);
298 else
299 assert(false);
300
301 return oss.str();
302 }
303
308 {
309 ParentType::updateBegin();
310
311 // find the a reference pressure. The first degree of freedom
312 // might correspond to non-interior entities which would lead
313 // to an undefined value, so we have to iterate...
314 size_t nDof = this->numTotalDof();
315 for (unsigned dofIdx = 0; dofIdx < nDof; ++ dofIdx) {
316 if (this->isLocalDof(dofIdx)) {
317 referencePressure_ =
318 this->solution(/*timeIdx=*/0)[dofIdx][/*pvIdx=*/Indices::pressure0Idx];
319 break;
320 }
321 }
322 }
323
327 Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
328 {
329 assert(referencePressure_ > 0);
330
331 Scalar tmp = EnergyModule::primaryVarWeight(asImp_(), globalDofIdx, pvIdx);
332 if (tmp > 0)
333 // energy related quantity
334 return tmp;
335 if (Indices::pressure0Idx == pvIdx) {
336 return 10 / referencePressure_;
337 }
338 return 1.0;
339 }
340
344 Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
345 {
346 Scalar tmp = EnergyModule::eqWeight(asImp_(), globalDofIdx, eqIdx);
347 if (tmp > 0)
348 // energy related equation
349 return tmp;
350
351#ifndef NDEBUG
352 unsigned compIdx = eqIdx - Indices::conti0EqIdx;
353 assert(compIdx <= numPhases);
354#endif
355
356 // make all kg equal
357 return 1.0;
358 }
359
361 {
363
364 if (enableEnergy)
365 this->addOutputModule(new Opm::VtkEnergyModule<TypeTag>(this->simulator_));
366 }
367
368private:
369 const Implementation& asImp_() const
370 { return *static_cast<const Implementation *>(this); }
371
372 mutable Scalar referencePressure_;
373};
374} // namespace Opm
375
376#endif
Provides the auxiliary methods required for consideration of the energy equation.
Definition: energymodule.hh:48
Implements a boundary vector for the fully implicit multi-phase model which assumes immiscibility.
Definition: immiscibleboundaryratevector.hh:46
This class provides the data all quantities that are required to calculate the fluxes of the fluid ph...
Definition: immiscibleextensivequantities.hh:52
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
Definition: immiscibleintensivequantities.hh:54
Calculates the local residual of the immiscible multi-phase model.
Definition: immisciblelocalresidual.hh:46
A fully-implicit multi-phase flow model which assumes immiscibility of the phases.
Definition: immisciblemodel.hh:221
static std::string name()
Definition: immisciblemodel.hh:257
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: immisciblemodel.hh:263
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Definition: immisciblemodel.hh:327
ImmiscibleModel(Simulator &simulator)
Definition: immisciblemodel.hh:239
void updateBegin()
Called by the update() method before it tries to apply the newton method. This is primary a hook whic...
Definition: immisciblemodel.hh:307
std::string eqName(unsigned eqIdx) const
Given an equation index, return a human readable name.
Definition: immisciblemodel.hh:288
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: immisciblemodel.hh:246
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Definition: immisciblemodel.hh:344
void registerOutputModules_()
Definition: immisciblemodel.hh:360
Represents the primary variables used by the immiscible multi-phase, model.
Definition: immiscibleprimaryvariables.hh:55
Implements a vector representing rates of conserved quantities.
Definition: immiscibleratevector.hh:51
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:153
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:179
void registerOutputModules_()
Definition: multiphasebasemodel.hh:254
VTK output module for quantities which make sense for models which assume thermal equilibrium.
Definition: vtkenergymodule.hh:85
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkenergymodule.hh:112
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
Defines the properties required for the immiscible multi-phase model.
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:242
The indices for the isothermal multi-phase model.
Definition: immiscibleindices.hh:45
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:136
Specify whether energy should be considered as a conservation quantity or not.
Definition: multiphasebaseproperties.hh:76
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:166
Opm::LiquidPhase< Scalar, Opm::NullComponent< Scalar > > type
Definition: immisciblemodel.hh:129
The fluid used by the model.
Definition: immiscibleproperties.hh:49
Opm::SinglePhaseFluidSystem< Scalar, Fluid > type
Definition: immisciblemodel.hh:119
Opm::TwoPhaseImmiscibleFluidSystem< Scalar, WettingPhase, NonwettingPhase > type
Definition: immisciblemodel.hh:173
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:69
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:48
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:150
The type of the local residual function.
Definition: fvbaseproperties.hh:111
The type of the model.
Definition: basicproperties.hh:81
Opm::LiquidPhase< Scalar, Opm::NullComponent< Scalar > > type
Definition: immisciblemodel.hh:161
The non-wetting phase for two-phase models.
Definition: immiscibleproperties.hh:44
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:147
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:133
The generic type tag for problems using the immiscible multi-phase model.
Definition: immisciblemodel.hh:63
std::tuple< VtkEnergy, MultiPhaseBaseModel > InheritsFrom
Definition: immisciblemodel.hh:63
The type tag for single-phase immiscible problems.
Definition: immisciblemodel.hh:66
std::tuple< ImmiscibleModel > InheritsFrom
Definition: immisciblemodel.hh:66
The type tag for two-phase immiscible problems.
Definition: immisciblemodel.hh:69
std::tuple< ImmiscibleModel > InheritsFrom
Definition: immisciblemodel.hh:69
Definition: vtkmultiphasemodule.hh:63
Definition: vtkmultiphasemodule.hh:65
Definition: vtkmultiphasemodule.hh:61
Opm::LiquidPhase< Scalar, Opm::NullComponent< Scalar > > type
Definition: immisciblemodel.hh:151
The wetting phase for two-phase models.
Definition: immiscibleproperties.hh:41