Skip to content

Conversation

@kriben
Copy link
Collaborator

@kriben kriben commented Dec 23, 2025

No description provided.

Changed segment count calculation from trunc() to ceil() in
createSubSegmentMDPairs for more intuitive behavior. When a distance
divides evenly by maxSegmentLength, ceil() correctly calculates the
exact number of segments needed, while trunc() + 1 would create an
unnecessary extra segment.

Example: For 100 units with maxSegmentLength=50:
- Old: trunc(100/50) + 1 = 3 segments of 33.33 units each
- New: ceil(100/50) = 2 segments of 50 units each

Also added 20 comprehensive unit tests for createSubSegmentMDPairs.
Added optional minSegmentLength parameter to prevent creating segments
smaller than a specified minimum length. The parameter uses std::optional
and is positioned before maxSegmentLength in the parameter list.

Key features:
- When subdividing would create segments smaller than minSegmentLength,
  the segment count is reduced to ensure all segments meet the minimum
- Uses floor(length / minSegmentLength) to calculate fewer, larger segments
- Custom intervals are exempt and can be smaller than minSegmentLength
- Includes CVF_ASSERT to validate minSegmentLength < maxSegmentLength
  (only when both are specified and maxSegmentLength > 0)

Example: For 55 units with maxSegmentLength=40, minSegmentLength=30:
- Without min: ceil(55/40) = 2 segments of 27.5 units each
- With min=30: floor(55/30) = 1 segment of 55 units (27.5 < 30)

Added 9 comprehensive unit tests covering:
- Prevention of too-small segments
- Segment count reduction when needed
- Interaction with custom intervals (gaps respect min, intervals exempt)
- Edge cases (minSegmentLength=0, no maxSegmentLength)

All existing tests pass unchanged (backward compatible with std::nullopt).
Total test count: 599 tests (29 for createSubSegmentMDPairs).
@kriben
Copy link
Collaborator Author

kriben commented Dec 23, 2025

Attempt to fix #13340, but it does not merge enough of the short segments. In RicMswTableFormatterTools::createSubSegmentMDPairs only parts of the wellpath is considered at a time, and this makes it hard to merge segments since we only see a few at a time. Merging them will still lead to segments that are smaller than the minimum segment length.

Needs discussion, and possibly a rewrite of the branch segment generation.

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.

2 participants