Skip to content

Add a fused relperm + capillary pressure entry point - #5287

Draft
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:pr-fused-satfunc-eval
Draft

Add a fused relperm + capillary pressure entry point#5287
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:pr-fused-satfunc-eval

Conversation

@hnil

@hnil hnil commented Aug 11, 2026

Copy link
Copy Markdown
Member

krw(), krn(), krg(), pcnw() and pcgn() each re-read the fluid state and re-derive their own two-phase saturation argument; krn() calls two helpers that derive sw and sg again. A caller needing both sets — the intensive quantities do — pays for that five times per cell.

relativePermeabilitiesAndCapillaryPressures() forms the three distinct arguments once and calls the two-phase laws directly. Same arithmetic, same lookups, same results; the new test checks both paths agree exactly over a saturation sweep, float and double.

Norne, 44 927 cells, 3-derivative AD, identical states and checksums: 89.9 → 59.8 ns/cell (−33 %) for relperm + pc. The gain is larger for AD than for plain double (−13 %) because the redundant derivation runs in Evaluation arithmetic.

No representation change, no new storage, no accuracy question. Consumer-side hook: OPM/opm-simulators#7304.

🤖 Generated with Claude Code

krw(), krn(), krg(), pcnw() and pcgn() each re-read the fluid state and
re-derive their own two-phase saturation argument, and krn() calls two
helpers that derive sw and sg a third time. A caller that needs relperms
and capillary pressures together -- the intensive quantities do -- pays
for that five times over.

relativePermeabilitiesAndCapillaryPressures() forms the three distinct
arguments once and calls the two-phase laws directly. Same arithmetic,
same table lookups, same results; the new test checks the fused and
separate paths agree exactly over a saturation sweep, float and double.

Measured on Norne (44 927 cells, 3-derivative AD, standalone harness,
identical states and checksums): 89.9 -> 59.8 ns/cell for relperm + pc.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hnil hnil added the manual:enhancement This is an enhancement/improvent that needs to be documented in the manual label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:enhancement This is an enhancement/improvent that needs to be documented in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant