mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Use the Equil initializer directly
Do not relay on opm-core objects like phaseUsage and BlackoilState but instead use the initializer directly.
This commit is contained in:
parent
029de3542e
commit
5a9123c1b1
@ -36,9 +36,8 @@
|
|||||||
// the ordering of these includes matters. do not touch it if you're not prepared to deal
|
// the ordering of these includes matters. do not touch it if you're not prepared to deal
|
||||||
// with some trouble!
|
// with some trouble!
|
||||||
#include <dune/grid/cpgrid/GridHelpers.hpp>
|
#include <dune/grid/cpgrid/GridHelpers.hpp>
|
||||||
#include <opm/core/props/BlackoilPropertiesFromDeck.hpp>
|
|
||||||
#include <opm/core/simulator/initStateEquil.hpp>
|
#include <opm/core/simulator/initStateEquil.hpp>
|
||||||
#include <opm/core/simulator/BlackoilState.hpp>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -122,31 +121,13 @@ public:
|
|||||||
std::make_shared<Opm::EclMaterialLawManager<EquilTraits> >();
|
std::make_shared<Opm::EclMaterialLawManager<EquilTraits> >();
|
||||||
equilMaterialLawManager->initFromDeck(deck, eclState, compressedToCartesianEquilElemIdx);
|
equilMaterialLawManager->initFromDeck(deck, eclState, compressedToCartesianEquilElemIdx);
|
||||||
|
|
||||||
// create the data structures which are used by initStateEquil()
|
|
||||||
Opm::ParameterGroup tmpParam;
|
|
||||||
Opm::BlackoilPropertiesFromDeck opmBlackoilProps(
|
|
||||||
gridManager.deck(),
|
|
||||||
gridManager.eclState(),
|
|
||||||
equilMaterialLawManager,
|
|
||||||
Opm::UgGridHelpers::numCells(equilGrid),
|
|
||||||
Opm::UgGridHelpers::globalCell(equilGrid),
|
|
||||||
Opm::UgGridHelpers::cartDims(equilGrid),
|
|
||||||
tmpParam);
|
|
||||||
|
|
||||||
// initialize the boiler plate of opm-core the state structure.
|
Opm::EQUIL::DeckDependent::InitialStateComputer<FluidSystem> initialState(equilMaterialLawManager,
|
||||||
const auto opmPhaseUsage = opmBlackoilProps.phaseUsage();
|
gridManager.eclState(),
|
||||||
Opm::BlackoilState opmBlackoilState(numEquilElems,
|
equilGrid,
|
||||||
/*numFaces=*/0, // we don't care here
|
simulator.problem().gravity()[dimWorld - 1],
|
||||||
opmPhaseUsage.num_phases);
|
enableSwatinit);
|
||||||
|
|
||||||
// do the actual computation.
|
|
||||||
Opm::initStateEquil(equilGrid,
|
|
||||||
opmBlackoilProps,
|
|
||||||
gridManager.deck(),
|
|
||||||
gridManager.eclState(),
|
|
||||||
simulator.problem().gravity()[dimWorld - 1],
|
|
||||||
opmBlackoilState,
|
|
||||||
enableSwatinit);
|
|
||||||
|
|
||||||
std::vector<int> localToEquilIndex( numElems, -1 );
|
std::vector<int> localToEquilIndex( numElems, -1 );
|
||||||
for( unsigned int elemIdx = 0; elemIdx < numElems; ++elemIdx )
|
for( unsigned int elemIdx = 0; elemIdx < numElems; ++elemIdx )
|
||||||
@ -173,42 +154,18 @@ public:
|
|||||||
if (!FluidSystem::phaseIsActive(phaseIdx))
|
if (!FluidSystem::phaseIsActive(phaseIdx))
|
||||||
S = 0.0;
|
S = 0.0;
|
||||||
else {
|
else {
|
||||||
unsigned opmPhasePos = 10000;
|
S = initialState.saturation()[phaseIdx][equilElemIdx];
|
||||||
switch (phaseIdx) {
|
|
||||||
case oilPhaseIdx:
|
|
||||||
opmPhasePos = opmPhaseUsage.phase_pos[Opm::BlackoilPhases::Liquid];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case gasPhaseIdx:
|
|
||||||
opmPhasePos = opmPhaseUsage.phase_pos[Opm::BlackoilPhases::Vapour];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case waterPhaseIdx:
|
|
||||||
opmPhasePos = opmPhaseUsage.phase_pos[Opm::BlackoilPhases::Aqua];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
S = opmBlackoilState.saturation()[equilElemIdx*opmPhaseUsage.num_phases
|
|
||||||
+ opmPhasePos];
|
|
||||||
}
|
}
|
||||||
fluidState.setSaturation(phaseIdx, S);
|
fluidState.setSaturation(phaseIdx, S);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the temperature
|
// set the temperature
|
||||||
const auto& temperatureVector = opmBlackoilState.temperature();
|
|
||||||
Scalar T = FluidSystem::surfaceTemperature;
|
Scalar T = FluidSystem::surfaceTemperature;
|
||||||
if (!temperatureVector.empty())
|
|
||||||
T = temperatureVector[equilElemIdx];
|
|
||||||
fluidState.setTemperature(T);
|
fluidState.setTemperature(T);
|
||||||
|
|
||||||
// set the phase pressures. the Opm::BlackoilState only provides the oil
|
// set the phase pressures.
|
||||||
// phase pressure, so we need to calculate the other phases' pressures
|
|
||||||
// ourselfs.
|
|
||||||
Dune::FieldVector< Scalar, numPhases > pC( 0 );
|
|
||||||
const auto& matParams = simulator.problem().materialLawParams(elemIdx);
|
|
||||||
MaterialLaw::capillaryPressures(pC, matParams, fluidState);
|
|
||||||
Scalar po = opmBlackoilState.pressure()[equilElemIdx];
|
|
||||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||||
fluidState.setPressure(phaseIdx, po + (pC[phaseIdx] - pC[oilPhaseIdx]));
|
fluidState.setPressure(phaseIdx, initialState.press()[phaseIdx][equilElemIdx]);
|
||||||
|
|
||||||
// reset the phase compositions
|
// reset the phase compositions
|
||||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
||||||
@ -222,7 +179,7 @@ public:
|
|||||||
if (FluidSystem::enableDissolvedGas()) {
|
if (FluidSystem::enableDissolvedGas()) {
|
||||||
// for gas and oil we have to translate surface volumes to mole fractions
|
// for gas and oil we have to translate surface volumes to mole fractions
|
||||||
// before we can set the composition in the fluid state
|
// before we can set the composition in the fluid state
|
||||||
Scalar Rs = opmBlackoilState.gasoilratio()[equilElemIdx];
|
Scalar Rs = initialState.rs()[equilElemIdx];
|
||||||
Scalar RsSat = FluidSystem::saturatedDissolutionFactor(fluidState, oilPhaseIdx, regionIdx);
|
Scalar RsSat = FluidSystem::saturatedDissolutionFactor(fluidState, oilPhaseIdx, regionIdx);
|
||||||
|
|
||||||
if (Rs > RsSat)
|
if (Rs > RsSat)
|
||||||
@ -238,7 +195,7 @@ public:
|
|||||||
|
|
||||||
// retrieve the surface volume of vaporized gas
|
// retrieve the surface volume of vaporized gas
|
||||||
if (FluidSystem::enableVaporizedOil()) {
|
if (FluidSystem::enableVaporizedOil()) {
|
||||||
Scalar Rv = opmBlackoilState.rv()[equilElemIdx];
|
Scalar Rv = initialState.rv()[equilElemIdx];
|
||||||
Scalar RvSat = FluidSystem::saturatedDissolutionFactor(fluidState, gasPhaseIdx, regionIdx);
|
Scalar RvSat = FluidSystem::saturatedDissolutionFactor(fluidState, gasPhaseIdx, regionIdx);
|
||||||
|
|
||||||
if (Rv > RvSat)
|
if (Rv > RvSat)
|
||||||
|
Loading…
Reference in New Issue
Block a user