blackoilintensivequantities.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_BLACK_OIL_INTENSIVE_QUANTITIES_HH
29#define EWOMS_BLACK_OIL_INTENSIVE_QUANTITIES_HH
30
31#include "blackoilproperties.hh"
41
42#include <opm/common/TimingMacros.hpp>
43#include <opm/common/OpmLog/OpmLog.hpp>
44
45#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
46
47#include <opm/material/fluidstates/BlackOilFluidState.hpp>
48#include <opm/material/common/Valgrind.hpp>
49
51
52#include <opm/utility/CopyablePtr.hpp>
53
54#include <dune/common/fmatrix.hh>
55
56#include <cstring>
57#include <utility>
58
59#include <fmt/format.h>
60
61namespace Opm {
69template <class TypeTag>
71 : public GetPropType<TypeTag, Properties::DiscIntensiveQuantities>
72 , public GetPropType<TypeTag, Properties::FluxModule>::FluxIntensiveQuantities
73 , public BlackOilDiffusionIntensiveQuantities<TypeTag, getPropValue<TypeTag, Properties::EnableDiffusion>() >
74 , public BlackOilDispersionIntensiveQuantities<TypeTag, getPropValue<TypeTag, Properties::EnableDispersion>() >
76 , public BlackOilExtboIntensiveQuantities<TypeTag>
78 , public BlackOilFoamIntensiveQuantities<TypeTag>
79 , public BlackOilBrineIntensiveQuantities<TypeTag>
80 , public BlackOilEnergyIntensiveQuantities<TypeTag>
81 , public BlackOilMICPIntensiveQuantities<TypeTag>
82{
85
95
96 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
97 enum { enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>() };
98 enum { enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>() };
99 enum { enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>() };
100 enum { enableFoam = getPropValue<TypeTag, Properties::EnableFoam>() };
101 enum { enableBrine = getPropValue<TypeTag, Properties::EnableBrine>() };
102 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
103 enum { has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
104 enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
105 enum { enableTemperature = getPropValue<TypeTag, Properties::EnableTemperature>() };
106 enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
107 enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
108 enum { enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>() };
109 enum { enableMICP = getPropValue<TypeTag, Properties::EnableMICP>() };
110 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
111 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
112 enum { waterCompIdx = FluidSystem::waterCompIdx };
113 enum { oilCompIdx = FluidSystem::oilCompIdx };
114 enum { gasCompIdx = FluidSystem::gasCompIdx };
115 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
116 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
117 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
118 enum { dimWorld = GridView::dimensionworld };
119 enum { compositionSwitchIdx = Indices::compositionSwitchIdx };
120
121 static constexpr bool compositionSwitchEnabled = Indices::compositionSwitchIdx >= 0;
122 static constexpr bool waterEnabled = Indices::waterEnabled;
123 static constexpr bool gasEnabled = Indices::gasEnabled;
124 static constexpr bool oilEnabled = Indices::oilEnabled;
125
126 using Toolbox = MathToolbox<Evaluation>;
127 using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
128 using FluxIntensiveQuantities = typename FluxModule::FluxIntensiveQuantities;
131
132 using DirectionalMobilityPtr = Opm::Utility::CopyablePtr<DirectionalMobility<TypeTag, Evaluation>>;
134
135
136public:
137 using FluidState = BlackOilFluidState<Evaluation,
138 FluidSystem,
139 enableTemperature,
140 enableEnergy,
141 compositionSwitchEnabled,
142 enableVapwat,
143 enableBrine,
144 enableSaltPrecipitation,
145 has_disgas_in_water,
146 Indices::numPhases>;
147 using ScalarFluidState = BlackOilFluidState<Scalar,
148 FluidSystem,
149 enableTemperature,
150 enableEnergy,
151 compositionSwitchEnabled,
152 enableVapwat,
153 enableBrine,
154 enableSaltPrecipitation,
155 has_disgas_in_water,
156 Indices::numPhases>;
158
160 {
161 if (compositionSwitchEnabled) {
162 fluidState_.setRs(0.0);
163 fluidState_.setRv(0.0);
164 }
165 if (enableVapwat) {
166 fluidState_.setRvw(0.0);
167 }
168 if (has_disgas_in_water) {
169 fluidState_.setRsw(0.0);
170 }
171 }
173
175
179 void update(const ElementContext& elemCtx, unsigned dofIdx, unsigned timeIdx)
180 {
181 ParentType::update(elemCtx, dofIdx, timeIdx);
182 OPM_TIMEBLOCK_LOCAL(blackoilIntensiveQuanititiesUpdate);
183 const auto& problem = elemCtx.problem();
184 const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
185 const auto& linearizationType = problem.model().linearizer().getLinearizationType();
186 unsigned globalSpaceIdx = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
187 Scalar RvMax = FluidSystem::enableVaporizedOil()
188 ? problem.maxOilVaporizationFactor(timeIdx, globalSpaceIdx)
189 : 0.0;
190 Scalar RsMax = FluidSystem::enableDissolvedGas()
191 ? problem.maxGasDissolutionFactor(timeIdx, globalSpaceIdx)
192 : 0.0;
193
194 asImp_().updateTemperature_(elemCtx, dofIdx, timeIdx);
195
196 unsigned pvtRegionIdx = priVars.pvtRegionIndex();
197 fluidState_.setPvtRegionIndex(pvtRegionIdx);
198
199 asImp_().updateSaltConcentration_(elemCtx, dofIdx, timeIdx);
200
201 // extract the water and the gas saturations for convenience
202 Evaluation Sw = 0.0;
203 if constexpr (waterEnabled) {
204 if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw) {
205 Sw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
206 } else if(priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rsw ||
207 priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Disabled) {
208 // water is enabled but is not a primary variable i.e. one component/phase case
209 // or two-phase water + gas with only water present
210 Sw = 1.0;
211 } // else i.e. for MeaningWater() = Rvw, Sw is still 0.0;
212 }
213 Evaluation Sg = 0.0;
214 if constexpr (gasEnabled) {
215 if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg) {
216 Sg = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
217 } else if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rv) {
218 Sg = 1.0 - Sw;
219 } else if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Disabled) {
220 if constexpr (waterEnabled) {
221 Sg = 1.0 - Sw; // two phase water + gas
222 } else {
223 // one phase case
224 Sg = 1.0;
225 }
226 }
227 }
228 Valgrind::CheckDefined(Sg);
229 Valgrind::CheckDefined(Sw);
230
231 Evaluation So = 1.0 - Sw - Sg;
232
233 // deal with solvent
234 if constexpr (enableSolvent) {
235 if(priVars.primaryVarsMeaningSolvent() == PrimaryVariables::SolventMeaning::Ss) {
236 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
237 So -= priVars.makeEvaluation(Indices::solventSaturationIdx, timeIdx);
238 } else if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
239 Sg -= priVars.makeEvaluation(Indices::solventSaturationIdx, timeIdx);
240 }
241 }
242 }
243
244 if (FluidSystem::phaseIsActive(waterPhaseIdx))
245 fluidState_.setSaturation(waterPhaseIdx, Sw);
246
247 if (FluidSystem::phaseIsActive(gasPhaseIdx))
248 fluidState_.setSaturation(gasPhaseIdx, Sg);
249
250 if (FluidSystem::phaseIsActive(oilPhaseIdx))
251 fluidState_.setSaturation(oilPhaseIdx, So);
252
253 asImp_().solventPreSatFuncUpdate_(elemCtx, dofIdx, timeIdx);
254
255 // now we compute all phase pressures
256 std::array<Evaluation, numPhases> pC;
257 const auto& materialParams = problem.materialLawParams(globalSpaceIdx);
258 MaterialLaw::capillaryPressures(pC, materialParams, fluidState_);
259 problem.updateRelperms(mobility_, dirMob_, fluidState_, globalSpaceIdx);
260
261 // scaling the capillary pressure due to salt precipitation
262 if (BrineModule::hasPcfactTables() && priVars.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) {
263 unsigned satnumRegionIdx = elemCtx.problem().satnumRegionIndex(elemCtx, dofIdx, timeIdx);
264 const Evaluation Sp = priVars.makeEvaluation(Indices::saltConcentrationIdx, timeIdx);
265 const Evaluation porosityFactor = min(1.0 - Sp, 1.0); //phi/phi_0
266 const auto& pcfactTable = BrineModule::pcfactTable(satnumRegionIdx);
267 const Evaluation pcFactor = pcfactTable.eval(porosityFactor, /*extrapolation=*/true);
268 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
269 if (FluidSystem::phaseIsActive(phaseIdx)) {
270 pC[phaseIdx] *= pcFactor;
271 }
272 }
273
274 // oil is the reference phase for pressure
275 if (priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Pg) {
276 const Evaluation& pg = priVars.makeEvaluation(Indices::pressureSwitchIdx, timeIdx);
277 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
278 if (FluidSystem::phaseIsActive(phaseIdx))
279 fluidState_.setPressure(phaseIdx, pg + (pC[phaseIdx] - pC[gasPhaseIdx]));
280 } else if (priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Pw) {
281 const Evaluation& pw = priVars.makeEvaluation(Indices::pressureSwitchIdx, timeIdx);
282 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
283 if (FluidSystem::phaseIsActive(phaseIdx))
284 fluidState_.setPressure(phaseIdx, pw + (pC[phaseIdx] - pC[waterPhaseIdx]));
285 } else {
286 assert(FluidSystem::phaseIsActive(oilPhaseIdx));
287 const Evaluation& po = priVars.makeEvaluation(Indices::pressureSwitchIdx, timeIdx);
288 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
289 if (FluidSystem::phaseIsActive(phaseIdx))
290 fluidState_.setPressure(phaseIdx, po + (pC[phaseIdx] - pC[oilPhaseIdx]));
291 }
292
293 // update the Saturation functions for the blackoil solvent module.
294 asImp_().solventPostSatFuncUpdate_(elemCtx, dofIdx, timeIdx);
295
296 // update extBO parameters
297 asImp_().zFractionUpdate_(elemCtx, dofIdx, timeIdx);
298
299 Evaluation SoMax = 0.0;
300 if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
301 SoMax = max(fluidState_.saturation(oilPhaseIdx),
302 problem.maxOilSaturation(globalSpaceIdx));
303 }
304
305 // take the meaning of the switching primary variable into account for the gas
306 // and oil phase compositions
307 if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rs) {
308 const auto& Rs = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
309 fluidState_.setRs(Rs);
310 } else {
311 if (FluidSystem::enableDissolvedGas()) { // Add So > 0? i.e. if only water set rs = 0)
312 const Evaluation& RsSat = enableExtbo ? asImp_().rs() :
313 FluidSystem::saturatedDissolutionFactor(fluidState_,
314 oilPhaseIdx,
315 pvtRegionIdx,
316 SoMax);
317 fluidState_.setRs(min(RsMax, RsSat));
318 }
319 else if constexpr (compositionSwitchEnabled)
320 fluidState_.setRs(0.0);
321 }
322
323 if (priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rv) {
324 const auto& Rv = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx);
325 fluidState_.setRv(Rv);
326 } else {
327 if (FluidSystem::enableVaporizedOil() ) { // Add Sg > 0? i.e. if only water set rv = 0)
328 const Evaluation& RvSat = enableExtbo ? asImp_().rv() :
329 FluidSystem::saturatedDissolutionFactor(fluidState_,
330 gasPhaseIdx,
331 pvtRegionIdx,
332 SoMax);
333 fluidState_.setRv(min(RvMax, RvSat));
334 }
335 else if constexpr (compositionSwitchEnabled)
336 fluidState_.setRv(0.0);
337 }
338
339 if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rvw) {
340 const auto& Rvw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
341 fluidState_.setRvw(Rvw);
342 } else {
343 if (FluidSystem::enableVaporizedWater()) { // Add Sg > 0? i.e. if only water set rv = 0)
344 const Evaluation& RvwSat = FluidSystem::saturatedVaporizationFactor(fluidState_,
345 gasPhaseIdx,
346 pvtRegionIdx);
347 fluidState_.setRvw(RvwSat);
348 }
349 }
350
351 if (priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Rsw) {
352 const auto& Rsw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx);
353 fluidState_.setRsw(Rsw);
354 } else {
355 if (FluidSystem::enableDissolvedGasInWater()) {
356 const Evaluation& RswSat = FluidSystem::saturatedDissolutionFactor(fluidState_,
357 waterPhaseIdx,
358 pvtRegionIdx);
359 fluidState_.setRsw(RswSat);
360 }
361 }
362
363 typename FluidSystem::template ParameterCache<Evaluation> paramCache;
364 paramCache.setRegionIndex(pvtRegionIdx);
365 if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
366 paramCache.setMaxOilSat(SoMax);
367 }
368 paramCache.updateAll(fluidState_);
369
370 // compute the phase densities and transform the phase permeabilities into mobilities
371 int nmobilities = 1;
372 std::vector<std::array<Evaluation,numPhases>*> mobilities = {&mobility_};
373 if (dirMob_) {
374 for (int i=0; i<3; i++) {
375 nmobilities += 1;
376 mobilities.push_back(&(dirMob_->getArray(i)));
377 }
378 }
379 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
380 if (!FluidSystem::phaseIsActive(phaseIdx))
381 continue;
382 const auto& b = FluidSystem::inverseFormationVolumeFactor(fluidState_, phaseIdx, pvtRegionIdx);
383 fluidState_.setInvB(phaseIdx, b);
384 const auto& mu = FluidSystem::viscosity(fluidState_, paramCache, phaseIdx);
385 for (int i = 0; i<nmobilities; i++) {
386 if (enableExtbo && phaseIdx == oilPhaseIdx) {
387 (*mobilities[i])[phaseIdx] /= asImp_().oilViscosity();
388 }
389 else if (enableExtbo && phaseIdx == gasPhaseIdx) {
390 (*mobilities[i])[phaseIdx] /= asImp_().gasViscosity();
391 }
392 else {
393 (*mobilities[i])[phaseIdx] /= mu;
394 }
395 }
396 }
397 Valgrind::CheckDefined(mobility_);
398
399 // calculate the phase densities
400 Evaluation rho;
401 if (FluidSystem::phaseIsActive(waterPhaseIdx)) {
402 rho = fluidState_.invB(waterPhaseIdx);
403 rho *= FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx);
404 if (FluidSystem::enableDissolvedGasInWater()) {
405 rho +=
406 fluidState_.invB(waterPhaseIdx) *
407 fluidState_.Rsw() *
408 FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
409 }
410 fluidState_.setDensity(waterPhaseIdx, rho);
411 }
412
413 if (FluidSystem::phaseIsActive(gasPhaseIdx)) {
414 rho = fluidState_.invB(gasPhaseIdx);
415 rho *= FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
416 if (FluidSystem::enableVaporizedOil()) {
417 rho +=
418 fluidState_.invB(gasPhaseIdx) *
419 fluidState_.Rv() *
420 FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx);
421 }
422 if (FluidSystem::enableVaporizedWater()) {
423 rho +=
424 fluidState_.invB(gasPhaseIdx) *
425 fluidState_.Rvw() *
426 FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx);
427 }
428 fluidState_.setDensity(gasPhaseIdx, rho);
429 }
430
431 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
432 rho = fluidState_.invB(oilPhaseIdx);
433 rho *= FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx);
434 if (FluidSystem::enableDissolvedGas()) {
435 rho +=
436 fluidState_.invB(oilPhaseIdx) *
437 fluidState_.Rs() *
438 FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx);
439 }
440 fluidState_.setDensity(oilPhaseIdx, rho);
441 }
442
443 // retrieve the porosity from the problem
444 referencePorosity_ = problem.porosity(elemCtx, dofIdx, timeIdx);
445 porosity_ = referencePorosity_;
446
447 // the porosity must be modified by the compressibility of the
448 // rock...
449 Scalar rockCompressibility = problem.rockCompressibility(globalSpaceIdx);
450 if (rockCompressibility > 0.0) {
451 Scalar rockRefPressure = problem.rockReferencePressure(globalSpaceIdx);
452 Evaluation x;
453 if (FluidSystem::phaseIsActive(oilPhaseIdx)) {
454 x = rockCompressibility*(fluidState_.pressure(oilPhaseIdx) - rockRefPressure);
455 } else if (FluidSystem::phaseIsActive(waterPhaseIdx)){
456 x = rockCompressibility*(fluidState_.pressure(waterPhaseIdx) - rockRefPressure);
457 } else {
458 x = rockCompressibility*(fluidState_.pressure(gasPhaseIdx) - rockRefPressure);
459 }
460 porosity_ *= 1.0 + x + 0.5*x*x;
461 }
462
463 // deal with water induced rock compaction
464 porosity_ *= problem.template rockCompPoroMultiplier<Evaluation>(*this, globalSpaceIdx);
465
466 // the MICP processes change the porosity
467 if constexpr (enableMICP){
468 Evaluation biofilm_ = priVars.makeEvaluation(Indices::biofilmConcentrationIdx, timeIdx, linearizationType);
469 Evaluation calcite_ = priVars.makeEvaluation(Indices::calciteConcentrationIdx, timeIdx, linearizationType);
470 porosity_ += - biofilm_ - calcite_;
471 }
472
473 // deal with salt-precipitation
474 if (enableSaltPrecipitation && priVars.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) {
475 Evaluation Sp = priVars.makeEvaluation(Indices::saltConcentrationIdx, timeIdx);
476 porosity_ *= (1.0 - Sp);
477 }
478
479 rockCompTransMultiplier_ = problem.template rockCompTransMultiplier<Evaluation>(*this, globalSpaceIdx);
480
481 asImp_().solventPvtUpdate_(elemCtx, dofIdx, timeIdx);
482 asImp_().zPvtUpdate_();
483 asImp_().polymerPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
484 asImp_().updateEnergyQuantities_(elemCtx, dofIdx, timeIdx, paramCache);
485 asImp_().foamPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
486 asImp_().MICPPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
487 asImp_().saltPropertiesUpdate_(elemCtx, dofIdx, timeIdx);
488
489 // update the quantities which are required by the chosen
490 // velocity model
491 FluxIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);
492
493 // update the diffusion specific quantities of the intensive quantities
494 DiffusionIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
495
496 // update the dispersion specific quantities of the intensive quantities
497 DispersionIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);
498
499#ifndef NDEBUG
500 // some safety checks in debug mode
501 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
502 if (!FluidSystem::phaseIsActive(phaseIdx))
503 continue;
504
505 assert(isfinite(fluidState_.density(phaseIdx)));
506 assert(isfinite(fluidState_.saturation(phaseIdx)));
507 assert(isfinite(fluidState_.temperature(phaseIdx)));
508 assert(isfinite(fluidState_.pressure(phaseIdx)));
509 assert(isfinite(fluidState_.invB(phaseIdx)));
510 }
511 assert(isfinite(fluidState_.Rs()));
512 assert(isfinite(fluidState_.Rv()));
513
514#endif
515 }
516
520 const FluidState& fluidState() const
521 { return fluidState_; }
522
526 const Evaluation& mobility(unsigned phaseIdx) const
527 { return mobility_[phaseIdx]; }
528
529 const Evaluation& mobility(unsigned phaseIdx, FaceDir::DirEnum facedir) const
530 {
531 using Dir = FaceDir::DirEnum;
532 if (dirMob_) {
533 switch(facedir) {
534 case Dir::XMinus:
535 case Dir::XPlus:
536 return dirMob_->mobilityX_[phaseIdx];
537 case Dir::YMinus:
538 case Dir::YPlus:
539 return dirMob_->mobilityY_[phaseIdx];
540 case Dir::ZMinus:
541 case Dir::ZPlus:
542 return dirMob_->mobilityZ_[phaseIdx];
543 default:
544 throw std::runtime_error("Unexpected face direction");
545 }
546 }
547 else {
548 return mobility_[phaseIdx];
549 }
550
551 }
552
556 const Evaluation& porosity() const
557 { return porosity_; }
558
562 const Evaluation& rockCompTransMultiplier() const
563 { return rockCompTransMultiplier_; }
564
572 auto pvtRegionIndex() const
573 -> decltype(std::declval<FluidState>().pvtRegionIndex())
574 { return fluidState_.pvtRegionIndex(); }
575
579 Evaluation relativePermeability(unsigned phaseIdx) const
580 {
581 // warning: slow
582 return fluidState_.viscosity(phaseIdx)*mobility(phaseIdx);
583 }
584
591 Scalar referencePorosity() const
592 { return referencePorosity_; }
593
594private:
602
603 Implementation& asImp_()
604 { return *static_cast<Implementation*>(this); }
605
606 FluidState fluidState_;
607 Scalar referencePorosity_;
608 Evaluation porosity_;
609 Evaluation rockCompTransMultiplier_;
610 std::array<Evaluation,numPhases> mobility_;
611
612 // Instead of writing a custom copy constructor and a custom assignment operator just to handle
613 // the dirMob_ unique ptr member variable when copying BlackOilIntensiveQuantites (see for example
614 // updateIntensitiveQuantities_() in fvbaseelementcontext.hh for a copy example) we write the below
615 // custom wrapper class CopyablePtr which wraps the unique ptr and makes it copyable.
616 //
617 // The advantage of this approach is that we avoid having to call all the base class copy constructors and
618 // assignment operators explicitly (which is needed when writing the custom copy constructor and assignment
619 // operators) which could become a maintenance burden. For example, when adding a new base class (if that should
620 // be needed sometime in the future) to BlackOilIntensiveQuantites we could forget to update the copy
621 // constructor and assignment operators.
622 //
623 // We want each copy of the BlackOilIntensiveQuantites to be unique, (TODO: why?) so we have to make a copy
624 // of the unique_ptr each time we copy construct or assign to it from another BlackOilIntensiveQuantites.
625 // (On the other hand, if a copy could share the ptr with the original, a shared_ptr could be used instead and the
626 // wrapper would not be needed)
627 DirectionalMobilityPtr dirMob_;
628};
629
630} // namespace Opm
631
632#endif
Contains the classes required to extend the black-oil model by brine.
Classes required for molecular diffusion.
Classes required for mechanical dispersion.
Contains the classes required to extend the black-oil model by energy.
Contains the classes required to extend the black-oil model by solvent component. For details,...
Contains the classes required to extend the black-oil model to include the effects of foam.
Contains the classes required to extend the black-oil model by MICP.
Contains the classes required to extend the black-oil model by polymer.
Declares the properties required by the black oil model.
Contains the classes required to extend the black-oil model by solvents.
Definition: blackoilbrinemodules.hh:416
Contains the high level supplements required to extend the black oil model by brine.
Definition: blackoilbrinemodules.hh:58
static const TabulatedFunction & pcfactTable(unsigned satnumRegionIdx)
Definition: blackoilbrinemodules.hh:342
static bool hasPcfactTables()
Definition: blackoilbrinemodules.hh:386
Provides the volumetric quantities required for the calculation of molecular diffusive fluxes.
Definition: blackoildiffusionmodule.hh:274
Provides the volumetric quantities required for the calculation of dispersive fluxes.
Definition: blackoildispersionmodule.hh:278
Provides the volumetric quantities required for the equations needed by the energys extension of the ...
Definition: blackoilenergymodules.hh:333
Provides the volumetric quantities required for the equations needed by the solvents extension of the...
Definition: blackoilextbomodules.hh:562
Provides the volumetric quantities required for the equations needed by the polymers extension of the...
Definition: blackoilfoammodules.hh:461
Contains the quantities which are are constant within a finite volume in the black-oil model.
Definition: blackoilintensivequantities.hh:82
const Evaluation & porosity() const
Returns the average porosity within the control volume.
Definition: blackoilintensivequantities.hh:556
const Evaluation & mobility(unsigned phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition: blackoilintensivequantities.hh:526
void update(const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx)
Definition: blackoilintensivequantities.hh:179
Evaluation relativePermeability(unsigned phaseIdx) const
Returns the relative permeability of a given phase within the control volume.
Definition: blackoilintensivequantities.hh:579
auto pvtRegionIndex() const -> decltype(std::declval< FluidState >().pvtRegionIndex())
Returns the index of the PVT region used to calculate the thermodynamic quantities.
Definition: blackoilintensivequantities.hh:572
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition: blackoilintensivequantities.hh:520
BlackOilIntensiveQuantities & operator=(const BlackOilIntensiveQuantities &other)=default
const Evaluation & rockCompTransMultiplier() const
Definition: blackoilintensivequantities.hh:562
BlackOilIntensiveQuantities(const BlackOilIntensiveQuantities &other)=default
BlackOilIntensiveQuantities()
Definition: blackoilintensivequantities.hh:159
BlackOilFluidState< Scalar, FluidSystem, enableTemperature, enableEnergy, compositionSwitchEnabled, enableVapwat, enableBrine, enableSaltPrecipitation, has_disgas_in_water, Indices::numPhases > ScalarFluidState
Definition: blackoilintensivequantities.hh:156
const Evaluation & mobility(unsigned phaseIdx, FaceDir::DirEnum facedir) const
Definition: blackoilintensivequantities.hh:529
Scalar referencePorosity() const
Returns the porosity of the rock at reference conditions.
Definition: blackoilintensivequantities.hh:591
BlackOilFluidState< Evaluation, FluidSystem, enableTemperature, enableEnergy, compositionSwitchEnabled, enableVapwat, enableBrine, enableSaltPrecipitation, has_disgas_in_water, Indices::numPhases > FluidState
Definition: blackoilintensivequantities.hh:146
Provides the volumetric quantities required for the equations needed by the MICP extension of the bla...
Definition: blackoilmicpmodules.hh:459
Provides the volumetric quantities required for the equations needed by the polymers extension of the...
Definition: blackoilpolymermodules.hh:807
Provides the volumetric quantities required for the equations needed by the solvents extension of the...
Definition: blackoilsolventmodules.hh:779
This file contains definitions related to directional mobilities.
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