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> 70 template <
class TypeTag>
81 {
using InheritsFrom = std::tuple<MultiPhaseBaseModel>; };
86 template<
class TypeTag>
91 template<
class TypeTag>
96 template<
class TypeTag>
101 template<
class TypeTag>
106 template<
class TypeTag>
111 template<
class TypeTag>
116 template<
class TypeTag>
121 template<
class TypeTag>
126 template<
class TypeTag>
132 template<
class TypeTag>
137 template<
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>()>;
151 template<
class TypeTag>
157 using type = BlackOilFluidSystem<Scalar>;
161 template<
class TypeTag>
163 {
static constexpr
bool value =
false; };
165 template<
class TypeTag>
167 {
static constexpr
bool value =
false; };
169 template<
class TypeTag>
171 {
static constexpr
bool value =
false; };
173 template<
class TypeTag>
175 {
static constexpr
bool value =
false; };
177 template<
class TypeTag>
179 {
static constexpr
bool value =
false; };
181 template<
class TypeTag>
183 {
static constexpr
bool value =
false; };
185 template<
class TypeTag>
187 {
static constexpr
bool value =
false; };
189 template<
class TypeTag>
191 {
static constexpr
bool value =
false; };
193 template<
class TypeTag>
195 {
static constexpr
bool value =
false; };
197 template<
class TypeTag>
199 {
static constexpr
bool value =
false; };
201 template<
class TypeTag>
203 {
static constexpr EnergyModules value = EnergyModules::NoTemperature; };
206 template<
class TypeTag>
208 {
static constexpr
bool value =
false; };
211 template<
class TypeTag>
213 {
static constexpr
bool value =
false; };
215 template<
class TypeTag>
217 {
static constexpr
bool value =
false; };
219 template<
class TypeTag>
221 {
static constexpr
bool value =
false; };
223 template<
class TypeTag>
225 {
static constexpr
bool value =
false; };
233 template<
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);
247 template<
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);
262 template<
class TypeTag>
264 {
static constexpr
bool value =
false; };
333 template<
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>;
367 using DiffusionModule = BlackOilDiffusionModule<TypeTag, enableDiffusion>;
368 using DispersionModule = BlackOilDispersionModule<TypeTag, enableDispersion>;
369 using EnergyModule = BlackOilEnergyModule<TypeTag, energyModuleType>;
370 using ExtboModule = BlackOilExtboModule<TypeTag, enableExtbo>;
371 using PolymerModule = BlackOilPolymerModule<TypeTag, enablePolymer>;
372 using SolventModule = BlackOilSolventModule<TypeTag, enableSolvent>;
375 using LocalResidual = GetPropType<TypeTag, Properties::LocalResidual>;
377 explicit BlackOilModel(Simulator& simulator)
378 : ParentType(simulator)
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];
581 void setEqWeight(
unsigned eqIdx, Scalar value)
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);
682 using PVM_G =
typename PrimaryVariables::GasMeaning;
683 using PVM_W =
typename PrimaryVariables::WaterMeaning;
684 using PVM_P =
typename PrimaryVariables::PressureMeaning;
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>
730 void supplementInitialSolution_(PrimaryVariables& priVars,
731 const Context& context,
734 { updatePvtRegionIndex_(priVars, context, dofIdx, timeIdx); }
736 void registerOutputModules_()
738 ParentType::registerOutputModules_();
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_);
754 this->addOutputModule(std::make_unique<VtkBlackOilModule<TypeTag>>(this->simulator_));
755 this->addOutputModule(std::make_unique<VtkCompositionModule<TypeTag>>(this->simulator_));
757 if constexpr (enableDiffusion) {
758 this->addOutputModule(std::make_unique<VtkDiffusionModule<TypeTag>>(this->simulator_));
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>
772 void updatePvtRegionIndex_(PrimaryVariables& priVars,
773 const Context& context,
777 const unsigned regionIdx = context.problem().pvtRegionIndex(context, dofIdx, timeIdx);
778 priVars.setPvtRegionIndex(regionIdx);
784 #endif // OPM_BLACK_OIL_MODEL_HPP Definition: blackoilproperties.hh:86
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition: blackoilmodel.hh:700
Enable dispersive fluxes?
Definition: multiphasebaseproperties.hh:95
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
Base class for all problems which use the black-oil model.
The type of the base class for all problems which use this model.
Definition: fvbaseproperties.hh:90
The type of the local residual function.
Definition: fvbaseproperties.hh:100
Specifies the type of the actual Newton method.
Definition: fvbaseproblem.hh:54
Enable the ECL-blackoil extension for polymer.
Definition: blackoilproperties.hh:51
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkcompositionmodule.hpp:87
Enumerations used by the model.
Definition: multiphasebaseproperties.hh:51
Contains the quantities which are are constant within a finite volume in the black-oil model...
Similarly to the energy equation, a scaling is applied to the urea equation in MICP.
Definition: blackoilproperties.hh:104
Implements a boundary vector for the fully implicit black-oil model.
Scalar primaryVarWeight(unsigned globalDofIdx, unsigned pvIdx) const
Returns the relative weight of a primary variable for calculating relative errors.
Definition: blackoilmodel.hh:506
Enable the ECL-blackoil extension for disolution of gas into water.
Definition: blackoilproperties.hh:79
Enable the ECL-blackoil extension for water evaporation.
Definition: blackoilproperties.hh:75
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: blackoilmodel.hh:386
Contains the quantities which are are constant within a finite volume in the black-oil model...
Definition: blackoilintensivequantities.hh:67
std::string eqName(int eqIdx) const
Given an equation index, return a human readable name.
Definition: blackoilmodel.hh:468
Enable the ECL-blackoil extension for salt precipitation.
Definition: blackoilproperties.hh:71
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Contains classes extending the black-oil model.
Enable the ECL-blackoil extension for solvents. ("Second gas")
Definition: blackoilproperties.hh:43
The discretization specific part of the intensive quantities.
Definition: fvbaseproperties.hh:148
VTK output module for the black oil model's parameters.
static std::string name()
Definition: blackoilmodel.hh:420
Vector containing volumetric or areal rates of quantities.
Definition: fvbaseproperties.hh:122
Type of object for specifying boundary conditions.
Definition: fvbaseproperties.hh:125
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtkdiffusionmodule.hpp:88
The fluid systems including the information about the phases.
Definition: multiphasebaseproperties.hh:79
Declares the properties required by the black oil model.
Enable the ECL-blackoil extension for foam.
Definition: blackoilproperties.hh:63
Enable the ECL-blackoil extension for extended BO. ("Second gas" - alternative approach) ...
Definition: blackoilproperties.hh:47
This file contains the default flux module of the blackoil model.
The primary variable and equation indices for the three-phase black-oil model.
Definition: blackoilvariableandequationindices.hh:48
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:197
Calculates the local residual of the black oil model.
A newton solver which is specific to the black oil model.
Definition: blackoilnewtonmethod.hpp:63
Data required to calculate a flux over a face.
Definition: fvbaseproperties.hh:164
Specifies who temperature is modeled by the simulator.
Definition: blackoilproperties.hh:108
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
Enable the ECL-blackoil extension for bioeffects (biofilm/MICP)
Definition: blackoilproperties.hh:83
Calculates the local residual of the black oil model.
Definition: blackoillocalresidual.hh:50
The relative weight of the residual of the energy equation compared to the mass residuals.
Definition: blackoilproperties.hh:100
Implements a vector representing mass, molar or volumetric rates for the black oil model...
Provides a Darcy flux module for the blackoil model.
Definition: blackoildarcyfluxmodule.hh:48
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
Represents the primary variables used by the black-oil model.
This template class contains the data which is required to calculate the fluxes of the fluid phases o...
Definition: blackoilextensivequantities.hh:50
The secondary variables within a sub-control volume.
Definition: fvbaseproperties.hh:139
This template class contains the data which is required to calculate the fluxes of the fluid phases o...
Represents the primary variables used by the black-oil model.
Definition: blackoilprimaryvariables.hh:69
Specifies the relation used for velocity.
Definition: multiphasebaseproperties.hh:83
The type of the model.
Definition: basicproperties.hh:92
Scalar eqWeight(unsigned globalDofIdx, unsigned eqIdx) const
Returns the relative weight of an equation.
Definition: blackoilmodel.hh:570
Enable surface volume scaling.
Definition: blackoilproperties.hh:59
Implements a vector representing mass, molar or volumetric rates for the black oil model...
Definition: blackoilratevector.hh:56
The Opm property system, traits with inheritance.
The primary variable and equation indices for the three-phase black-oil model.
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
std::string primaryVarName(unsigned pvIdx) const
Given an primary variable index, return a human readable name.
Definition: blackoilmodel.hh:426
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkblackoilmodule.hpp:93
The primary variable and equation indices for the black-oil model.
Implements a boundary vector for the fully implicit black-oil model.
Definition: blackoilboundaryratevector.hh:54
A fully-implicit black-oil flow model.
Definition: blackoilmodel.hh:71
Enable the ECL-blackoil extension for salt.
Definition: blackoilproperties.hh:67
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:83
Definition: blackoilmodel.hh:75
A newton solver which is specific to the black oil model.
VTK output module for quantities which make sense for models which incorperate molecular diffusion...
Enable the tracking polymer molecular weight tracking and related functionalities.
Definition: blackoilproperties.hh:55
A vector of primary variables within a sub-control volume.
Definition: fvbaseproperties.hh:136
Enable diffusive fluxes?
Definition: multiphasebaseproperties.hh:91
VTK output module for the fluid composition.
Base class for all problems which use the black-oil model.
Definition: blackoilproblem.hh:42
Enable convective mixing?
Definition: multiphasebaseproperties.hh:99
The type tag for the black-oil problems.
Definition: blackoilmodel.hh:80
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:57