From b31ceff970d89ca8d5fdf2846771912416f3c40d Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 13 Apr 2016 13:32:15 +0200 Subject: [PATCH] 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... --- examples/problems/co2injectionflash.hh | 14 ++++---------- examples/problems/co2injectionproblem.hh | 11 ++++++----- examples/problems/cuvetteproblem.hh | 17 +++++++---------- examples/problems/diffusionproblem.hh | 2 +- examples/problems/fractureproblem.hh | 2 +- examples/problems/infiltrationproblem.hh | 2 +- examples/problems/lensproblem.hh | 2 +- examples/problems/obstacleproblem.hh | 5 ++--- examples/problems/reservoirproblem.hh | 2 +- examples/problems/waterairproblem.hh | 4 ++-- 10 files changed, 26 insertions(+), 35 deletions(-) diff --git a/examples/problems/co2injectionflash.hh b/examples/problems/co2injectionflash.hh index 1a948b0a7..8e0840827 100644 --- a/examples/problems/co2injectionflash.hh +++ b/examples/problems/co2injectionflash.hh @@ -43,8 +43,6 @@ class Co2InjectionFlash : public Opm::NcpFlash { typedef Opm::NcpFlash ParentType; - typedef typename FluidSystem::ParameterCache ParameterCache; - enum { numPhases = FluidSystem::numPhases }; public: @@ -52,18 +50,14 @@ public: * \brief Guess initial values for all quantities. */ template - static void guessInitial(FluidState &fluidState, ParameterCache ¶mCache, - 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); } }; diff --git a/examples/problems/co2injectionproblem.hh b/examples/problems/co2injectionproblem.hh index 75326d701..f697a8944 100644 --- a/examples/problems/co2injectionproblem.hh +++ b/examples/problems/co2injectionproblem.hh @@ -461,7 +461,6 @@ public: unsigned spaceIdx, unsigned timeIdx) const { const auto &pos = context.pos(spaceIdx, timeIdx); - if (onLeftBoundary_(pos)) { Opm::CompositionalFluidState 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 fs; + typedef Opm::ImmiscibleFluidState 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 paramCache; paramCache.updatePhase(fs, gasPhaseIdx); - Scalar h = FluidSystem::enthalpy(fs, paramCache, gasPhaseIdx); + Scalar h = FluidSystem::template enthalpy(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 paramCache; typedef Opm::ComputeFromReferencePhase CFRP; CFRP::solve(fs, paramCache, /*refPhaseIdx=*/liquidPhaseIdx, diff --git a/examples/problems/cuvetteproblem.hh b/examples/problems/cuvetteproblem.hh index e9412e771..9518b8b6f 100644 --- a/examples/problems/cuvetteproblem.hh +++ b/examples/problems/cuvetteproblem.hh @@ -516,9 +516,8 @@ private: // compute the phase compositions typedef Opm::MiscibleMultiPhaseComposition MMPC; - typename FluidSystem::ParameterCache paramCache; - MMPC::solve(fs, paramCache, /*setViscosity=*/true, - /*setEnthalpy=*/true); + typename FluidSystem::template ParameterCache 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 MMPC; - typename FluidSystem::ParameterCache paramCache; - MMPC::solve(fs, paramCache, /*setViscosity=*/true, - /*setEnthalpy=*/true); + typename FluidSystem::template ParameterCache 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 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 paramCache; paramCache.updatePhase(injectFluidState_, gasPhaseIdx); Scalar h = FluidSystem::enthalpy(injectFluidState_, paramCache, gasPhaseIdx); diff --git a/examples/problems/diffusionproblem.hh b/examples/problems/diffusionproblem.hh index 53c5d84b4..b038975ed 100644 --- a/examples/problems/diffusionproblem.hh +++ b/examples/problems/diffusionproblem.hh @@ -336,7 +336,7 @@ private: leftInitialFluidState_.setMoleFraction(gasPhaseIdx, N2Idx, 1 - xH2O); typedef Opm::ComputeFromReferencePhase CFRP; - typename FluidSystem::ParameterCache paramCache; + typename FluidSystem::template ParameterCache paramCache; CFRP::solve(leftInitialFluidState_, paramCache, gasPhaseIdx, /*setViscosity=*/false, /*setEnthalpy=*/false); diff --git a/examples/problems/fractureproblem.hh b/examples/problems/fractureproblem.hh index 050fa6ad4..3b818227e 100644 --- a/examples/problems/fractureproblem.hh +++ b/examples/problems/fractureproblem.hh @@ -575,7 +575,7 @@ private: fs.setPressure(phaseIdx, 1.0135e5); } - typename FluidSystem::ParameterCache paramCache; + typename FluidSystem::template ParameterCache paramCache; paramCache.updateAll(fs); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx); diff --git a/examples/problems/infiltrationproblem.hh b/examples/problems/infiltrationproblem.hh index e2a77bbaf..e45dd57b8 100644 --- a/examples/problems/infiltrationproblem.hh +++ b/examples/problems/infiltrationproblem.hh @@ -457,7 +457,7 @@ private: fs.setMoleFraction(gasPhaseIdx, NAPLIdx, 0); typedef Opm::ComputeFromReferencePhase CFRP; - typename FluidSystem::ParameterCache paramCache; + typename FluidSystem::template ParameterCache paramCache; CFRP::solve(fs, paramCache, gasPhaseIdx, /*setViscosity=*/false, /*setEnthalpy=*/false); diff --git a/examples/problems/lensproblem.hh b/examples/problems/lensproblem.hh index 48de62faa..92b214edb 100644 --- a/examples/problems/lensproblem.hh +++ b/examples/problems/lensproblem.hh @@ -491,7 +491,7 @@ public: fs.setTemperature(temperature_); - typename FluidSystem::ParameterCache paramCache; + typename FluidSystem::template ParameterCache paramCache; paramCache.updatePhase(fs, wettingPhaseIdx); Scalar densityW = FluidSystem::density(fs, paramCache, wettingPhaseIdx); diff --git a/examples/problems/obstacleproblem.hh b/examples/problems/obstacleproblem.hh index d3d5c1cd6..3bd0ec645 100644 --- a/examples/problems/obstacleproblem.hh +++ b/examples/problems/obstacleproblem.hh @@ -453,8 +453,7 @@ private: } template - 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 ComputeFromReferencePhase; - typename FluidSystem::ParameterCache paramCache; + typename FluidSystem::template ParameterCache paramCache; ComputeFromReferencePhase::solve(fs, paramCache, refPhaseIdx, /*setViscosity=*/false, /*setEnthalpy=*/false); diff --git a/examples/problems/reservoirproblem.hh b/examples/problems/reservoirproblem.hh index c6cffa37c..518f82aa6 100644 --- a/examples/problems/reservoirproblem.hh +++ b/examples/problems/reservoirproblem.hh @@ -603,7 +603,7 @@ private: fs.setMoleFraction(oilPhaseIdx, oilCompIdx, xoO); typedef Opm::ComputeFromReferencePhase CFRP; - typename FluidSystem::ParameterCache paramCache; + typename FluidSystem::template ParameterCache paramCache; CFRP::solve(fs, paramCache, /*refPhaseIdx=*/oilPhaseIdx, diff --git a/examples/problems/waterairproblem.hh b/examples/problems/waterairproblem.hh index fef03ea50..92aa42dff 100644 --- a/examples/problems/waterairproblem.hh +++ b/examples/problems/waterairproblem.hh @@ -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 paramCache; typedef Opm::ComputeFromReferencePhase 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 paramCache; paramCache.updateAll(fs); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { Scalar rho = FluidSystem::density(fs, paramCache, phaseIdx);