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>
70template <
class TypeTag>
86template<
class TypeTag>
91template<
class TypeTag>
96template<
class TypeTag>
101template<
class TypeTag>
106template<
class TypeTag>
111template<
class TypeTag>
116template<
class TypeTag>
121template<
class TypeTag>
126template<
class TypeTag>
132template<
class TypeTag>
137template<
class TypeTag>
141 getPropValue<TypeTag, Properties::EnableExtbo>(),
142 getPropValue<TypeTag, Properties::EnablePolymer>(),
143 getPropValue<TypeTag, Properties::EnergyModuleType>() == EnergyModules::FullyImplicitThermal,
144 getPropValue<TypeTag, Properties::EnableFoam>(),
145 getPropValue<TypeTag, Properties::EnableBrine>(),
147 getPropValue<TypeTag, Properties::EnableBioeffects>()>;
151template<
class TypeTag>
157 using type = BlackOilFluidSystem<Scalar>;
161template<
class TypeTag>
163{
static constexpr bool value =
false; };
165template<
class TypeTag>
167{
static constexpr bool value =
false; };
169template<
class TypeTag>
171{
static constexpr bool value =
false; };
173template<
class TypeTag>
175{
static constexpr bool value =
false; };
177template<
class TypeTag>
179{
static constexpr bool value =
false; };
181template<
class TypeTag>
183{
static constexpr bool value =
false; };
185template<
class TypeTag>
187{
static constexpr bool value =
false; };
189template<
class TypeTag>
191{
static constexpr bool value =
false; };
193template<
class TypeTag>
195{
static constexpr bool value =
false; };
197template<
class TypeTag>
199{
static constexpr bool value =
false; };
201template<
class TypeTag>
203{
static constexpr EnergyModules value = EnergyModules::NoTemperature; };
206template<
class TypeTag>
208{
static constexpr bool value =
false; };
211template<
class TypeTag>
213{
static constexpr bool value =
false; };
215template<
class TypeTag>
217{
static constexpr bool value =
false; };
219template<
class TypeTag>
221{
static constexpr bool value =
false; };
223template<
class TypeTag>
225{
static constexpr bool value =
false; };
233template<
class TypeTag>
238 static constexpr Scalar alpha =
239 getPropValue<TypeTag, Properties::BlackoilConserveSurfaceVolume>() ? 1000.0 : 1.0;
243 static constexpr Scalar value = 1.0/(30.0*4184.0*alpha);
247template<
class TypeTag>
252 static constexpr Scalar alpha =
253 getPropValue<TypeTag, Properties::BlackoilConserveSurfaceVolume>() ? 1000.0 : 1.0;
257 static constexpr Scalar value = 1.0/(10.0*alpha);
262template<
class TypeTag>
264{
static constexpr bool value =
false; };
333template<
class TypeTag >
351 enum { numComponents = FluidSystem::numComponents };
352 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
354 static constexpr bool compositionSwitchEnabled =
355 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
356 static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>();
357 static constexpr bool enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>();
358 static constexpr bool enableDispersion = getPropValue<TypeTag, Properties::EnableDispersion>();
359 static constexpr bool enableExtbo = getPropValue<TypeTag, Properties::EnableExtbo>();
360 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
361 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
362 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
363 static constexpr bool enableFullyImplicitThermal = energyModuleType == EnergyModules::FullyImplicitThermal;
364 static constexpr bool waterEnabled = Indices::waterEnabled;
366 using BioeffectsModule = BlackOilBioeffectsModule<TypeTag, enableBioeffects>;
369 using EnergyModule = BlackOilEnergyModule<TypeTag, energyModuleType>;
370 using ExtboModule = BlackOilExtboModule<TypeTag, enableExtbo>;
371 using PolymerModule = BlackOilPolymerModule<TypeTag, enablePolymer>;
372 using SolventModule = BlackOilSolventModule<TypeTag, enableSolvent>;
380 eqWeights_.resize(numEq, 1.0);
390 if constexpr (enableSolvent) {
391 SolventModule::registerParameters();
393 if constexpr (enableExtbo) {
394 ExtboModule::registerParameters();
396 if constexpr (enablePolymer) {
397 PolymerModule::registerParameters();
399 if constexpr (enableFullyImplicitThermal) {
400 EnergyModule::registerParameters();
402 if constexpr (enableDiffusion) {
403 DiffusionModule::registerParameters();
405 if constexpr (enableBioeffects) {
406 BioeffectsModule::registerParameters();
412 if constexpr (enableDiffusion) {
421 {
return "blackoil"; }
428 if (pvIdx == Indices::waterSwitchIdx) {
429 return "water_switching";
431 else if (pvIdx == Indices::pressureSwitchIdx) {
432 return "pressure_switching";
434 else if (pvIdx == Indices::compositionSwitchIdx) {
435 return "composition_switching";
438 if constexpr (enableSolvent) {
439 if (SolventModule::primaryVarApplies(pvIdx)) {
440 return SolventModule::primaryVarName(pvIdx);
444 if constexpr (enableExtbo) {
445 if (ExtboModule::primaryVarApplies(pvIdx)) {
446 return ExtboModule::primaryVarName(pvIdx);
450 if constexpr (enablePolymer) {
451 if (PolymerModule::primaryVarApplies(pvIdx)) {
452 return PolymerModule::primaryVarName(pvIdx);
456 if constexpr (enableFullyImplicitThermal) {
457 if (EnergyModule::primaryVarApplies(pvIdx)) {
458 return EnergyModule::primaryVarName(pvIdx);
462 throw std::logic_error(
"Invalid primary variable index");
470 if (Indices::conti0EqIdx <= eqIdx && eqIdx < Indices::conti0EqIdx + numComponents) {
471 std::ostringstream oss;
472 oss <<
"conti_" << FluidSystem::phaseName(eqIdx - Indices::conti0EqIdx);
476 if constexpr (enableSolvent) {
477 if (SolventModule::eqApplies(eqIdx)) {
478 return SolventModule::eqName(eqIdx);
482 if constexpr (enableExtbo) {
483 if (ExtboModule::eqApplies(eqIdx)) {
484 return ExtboModule::eqName(eqIdx);
488 if constexpr (enablePolymer) {
489 if (PolymerModule::eqApplies(eqIdx)) {
490 return PolymerModule::eqName(eqIdx);
494 if constexpr (enableFullyImplicitThermal) {
495 if (EnergyModule::eqApplies(eqIdx)) {
496 return EnergyModule::eqName(eqIdx);
500 throw std::logic_error(
"Invalid equation index");
510 if (globalDofIdx >= this->numGridDof()) {
515 if (Indices::waterSwitchIdx == pvIdx) {
521 else if (
int(Indices::pressureSwitchIdx) ==
int(pvIdx)) {
526 if constexpr (enableSolvent) {
527 if (SolventModule::primaryVarApplies(pvIdx)) {
528 return SolventModule::primaryVarWeight(pvIdx);
533 if constexpr (enableExtbo) {
534 if (ExtboModule::primaryVarApplies(pvIdx)) {
535 return ExtboModule::primaryVarWeight(pvIdx);
540 if constexpr (enablePolymer) {
541 if (PolymerModule::primaryVarApplies(pvIdx)) {
542 return PolymerModule::primaryVarWeight(pvIdx);
547 if constexpr (enableFullyImplicitThermal) {
548 if (EnergyModule::primaryVarApplies(pvIdx)) {
549 return EnergyModule::primaryVarWeight(pvIdx);
554 assert(Indices::compositionSwitchIdx == pvIdx);
556 switch (this->solution(0)[globalDofIdx].primaryVarsMeaningGas()) {
557 case PrimaryVariables::GasMeaning::Sg:
return 1.0;
558 case PrimaryVariables::GasMeaning::Rs:
return 1.0 / 250.;
559 case PrimaryVariables::GasMeaning::Rv:
return 1.0 / 0.025;
560 default:
throw std::logic_error(
"Invalid primary variable meaning flag for gas");
570 Scalar
eqWeight(
unsigned globalDofIdx,
unsigned eqIdx)
const
574 if (globalDofIdx >= this->numGridDof()) {
578 return eqWeights_[eqIdx];
582 { eqWeights_[eqIdx] = value; }
592 template <
class DofEntity>
595 const unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
598 if (!outstream.good()) {
599 throw std::runtime_error(
"Could not serialize degree of freedom " +
std::to_string(dofIdx));
603 const auto& priVars = this->solution(0)[dofIdx];
604 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
605 outstream << priVars[eqIdx] <<
" ";
609 outstream << static_cast<int>(priVars.primaryVarsMeaningGas()) <<
" ";
610 outstream << static_cast<int>(priVars.primaryVarsMeaningWater()) <<
" ";
611 outstream << static_cast<int>(priVars.primaryVarsMeaningPressure()) <<
" ";
613 outstream << priVars.pvtRegionIndex() <<
" ";
615 if constexpr (enableSolvent) {
616 SolventModule::serializeEntity(asImp_(), outstream, dof);
618 if constexpr (enableExtbo) {
619 ExtboModule::serializeEntity(asImp_(), outstream, dof);
621 if constexpr (enablePolymer) {
622 PolymerModule::serializeEntity(asImp_(), outstream, dof);
624 if constexpr (enableFullyImplicitThermal) {
625 EnergyModule::serializeEntity(asImp_(), outstream, dof);
637 template <
class DofEntity>
639 const DofEntity& dof)
641 const unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
644 auto& priVars = this->solution(0)[dofIdx];
645 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
646 if (!instream.good()) {
647 throw std::runtime_error(
"Could not deserialize degree of freedom " +
std::to_string(dofIdx));
649 instream >> priVars[eqIdx];
653 unsigned primaryVarsMeaningGas;
654 instream >> primaryVarsMeaningGas;
656 unsigned primaryVarsMeaningWater;
657 instream >> primaryVarsMeaningWater;
659 unsigned primaryVarsMeaningPressure;
660 instream >> primaryVarsMeaningPressure;
662 unsigned pvtRegionIdx;
663 instream >> pvtRegionIdx;
665 if (!instream.good()) {
666 throw std::runtime_error(
"Could not deserialize degree of freedom " +
std::to_string(dofIdx));
669 if constexpr (enableSolvent) {
670 SolventModule::deserializeEntity(asImp_(), instream, dof);
672 if constexpr (enableExtbo) {
673 ExtboModule::deserializeEntity(asImp_(), instream, dof);
675 if constexpr (enablePolymer) {
676 PolymerModule::deserializeEntity(asImp_(), instream, dof);
678 if constexpr (enableFullyImplicitThermal) {
679 EnergyModule::deserializeEntity(asImp_(), instream, dof);
685 priVars.setPrimaryVarsMeaningGas(
static_cast<PVM_G
>(primaryVarsMeaningGas));
686 priVars.setPrimaryVarsMeaningWater(
static_cast<PVM_W
>(primaryVarsMeaningWater));
687 priVars.setPrimaryVarsMeaningPressure(
static_cast<PVM_P
>(primaryVarsMeaningPressure));
689 priVars.setPvtRegionIndex(pvtRegionIdx);
699 template <
class Restarter>
702 ParentType::deserialize(res);
707 ElementContext elemCtx(this->simulator_);
708 for (
const auto& elem : elements(this->gridView())) {
709 elemCtx.updateStencil(elem);
710 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
711 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
712 updatePvtRegionIndex_(this->solution(0)[globalDofIdx],
719 this->solution(1) = this->solution(0);
729 template <
class Context>
731 const Context& context,
734 { updatePvtRegionIndex_(priVars, context, dofIdx, timeIdx); }
741 if constexpr (enableSolvent) {
742 SolventModule::registerOutputModules(asImp_(), this->simulator_);
744 if constexpr (enablePolymer) {
745 PolymerModule::registerOutputModules(asImp_(), this->simulator_);
747 if constexpr (enableFullyImplicitThermal) {
748 EnergyModule::registerOutputModules(asImp_(), this->simulator_);
750 if constexpr (enableBioeffects) {
751 BioeffectsModule::registerOutputModules(asImp_(), this->simulator_);
757 if constexpr (enableDiffusion) {
763 std::vector<Scalar> eqWeights_;
765 Implementation& asImp_()
766 {
return *
static_cast<Implementation*
>(
this); }
768 const Implementation& asImp_()
const
769 {
return *
static_cast<const Implementation*
>(
this); }
771 template <
class Context>
773 const Context& context,
777 const unsigned regionIdx = context.problem().pvtRegionIndex(context, dofIdx, timeIdx);
778 priVars.setPvtRegionIndex(regionIdx);
This file contains the default flux module of the blackoil model.
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:336
GetPropType< TypeTag, Properties::PrimaryVariables > PrimaryVariables
Definition: blackoilmodel.hh:340
BlackOilModel(Simulator &simulator)
Definition: blackoilmodel.hh:377
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: blackoilmodel.hh:506
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition: blackoilmodel.hh:570
void supplementInitialSolution_(PrimaryVariables &priVars, const Context &context, unsigned dofIdx, unsigned timeIdx)
Definition: blackoilmodel.hh:730
void serializeEntity(std::ostream &outstream, const DofEntity &dof)
Write the current solution for a degree of freedom to a restart file.
Definition: blackoilmodel.hh:593
void registerOutputModules_()
Definition: blackoilmodel.hh:736
std::string eqName(int eqIdx) const
Given an equation index, return a human readable name.
Definition: blackoilmodel.hh:468
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: blackoilmodel.hh:339
static std::string name()
Definition: blackoilmodel.hh:420
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: blackoilmodel.hh:426
GetPropType< TypeTag, Properties::Indices > Indices
Definition: blackoilmodel.hh:338
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:638
GetPropType< TypeTag, Properties::LocalResidual > LocalResidual
Definition: blackoilmodel.hh:375
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: blackoilmodel.hh:386
void setEqWeight(unsigned eqIdx, Scalar value)
Definition: blackoilmodel.hh:581
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition: blackoilmodel.hh:700
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:175
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:197
void registerOutputModules_()
Definition: multiphasebasemodel.hh:273
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:75
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.
Provides a Darcy flux module for the blackoil model.
Definition: blackoildarcyfluxmodule.hh:49
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:90
Scalar type
Definition: blackoilmodel.hh:242
Definition: blackoilproperties.hh:100
Scalar type
Definition: blackoilmodel.hh:256
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:125
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:164
GetPropType< TypeTag, Properties::Evaluation > Evaluation
Definition: blackoilmodel.hh:156
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: blackoilmodel.hh:155
BlackOilFluidSystem< Scalar > type
Definition: blackoilmodel.hh:157
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
Specifies the relation used for velocity.
Definition: multiphasebaseproperties.hh:83
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:51
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:139
The type of the local residual function.
Definition: fvbaseproperties.hh:100
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:136
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:122
The discretization specific part of the intensive quantities.
Definition: fvbaseproperties.hh:148
The type tag for the black-oil problems.
Definition: blackoilmodel.hh:81
std::tuple< MultiPhaseBaseModel > InheritsFrom
Definition: blackoilmodel.hh:81