Skip to content

Cache ensemble contour map statistics as GRI surface files - #14416

Draft
magnesj wants to merge 6 commits into
ensemble-contour-map-batch-compute-14319from
ensemble-contour-map-roff-cache-14319
Draft

Cache ensemble contour map statistics as GRI surface files#14416
magnesj wants to merge 6 commits into
ensemble-contour-map-batch-compute-14319from
ensemble-contour-map-roff-cache-14319

Conversation

@magnesj

@magnesj magnesj commented Jul 30, 2026

Copy link
Copy Markdown
Member

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 the RimReservoirCellResultsStorage lifecycle pattern: one GRI (binary IRAP) surface file per statistics type per selected time step in a <project>_cache directory, written and read with the existing RifSurfio. 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 QString field, since caf::FilePath fields 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

magnesj added 6 commits July 30, 2026 10:03
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contour Map: Cache computed ensemble contour map statistics with the project

1 participant