Commit Graph
620 Commits
Author SHA1 Message Date
Magne Sjaastad a9f420bfde #14384 Guard residual oil and gas data against missing static results 2026-07-28 14:33:49 +02:00
Kristian Bendiksen 87518f2f2f #14365 Nested hybrid grid: import as a reconstructed LGR hierarchy 2026-07-27 15:24:25 +02:00
Kristian Bendiksen 6357cef1ab #14334 Fix formation dip sign when aligning fracture with formation dip
The sign of the projected formation direction vector flips with the fracture
direction normal, which follows the well drilling direction, while the fracture
azimuth defining the dip rotation in RimFracture::transformMatrix() is only
defined mod 180 degrees. Canonicalize the formation direction against the
fracture azimuth direction before computing the dip, so a positive dip means
the formation descends toward the azimuth direction.

Restore std::abs() in calculateFormationDipFromHorizontal() so the StimPlan
model formation dip (BedDipDeg in the Asymmetric FRK export) keeps the
non-negative convention from #8877.
2026-07-13 14:34:17 +02:00
jonjenssen 4c3791698e Reduce line length for ACTNUM grdecl export 2026-07-10 14:23:50 +02:00
jonjenssen f96c9354c1 Possible fix for #14334 2026-07-08 15:40:08 +02:00
Magne Sjaastad 189bf3e35c #14324 Avoid crash in Mobile Pore Volume when SWCR/MULTPV size differs from PORV 2026-06-26 17:09:04 +02:00
Magne Sjaastad 2ac1948abe #14245 Remove gsl functions and ThirdParty/gsl folder 2026-06-24 18:47:04 +02:00
Magne Sjaastad 592fe88d5b #14296 Fix spelling: tesselated -> tessellated 2026-06-24 11:52:33 +02:00
Magne Sjaastad 4e229c55d1 #14296 Fix contour map crash on degenerate grid bounds 2026-06-24 11:52:33 +02:00
Magne Sjaastad de10dcf0de #14300 Guard flow diagnostics frame access against out-of-range time step 2026-06-24 11:21:38 +02:00
Magne Sjaastad a4b8570b3a #14287 Fix out-of-range access when computing Max Fraction Tracer result 2026-06-23 07:29:51 +02:00
Kristian Bendiksen a489db3e64 #14227 Compute depth-related geometry results once for both porosity models
The depth-related geometry results (DEPTH/DX/DY/DZ/TOPS/BOTTOM) are derived
purely from the shared grid geometry and were computed independently for the
matrix and fracture porosity models. For dual-porosity cases this recomputed the
identical per-cell geometry twice.

Replace the per-model computeDepthRelatedResults() with a single static routine
that traverses the shared main grid once, computing each cell's geometry a single
time and writing it to every porosity model in which the cell is active. The
per-property already-computed guards and the temporary-grid recompute path are
preserved, so the stored values are unchanged. All six matrix+fracture call sites
now go through a thin RigEclipseCaseData::computeDepthRelatedResults() wrapper.
2026-06-19 12:25:55 +02:00
Kristian Bendiksen 8bb8b190e4 #10122 Prevent default selected result variable "SOIL" when not available
Fixes #10122.
2026-06-12 16:30:43 +02:00
Magne Sjaastad 6baee431a7 #14209 Guard contour map aggregation against out-of-range result index 2026-06-12 08:32:32 +02:00
Magne Sjaastad ed96d155fc #14007 Contour Map: rebuild projection when cached case data is stale
Reloading a grid file frees and recreates RigEclipseCaseData. The contour map projection caches raw pointers into the case data and previously only refreshed them when reset explicitly via RimReloadCaseTools::updateAll3dViews(). Callers of RimEclipseCase::reloadEclipseGridFile() that bypass updateAll3dViews(), such as RimOpmFlowJob::onCompleted(), left the projection holding dangling pointers that crashed in generateResults/hasResultEntry on the next redraw. The projection now detects that its cached RigEclipseCaseData no longer matches the current case and rebuilds itself before the stale pointers are dereferenced.
2026-06-10 12:33:45 +02:00
Magne Sjaastad f1218e527f #14183 Fix crash in AABB cell search tree from unsynchronized lazy build
RigMainGrid::findIntersectingCells is const and lazily builds the mutable m_cellSearchTree without synchronization, yet it is called from many multi-threaded (OpenMP) query paths. When two threads race the isNull check, both build a new tree and the cvf::ref reassignment deletes the first tree while it is still being built, leading to a use-after-free and a segfault deep in AABBTree::buildTree (BoundingBox::addValid reading a dangling leaf box).

Serialize building of the cell search tree with a mutex, both in computeCachedData (which nulls and rebuilds the tree) and in the lazy build in findIntersectingCells. The query also keeps a local reference to the tree so it stays alive if another thread rebuilds m_cellSearchTree during the read-only intersection query.
2026-06-10 12:32:54 +02:00
Magne Sjaastad 0410635815 #14179 Fix crash building cell search tree for LGR-heavy grids
The leaf-node cap that selects between the optimized and the
non-optimized cell search tree construction used cellCount(), which
only counts main grid cells and excludes LGR cells. The non-optimized
buildCellSearchTree() iterates totalCellCount() (main grid plus all LGR
cells) and creates one leaf per cell, so a grid with few main cells but
many LGR cells could be routed into that path and exhaust memory,
crashing while building the AABB tree.

Base the threshold on totalCellCount() so LGR-inflated grids are routed
to the optimized aggregating path and the leaf count stays bounded.
2026-06-10 08:47:24 +02:00
Magne Sjaastad 25921d1169 #14161 Fix crash in sim well centerline from null eclipse case
calculateWellPipeStaticCenterline dereferenced eclipseView->eclipseCase()
without checking for null. When the view has no eclipse case (or no case
data), calling eclipseCaseData() on the null RimEclipseCase segfaulted
during a timestep frame change that redraws simulation well pipes.

Add the same null guard already used by the sibling method
RimSimWellInView::wellHeadTopBottomPosition, returning early so no pipe
geometry is produced when there is no case data.
2026-06-10 08:45:53 +02:00
Kristian Bendiksen 984d70237b #14101 Add progress bar to fault distance calculation 2026-06-08 21:42:19 +02:00
Kristian Bendiksen 5ee62c61e1 #14128 Use KD-tree (nanoflann) for fault distance nearest-face search
computeFaultDistances faked a nearest-point query with cvf::BoundingBoxTree,
which only supports box overlap: it grew a cell-sized box until it overlapped a
fault face. For cells far from any fault this did many full tree traversals and
then brute-forced the distance to a large, over-collected candidate set, and the
answer was only approximate. This was slow on grids with ~10 million cells.

The metric is the distance from each cell center to the nearest fault face
center, which is exactly a nearest-point search. Replace the bounding-box tree
and the grow-the-box loop with a nanoflann KD-tree built over the fault face
centers and a single nearest-neighbor query per active cell. A zero-copy adaptor
reads the existing std::vector<cvf::Vec3d> directly. The OpenMP loop is retained
since nanoflann queries are read-only. The result is O(F log F) build plus
O(N log F) queries, the full grid-node array copy is gone, and distances are now
exact rather than approximate.

Add nanoflann as a vcpkg dependency, wired in like Clipper2 as an imported
target.

Refs: https://github.com/OPM/ResInsight/issues/14128
2026-06-08 21:39:08 +02:00
Kristian Bendiksen 5e2156fca1 #14127 Add static Completion Type result for grid-only cases
The Completion Type result was registered only as a dynamic result, which
requires simulation time steps. Loading only grid geometry (e.g. a ROFF grid)
therefore made the result unavailable, since there are no time steps to compute
it for.

Register and compute a STATIC_NATIVE variant of Completion Type in addition to
the existing DYNAMIC_NATIVE one, computed as a single time-step-independent
frame. The shared per-frame computation is factored out of
computeCompletionTypeForTimeStep so both variants reuse it. The virtual
perforation transmissibilities already handle the no-restart case by clamping to
a single frame, so the static result can be computed at calc time step 0.

The legend/category predicates and the completion-type result clearing are
broadened to recognise the static variant so it renders with the same discrete
named-category legend as the dynamic one.
2026-06-08 15:35:31 +02:00
Magne Sjaastad cd59e2a181 #14138 Fix crash when picking a cell with a combined MULT result
RigCombMultResultAccessor::cellFaceScalar called oppositeFace() with the
face passed from the picked selection. A plain cell pick leaves the face
as NO_FACE, which has no opposite and tripped CVF_ASSERT(false) in
oppositeFace, crashing the application.

Guard against a non-directional face and return 1.0, consistent with the
no-change-in-MULT-factor convention already used in nativeMultScalar.
2026-06-08 10:18:41 +02:00
Kristian Bendiksen 2a158dce58 #14121 Well Path: guard remaining null wellPathGeometry() dereferences
A file-based well path whose source file is missing has a null wellPathGeometry(). Add null checks at the remaining call sites that dereferenced it without one, so operations on such a well path no longer crash:

- RimWellPathGroup: skip geometry merging for a child with no geometry (grouping runs on import and project load).
- RimWellPathFracture::computeFractureDirectionNormal: return undefined when geometry is missing.
- RivWellPathPartMgr: extend the existing well path null checks to also require geometry in the attribute, well measurement, and valve append paths.
- RimCompletionCellIntersectionCalc, RicExportLgrFeature, RicCreateMultipleWellPathLaterals, RigLasFileExporter, RiuWellPathComponentPlotItem: guard the geometry before use.

Sites that were already guarded or only reachable through guarded paths were left unchanged.
2026-06-08 08:46:40 +02:00
Kristian Bendiksen 054dbdb255 Move oil volume result to experimental features and demote ROFF logs to debug
Gate the derived oil volume cell result behind the new 'oil-volume-result'
experimental feature instead of RiaApplication::enableDevelopmentFeatures().

In the ROFF file reader, drop the enableDevelopmentFeatures() gates around the
grid dimension, timing and array diagnostics and log them at debug level instead,
so the output is available without RESINSIGHT_DEVEL but stays quiet in normal
runs.
2026-06-01 16:41:00 +02:00
Kristian Bendiksen b51dc28854 #13890 Faults: Add FAULTDIST result for a user-selected subset of faults
The existing FAULTDIST result always considered every fault in the main
grid. Users with many faults need to compute distance fields against a
named subset, so this adds a Fault Distance Results collection under
each view's Faults node. Each entry holds a multiselect of faults and a
name (FAULTDIST1, FAULTDIST2, ...) and publishes the result into the
Generated cell-result category.

The per-cell BVH-based distance loop was extracted from
RigFaultDistanceResultCalculator into a reusable utility that accepts
the subset of faults to include; the original all-faults entry point
delegates to the same utility and keeps the static-native FAULTDIST
behavior unchanged.
2026-06-01 11:28:46 +02:00
Magne Sjaastad 071d6cc19e #14050 CMake: Remove dead variable definitions and references
* CMake: Remove dead CODE_HEADER_FILES variable
* CMake: Remove dead COMMAND_CODE_HEADER_FILES and COMMAND_MOC_SOURCE_FILES
* CMake: Remove dead MOC_SOURCE_FILES and FORM_FILES_CPP references
* CMake: Remove dead HEADER_FILES reference
* CMake: Delete unused CustomPCH.cmake superseded by target_precompile_headers
2026-05-26 13:10:20 +02:00
Magne Sjaastad 9e60bf1ce4 #13967 RigMainGrid: Invalidate face-normal direction cache on setFlipAxis
isFaceNormalsOutwards lazily computes whether cell face normals point outward
and caches the answer in m_isFaceNormalsOutwardsComputed. setFlipAxis was
mirroring the node coordinates without resetting that cache, so any consumer
that had triggered the lazy computation before the user toggled Flip X/Y kept
the pre-flip answer. The well-path/cell intersection in
RigEclipseWellLogExtractor::calculateIntersection then inverted the
entering/leaving flag the wrong way, causing the proper-pair filter in
populateReturnArrays to discard every intermediate cell along a perforation
interval - only the start and end cells survived through the
well-starts/ends-inside-a-cell fallback.

Reset m_isFaceNormalsOutwardsComputed when the flip state actually changes.

Add unit tests covering all four combinations of Flip X / Flip Y for both the
data-level node mirroring and the well-path/cell intersection (freshly-built
grid and interactive-toggle scenarios).
2026-05-08 10:28:31 +02:00
Kristian Bendiksen 5ffcb69acc #13126 RiaLogging: Use std::string_view instead of QString for logging 2026-05-08 10:11:09 +02:00
Kristian Bendiksen bb0afbf962 #13126 RiaLogging: Extract errorInMessageBox to RiuMessageDialog
Move the QMessageBox-displaying helper out of the logging utility into a
dedicated UI class. RiaLogging.h no longer pulls QMessageBox/QWidget into
the ~270 files that include it. Behavior is preserved: showError displays
the dialog when running interactively (and not under regression tests),
then forwards the text to RiaLogging::error.
2026-05-08 10:11:09 +02:00
jonjenssen 1564df8115 Soil calculation: Keep trying next time steps. 2026-05-04 18:14:33 +02:00
Kristian Bendiksen 5fcca6bf09 #13940 Fracture export: Guard transmissibility condenser against internal-only neighbor sets
Replace the fatal CAF_ASSERT in calculateCondensedTransmissibilities() with an
early return when no external cells are present. The fracture export pipeline
now yields no completions for such fractures instead of aborting the process.

Fixes #13940.
2026-05-04 15:29:07 +02:00
jonjenssen 09bbaa58bf Add additional result size checks 2026-05-04 15:22:10 +02:00
Magne Sjaastad 86500efbdc #13926 GeoMech well log: Guard against OOB indices when interpolating results
Bounds-check every gridResultValues access in interpolateGridResultValue
to prevent segfaults observed in interpolateInterfaceValues' OMP loop
when a result vector was empty or sized for a different result position
type. OOB now returns the infinity sentinel that matches the existing
undefined-value path and the initializeResultValues pre-fill, so
downstream invalid-value checks correctly skip these slots.

interpolateInterfaceValues additionally short-circuits and logs a
warning with the field/component name when the input result vector is
empty, instead of failing silently.
2026-04-30 21:50:45 +02:00
Kristian Bendiksen 87e9ab7b5b Sector Export: scale MINPV with refinement
This avoids marking small cells as inactive.
2026-04-29 13:14:49 +02:00
Kristian Bendiksen 9d04f0b122 Sector export: Add refinement regions
Promote sector-export refinement from inline wizard fields to first-class
PDM objects so users can create, edit, and preview refinement regions in
the 3D view before opening the export dialog.
2026-04-29 13:14:49 +02:00
jonjenssen bc7fbc7b76 Add valve keywords to list of well keywords to filter when exporting sector model 2026-04-27 15:09:39 +02:00
Kristian Bendiksen 0c949f2dc3 #13854 Sector export: Shift BCCON Z-face K indices when pad model is enabled
Pad-model extension assumed OPM-style "Z+" for the positive-Z exterior face,
but ResInsight emits "Z" (OPM-Flow short form). The K1/K2 shift never fired,
leaving the bottom boundary face at the original NZ instead of the new
padded NZ. Match both "Z" and "Z+" so the extension applies.

Adds a regression test verifying that with BCCON_BCPROP and padding the "Z"
exterior face is shifted by nzUpper + nzLower while the "Z-" face remains
at K=1, and documents the exterior-face semantics of the direction mapping.
2026-04-23 19:50:19 +02:00
Magne Sjaastad 75c1cedaec #13806 Python: Add API for creating discrete grid properties
Add a data_type parameter to set_active_cell_property, set_active_cell_property_async
and set_grid_property so callers can upload INTEGER-typed discrete properties in
addition to the existing FLOAT properties. Previously a discrete property required
the result name to end with "NUM"; the explicit data type makes the intent
independent of the name.

The gRPC service now forwards the selected data type to
RigCaseCellResultsData::createCategoryResult, and the Python tests cover both
float and integer property uploads.
2026-04-20 18:55:36 +02:00
Kristian Bendiksen f881899815 #13855 Ensure BCPROP goes first in schedule section during sector export 2026-04-17 19:56:49 +02:00
Magne Sjaastad 387b19ef62 #12276 Add RFT correlation report plot with cross-plot and tornado plot
* Fix defensive guards and TVD interpolation

Guard against out-of-bounds IJK and invalid cells in RifReaderRftInterface.
Guard against null eclCase in RimDataSourceForRftPlt::address.
Guard against null plot widgets in RiuMultiPlotPage.
Fix interpolateMdFromTvd corrupting valid entries after infinity TVD values
by skipping infinity entries in the first pass and tracking only the last
two valid MD values for the startMD adjustment.

* Add RiuQwtCurveSelectorFilter for click-to-select realization in Qwt plots

New shared event filter class that installs on a QwtPlot canvas and calls a
user-supplied callback with the closest data point on each click.

Migrate the local CurveSelectorFilter in RimParameterResultCrossPlot to use
the new shared class. Add Z_HIGHLIGHTED_CURVE to ZIndex enum and replace all
raw z-order integers in RiuQwtPlotCurveDefines with named constants.

* Add RFT correlation report plot with cross-plot and tornado plot

New classes:
- RimRftCorrelationReportPlot: composite plot showing an RFT well log track
  alongside a parameter cross-plot and a tornado plot sub-plot.
- RimParameterRftCrossPlot: cross-plot of ensemble parameters vs RFT-derived
  measured depth values, with click-to-select realization support.
- RimRftTornadoPlot: tornado plot with correlation-sorted parameter list and
  click-to-select realization support.
- RicCreateRftCorrelationReportFeature: context menu command on RimWellRftPlot
  that creates a RimRftCorrelationReportPlot in the correlation plot collection.

Wire up in RimCorrelationPlotCollection and RimContextCommandBuilder.

* Add click-to-select and highlight selected realization in RFT plots

Install RiuQwtCurveSelectorFilter on RimWellRftPlot canvas to support
click-to-select realization. Highlight the selected realization using a
contrast color (orange-red) and increased line thickness. React to both
click-to-select in the plot and selection changes in the Data Sources panel.

Add Z_HIGHLIGHTED_CURVE z-order and replace raw z-order integers with
named constants in RimWellRftPlot.

Highlight selected realization with XCROSS symbol in RimParameterRftCrossPlot
via RimSummaryEnsembleTools::findSummaryCase.

* RimWellRftPlot: add Create RFT Correlation Report to canvas right-click menu

Override appendMenuItems in RimWellRftPlot to add RicCreateRftCorrelationReportFeature.
Call appendMenuItems from RiuMultiPlotPage::contextMenuEvent so any plot type
can contribute canvas menu items without modifying RiuMultiPlotPage.

* RicShowPlotDataFeature: support RimRftCorrelationReportPlot

Add RimRftCorrelationReportPlot to the isCommandEnabled check and expand
it into its cross-plot and tornado sub-plots in onActionTriggered, matching
the pattern used for RimCorrelationReportPlot.
2026-04-16 16:45:44 +02:00
Magne Sjaastad d37e50b55b #13876 WellPathGeometry: Return default values instead of assert and crash 2026-04-16 16:43:36 +02:00
Magne Sjaastad ca658165bf #13877 ContourMap: Replace assert and crash with std::expected
Replace CVF_ASSERT with bounds checks returning std::unexpected with
descriptive error messages. Call site updated with TODO to propagate
the error when the receiving system is ready.
2026-04-16 16:43:36 +02:00
Kristian BendiksenandVegard Kippe 0aee9033ac Fix monotonicity of depth values in extendDepthTable and add tests
Only prepend/append padding rows to RSVD/RVVD/RTEMPVD/PBVD/PDVD tables
when the existing table does not already cover the padding depth range.
This prevents non-monotonic depth sequences that caused issues in OPM.

Also expose extendDepthTable as a public static method on RigPadModel
and add unit tests for all extension scenarios.

Co-authored-by: Vegard Kippe <vkip@equinor.com>
2026-04-10 11:49:45 +02:00
Kristian Bendiksen a0dbbf6cb1 Remove deprecated size_t overloads from RigActiveCellInfo
Migrate all callers to use type-safe ReservoirCellIndex and
ActiveCellIndex wrappers, then remove the deprecated isActive(size_t),
cellResultIndex(size_t), and setCellResultIndex(size_t, size_t) methods.
2026-03-31 12:32:05 +02:00
Kristian Bendiksen 49ea27ed62 #12957 Sector Model Export: require resolved max in RigGridExportAdapter
Move UNDEFINED max resolution to callers so it happens exactly once.
RigGridExportAdapter now asserts that max is resolved on construction.
2026-03-30 11:24:56 +02:00
Kristian Bendiksen 3067823e71 #12957 Sector Model Export: introduce RigRefinement interface hierarchy
Replace the monolithic RigNonUniformRefinement class with a proper
polymorphic hierarchy: RigRefinement (abstract base), RigNoRefinement
(identity), RigUniformRefinement (O(1) uniform), and
RigNonUniformRefinement (per-cell custom fractions).

Ownership uses std::unique_ptr<RigRefinement>, consumers receive
const RigRefinement&. This eliminates the misleading class name,
removes effectiveRefinement() indirection, and gives each refinement
mode an appropriately optimized implementation.
2026-03-30 11:24:56 +02:00
Kristian Bendiksen 4aa0910db3 #12957 Sector Model Export: add non-uniform refinement support to faults code path
Add RigNonUniformRefinement overloads for extractFaults and faultsKeyword,
following the existing dual-overload pattern. The Vec3st overloads now
delegate via fromUniform() to preserve backward compatibility. Update
addFaultsToDeckFile to call effectiveRefinement() instead of refinement().
2026-03-30 11:24:56 +02:00
Kristian Bendiksen 5d6aba0f70 #12957 Sector Model Export: unified refinement abstraction via effectiveRefinement()
Add effectiveRefinement() to RicRefinementSettings, RicExportSectorModelUi, and
RigSimulationInputSettings, always returning RigNonUniformRefinement regardless of
whether uniform, non-uniform, or no refinement is active.

Merge the dual RigGridExportAdapter constructors into a single one taking
RigNonUniformRefinement, and unify transformIjkToSectorCoordinates to a single
overload. Eliminate all hasNonUniformRefinement() branching patterns in
RigSimulationInputTool.cpp in favour of effectiveRefinement().
2026-03-30 11:24:56 +02:00
Kristian Bendiksen 3e0b2b3fe8 #12957 Sector Model Export: fix off-by-one in WELSPECS HEAD coordinates for non-uniform refinement
The non-uniform path produced 0-based indices using subcellCount/2,
while WELSPECS expects 1-based values. Use (subcellCount+1)/2 to match
the uniform formula semantics of (ref+1)/2.
2026-03-30 11:24:56 +02:00
Kristian Bendiksen 282175bdb4 #12957 Sector Model Export: add linear and logarithmic non-uniform refinement sub-modes
Add NonUniformSubMode enum (Custom Widths, Linear Equal Split, Logarithmic
Towards Center) to give users simpler alternatives to manually entering
comma-separated fractional widths.

Linear mode splits each cell in the range into N equal subcells.
Logarithmic mode auto-computes widths with finer resolution near the
center of the range using a geometric series.
2026-03-30 11:24:56 +02:00