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> 57 template <
class TypeTag>
67 enum { numPhases = FluidSystem::numPhases };
68 enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
69 enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
70 enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
72 enum { numComponents = FluidSystem::numComponents };
73 enum { oilCompIdx = FluidSystem::oilCompIdx };
74 enum { gasCompIdx = FluidSystem::gasCompIdx };
75 enum { waterCompIdx = FluidSystem::waterCompIdx };
77 enum { dimWorld = GridView::dimensionworld };
78 static constexpr
bool enableDissolution =
79 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
80 static constexpr
bool enableBrine = getPropValue<TypeTag, Properties::EnableBrine>();
81 enum { enableVapwat = getPropValue<TypeTag, Properties::EnableVapwat>() };
82 enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
83 enum { enableDisgasInWater = getPropValue<TypeTag, Properties::EnableDisgasInWater>() };
84 static constexpr
bool enableDissolvedGas =
85 Indices::compositionSwitchIdx != std::numeric_limits<unsigned>::max();
86 static constexpr
bool enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>();
87 static constexpr EnergyModules energyModuleType = getPropValue<TypeTag, Properties::EnergyModuleType>();
92 using ScalarFluidState = BlackOilFluidState<Scalar,
94 energyModuleType != EnergyModules::NoTemperature,
95 energyModuleType == EnergyModules::FullyImplicitThermal,
99 enableSaltPrecipitation,
105 template <
class EclMaterialLawManager>
107 EclMaterialLawManager& materialLawManager)
108 : simulator_(simulator)
110 const auto& vanguard = simulator.vanguard();
111 const auto& eclState = vanguard.eclState();
113 unsigned numElems = vanguard.grid().size(0);
121 CartesianIndexMapper>;
123 Initializer initialState(materialLawManager,
127 vanguard.cartesianMapper(),
128 simulator.problem().gravity()[dimWorld - 1],
129 simulator.problem().numPressurePointsEquil());
132 initialFluidStates_.resize(numElems);
133 for (
unsigned int elemIdx = 0; elemIdx < numElems; ++elemIdx) {
134 auto& fluidState = initialFluidStates_[elemIdx];
137 unsigned regionIdx = simulator_.problem().pvtRegionIndex(elemIdx);
138 fluidState.setPvtRegionIndex(regionIdx);
141 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
142 if (FluidSystem::phaseIsActive(phaseIdx))
143 fluidState.setSaturation(phaseIdx, initialState.saturation()[phaseIdx][elemIdx]);
144 else if (Indices::numPhases == 3)
145 fluidState.setSaturation(phaseIdx, 0.0);
148 if constexpr (enableDissolvedGas) {
149 if (FluidSystem::enableDissolvedGas())
150 fluidState.setRs(initialState.rs()[elemIdx]);
151 else if (Indices::gasEnabled && Indices::oilEnabled)
152 fluidState.setRs(0.0);
153 if (FluidSystem::enableVaporizedOil())
154 fluidState.setRv(initialState.rv()[elemIdx]);
155 else if (Indices::gasEnabled && Indices::oilEnabled)
156 fluidState.setRv(0.0);
159 if constexpr (enableVapwat) {
160 if (FluidSystem::enableVaporizedWater())
161 fluidState.setRvw(initialState.rvw()[elemIdx]);
165 if constexpr (energyModuleType != EnergyModules::NoTemperature)
166 fluidState.setTemperature(initialState.temperature()[elemIdx]);
169 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
170 if (!FluidSystem::phaseIsActive(phaseIdx))
172 fluidState.setPressure(phaseIdx, initialState.press()[phaseIdx][elemIdx]);
174 const auto& b = FluidSystem::inverseFormationVolumeFactor(fluidState, phaseIdx, regionIdx);
175 fluidState.setInvB(phaseIdx, b);
177 const auto& rho = FluidSystem::density(fluidState, phaseIdx, regionIdx);
178 fluidState.setDensity(phaseIdx, rho);
180 if constexpr (energyModuleType == EnergyModules::FullyImplicitThermal) {
181 const auto& h = FluidSystem::enthalpy(fluidState, phaseIdx, regionIdx);
182 fluidState.setEnthalpy(phaseIdx, h);
187 if constexpr (enableBrine)
188 fluidState.setSaltConcentration(initialState.saltConcentration()[elemIdx]);
191 if constexpr (enableSaltPrecipitation)
192 fluidState.setSaltSaturation(initialState.saltSaturation()[elemIdx]);
204 return initialFluidStates_[elemIdx];
210 std::vector<ScalarFluidState> initialFluidStates_;
214 #endif // OPM_EQUIL_INITIALIZER_HPP 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
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
const ScalarFluidState & initialFluidState(unsigned elemIdx) const
Return the initial thermodynamic state which should be used as the initial condition.
Definition: EquilInitializer.hpp:202
Definition: InitStateEquil.hpp:703
Declares the properties required by the black oil model.
Declare the properties used by the infrastructure code of the finite volume discretizations.
Computes the initial condition based on the EQUIL keyword from ECL.
Definition: EquilInitializer.hpp:58
The Opm property system, traits with inheritance.
Routines that actually solve the ODEs that emerge from the hydrostatic equilibrium problem...
Definition: CollectDataOnIORank.hpp:50
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:83