Skip to content
Draft
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
21 changes: 15 additions & 6 deletions opm/models/blackoil/blackoilintensivequantities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,23 @@ public:
asImp_().solventPreSatFuncUpdate_(priVars, timeIdx, lintype);
}

// Phase relperms.
problem.template updateRelperms<FluidState, Args...>(mobility_, dirMob_, fluidState_, globalSpaceIdx);

// now we compute all phase pressures
// Phase relperms and capillary pressures. A problem may provide a
// fused implementation (a table-based evaluation can serve both from
// one lookup pass); otherwise the two separate calls are used.
using EvalArr = std::array<Evaluation, numPhases>;
EvalArr pC;
const auto& materialParams = problem.materialLawParams(globalSpaceIdx);
MaterialLaw::template capillaryPressures<EvalArr, FluidState, Args...>(pC, materialParams, fluidState_);
if constexpr (requires {
problem.template updateRelpermsAndCapillaryPressures<FluidState, Args...>(
mobility_, dirMob_, pC, fluidState_, globalSpaceIdx); })
{
problem.template updateRelpermsAndCapillaryPressures<FluidState, Args...>(
mobility_, dirMob_, pC, fluidState_, globalSpaceIdx);
}
else {
problem.template updateRelperms<FluidState, Args...>(mobility_, dirMob_, fluidState_, globalSpaceIdx);
const auto& materialParams = problem.materialLawParams(globalSpaceIdx);
MaterialLaw::template capillaryPressures<EvalArr, FluidState, Args...>(pC, materialParams, fluidState_);
}

// scaling the capillary pressure due to porosity changes
if constexpr (enableBrine) {
Expand Down
20 changes: 20 additions & 0 deletions opm/simulators/flow/FlowProblem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,26 @@ class FlowProblem : public GetPropType<TypeTag, Properties::BaseProblem>
std::shared_ptr<const EclThermalLawManager> thermalLawManager() const
{ return thermalLawManager_; }

// Fused variant used by the intensive quantities: relperms and capillary
// pressures from one call, so a table-based satfunc representation can
// serve both from a single lookup pass. This default implementation is
// behaviorally identical to updateRelperms + MaterialLaw::capillaryPressures;
// the dispatch through asImp_() keeps derived-problem updateRelperms
// overrides effective, exactly as when the intensive quantities called it.
template <class FluidState, class ...Args>
void updateRelpermsAndCapillaryPressures(
std::array<Evaluation,numPhases> &mobility,
DirectionalMobilityPtr &dirMob,
std::array<Evaluation,numPhases> &pC,
FluidState &fluidState,
unsigned globalSpaceIdx) const
{
using ContainerT = std::array<Evaluation, numPhases>;
asImp_().template updateRelperms<FluidState, Args...>(mobility, dirMob, fluidState, globalSpaceIdx);
const auto& materialParams = materialLawParams(globalSpaceIdx);
MaterialLaw::template capillaryPressures<ContainerT, FluidState, Args...>(pC, materialParams, fluidState);
}

template <class FluidState, class ...Args>
void updateRelperms(
std::array<Evaluation,numPhases> &mobility,
Expand Down