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

View File

@ -461,7 +461,6 @@ public:
unsigned spaceIdx, unsigned timeIdx) const
{
const auto &pos = context.pos(spaceIdx, timeIdx);
if (onLeftBoundary_(pos)) {
Opm::CompositionalFluidState<Scalar, FluidSystem> fs;
initialFluidState_(fs, context, spaceIdx, timeIdx);
@ -474,15 +473,17 @@ public:
RateVector massRate(0.0);
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);
const auto& pg =
context.intensiveQuantities(spaceIdx, timeIdx).fluidState().pressure(gasPhaseIdx);
fs.setPressure(gasPhaseIdx, Toolbox::value(pg));
fs.setTemperature(temperature(context, spaceIdx, timeIdx));
typename FluidSystem::ParameterCache paramCache;
typename FluidSystem::template ParameterCache<Scalar> paramCache;
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
values.setMassRate(massRate);
@ -568,7 +569,7 @@ private:
fs.setMoleFraction(liquidPhaseIdx, BrineIdx,
1.0 - fs.moleFraction(liquidPhaseIdx, CO2Idx));
typename FluidSystem::ParameterCache paramCache;
typename FluidSystem::template ParameterCache<Scalar> paramCache;
typedef Opm::ComputeFromReferencePhase<Scalar, FluidSystem> CFRP;
CFRP::solve(fs, paramCache,
/*refPhaseIdx=*/liquidPhaseIdx,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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