Cache ensemble contour map statistics as GRI surface files - #14416
Draft
magnesj wants to merge 6 commits into
Draft
Cache ensemble contour map statistics as GRI surface files#14416magnesj wants to merge 6 commits into
magnesj wants to merge 6 commits into
Conversation
…ext to the project
…contour map results
…bytes The xtgeo binary IRAP importer reads value blocks until end of file and then reshapes to (ncol, nrow), so a metadata footer appended after the value records makes the import fail. Since interoperability with external tools is the reason the cache uses GRI surface files, the cache metadata is kept in PDM fields and the cache files stay fully standard.
This was referenced Jul 30, 2026
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.
Persist computed ensemble contour map statistics to a project-adjacent cache, so that reloading a project skips the sweep over the ensemble realizations entirely. Stacked on #14408, which computes all pending sibling contour maps in one sweep; together they address the slow project load described in #14319.
The cache is written in
setupBeforeSave()following theRimReservoirCellResultsStoragelifecycle pattern: one GRI (binary IRAP) surface file per statistics type per selected time step in a<project>_cachedirectory, written and read with the existingRifSurfio. The surface nodes are placed at the contour map cell centers, so every cached statistics map can be imported directly as a regular surface in ResInsight, xtgeo or RMS. Undefined cells round-trip as NaN. On load,ensureResultsComputed()restores the contour map grid and results from the cache when a validity key (MD5 of all settings affecting the result: result definition, aggregation, flooding settings, resolution, bounding box expansion, time steps, formations, polygon geometry and realization file paths) matches the current settings; the key is captured at compute time, so results computed under outdated settings are never cached, and any setting change falls through to recomputation. Malformed or missing cache files fall back to recomputation.Cache metadata (validity key, grid definition, time steps) is stored in hidden PDM fields. An alternative design storing the metadata in a text footer inside the GRI files was implemented and reverted (last two commits): ResInsight's surfio importer ignores trailing bytes, but xtgeo reads value blocks to end-of-file and fails on such files, which would defeat the interoperability that motivated the GRI format. The cache file name is stored as a bare file name in a plain
QStringfield, sincecaf::FilePathfields are rewritten by the global path list macros on save.The branch also adds a binary ROFF writer (
RifRoffWriter) with round-trip unit tests, developed for an earlier iteration of the cache format and kept as general infrastructure; it can be dropped from the PR if not wanted.Verified with an ensemble test project: save writes the cache files, reload restores the maps with exports identical to a fresh computation, corrupt files and setting changes trigger recomputation, and the cache files import as surfaces in both ResInsight and xtgeo.
Fixes #14418