immiscibleintensivequantities.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_INTENSIVE_QUANTITIES_HH
29#define EWOMS_IMMISCIBLE_INTENSIVE_QUANTITIES_HH
30
32
34
35#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
36#include <opm/material/common/Valgrind.hpp>
37
38#include <dune/common/fvector.hh>
39#include <dune/common/fmatrix.hh>
40
41namespace Opm {
49template <class TypeTag>
51 : public GetPropType<TypeTag, Properties::DiscIntensiveQuantities>
52 , public EnergyIntensiveQuantities<TypeTag, getPropValue<TypeTag, Properties::EnableEnergy>()>
53 , public GetPropType<TypeTag, Properties::FluxModule>::FluxIntensiveQuantities
54{
56
65
66 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
67 enum { pressure0Idx = Indices::pressure0Idx };
68 enum { saturation0Idx = Indices::saturation0Idx };
69 enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
70 enum { dimWorld = GridView::dimensionworld };
71
72 using Toolbox = Opm::MathToolbox<Evaluation>;
73 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
74 using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
75 using EvalPhaseVector = Dune::FieldVector<Evaluation, numPhases>;
76
77 using FluxIntensiveQuantities = typename FluxModule::FluxIntensiveQuantities;
79 using FluidState = Opm::ImmiscibleFluidState<Evaluation, FluidSystem,
80 /*storeEnthalpy=*/enableEnergy>;
81
82public:
84 { }
85
87
89
93 void update(const ElementContext& elemCtx, unsigned dofIdx, unsigned timeIdx)
94 {
95 ParentType::update(elemCtx, dofIdx, timeIdx);
96 EnergyIntensiveQuantities::updateTemperatures_(fluidState_, elemCtx, dofIdx, timeIdx);
97
98 // material law parameters
99 const auto& problem = elemCtx.problem();
100 const typename MaterialLaw::Params& materialParams =
101 problem.materialLawParams(elemCtx, dofIdx, timeIdx);
102 const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
103 Opm::Valgrind::CheckDefined(priVars);
104
105 Evaluation sumSat = 0.0;
106 for (unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
107 const Evaluation& Salpha = priVars.makeEvaluation(saturation0Idx + phaseIdx, timeIdx);
108 fluidState_.setSaturation(phaseIdx, Salpha);
109 sumSat += Salpha;
110 }
111 fluidState_.setSaturation(numPhases - 1, 1 - sumSat);
112
113 EvalPhaseVector pC;
114 MaterialLaw::capillaryPressures(pC, materialParams, fluidState_);
115 Opm::Valgrind::CheckDefined(pC);
116
117 // calculate relative permeabilities
118 MaterialLaw::relativePermeabilities(relativePermeability_, materialParams, fluidState_);
119 Opm::Valgrind::CheckDefined(relativePermeability_);
120
121 const Evaluation& p0 = priVars.makeEvaluation(pressure0Idx, timeIdx);
122 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
123 fluidState_.setPressure(phaseIdx, p0 + (pC[phaseIdx] - pC[0]));
124
125 typename FluidSystem::template ParameterCache<Evaluation> paramCache;
126 paramCache.updateAll(fluidState_);
127
128 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
129 // compute and set the viscosity
130 const Evaluation& mu = FluidSystem::viscosity(fluidState_, paramCache, phaseIdx);
131 fluidState_.setViscosity(phaseIdx, mu);
132
133 // compute and set the density
134 const Evaluation& rho = FluidSystem::density(fluidState_, paramCache, phaseIdx);
135 fluidState_.setDensity(phaseIdx, rho);
136
137 mobility_[phaseIdx] = relativePermeability_[phaseIdx]/mu;
138 }
139
140 // porosity
141 porosity_ = problem.porosity(elemCtx, dofIdx, timeIdx);
142
143 // intrinsic permeability
144 intrinsicPerm_ = problem.intrinsicPermeability(elemCtx, dofIdx, timeIdx);
145
146 // energy related quantities
147 EnergyIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
148
149 // update the quantities specific for the velocity model
150 FluxIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);
151 }
152
156 const FluidState& fluidState() const
157 { return fluidState_; }
158
162 const DimMatrix& intrinsicPermeability() const
163 { return intrinsicPerm_; }
164
171 const Evaluation& relativePermeability(unsigned phaseIdx) const
172 { return relativePermeability_[phaseIdx]; }
173
180 const Evaluation& mobility(unsigned phaseIdx) const
181 { return mobility_[phaseIdx]; }
182
186 const Evaluation& porosity() const
187 { return porosity_; }
188
189protected:
190 FluidState fluidState_;
191 Evaluation porosity_;
192 DimMatrix intrinsicPerm_;
193 Evaluation relativePermeability_[numPhases];
194 Evaluation mobility_[numPhases];
195};
196
197} // namespace Opm
198
199#endif
Provides the volumetric quantities required for the energy equation.
Definition: energymodule.hh:532
Contains the quantities which are are constant within a finite volume for the immiscible multi-phase ...
Definition: immiscibleintensivequantities.hh:54
FluidState fluidState_
Definition: immiscibleintensivequantities.hh:190
const Evaluation & relativePermeability(unsigned phaseIdx) const
Returns the relative permeability of a given phase within the control volume.
Definition: immiscibleintensivequantities.hh:171
ImmiscibleIntensiveQuantities & operator=(const ImmiscibleIntensiveQuantities &other)=default
Evaluation mobility_[numPhases]
Definition: immiscibleintensivequantities.hh:194
void update(const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx)
Definition: immiscibleintensivequantities.hh:93
ImmiscibleIntensiveQuantities()
Definition: immiscibleintensivequantities.hh:83
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: immiscibleintensivequantities.hh:156
const Evaluation & mobility(unsigned phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: immiscibleintensivequantities.hh:180
const Evaluation & porosity() const
Returns the average porosity within the control volume.
Definition: immiscibleintensivequantities.hh:186
DimMatrix intrinsicPerm_
Definition: immiscibleintensivequantities.hh:192
Evaluation porosity_
Definition: immiscibleintensivequantities.hh:191
const DimMatrix & intrinsicPermeability() const
Returns the intrinsic permeability tensor a degree of freedom.
Definition: immiscibleintensivequantities.hh:162
Evaluation relativePermeability_[numPhases]
Definition: immiscibleintensivequantities.hh:193
ImmiscibleIntensiveQuantities(const ImmiscibleIntensiveQuantities &other)=default
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: 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:235