Well event improvements#14068
Merged
Merged
Conversation
`add_well_keyword_event` previously emitted items in `keyword_data` dict insertion order. Eclipse keywords such as WCONHIST are positional, so a non-canonical order silently corrupted the simulator input. `RifEventKeywordFormatter::formatKeyword` now walks the OPM `ParserRecord` schema and emits items in canonical order, inserting `1*` defaults for intermediate gaps and dropping trailing unspecified items. Items that are not part of the keyword schema (e.g. mnemonic-list keywords like RPTRST/RPTSCHED) are appended after the canonical block in caller-supplied order to preserve existing behaviour. Fixes #14065.
Schedule-level keywords whose OPM ParserRecord is a single ALL-sized item
(RPTRST, RPTSCHED, ...) are not positional — they take a free-form list
of mnemonic tokens like `BASIC=2 DEN ROCKC NORST=1`. Previously each
`keyword_data` entry became its own DeckItem, and OPM emitted them
either as truncated positional values or as a quoted, space-collapsed
single string.
Detect that schema shape in `RifEventKeywordFormatter::formatKeyword`
and pack the user's entries into one RawString DeckItem of mnemonic
tokens: `KEY` for FLAG items, `KEY=VALUE` otherwise.
To distinguish flag mnemonics (`DEN`) from `KEY=1`-style entries, add a
new `FLAG` value to `RimWellEventKeywordItem::ItemType` plumbed end to
end (Python -> GRPC -> Rimc -> storage -> formatter). The Python API
now maps `bool True` to FLAG and silently drops `bool False`.
For positional keywords (WCONHIST etc.) FLAG items have no value to
emit and are rendered as default markers ("1*").
A `rawStringItem` helper is added to `RifOpmDeckTools` so the
mnemonic-list path can produce DeckItems whose OPM output is not
quoted.
The schedule generator previously concatenated full keyword blocks (`KEYWORD ... /\n/\n`) — one per well — producing verbose output where each WELSPECS / COMPDAT / WCONHIST / WELSEGS / COMPSEGS / etc. block appeared once per contributing well. Eclipse keywords are designed to hold multiple records under a single header; the per-well repetition is syntactically valid but bloats the file and obscures intent. Switch `RicScheduleDataGenerator` to accumulate `std::map<QString, Opm::DeckKeyword>` instead of raw concatenated text. Each per-well helper now returns an `Opm::DeckKeyword`, and a new `mergeKeyword` primitive appends its records into the accumulator entry, creating the entry from the helper's keyword on first encounter. At emission time each accumulated keyword is serialised once. To support this, `RifEventKeywordFormatter` is split: each `format*` QString function now wraps a corresponding `build*` function that returns `std::optional<Opm::DeckKeyword>`. `RimWellEventKeyword` and `RimKeywordEvent` expose a parallel `generateDeckKeyword` accessor. The text-scraping `extractKeywordName` helper becomes dead code and is removed.
Add include_welsegs and include_compsegs flags (default True, preserving current behaviour) to the schedule-generation API. Plumbed through RimcWellEventTimeline_generateSchedule -> RicScheduleDataGenerator -> generateMswForWell, gating only the WELSEGS / COMPSEGS merge calls. WSEGVALV and WSEGAICD are unaffected. Python: generate_schedule_text gains include_welsegs / include_compsegs keyword arguments that forward to generate_schedule. Callers wanting control-only / well-header-only schedule updates can now suppress the verbose MSW table blocks.
Replace the integer eclipse_case_id parameter on RimcWellEventTimeline_generateSchedule with a caf::PdmPtrField<RimEclipseCase*>. The execute() method no longer needs to walk the project tree and look up the case by ID — the gRPC layer resolves the object pointer for us. generate_schedule_text passes the Eclipse case object through to the underlying generate_schedule call, matching how add_perf_event / add_well_keyword_event already take a WellPath object rather than an ID.
00e3cb1 to
67ec866
Compare
magnesj
approved these changes
May 28, 2026
Member
magnesj
left a comment
There was a problem hiding this comment.
Useful refactoring to make the code more readable
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.
Fixes #14063.
Fixes #14064.
Fixes #14065.