adapt to the recent opm-material API change w.r.t. the ParameterCache

this is necessary to allow non-trivial ParameterCache objects with
Local-AD evaluations. So far, the only fluid system in opm-material
which needs this is the Spe5 fluid system (which is unused by eWoms),
but sooner or later this change would have been required anyway.

Note that it is possible that this patch is errornous if Evaluation !=
Scalar for a fluid system that uses a non-trivial ParameterCache
object, but the errors should be relatively easy to fix...
This commit is contained in:
Andreas Lauser 2016-04-13 13:32:15 +02:00
parent 8a420748f5
commit b31ceff970
10 changed files with 26 additions and 35 deletions

View File

@ -43,8 +43,6 @@ class Co2InjectionFlash : public Opm::NcpFlash<Scalar, FluidSystem>
{ {
typedef Opm::NcpFlash<Scalar, FluidSystem> ParentType; typedef Opm::NcpFlash<Scalar, FluidSystem> ParentType;
typedef typename FluidSystem::ParameterCache ParameterCache;
enum { numPhases = FluidSystem::numPhases }; enum { numPhases = FluidSystem::numPhases };
public: public:
@ -52,18 +50,14 @@ public:
* \brief Guess initial values for all quantities. * \brief Guess initial values for all quantities.
*/ */
template <class FluidState, class ComponentVector> template <class FluidState, class ComponentVector>
static void guessInitial(FluidState &fluidState, ParameterCache &paramCache, static void guessInitial(FluidState &fluidState, const ComponentVector &globalMolarities)
const ComponentVector &globalMolarities)
{ {
ParentType::guessInitial(fluidState, paramCache, globalMolarities); ParentType::guessInitial(fluidState, globalMolarities);
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
// pressure. something close to the reservoid pressure as initial // pressure. use something close to the reservoir pressure as initial guess
// guess fluidState.setPressure(phaseIdx, 100e5);
fluidState.setPressure(phaseIdx, 1.0135e6);
} }
paramCache.updateAllPressures(fluidState);
} }
}; };

View File

@ -461,7 +461,6 @@ public:
unsigned spaceIdx, unsigned timeIdx) const unsigned spaceIdx, unsigned timeIdx) const
{ {
const auto &pos = context.pos(spaceIdx, timeIdx); const auto &pos = context.pos(spaceIdx, timeIdx);
if (onLeftBoundary_(pos)) { if (onLeftBoundary_(pos)) {
Opm::CompositionalFluidState<Scalar, FluidSystem> fs; Opm::CompositionalFluidState<Scalar, FluidSystem> fs;
initialFluidState_(fs, context, spaceIdx, timeIdx); initialFluidState_(fs, context, spaceIdx, timeIdx);
@ -474,15 +473,17 @@ public:
RateVector massRate(0.0); RateVector massRate(0.0);
massRate[contiCO2EqIdx] = -1e-3; // [kg/(m^3 s)] massRate[contiCO2EqIdx] = -1e-3; // [kg/(m^3 s)]
Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs; typedef Opm::ImmiscibleFluidState<Scalar, FluidSystem> FluidState;
FluidState fs;
fs.setSaturation(gasPhaseIdx, 1.0); fs.setSaturation(gasPhaseIdx, 1.0);
const auto& pg = const auto& pg =
context.intensiveQuantities(spaceIdx, timeIdx).fluidState().pressure(gasPhaseIdx); context.intensiveQuantities(spaceIdx, timeIdx).fluidState().pressure(gasPhaseIdx);
fs.setPressure(gasPhaseIdx, Toolbox::value(pg)); fs.setPressure(gasPhaseIdx, Toolbox::value(pg));
fs.setTemperature(temperature(context, spaceIdx, timeIdx)); fs.setTemperature(temperature(context, spaceIdx, timeIdx));
typename FluidSystem::ParameterCache paramCache;
typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updatePhase(fs, gasPhaseIdx); paramCache.updatePhase(fs, gasPhaseIdx);
Scalar h = FluidSystem::enthalpy(fs, paramCache, gasPhaseIdx); Scalar h = FluidSystem::template enthalpy<FluidState, Scalar>(fs, paramCache, gasPhaseIdx);
// impose an forced inflow boundary condition for pure CO2 // impose an forced inflow boundary condition for pure CO2
values.setMassRate(massRate); values.setMassRate(massRate);
@ -568,7 +569,7 @@ private:
fs.setMoleFraction(liquidPhaseIdx, BrineIdx, fs.setMoleFraction(liquidPhaseIdx, BrineIdx,
1.0 - fs.moleFraction(liquidPhaseIdx, CO2Idx)); 1.0 - fs.moleFraction(liquidPhaseIdx, CO2Idx));
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP; typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
CFRP::solve(fs, paramCache, CFRP::solve(fs, paramCache,
/*refPhaseIdx=*/liquidPhaseIdx, /*refPhaseIdx=*/liquidPhaseIdx,

View File

@ -516,9 +516,8 @@ private:
// compute the phase compositions // compute the phase compositions
typedef Opm::MiscibleMultiPhaseComposition<Scalar, FluidSystem> MMPC; typedef Opm::MiscibleMultiPhaseComposition<Scalar, FluidSystem> MMPC;
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
MMPC::solve(fs, paramCache, /*setViscosity=*/true, MMPC::solve(fs, paramCache, /*setViscosity=*/true, /*setEnthalpy=*/true);
/*setEnthalpy=*/true);
} }
else { else {
fs.setSaturation(waterPhaseIdx, 0.12); fs.setSaturation(waterPhaseIdx, 0.12);
@ -534,12 +533,10 @@ private:
// compute the phase compositions // compute the phase compositions
typedef Opm::MiscibleMultiPhaseComposition<Scalar, FluidSystem> MMPC; typedef Opm::MiscibleMultiPhaseComposition<Scalar, FluidSystem> MMPC;
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
MMPC::solve(fs, paramCache, /*setViscosity=*/true, MMPC::solve(fs, paramCache, /*setViscosity=*/true, /*setEnthalpy=*/true);
/*setEnthalpy=*/true);
// set the contaminant mole fractions to zero. this is a // set the contaminant mole fractions to zero. this is a little bit hacky...
// little bit hacky...
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
fs.setMoleFraction(phaseIdx, NAPLIdx, 0.0); fs.setMoleFraction(phaseIdx, NAPLIdx, 0.0);
@ -568,7 +565,7 @@ private:
fs.setPressure(phaseIdx, 1.0135e5); fs.setPressure(phaseIdx, 1.0135e5);
} }
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updateAll(fs); paramCache.updateAll(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx); Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx);
@ -605,7 +602,7 @@ private:
injectFluidState_.setMoleFraction(gasPhaseIdx, NAPLIdx, 0.0); // [-] injectFluidState_.setMoleFraction(gasPhaseIdx, NAPLIdx, 0.0); // [-]
// set the specific enthalpy of the gas phase // set the specific enthalpy of the gas phase
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updatePhase(injectFluidState_, gasPhaseIdx); paramCache.updatePhase(injectFluidState_, gasPhaseIdx);
Scalar h = FluidSystem::enthalpy(injectFluidState_, paramCache, gasPhaseIdx); Scalar h = FluidSystem::enthalpy(injectFluidState_, paramCache, gasPhaseIdx);

View File

@ -336,7 +336,7 @@ private:
leftInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O); leftInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O);
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP; typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
CFRP::solve(leftInitialFluidState_, paramCache, gasPhaseIdx, CFRP::solve(leftInitialFluidState_, paramCache, gasPhaseIdx,
/*setViscosity=*/false, /*setEnthalpy=*/false); /*setViscosity=*/false, /*setEnthalpy=*/false);

View File

@ -575,7 +575,7 @@ private:
fs.setPressure(phaseIdx, 1.0135e5); fs.setPressure(phaseIdx, 1.0135e5);
} }
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updateAll(fs); paramCache.updateAll(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx); Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx);

View File

@ -457,7 +457,7 @@ private:
fs.setMoleFraction(gasPhaseIdx, NAPLIdx, 0); fs.setMoleFraction(gasPhaseIdx, NAPLIdx, 0);
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP; typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
CFRP::solve(fs, paramCache, gasPhaseIdx, CFRP::solve(fs, paramCache, gasPhaseIdx,
/*setViscosity=*/false, /*setViscosity=*/false,
/*setEnthalpy=*/false); /*setEnthalpy=*/false);

View File

@ -491,7 +491,7 @@ public:
fs.setTemperature(temperature_); fs.setTemperature(temperature_);
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updatePhase(fs, wettingPhaseIdx); paramCache.updatePhase(fs, wettingPhaseIdx);
Scalar densityW = FluidSystem::density(fs, paramCache, wettingPhaseIdx); Scalar densityW = FluidSystem::density(fs, paramCache, wettingPhaseIdx);

View File

@ -453,8 +453,7 @@ private:
} }
template <class FluidState> template <class FluidState>
void initFluidState_(FluidState &fs, const MaterialLawParams &matParams, void initFluidState_(FluidState &fs, const MaterialLawParams &matParams, bool isInlet)
bool isInlet)
{ {
unsigned refPhaseIdx; unsigned refPhaseIdx;
unsigned otherPhaseIdx; unsigned otherPhaseIdx;
@ -507,7 +506,7 @@ private:
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem>
ComputeFromReferencePhase; ComputeFromReferencePhase;
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
ComputeFromReferencePhase::solve(fs, paramCache, refPhaseIdx, ComputeFromReferencePhase::solve(fs, paramCache, refPhaseIdx,
/*setViscosity=*/false, /*setViscosity=*/false,
/*setEnthalpy=*/false); /*setEnthalpy=*/false);

View File

@ -603,7 +603,7 @@ private:
fs.setMoleFraction(oilPhaseIdx, oilCompIdx, xoO); fs.setMoleFraction(oilPhaseIdx, oilCompIdx, xoO);
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP; typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
CFRP::solve(fs, CFRP::solve(fs,
paramCache, paramCache,
/*refPhaseIdx=*/oilPhaseIdx, /*refPhaseIdx=*/oilPhaseIdx,

View File

@ -499,7 +499,7 @@ private:
MaterialLaw::capillaryPressures(pc, matParams, fs); MaterialLaw::capillaryPressures(pc, matParams, fs);
fs.setPressure(gasPhaseIdx, fs.pressure(liquidPhaseIdx) + (pc[gasPhaseIdx] - pc[liquidPhaseIdx])); fs.setPressure(gasPhaseIdx, fs.pressure(liquidPhaseIdx) + (pc[gasPhaseIdx] - pc[liquidPhaseIdx]));
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP; typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
CFRP::solve(fs, paramCache, liquidPhaseIdx, /*setViscosity=*/false, /*setEnthalpy=*/true); CFRP::solve(fs, paramCache, liquidPhaseIdx, /*setViscosity=*/false, /*setEnthalpy=*/true);
} }
@ -515,7 +515,7 @@ private:
fs.setPressure(phaseIdx, 1.0135e5); fs.setPressure(phaseIdx, 1.0135e5);
} }
typename FluidSystem::ParameterCache paramCache; typename FluidSystem::template ParameterCache<Scalar> paramCache;
paramCache.updateAll(fs); paramCache.updateAll(fs);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx); Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx);