Add a fused relperm + capillary pressure entry point - #5287
Draft
hnil wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
krw(),krn(),krg(),pcnw()andpcgn()each re-read the fluid state and re-derive their own two-phase saturation argument;krn()calls two helpers that deriveswandsgagain. 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
Evaluationarithmetic.No representation change, no new storage, no accuracy question. Consumer-side hook: OPM/opm-simulators#7304.
🤖 Generated with Claude Code