Skip to content

Nested CARFIN: validate and index against the parent LGR - #5256

Open
hnil wants to merge 2 commits into
OPM:masterfrom
hnil:pr/carfin-nested-parent
Open

Nested CARFIN: validate and index against the parent LGR#5256
hnil wants to merge 2 commits into
OPM:masterfrom
hnil:pr/carfin-nested-parent

Conversation

@hnil

@hnil hnil commented Jul 31, 2026

Copy link
Copy Markdown
Member

Split out of #5250 so the serialization fix there can land on its own — akva2 approved that part but was reasonably unsure about the nested semantics, which is all that is here.

LgrCollection::addLgr always built the Carfin against the global GridDims. A nested CARFIN (PARENT other than GLOBAL) addresses cells in its parent LGR's refined space, so one whose parent-local extent exceeds the global grid — a child in a parent with refined NZ=9 over a global NZ=3 — was rejected with "Index values for lgr greater than global grid size" despite being valid.

It now reads CARFIN::PARENT and, for a non-GLOBAL parent, constructs against that parent's NX/NY/NZ. Requires parent-before-child ordering in the deck; an undefined parent throws OpmInputError carrying the CARFIN keyword location (the second commit — this was the bare throw akva2 flagged on #5250).

No change for PARENT GLOBAL, which is every existing deck.

Depends on nothing; #5250 is independent.

hnil and others added 2 commits July 31, 2026 09:02
…grid

A nested CARFIN (PARENT != GLOBAL) addresses cells in its parent LGR's own
refined Cartesian space, so its I/J/K range and the divisibility of NX/NY/NZ
must be checked against the parent LGR's dimensions - not the global grid.
Previously LgrCollection::addLgr always built the Carfin with the global
GridDims, so a nested box whose parent-local extent exceeds the global grid in
some direction (e.g. a child reaching deep into a parent refined NZ=9 over a
global NZ=3) was wrongly rejected with 'Index values for lgr greater than global
grid size'.

addLgr now reads the CARFIN PARENT item; for a nested box it looks up the
already-defined parent LGR (parent-before-child deck order) and constructs the
Carfin with the parent LGR's dimensions and a trivial all-active/identity index
map (a refined Cartesian block is fully active). GLOBAL-parent CARFINs are
unchanged. A clear error is thrown if the parent LGR is not yet defined.

Verified: a nested deck with NEST1 addressing LGR1-local k 2-8 (LGR1 is NZ=9
over the global NZ=3) now parses, builds the grid, and runs the solve to
completion (output disabled) on the gridrefined nested-lgr-serial branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… location

Per review of the bare throw. This is a deck-input error, so it should carry
the keyword location the way the rest of the parsing path does -- the caller
already logs 'CARFIN in {file} line {line}' and this file already includes
OpmInputError.hpp for exactly that.

addLgr now takes the KeywordLocation and throws OpmInputError, so the user
gets the CARFIN record that names the missing parent instead of a bare
std::invalid_argument with no deck context.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@arturcastiel

Copy link
Copy Markdown
Member

@hnil I am out of the office for the next two weeks. I will get back to it when I come back.

@hnil hnil added the manual:bugfix This PR is a bug fix and should be noted in the manual label Aug 2, 2026
@hnil
hnil removed the request for review from arturcastiel August 2, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:bugfix This PR is a bug fix and should be noted in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants