Skip to content

[LGR] Write complete restart records for local-grid runs - #5246

Open
arturcastiel wants to merge 4 commits into
OPM:masterfrom
arturcastiel:lgr-restart-nwmaxz
Open

arturcastiel wants to merge 4 commits into
OPM:masterfrom
arturcastiel:lgr-restart-nwmaxz

Conversation

@arturcastiel

@arturcastiel arturcastiel commented Jul 22, 2026

Copy link
Copy Markdown
Member

What this does

Corrects the per-grid header content that OPM flow writes for models with
local grid refinements (CARFIN): a local grid's INTEHEAD well- and
group-allocation items are now per-grid quantities, and the header records
the model's refinement count. Previously these items carried field-wide
values or were left at zero.

As requested in review, the additional header items
(lgrRestartHeaderItems), the solution-term count, and the local-grid
solution-section resequencing have been removed from this PR. They are not
needed for restarting our own simulations: flow currently rejects
refined-grid restarts at initialization (FlowProblemBlackoil.hpp), the
restart loader reads INTEHEAD exclusively through the named items of
VectorItems/intehead.hpp (none of the removed items had a named entry),
and solution arrays are looked up by name, so section order is immaterial
to the loader. With the resequencing gone, RestartIO.cpp is no longer
touched by this PR.

The changes

  • Per-grid NWMAXZ (CreateInteHead): a local grid's INTEHEAD
    well-allocation size is now max(wells-in-that-grid, 1) instead of the
    field-global WELLDIMS(1) — the slot is a per-grid quantity. Follows the
    sibling per-grid fix precedent in the same overload.
  • Per-grid group accounting (CreateInteHead): a local grid's
    actual-group and maximum-group header items now hold the number of
    distinct groups of the wells inside that grid (minimum one), while the
    maximum-wells-per-group item keeps the field-wide capacity; the two
    conventions coincide on single-group models. This resolves the
    long-standing placeholder in the local-grid group accounting.
  • INTEHEAD[NLGR]: the model-total count of local grid refinements,
    written to every grid's header. The item identifies the file as a
    local-grid restart; it was previously left at zero.
  • Tests: test_HeadersLGR extended with per-grid NWMAXZ and NLGR
    assertions across the existing LGR fixtures.

Scope guarantee

Every addition is gated on the model actually containing local grid
refinements — restart output for non-LGR models is unchanged.

Testing performed

Unit battery on this branch: the header and restart suites
(test_HeadersLGR, test_InteHEAD, test_Restart, test_RestartLGR,
test_RestartFileView) and the full opm-common test suite pass.

@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

@arturcastiel arturcastiel added the manual:enhancement This is an enhancement/improvent that needs to be documented in the manual label Jul 22, 2026
@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

2 similar comments
@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

@arturcastiel
arturcastiel marked this pull request as ready for review July 23, 2026 12:41
@arturcastiel
arturcastiel requested a review from bska July 23, 2026 12:41
@arturcastiel arturcastiel changed the title [WIP] [LGR] Flow Run + Ref Simulator Restart Enabled [LGR] Flow Run + Ref Simulator Restart Enabled Jul 23, 2026
@arturcastiel

Copy link
Copy Markdown
Member Author

@bska

@bska

bska commented Aug 18, 2026

Copy link
Copy Markdown
Member

This PR is doing too much work in my opinion and I'd really appreciate it if it were split into more parts. In particular, I'd like the tracer bits to be a separate, follow-on PR instead of included here.

@arturcastiel

Copy link
Copy Markdown
Member Author

This PR is doing too much work in my opinion and I'd really appreciate it if it were split into more parts. In particular, I'd like the tracer bits to be a separate, follow-on PR instead of included here.

I will split into more pieces.

@arturcastiel arturcastiel changed the title [LGR] Flow Run + Ref Simulator Restart Enabled [LGR] Write complete restart records for local-grid runs Aug 18, 2026
@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

@arturcastiel

Copy link
Copy Markdown
Member Author

@bska

@arturcastiel

Copy link
Copy Markdown
Member Author

This PR is doing too much work in my opinion and I'd really appreciate it if it were split into more parts. In particular, I'd like the tracer bits to be a separate, follow-on PR instead of included here.

The split is done. This PR is now the six-commit core on current master:
the four header commits (per-grid NWMAXZ, refinement count, local-grid
group items, additional header items), the solution-layout commit, and
the test pins. It merges cleanly against master.

The tracer-counting change is out of this PR entirely and will follow as
a separate PR, re-authored on the reduced Aggregate* signatures rather
than rebased mechanically.

After the rebase we re-ran the full validation set on this head: the
complete unit suite plus restart-coverage runs across the local-grid
model matrix (single- and multi-refinement, wells-in-LGR, and amalgamated
cases). Results are at par with the pre-rebase branch across the matrix;
the amalgamated-LGR case now completes cleanly on current master. The
tracer cases are covered by the follow-up PR.

@bska bska left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for splitting up the original PR. There is still too much happening here, and some of the INTEHEAD values are too obtuse. Unless we need them for restarting our own simulations, I suggest we leave them out for now. If we do need them, then they should be properly documented. The weird 3D array ordering in the restart file should similarly not be added unless it's needed four our own simulation restart or postprocessors like ResInsight.

Comment thread opm/output/eclipse/CreateInteHead.cpp Outdated
Comment on lines +692 to +701
// Solution-term count as recomputed by restarting runs: active
// phases plus two, plus one when a dissolution or vaporisation
// transfer is active.
const auto& phasePred = rspec.phases();
const int numActivePhases =
static_cast<int>(phasePred.active(Phase::OIL))
+ static_cast<int>(phasePred.active(Phase::WATER))
+ static_cast<int>(phasePred.active(Phase::GAS));
const int solutionTermCount = numActivePhases + 2
+ ((simConfig.hasDISGAS() || simConfig.hasVAPOIL()) ? 1 : 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't this solutionTermCount for our simulation restart so please remove it.

Comment thread opm/output/eclipse/RestartIO.cpp Outdated
// fluid-in-place arrays leading the section, or placed after the
// saturation-pressure terms, is rejected while being read back.
template <typename OutputVector, typename OutputVectorInt>
void writeLgrOrderedSolutionVectors(const RestartValue& value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not doing this at this point. Please continue to use the existing order for everything.

Comment thread opm/output/eclipse/InteHEAD.hpp Outdated
Comment on lines +213 to +214
InteHEAD& lgrRestartHeaderItems(const bool modelHasLgr,
const int solutionTermCount);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the lgrRestartHeaderItems() for restarting our own simulations? If not, I'd really prefer that we not define them.

arturcastiel and others added 4 commits August 27, 2026 08:17
The local-grid overload of getWellTableDims() dimensioned NWMAXZ with the
field-wide WELLDIMS item 1 value.  NWMAXZ is a per-grid allocation size —
the number of wells located in that grid, with a minimum of one — so the
local-grid header now carries the local grid's own well count.

Co-authored-by: AXON <axon@arturcastiel.github.io>
Write the model-total count of local grid refinements to INTEHEAD item 95
of every grid's header.  The item identifies the file as a local-grid
restart and was previously left at zero.

Co-authored-by: AXON <axon@arturcastiel.github.io>
A local grid's actual-group and maximum-group header items are per-grid
quantities: the number of distinct groups of the wells inside that grid,
with a minimum of one.  The local-grid path copied the field-wide values
into all three group items, which coincides on single-group models only.
The maximum-wells-per-group item keeps the field-wide capacity.  This
resolves the long-standing placeholder in the local-grid group
accounting, which is removed.

Co-authored-by: AXON <axon@arturcastiel.github.io>
Co-authored-by: AXON <axon@arturcastiel.github.io>
@arturcastiel

arturcastiel commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

All three points taken — done:

  • lgrRestartHeaderItems() and the solutionTermCount computation are
    removed.
  • The solution-section resequencing is removed as well; RestartIO.cpp is
    no longer touched by this PR, so record order is the existing one
    everywhere.

The branch is now the four-commit core: per-grid NWMAXZ, the refinement
count, per-grid group items, and the test pins. Body updated to match.

@arturcastiel

Copy link
Copy Markdown
Member Author

jenkins build this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:enhancement This is an enhancement/improvent that needs to be documented in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants