28#ifndef EWOMS_BLACK_OIL_BOUNDARY_RATE_VECTOR_HH
29#define EWOMS_BLACK_OIL_BOUNDARY_RATE_VECTOR_HH
31#include <opm/material/common/Valgrind.hpp>
32#include <opm/material/constraintsolvers/NcpFlash.hpp>
53template <
class TypeTag>
65 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
66 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
67 static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>();
68 static constexpr bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
69 enum { enableFullyImplicitThermal = (getPropValue<TypeTag, Properties::EnergyModuleType>() == EnergyModules::FullyImplicitThermal) };
70 enum { contiEnergyEqIdx = Indices::contiEnergyEqIdx };
71 static constexpr bool enableFoam = getPropValue<TypeTag, Properties::EnableFoam>();
72 enum { enableMICP = Indices::enableMICP };
74 static constexpr bool blackoilConserveSurfaceVolume =
75 getPropValue<TypeTag, Properties::BlackoilConserveSurfaceVolume>();
77 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
101 template <
class Context,
class Flu
idState>
105 const FluidState& fluidState)
107 ExtensiveQuantities extQuants;
108 extQuants.updateBoundary(context, bfIdx, timeIdx, fluidState);
109 const auto& insideIntQuants = context.intensiveQuantities(bfIdx, timeIdx);
110 const unsigned focusDofIdx = context.focusDofIndex();
111 const unsigned interiorDofIdx = context.interiorScvIndex(bfIdx, timeIdx);
117 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
118 if (!FluidSystem::phaseIsActive(phaseIdx)) {
121 const auto& pBoundary = fluidState.pressure(phaseIdx);
122 const Evaluation& pInside = insideIntQuants.fluidState().pressure(phaseIdx);
127 if (pBoundary < pInside) {
129 LocalResidual::template evalPhaseFluxes_<Evaluation>(tmp,
131 insideIntQuants.pvtRegionIndex(),
133 insideIntQuants.fluidState());
135 else if (pBoundary > pInside) {
136 using RhsEval = std::conditional_t<std::is_same_v<typename FluidState::ValueType, Evaluation>,
139 LocalResidual::template evalPhaseFluxes_<RhsEval>(tmp,
141 insideIntQuants.pvtRegionIndex(),
146 for (
unsigned i = 0; i < tmp.size(); ++i) {
147 (*this)[i] += tmp[i];
151 if constexpr (enableFullyImplicitThermal) {
153 Evaluation specificEnthalpy;
154 if (pBoundary > pInside) {
155 if (focusDofIdx == interiorDofIdx) {
156 density = fluidState.density(phaseIdx);
157 specificEnthalpy = fluidState.enthalpy(phaseIdx);
160 density = getValue(fluidState.density(phaseIdx));
161 specificEnthalpy = getValue(fluidState.enthalpy(phaseIdx));
164 else if (focusDofIdx == interiorDofIdx) {
165 density = insideIntQuants.fluidState().density(phaseIdx);
166 specificEnthalpy = insideIntQuants.fluidState().enthalpy(phaseIdx);
169 density = getValue(insideIntQuants.fluidState().density(phaseIdx));
170 specificEnthalpy = getValue(insideIntQuants.fluidState().enthalpy(phaseIdx));
173 const Evaluation enthalpyRate = density * extQuants.volumeFlux(phaseIdx) * specificEnthalpy;
174 EnergyModule::addToEnthalpyRate(*
this, enthalpyRate *
175 getPropValue<TypeTag, Properties::BlackOilEnergyScalingFactor>());
179 if constexpr (enableSolvent) {
180 (*this)[Indices::contiSolventEqIdx] = extQuants.solventVolumeFlux();
181 if (blackoilConserveSurfaceVolume) {
182 (*this)[Indices::contiSolventEqIdx] *= insideIntQuants.solventInverseFormationVolumeFactor();
185 (*this)[Indices::contiSolventEqIdx] *= insideIntQuants.solventDensity();
189 if constexpr (enablePolymer) {
190 (*this)[Indices::contiPolymerEqIdx] = extQuants.volumeFlux(FluidSystem::waterPhaseIdx) *
191 insideIntQuants.polymerConcentration();
194 if constexpr (enableMICP) {
195 (*this)[Indices::contiMicrobialEqIdx] = extQuants.volumeFlux(FluidSystem::waterPhaseIdx) *
196 insideIntQuants.microbialConcentration();
197 (*this)[Indices::contiOxygenEqIdx] = extQuants.volumeFlux(FluidSystem::waterPhaseIdx) *
198 insideIntQuants.oxygenConcentration();
199 (*this)[Indices::contiUreaEqIdx] = extQuants.volumeFlux(FluidSystem::waterPhaseIdx) *
200 insideIntQuants.ureaConcentration();
202 (*this)[Indices::contiUreaEqIdx] *= getPropValue<TypeTag, Properties::BlackOilUreaScalingFactor>();
206 LocalResidual::adaptMassConservationQuantities_(*
this, insideIntQuants.pvtRegionIndex());
209 if constexpr (enableFullyImplicitThermal) {
210 EnergyModule::addToEnthalpyRate(*
this, extQuants.energyFlux() *
211 getPropValue<TypeTag, Properties::BlackOilEnergyScalingFactor>());
215 for (
unsigned i = 0; i < numEq; ++i) {
216 Valgrind::CheckDefined((*
this)[i]);
218 Valgrind::CheckDefined(*
this);
225 template <
class Context,
class Flu
idState>
229 const FluidState& fluidState)
231 this->
setFreeFlow(context, bfIdx, timeIdx, fluidState);
235 std::ranges::for_each(*
this,
236 [](
auto& val) { val = std::min(Scalar(0), val); });
242 template <
class Context,
class Flu
idState>
246 const FluidState& fluidState)
248 this->
setFreeFlow(context, bfIdx, timeIdx, fluidState);
252 std::ranges::for_each(*
this,
253 [](
auto& val) { val = std::max(Scalar(0), val); });
260 { (*this) = Scalar(0); }
269 template <
class Context,
class Flu
idState>
271 [[maybe_unused]]
unsigned bfIdx,
272 [[maybe_unused]]
unsigned timeIdx,
273 [[maybe_unused]]
const FluidState& boundaryFluidState)
279 if constexpr (enableFullyImplicitThermal) {
280 ExtensiveQuantities extQuants;
281 extQuants.updateBoundary(context, bfIdx, timeIdx, boundaryFluidState);
283 (*this)[contiEnergyEqIdx] += extQuants.energyFlux();
286 for (
unsigned i = 0; i < numEq; ++i) {
287 Valgrind::CheckDefined((*
this)[i]);
289 Valgrind::CheckDefined(*
this);
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
BlackOilBoundaryRateVector(Scalar value)
Definition: blackoilboundaryratevector.hh:89
void setOutFlow(const Context &context, unsigned bfIdx, unsigned timeIdx, const FluidState &fluidState)
Specify an outflow boundary.
Definition: blackoilboundaryratevector.hh:243
BlackOilBoundaryRateVector & operator=(const BlackOilBoundaryRateVector &value)=default
BlackOilBoundaryRateVector(const BlackOilBoundaryRateVector &value)=default
Copy constructor.
void setFreeFlow(const Context &context, unsigned bfIdx, unsigned timeIdx, const FluidState &fluidState)
Specify a free-flow boundary.
Definition: blackoilboundaryratevector.hh:102
BlackOilBoundaryRateVector()=default
Default constructor.
void setNoFlow()
Specify a no-flow boundary for all conserved quantities.
Definition: blackoilboundaryratevector.hh:259
void setInFlow(const Context &context, unsigned bfIdx, unsigned timeIdx, const FluidState &fluidState)
Specify an inflow boundary.
Definition: blackoilboundaryratevector.hh:226
void setThermalFlow(const Context &context, unsigned bfIdx, unsigned timeIdx, const FluidState &boundaryFluidState)
an energy flux that corresponds to the thermal conduction from
Definition: blackoilboundaryratevector.hh:270
Definition: blackoilmodules.hpp:63
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
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
The Opm property system, traits with inheritance.