diff --git a/opm/material/components/iapws/Common.hpp b/opm/material/components/iapws/Common.hpp index cc6444b61fd..0d3b1dcb1d9 100644 --- a/opm/material/components/iapws/Common.hpp +++ b/opm/material/components/iapws/Common.hpp @@ -103,8 +103,10 @@ class Common OPM_HOST_DEVICE static Evaluation viscosity(const Evaluation& temperature, const Evaluation& rho) { Evaluation rhoBar = rho/322.0; - Evaluation TBar = temperature/criticalTemperature; - // Evaluation TBar = temperature/Scalar(647.096); + // I do not know why, but NVCC will not allow writing out temperature/criticalTemperature + // HIPCC does this perfectly fine, should be allowed since it is static constexpr, but for + // now I'll have to write out the scalar here instead... + Evaluation TBar = temperature/Scalar(647.096); // muBar = muBar_1 const Scalar Hij[6][7] = { diff --git a/opm/material/fluidstates/BlackOilFluidState.hpp b/opm/material/fluidstates/BlackOilFluidState.hpp index c5115f15d3a..5f14f14bc30 100644 --- a/opm/material/fluidstates/BlackOilFluidState.hpp +++ b/opm/material/fluidstates/BlackOilFluidState.hpp @@ -139,6 +139,20 @@ template +friend class BlackOilFluidState; + using FluidSystem = FluidSystemT; using ValueType = ValueT; @@ -167,22 +181,31 @@ class BlackOilFluidState } } - // This is intended to be used when we are converting fluid - // state from a version that uses the static fluidsystem to - // a version that uses a dynamic fluid system. + /** + * \brief Create a new fluid state object with a different fluid system. + * + * \param other The new fluid system to use. + * \return A new BlackOilFluidState object with the specified fluid system. + */ template auto withOtherFluidSystem(const OtherFluidSystemType& other) const { - auto bfstate = BlackOilFluidState(other); + using FS = std::decay_t; + + auto bfstate = BlackOilFluidState< + ValueType, + FS, + storeTemperature, + storeEnthalpy, + enableDissolution, + enableVapwat, + enableBrine, + enableSaltPrecipitation, + enableDissolutionInWater, + enableSolvent, + numStoragePhases + >(other); + bfstate.assign(*this); return bfstate; } @@ -290,16 +313,14 @@ class BlackOilFluidState setSolventInvB(BlackOil::getSolventInvB_(fs, pvtRegionIdx)); setRsSolw(BlackOil::getRsSolw_(fs, pvtRegionIdx)); } - for (unsigned storagePhaseIdx = 0; storagePhaseIdx < numStoragePhases; ++storagePhaseIdx) { - unsigned phaseIdx = storageToCanonicalPhaseIndex_(storagePhaseIdx, fluidSystem()); - setSaturation(phaseIdx, fs.saturation(phaseIdx)); - setPressure(phaseIdx, fs.pressure(phaseIdx)); - setDensity(phaseIdx, fs.density(phaseIdx)); - + for (unsigned int storagePhaseIdx = 0; storagePhaseIdx < numStoragePhases; ++storagePhaseIdx) { + // No need to use setXXX as we would just have to convert index to canonical index and then back. + pressure_[storagePhaseIdx] = fs.pressure_[storagePhaseIdx]; + saturation_[storagePhaseIdx] = fs.saturation_[storagePhaseIdx]; + density_[storagePhaseIdx] = fs.density_[storagePhaseIdx]; + invB_[storagePhaseIdx] = fs.invB_[storagePhaseIdx]; if constexpr (storeEnthalpy) - setEnthalpy(phaseIdx, fs.enthalpy(phaseIdx)); - - setInvB(phaseIdx, getInvB_(fs, phaseIdx, pvtRegionIdx, fluidSystem())); + (*enthalpy_)[storagePhaseIdx] = (*fs.enthalpy_)[storagePhaseIdx]; } }