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>
74template <
class TypeTag>
79namespace Opm::Properties {
85{
using InheritsFrom = std::tuple<VtkBlackOilPolymer, MultiPhaseBaseModel>; };
89template<
class TypeTag>
94template<
class TypeTag>
99template<
class TypeTag>
104template<
class TypeTag>
109template<
class TypeTag>
114template<
class TypeTag>
119template<
class TypeTag>
124template<
class TypeTag>
129template<
class TypeTag>
135template<
class TypeTag>
140template<
class TypeTag>
154template<
class TypeTag>
160 using type = BlackOilFluidSystem<Scalar>;
164template<
class TypeTag>
166{
static constexpr bool value =
false; };
168template<
class TypeTag>
170{
static constexpr bool value =
false; };
172template<
class TypeTag>
174{
static constexpr bool value =
false; };
176template<
class TypeTag>
178{
static constexpr bool value =
false; };
180template<
class TypeTag>
182{
static constexpr bool value =
false; };
184template<
class TypeTag>
186{
static constexpr bool value =
false; };
188template<
class TypeTag>
190{
static constexpr bool value =
false; };
192template<
class TypeTag>
194{
static constexpr bool value =
false; };
196template<
class TypeTag>
198{
static constexpr bool value =
false; };
200template<
class TypeTag>
202{
static constexpr bool value =
false; };
205template<
class TypeTag>
207{
static constexpr bool value =
false; };
209template<
class TypeTag>
211{
static constexpr bool value =
false; };
214template<
class TypeTag>
216{
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 =
243 static constexpr Scalar value = 1.0/(30.0*4184.0*alpha);
247template<
class TypeTag>
252 static constexpr Scalar alpha =
257 static constexpr Scalar value = 1.0/(10.0*alpha);
262template<
class TypeTag>
264{
static constexpr bool value =
false; };
333template<
class TypeTag >
335 :
public MultiPhaseBaseModel<TypeTag>
344 using ParentType = MultiPhaseBaseModel<TypeTag>;
351 enum { numComponents = FluidSystem::numComponents };
356 static constexpr bool compositionSwitchEnabled = Indices::compositionSwitchIdx >= 0;
357 static constexpr bool waterEnabled = Indices::waterEnabled;
370 explicit BlackOilModel(Simulator& simulator)
371 : ParentType(simulator)
373 eqWeights_.resize(numEq, 1.0);
387 DiffusionModule::registerParameters();
400 {
return "blackoil"; }
407 if (pvIdx == Indices::waterSwitchIdx) {
408 return "water_switching";
410 else if (pvIdx == Indices::pressureSwitchIdx) {
411 return "pressure_switching";
413 else if (
static_cast<int>(pvIdx) == Indices::compositionSwitchIdx) {
414 return "composition_switching";
416 else if (SolventModule::primaryVarApplies(pvIdx)) {
417 return SolventModule::primaryVarName(pvIdx);
419 else if (ExtboModule::primaryVarApplies(pvIdx)) {
420 return ExtboModule::primaryVarName(pvIdx);
422 else if (PolymerModule::primaryVarApplies(pvIdx)) {
423 return PolymerModule::primaryVarName(pvIdx);
425 else if (EnergyModule::primaryVarApplies(pvIdx)) {
426 return EnergyModule::primaryVarName(pvIdx);
429 throw std::logic_error(
"Invalid primary variable index");
438 if (Indices::conti0EqIdx <= eqIdx && eqIdx < Indices::conti0EqIdx + numComponents) {
439 std::ostringstream oss;
440 oss <<
"conti_" << FluidSystem::phaseName(eqIdx - Indices::conti0EqIdx);
443 else if (SolventModule::eqApplies(eqIdx)) {
444 return SolventModule::eqName(eqIdx);
446 else if (ExtboModule::eqApplies(eqIdx)) {
447 return ExtboModule::eqName(eqIdx);
449 else if (PolymerModule::eqApplies(eqIdx)) {
450 return PolymerModule::eqName(eqIdx);
452 else if (EnergyModule::eqApplies(eqIdx)) {
453 return EnergyModule::eqName(eqIdx);
456 throw std::logic_error(
"Invalid equation index");
467 if (globalDofIdx >= this->numGridDof()) {
472 if (
int(Indices::waterSwitchIdx) ==
int(pvIdx)) {
478 else if (
int(Indices::pressureSwitchIdx) ==
int(pvIdx)) {
483 else if (SolventModule::primaryVarApplies(pvIdx)) {
484 return SolventModule::primaryVarWeight(pvIdx);
488 else if (ExtboModule::primaryVarApplies(pvIdx)) {
489 return ExtboModule::primaryVarWeight(pvIdx);
493 else if (PolymerModule::primaryVarApplies(pvIdx)) {
494 return PolymerModule::primaryVarWeight(pvIdx);
498 else if (EnergyModule::primaryVarApplies(pvIdx)) {
499 return EnergyModule::primaryVarWeight(pvIdx);
503 assert(
int(Indices::compositionSwitchIdx) ==
int(pvIdx));
505 switch (this->solution(0)[globalDofIdx].primaryVarsMeaningGas()) {
506 case PrimaryVariables::GasMeaning::Sg:
return 1.0;
507 case PrimaryVariables::GasMeaning::Rs:
return 1.0 / 250.;
508 case PrimaryVariables::GasMeaning::Rv:
return 1.0 / 0.025;
509 default:
throw std::logic_error(
"Invalid primary variable meaning flag for gas");
519 Scalar
eqWeight(
unsigned globalDofIdx,
unsigned eqIdx)
const
523 if (globalDofIdx >= this->numGridDof()) {
527 return eqWeights_[eqIdx];
530 void setEqWeight(
unsigned eqIdx, Scalar value)
531 { eqWeights_[eqIdx] = value; }
541 template <
class DofEntity>
544 const unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
547 if (!outstream.good()) {
548 throw std::runtime_error(
"Could not serialize degree of freedom " + std::to_string(dofIdx));
552 const auto& priVars = this->solution(0)[dofIdx];
553 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
554 outstream << priVars[eqIdx] <<
" ";
558 outstream << static_cast<int>(priVars.primaryVarsMeaningGas()) <<
" ";
559 outstream << static_cast<int>(priVars.primaryVarsMeaningWater()) <<
" ";
560 outstream << static_cast<int>(priVars.primaryVarsMeaningPressure()) <<
" ";
562 outstream << priVars.pvtRegionIndex() <<
" ";
564 SolventModule::serializeEntity(asImp_(), outstream, dof);
565 ExtboModule::serializeEntity(asImp_(), outstream, dof);
566 PolymerModule::serializeEntity(asImp_(), outstream, dof);
567 EnergyModule::serializeEntity(asImp_(), outstream, dof);
578 template <
class DofEntity>
580 const DofEntity& dof)
582 const unsigned dofIdx =
static_cast<unsigned>(asImp_().dofMapper().index(dof));
585 auto& priVars = this->solution(0)[dofIdx];
586 for (
unsigned eqIdx = 0; eqIdx < numEq; ++eqIdx) {
587 if (!instream.good()) {
588 throw std::runtime_error(
"Could not deserialize degree of freedom " + std::to_string(dofIdx));
590 instream >> priVars[eqIdx];
594 unsigned primaryVarsMeaningGas;
595 instream >> primaryVarsMeaningGas;
597 unsigned primaryVarsMeaningWater;
598 instream >> primaryVarsMeaningWater;
600 unsigned primaryVarsMeaningPressure;
601 instream >> primaryVarsMeaningPressure;
603 unsigned pvtRegionIdx;
604 instream >> pvtRegionIdx;
606 if (!instream.good()) {
607 throw std::runtime_error(
"Could not deserialize degree of freedom " + std::to_string(dofIdx));
610 SolventModule::deserializeEntity(asImp_(), instream, dof);
611 ExtboModule::deserializeEntity(asImp_(), instream, dof);
612 PolymerModule::deserializeEntity(asImp_(), instream, dof);
613 EnergyModule::deserializeEntity(asImp_(), instream, dof);
615 using PVM_G =
typename PrimaryVariables::GasMeaning;
616 using PVM_W =
typename PrimaryVariables::WaterMeaning;
617 using PVM_P =
typename PrimaryVariables::PressureMeaning;
618 priVars.setPrimaryVarsMeaningGas(
static_cast<PVM_G
>(primaryVarsMeaningGas));
619 priVars.setPrimaryVarsMeaningWater(
static_cast<PVM_W
>(primaryVarsMeaningWater));
620 priVars.setPrimaryVarsMeaningPressure(
static_cast<PVM_P
>(primaryVarsMeaningPressure));
622 priVars.setPvtRegionIndex(pvtRegionIdx);
632 template <
class Restarter>
635 ParentType::deserialize(res);
640 ElementContext elemCtx(this->simulator_);
641 for (
const auto& elem : elements(this->gridView())) {
642 elemCtx.updateStencil(elem);
643 for (
unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(0); ++dofIdx) {
644 const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, 0);
645 updatePvtRegionIndex_(this->solution(0)[globalDofIdx],
652 this->solution(1) = this->solution(0);
662 template <
class Context>
663 void supplementInitialSolution_(PrimaryVariables& priVars,
664 const Context& context,
667 { updatePvtRegionIndex_(priVars, context, dofIdx, timeIdx); }
669 void registerOutputModules_()
671 ParentType::registerOutputModules_();
679 this->addOutputModule(std::make_unique<VtkBlackOilModule<TypeTag>>(this->simulator_));
680 this->addOutputModule(std::make_unique<VtkCompositionModule<TypeTag>>(this->simulator_));
682 if constexpr (enableDiffusion) {
683 this->addOutputModule(std::make_unique<VtkDiffusionModule<TypeTag>>(this->simulator_));
688 std::vector<Scalar> eqWeights_;
690 Implementation& asImp_()
691 {
return *
static_cast<Implementation*
>(
this); }
693 const Implementation& asImp_()
const
694 {
return *
static_cast<const Implementation*
>(
this); }
696 template <
class Context>
697 void updatePvtRegionIndex_(PrimaryVariables& priVars,
698 const Context& context,
702 const unsigned regionIdx = context.problem().pvtRegionIndex(context, dofIdx, timeIdx);
703 priVars.setPvtRegionIndex(regionIdx);
Contains the classes required to extend the black-oil model by bioeffects.
Implements a boundary vector for the fully implicit black-oil model.
Contains the classes required to extend the black-oil model by brine.
This file contains the default flux module of the blackoil model.
Classes required for molecular diffusion.
Classes required for mechanical dispersion.
Contains the classes required to extend the black-oil model by solvent component.
This template class contains the data which is required to calculate the fluxes of the fluid phases o...
Contains the classes required to extend the black-oil model to include the effects of foam.
Contains the quantities which are are constant within a finite volume in the black-oil model.
Calculates the local residual of the black oil model.
A newton solver which is specific to the black oil model.
Contains the classes required to extend the black-oil model by polymer.
Represents the primary variables used by the black-oil model.
Base class for all problems which use the black-oil model.
Declares the properties required by the black oil model.
Implements a vector representing mass, molar or volumetric rates for the black oil model.
Contains the classes required to extend the black-oil model by solvents.
The primary variable and equation indices for the black-oil model.
The primary variable and equation indices for the three-phase black-oil model.
Contains the high level supplements required to extend the black oil model by bioeffects.
Definition blackoilbioeffectsmodules.hh:93
static void registerParameters()
Register all run-time parameters for the black-oil bioeffects module.
Definition blackoilbioeffectsmodules.hh:139
static void registerOutputModules(Model &model, Simulator &simulator)
Register all bioeffects specific VTK and ECL output modules.
Definition blackoilbioeffectsmodules.hh:148
Implements a boundary vector for the fully implicit black-oil model.
Definition blackoilboundaryratevector.hh:48
Provides the auxiliary methods required for consideration of the diffusion equation.
Definition blackoildiffusionmodule.hh:50
Provides the auxiliary methods required for consideration of the dispersion equation.
Definition blackoildispersionmodule.hh:58
Contains the high level supplements required to extend the black oil model by energy.
Definition blackoilenergymodules.hh:58
static void registerParameters()
Register all run-time parameters for the black-oil energy module.
Definition blackoilenergymodules.hh:84
static void registerOutputModules(Model &model, Simulator &simulator)
Register all energy specific VTK and ECL output modules.
Definition blackoilenergymodules.hh:94
Contains the high level supplements required to extend the black oil model.
Definition blackoilextbomodules.hh:62
static void registerParameters()
Register all run-time parameters for the black-oil solvent module.
Definition blackoilextbomodules.hh:95
This template class contains the data which is required to calculate the fluxes of the fluid phases o...
Definition blackoilextensivequantities.hh:59
Contains the quantities which are are constant within a finite volume in the black-oil model.
Definition blackoilintensivequantities.hh:85
Calculates the local residual of the black oil model.
Definition blackoillocalresidual.hh:56
A fully-implicit black-oil flow model.
Definition blackoilmodel.hh:336
std::string primaryVarName(int pvIdx) const
Given an primary variable index, return a human readable name.
Definition blackoilmodel.hh:405
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition blackoilmodel.hh:463
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition blackoilmodel.hh:519
void serializeEntity(std::ostream &outstream, const DofEntity &dof)
Write the current solution for a degree of freedom to a restart file.
Definition blackoilmodel.hh:542
std::string eqName(int eqIdx) const
Given an equation index, return a human readable name.
Definition blackoilmodel.hh:436
static std::string name()
Definition blackoilmodel.hh:399
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:579
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition blackoilmodel.hh:379
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition blackoilmodel.hh:633
A newton solver which is specific to the black oil model.
Definition blackoilnewtonmethod.hpp:61
Contains the high level supplements required to extend the black oil model by polymer.
Definition blackoilpolymermodules.hh:64
static void registerParameters()
Register all run-time parameters for the black-oil polymer module.
Definition blackoilpolymermodules.hh:146
static void registerOutputModules(Model &model, Simulator &simulator)
Register all polymer specific VTK and ECL output modules.
Definition blackoilpolymermodules.hh:156
Represents the primary variables used by the black-oil model.
Definition blackoilprimaryvariables.hh:68
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:62
Contains the high level supplements required to extend the black oil model by solvents.
Definition blackoilsolventmodules.hh:68
static void registerOutputModules(Model &model, Simulator &simulator)
Register all solvent specific VTK and ECL output modules.
Definition blackoilsolventmodules.hh:124
static void registerParameters()
Register all run-time parameters for the black-oil solvent module.
Definition blackoilsolventmodules.hh:114
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition multiphasebasemodel.hh:190
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition vtkblackoilmodule.hpp:93
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkcompositionmodule.hpp:87
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtkdiffusionmodule.hpp:88
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
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
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
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:47
The type of the base class for all problems which use this model.
Definition fvbaseproperties.hh:84
The relative weight of the residual of the energy equation compared to the mass residuals.
Definition blackoilproperties.hh:101
Similarly to the energy equation, a scaling is applied to the urea equation in MICP.
Definition blackoilproperties.hh:105
Enable surface volume scaling.
Definition blackoilproperties.hh:59
Type of object for specifying boundary conditions.
Definition fvbaseproperties.hh:119
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
Specify whether energy should be considered as a conservation quantity or not.
Definition multiphasebaseproperties.hh:87
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
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
Allow the spatial and temporal domains to exhibit non-constant temperature in the black-oil model.
Definition blackoilproperties.hh:88
Enable the ECL-blackoil extension for water evaporation.
Definition blackoilproperties.hh:75
Data required to calculate a flux over a face.
Definition fvbaseproperties.hh:149
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:133
The type of the local residual function.
Definition fvbaseproperties.hh:94
The type of the model.
Definition basicproperties.hh:88
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:130
Vector containing volumetric or areal rates of quantities.
Definition fvbaseproperties.hh:116
The type tag for the black-oil problems.
Definition blackoilmodel.hh:85
VTK output module for the black oil model's parameters.
VTK output module for the fluid composition.
VTK output module for quantities which make sense for models which incorperate molecular diffusion.