28#ifndef OPM_EQUIL_INITIALIZER_HPP
29#define OPM_EQUIL_INITIALIZER_HPP
31#include <opm/grid/common/CartesianIndexMapper.hpp>
33#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
34#include <opm/material/fluidstates/BlackOilFluidState.hpp>
56template <
class TypeTag>
66 enum { numPhases = FluidSystem::numPhases };
67 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
68 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
69 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
71 enum { numComponents = FluidSystem::numComponents };
72 enum { oilCompIdx = FluidSystem::oilCompIdx };
73 enum { gasCompIdx = FluidSystem::gasCompIdx };
74 enum { waterCompIdx = FluidSystem::waterCompIdx };
76 enum { dimWorld = GridView::dimensionworld };
77 enum { enableTemperature = getPropValue<TypeTag, Properties::EnableTemperature>() };
78 enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
79 enum { enableDissolution = Indices::compositionSwitchIdx >= 0 };
80 enum { enableBrine = getPropValue<TypeTag, Properties::EnableBrine>() };
81 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
82 enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
83 enum { has_disgas_in_water = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
96 enableSaltPrecipitation,
101 template <
class EclMaterialLawManager>
103 EclMaterialLawManager& materialLawManager)
106 const auto& vanguard = simulator.vanguard();
107 const auto& eclState = vanguard.eclState();
109 unsigned numElems = vanguard.grid().size(0);
117 CartesianIndexMapper>;
119 Initializer initialState(materialLawManager,
123 vanguard.cartesianMapper(),
124 simulator.problem().gravity()[dimWorld - 1],
125 simulator.problem().numPressurePointsEquil());
129 for (
unsigned int elemIdx = 0; elemIdx < numElems; ++elemIdx) {
133 unsigned regionIdx =
simulator_.problem().pvtRegionIndex(elemIdx);
134 fluidState.setPvtRegionIndex(regionIdx);
137 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
138 if (FluidSystem::phaseIsActive(phaseIdx))
139 fluidState.setSaturation(phaseIdx, initialState.saturation()[phaseIdx][elemIdx]);
140 else if (Indices::numPhases == 3)
141 fluidState.setSaturation(phaseIdx, 0.0);
144 if (FluidSystem::enableDissolvedGas())
145 fluidState.setRs(initialState.rs()[elemIdx]);
146 else if (Indices::gasEnabled && Indices::oilEnabled)
147 fluidState.setRs(0.0);
149 if (FluidSystem::enableVaporizedOil())
150 fluidState.setRv(initialState.rv()[elemIdx]);
151 else if (Indices::gasEnabled && Indices::oilEnabled)
152 fluidState.setRv(0.0);
154 if (FluidSystem::enableVaporizedWater())
155 fluidState.setRvw(initialState.rvw()[elemIdx]);
158 if (enableTemperature || enableEnergy)
159 fluidState.setTemperature(initialState.temperature()[elemIdx]);
162 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
163 if (!FluidSystem::phaseIsActive(phaseIdx))
165 fluidState.setPressure(phaseIdx, initialState.press()[phaseIdx][elemIdx]);
167 const auto& b = FluidSystem::inverseFormationVolumeFactor(fluidState, phaseIdx, regionIdx);
168 fluidState.setInvB(phaseIdx, b);
170 const auto& rho = FluidSystem::density(fluidState, phaseIdx, regionIdx);
171 fluidState.setDensity(phaseIdx, rho);
174 const auto& h = FluidSystem::enthalpy(fluidState, phaseIdx, regionIdx);
175 fluidState.setEnthalpy(phaseIdx, h);
180 if constexpr (enableBrine)
181 fluidState.setSaltConcentration(initialState.saltConcentration()[elemIdx]);
184 if constexpr (enableSaltPrecipitation)
185 fluidState.setSaltSaturation(initialState.saltSaturation()[elemIdx]);
Routines that actually solve the ODEs that emerge from the hydrostatic equilibrium problem.
Declares the properties required by the black oil model.
Definition: CollectDataOnIORank.hpp:49
Definition: InitStateEquil.hpp:691
Computes the initial condition based on the EQUIL keyword from ECL.
Definition: EquilInitializer.hpp:58
EquilInitializer(const Simulator &simulator, EclMaterialLawManager &materialLawManager)
Definition: EquilInitializer.hpp:102
const Simulator & simulator_
Definition: EquilInitializer.hpp:201
std::vector< ScalarFluidState > initialFluidStates_
Definition: EquilInitializer.hpp:203
const ScalarFluidState & initialFluidState(unsigned elemIdx) const
Return the initial thermodynamic state which should be used as the initial condition.
Definition: EquilInitializer.hpp:195
BlackOilFluidState< Scalar, FluidSystem, enableTemperature, enableEnergy, enableDissolution, enableVapwat, enableBrine, enableSaltPrecipitation, has_disgas_in_water, Indices::numPhases > ScalarFluidState
Definition: EquilInitializer.hpp:98
Declare the properties used by the infrastructure code of the finite volume discretizations.
Definition: blackoilboundaryratevector.hh:37
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:235
The Opm property system, traits with inheritance.