28#ifndef OPM_BLACK_OIL_MODEL_HPP
29#define OPM_BLACK_OIL_MODEL_HPP
31#include <opm/material/densead/Math.hpp>
33#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
69template <
class TypeTag>
85template<
class TypeTag>
90template<
class TypeTag>
95template<
class TypeTag>
100template<
class TypeTag>
105template<
class TypeTag>
110template<
class TypeTag>
115template<
class TypeTag>
120template<
class TypeTag>
125template<
class TypeTag>
130template<
class TypeTag>
134 getPropValue<TypeTag, Properties::EnableExtbo>(),
135 getPropValue<TypeTag, Properties::EnablePolymer>(),
136 getPropValue<TypeTag, Properties::EnergyModuleType>() == EnergyModules::FullyImplicitThermal,
137 getPropValue<TypeTag, Properties::EnableFoam>(),
138 getPropValue<TypeTag, Properties::EnableBrine>(),
140 getPropValue<TypeTag, Properties::EnableBioeffects>()>;
144template<
class TypeTag>
150 using type = BlackOilFluidSystem<Scalar>;
154template<
class TypeTag>
156{
static constexpr bool value =
false; };
158template<
class TypeTag>
160{
static constexpr bool value =
false; };
162template<
class TypeTag>
164{
static constexpr bool value =
false; };
166template<
class TypeTag>
168{
static constexpr bool value =
false; };
170template<
class TypeTag>
172{
static constexpr bool value =
false; };
174template<
class TypeTag>
176{
static constexpr bool value =
false; };
178template<
class TypeTag>
180{
static constexpr bool value =
false; };
182template<
class TypeTag>
184{
static constexpr bool value =
false; };
186template<
class TypeTag>
188{
static constexpr bool value =
false; };
190template<
class TypeTag>
192{
static constexpr bool value =
false; };
194template<
class TypeTag>
196{
static constexpr EnergyModules value = EnergyModules::NoTemperature; };
199template<
class TypeTag>
201{
static constexpr bool value =
false; };
204template<
class TypeTag>
206{
static constexpr bool value =
false; };
208template<
class TypeTag>
210{
static constexpr bool value =
false; };
212template<
class TypeTag>
214{
static constexpr bool value =
false; };
216template<
class TypeTag>
218{
static constexpr bool value =
false; };
226template<
class TypeTag>
231 static constexpr Scalar alpha =
232 getPropValue<TypeTag, Properties::BlackoilConserveSurfaceVolume>() ? 1000.0 : 1.0;
236 static constexpr Scalar value = 1.0/(30.0*4184.0*alpha);
240template<
class TypeTag>
245 static constexpr Scalar alpha =
246 getPropValue<TypeTag, Properties::BlackoilConserveSurfaceVolume>() ? 1000.0 : 1.0;
250 static constexpr Scalar value = 1.0/(10.0*alpha);
255template<
class TypeTag>
257{
static constexpr bool value =
false; };
326template<
class TypeTag >
344 enum { numComponents = FluidSystem::numComponents };
345 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
347 static constexpr bool compositionSwitchEnabled =
348 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
349 static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
350 static constexpr bool enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>();
351 static constexpr bool enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>();
352 static constexpr bool enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>();
353 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
354 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
355 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
356 static constexpr bool enableFullyImplicitThermal = energyModuleType == EnergyModules::FullyImplicitThermal;
357 static constexpr bool waterEnabled = Indices::waterEnabled;
359 using BioeffectsModule = BlackOilBioeffectsModule<TypeTag, enableBioeffects>;
362 using EnergyModule = BlackOilEnergyModule<TypeTag, energyModuleType>;
363 using ExtboModule = BlackOilExtboModule<TypeTag, enableExtbo>;
364 using PolymerModule = BlackOilPolymerModule<TypeTag, enablePolymer>;
365 using SolventModule = BlackOilSolventModule<TypeTag, enableSolvent>;
373 eqWeights_.resize(numEq, 1.0);
383 if constexpr (enableSolvent) {
384 SolventModule::registerParameters();
386 if constexpr (enableExtbo) {
387 ExtboModule::registerParameters();
389 if constexpr (enablePolymer) {
390 PolymerModule::registerParameters();
392 if constexpr (enableFullyImplicitThermal) {
393 EnergyModule::registerParameters();
395 if constexpr (enableDiffusion) {
396 DiffusionModule::registerParameters();
398 if constexpr (enableBioeffects) {
399 BioeffectsModule::registerParameters();
405 if constexpr (enableDiffusion) {
414 {
return "blackoil"; }
421 if (pvIdx == Indices::waterSwitchIdx) {
422 return "water_switching";
424 else if (pvIdx == Indices::pressureSwitchIdx) {
425 return "pressure_switching";
427 else if (pvIdx == Indices::compositionSwitchIdx) {
428 return "composition_switching";
431 if constexpr (enableSolvent) {
432 if (SolventModule::primaryVarApplies(pvIdx)) {
433 return SolventModule::primaryVarName(pvIdx);
437 if constexpr (enableExtbo) {
438 if (ExtboModule::primaryVarApplies(pvIdx)) {
439 return ExtboModule::primaryVarName(pvIdx);
443 if constexpr (enablePolymer) {
444 if (PolymerModule::primaryVarApplies(pvIdx)) {
445 return PolymerModule::primaryVarName(pvIdx);
449 if constexpr (enableFullyImplicitThermal) {
450 if (EnergyModule::primaryVarApplies(pvIdx)) {
451 return EnergyModule::primaryVarName(pvIdx);
455 throw std::logic_error(
"Invalid primary variable index");
463 if (Indices::conti0EqIdx <= eqIdx && eqIdx < Indices::conti0EqIdx + numComponents) {
464 std::ostringstream oss;
465 oss <<
"conti_" << FluidSystem::phaseName(eqIdx - Indices::conti0EqIdx);
469 if constexpr (enableSolvent) {
470 if (SolventModule::eqApplies(eqIdx)) {
471 return SolventModule::eqName(eqIdx);
475 if constexpr (enableExtbo) {
476 if (ExtboModule::eqApplies(eqIdx)) {
477 return ExtboModule::eqName(eqIdx);
481 if constexpr (enablePolymer) {
482 if (PolymerModule::eqApplies(eqIdx)) {
483 return PolymerModule::eqName(eqIdx);
487 if constexpr (enableFullyImplicitThermal) {
488 if (EnergyModule::eqApplies(eqIdx)) {
489 return EnergyModule::eqName(eqIdx);
493 throw std::logic_error(
"Invalid equation index");
503 if (globalDofIdx >= this->numGridDof()) {
508 if (Indices::waterSwitchIdx == pvIdx) {
514 else if (
int(Indices::pressureSwitchIdx) ==
int(pvIdx)) {
519 if constexpr (enableSolvent) {
520 if (SolventModule::primaryVarApplies(pvIdx)) {
521 return SolventModule::primaryVarWeight(pvIdx);
526 if constexpr (enableExtbo) {
527 if (ExtboModule::primaryVarApplies(pvIdx)) {
528 return ExtboModule::primaryVarWeight(pvIdx);
533 if constexpr (enablePolymer) {
534 if (PolymerModule::primaryVarApplies(pvIdx)) {
535 return PolymerModule::primaryVarWeight(pvIdx);
540 if constexpr (enableFullyImplicitThermal) {
541 if (EnergyModule::primaryVarApplies(pvIdx)) {
542 return EnergyModule::primaryVarWeight(pvIdx);
547 assert(Indices::compositionSwitchIdx == pvIdx);
549 switch (this->solution(0)[globalDofIdx].primaryVarsMeaningGas()) {
550 case PrimaryVariables::GasMeaning::Sg:
return 1.0;
551 case PrimaryVariables::GasMeaning::Rs:
return 1.0 / 250.;
552 case PrimaryVariables::GasMeaning::Rv:
return 1.0 / 0.025;
553 default:
throw std::logic_error(
"Invalid primary variable meaning flag for gas");
563 Scalar
eqWeight(
unsigned globalDofIdx,
unsigned eqIdx)
const
567 if (globalDofIdx >= this->numGridDof()) {
571 return eqWeights_[eqIdx];
575 { eqWeights_[eqIdx] = value; }
585 template <
class DofEntity>
588 const unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
591 if (!outstream.good()) {
592 throw std::runtime_error(
"Could not serialize degree of freedom " +
std::to_string(dofIdx));
596 const auto& priVars = this->solution(0)[dofIdx];
597 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
598 outstream << priVars[eqIdx] <<
" ";
602 outstream << static_cast<int>(priVars.primaryVarsMeaningGas()) <<
" ";
603 outstream << static_cast<int>(priVars.primaryVarsMeaningWater()) <<
" ";
604 outstream << static_cast<int>(priVars.primaryVarsMeaningPressure()) <<
" ";
606 outstream << priVars.pvtRegionIndex() <<
" ";
608 if constexpr (enableSolvent) {
609 SolventModule::serializeEntity(asImp_(), outstream, dof);
611 if constexpr (enableExtbo) {
612 ExtboModule::serializeEntity(asImp_(), outstream, dof);
614 if constexpr (enablePolymer) {
615 PolymerModule::serializeEntity(asImp_(), outstream, dof);
617 if constexpr (enableFullyImplicitThermal) {
618 EnergyModule::serializeEntity(asImp_(), outstream, dof);
630 template <
class DofEntity>
632 const DofEntity& dof)
634 const unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
637 auto& priVars = this->solution(0)[dofIdx];
638 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
639 if (!instream.good()) {
640 throw std::runtime_error(
"Could not deserialize degree of freedom " +
std::to_string(dofIdx));
642 instream >> priVars[eqIdx];
646 unsigned primaryVarsMeaningGas;
647 instream >> primaryVarsMeaningGas;
649 unsigned primaryVarsMeaningWater;
650 instream >> primaryVarsMeaningWater;
652 unsigned primaryVarsMeaningPressure;
653 instream >> primaryVarsMeaningPressure;
655 unsigned pvtRegionIdx;
656 instream >> pvtRegionIdx;
658 if (!instream.good()) {
659 throw std::runtime_error(
"Could not deserialize degree of freedom " +
std::to_string(dofIdx));
662 if constexpr (enableSolvent) {
663 SolventModule::deserializeEntity(asImp_(), instream, dof);
665 if constexpr (enableExtbo) {
666 ExtboModule::deserializeEntity(asImp_(), instream, dof);
668 if constexpr (enablePolymer) {
669 PolymerModule::deserializeEntity(asImp_(), instream, dof);
671 if constexpr (enableFullyImplicitThermal) {
672 EnergyModule::deserializeEntity(asImp_(), instream, dof);
678 priVars.setPrimaryVarsMeaningGas(
static_cast<PVM_G
>(primaryVarsMeaningGas));
679 priVars.setPrimaryVarsMeaningWater(
static_cast<PVM_W
>(primaryVarsMeaningWater));
680 priVars.setPrimaryVarsMeaningPressure(
static_cast<PVM_P
>(primaryVarsMeaningPressure));
682 priVars.setPvtRegionIndex(pvtRegionIdx);
692 template <
class Restarter>
695 ParentType::deserialize(res);
700 ElementContext elemCtx(this->simulator_);
701 for (
const auto& elem : elements(this->gridView())) {
702 elemCtx.updateStencil(elem);
703 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
704 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
705 updatePvtRegionIndex_(this->solution(0)[globalDofIdx],
712 this->solution(1) = this->solution(0);
722 template <
class Context>
724 const Context& context,
727 { updatePvtRegionIndex_(priVars, context, dofIdx, timeIdx); }
734 if constexpr (enableSolvent) {
735 SolventModule::registerOutputModules(asImp_(), this->simulator_);
737 if constexpr (enablePolymer) {
738 PolymerModule::registerOutputModules(asImp_(), this->simulator_);
740 if constexpr (enableFullyImplicitThermal) {
741 EnergyModule::registerOutputModules(asImp_(), this->simulator_);
743 if constexpr (enableBioeffects) {
744 BioeffectsModule::registerOutputModules(asImp_(), this->simulator_);
750 if constexpr (enableDiffusion) {
756 std::vector<Scalar> eqWeights_;
758 Implementation& asImp_()
759 {
return *
static_cast<Implementation*
>(
this); }
761 const Implementation& asImp_()
const
762 {
return *
static_cast<const Implementation*
>(
this); }
764 template <
class Context>
766 const Context& context,
770 const unsigned regionIdx = context.problem().pvtRegionIndex(context, dofIdx, timeIdx);
771 priVars.setPvtRegionIndex(regionIdx);
Contains classes extending the black-oil model. \detail This file holds dummy definitions,...
Declares the properties required by the black oil model.
Implements a boundary vector for the fully implicit black-oil model.
Definition: blackoilboundaryratevector.hh:55
Provides the auxiliary methods required for consideration of the diffusion equation.
Provides the auxiliary methods required for consideration of the dispersion equation.
This template class contains the data which is required to calculate the fluxes of the fluid phases o...
Definition: blackoilextensivequantities.hh:57
Contains the quantities which are are constant within a finite volume in the black-oil model.
Definition: blackoilintensivequantities.hh:80
Calculates the local residual of the black oil model.
Definition: blackoillocalresidual.hh:51
A fully-implicit black-oil flow model.
Definition: blackoilmodel.hh:329
GetPropType< TypeTag, Properties::PrimaryVariables > PrimaryVariables
Definition: blackoilmodel.hh:333
BlackOilModel(Simulator &simulator)
Definition: blackoilmodel.hh:370
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: blackoilmodel.hh:499
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition: blackoilmodel.hh:563
void supplementInitialSolution_(PrimaryVariables &priVars, const Context &context, unsigned dofIdx, unsigned timeIdx)
Definition: blackoilmodel.hh:723
void serializeEntity(std::ostream &outstream, const DofEntity &dof)
Write the current solution for a degree of freedom to a restart file.
Definition: blackoilmodel.hh:586
void registerOutputModules_()
Definition: blackoilmodel.hh:729
std::string eqName(int eqIdx) const
Given an equation index, return a human readable name.
Definition: blackoilmodel.hh:461
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: blackoilmodel.hh:332
static std::string name()
Definition: blackoilmodel.hh:413
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: blackoilmodel.hh:419
GetPropType< TypeTag, Properties::Indices > Indices
Definition: blackoilmodel.hh:331
void deserializeEntity(std::istream &instream, const DofEntity &dof)
Reads the current solution variables for a degree of freedom from a restart file.
Definition: blackoilmodel.hh:631
GetPropType< TypeTag, Properties::LocalResidual > LocalResidual
Definition: blackoilmodel.hh:368
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: blackoilmodel.hh:379
void setEqWeight(unsigned eqIdx, Scalar value)
Definition: blackoilmodel.hh:574
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition: blackoilmodel.hh:693
A newton solver which is specific to the black oil model.
Definition: blackoilnewtonmethod.hpp:64
Represents the primary variables used by the black-oil model.
Definition: blackoilprimaryvariables.hh:70
Base class for all problems which use the black-oil model.
Definition: blackoilproblem.hh:43
Implements a vector representing mass, molar or volumetric rates for the black oil model.
Definition: blackoilratevector.hh:59
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:161
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:183
void registerOutputModules_()
Definition: multiphasebasemodel.hh:259
VTK output module for the black oil model's parameters.
Definition: vtkblackoilmodule.hpp:57
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilmodule.hpp:93
VTK output module for the fluid composition.
Definition: vtkcompositionmodule.hpp:57
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkcompositionmodule.hpp:87
VTK output module for quantities which make sense for models which incorperate molecular diffusion.
Definition: vtkdiffusionmodule.hpp:58
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkdiffusionmodule.hpp:88
PressureMeaning
Definition: blackoilmeanings.hh:29
WaterMeaning
Definition: blackoilmeanings.hh:22
GasMeaning
Definition: blackoilmeanings.hh:35
Definition: blackoilmodel.hh:74
Definition: blackoilbioeffectsmodules.hh:45
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
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
The Opm property system, traits with inheritance.
The primary variable and equation indices for the three-phase black-oil model.
Definition: blackoilvariableandequationindices.hh:49
The type of the base class for all problems which use this model.
Definition: fvbaseproperties.hh:89
Scalar type
Definition: blackoilmodel.hh:235
Definition: blackoilproperties.hh:100
Scalar type
Definition: blackoilmodel.hh:249
Similarly to the energy equation, a scaling is applied to the urea equation in MICP.
Definition: blackoilproperties.hh:104
Enable surface volume scaling.
Definition: blackoilproperties.hh:59
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:124
Enable the ECL-blackoil extension for bioeffects (biofilm/MICP)
Definition: blackoilproperties.hh:83
Enable the ECL-blackoil extension for salt.
Definition: blackoilproperties.hh:67
Enable convective mixing?
Definition: multiphasebaseproperties.hh:99
Enable diffusive fluxes?
Definition: multiphasebaseproperties.hh:91
Enable the ECL-blackoil extension for disolution of gas into water.
Definition: blackoilproperties.hh:79
Enable dispersive fluxes?
Definition: multiphasebaseproperties.hh:95
Enable the ECL-blackoil extension for extended BO. ("Second gas" - alternative approach)
Definition: blackoilproperties.hh:47
Enable the ECL-blackoil extension for foam.
Definition: blackoilproperties.hh:63
Definition: blackoilproperties.hh:86
Enable the tracking polymer molecular weight tracking and related functionalities.
Definition: blackoilproperties.hh:55
Enable the ECL-blackoil extension for polymer.
Definition: blackoilproperties.hh:51
Enable the ECL-blackoil extension for salt precipitation.
Definition: blackoilproperties.hh:71
Enable the ECL-blackoil extension for solvents. ("Second gas")
Definition: blackoilproperties.hh:43
Enable the ECL-blackoil extension for water evaporation.
Definition: blackoilproperties.hh:75
Specifies who temperature is modeled by the simulator.
Definition: blackoilproperties.hh:108
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:163
GetPropType< TypeTag, Properties::Evaluation > Evaluation
Definition: blackoilmodel.hh:149
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: blackoilmodel.hh:148
BlackOilFluidSystem< Scalar > type
Definition: blackoilmodel.hh:150
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:51
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:138
The type of the local residual function.
Definition: fvbaseproperties.hh:99
The type of the model.
Definition: basicproperties.hh:92
Specifies the type of the actual Newton method.
Definition: newtonmethodproperties.hh:32
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:135
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:121
The discretization specific part of the intensive quantities.
Definition: fvbaseproperties.hh:147
The type tag for the black-oil problems.
Definition: blackoilmodel.hh:80
std::tuple< MultiPhaseBaseModel > InheritsFrom
Definition: blackoilmodel.hh:80