Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions opm/material/components/iapws/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down
65 changes: 43 additions & 22 deletions opm/material/fluidstates/BlackOilFluidState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ template <class ValueT,
class BlackOilFluidState
{
public:

template <class OtherScalarT,
class OtherFluidSystemT,
bool otherStoreTemperature,
bool otherStoreEnthalpy,
bool otherEnableDissolution,
bool otherEnableVapwat,
bool otherEnableBrine,
bool otherEnableSaltPrecipitation,
bool otherEnableDissolutionInWater,
bool otherEnableSolvent,
unsigned otherNumStoragePhases>
friend class BlackOilFluidState;

using FluidSystem = FluidSystemT;
using ValueType = ValueT;

Expand Down Expand Up @@ -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<class OtherFluidSystemType>
auto withOtherFluidSystem(const OtherFluidSystemType& other) const
{
auto bfstate = BlackOilFluidState<ValueType, OtherFluidSystemType,
storeTemperature,
storeEnthalpy,
enableDissolution,
enableVapwat,
enableBrine,
enableSaltPrecipitation,
enableDissolutionInWater,
enableSolvent,
numStoragePhases>(other);
using FS = std::decay_t<OtherFluidSystemType>;

auto bfstate = BlackOilFluidState<
ValueType,
FS,
storeTemperature,
storeEnthalpy,
enableDissolution,
enableVapwat,
enableBrine,
enableSaltPrecipitation,
enableDissolutionInWater,
enableSolvent,
numStoragePhases
>(other);

bfstate.assign(*this);
return bfstate;
}
Expand Down Expand Up @@ -290,16 +313,14 @@ class BlackOilFluidState
setSolventInvB(BlackOil::getSolventInvB_<FluidState, ValueType>(fs, pvtRegionIdx));
setRsSolw(BlackOil::getRsSolw_<FluidState, ValueType>(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_<FluidSystem, FluidState, ValueType>(fs, phaseIdx, pvtRegionIdx, fluidSystem()));
(*enthalpy_)[storagePhaseIdx] = (*fs.enthalpy_)[storagePhaseIdx];
}
}

Expand Down