Write INIT/restart LGR sections in EGRID grid order, and mirror integer maps onto LGR grids - #5252
Merged
Merged
Conversation
EclipseGrid::save_children() writes the LGR grids to the EGRID by applying the print-order permutation to the father-sorted child-cell storage (getLGRCell(index) / lgr_children_cells[index]). WriteInit's writeLGRLocalProperties() and RestartIO's writeLGRRestart() instead applied that same father-sorted permutation index to get_all_lgr_labels(), which is in deck order. When the deck order and the father (host-cell) order differ - e.g. a CARFIN box with a low host-cell index declared after one with a high host-cell index - the INIT and UNRST emit their per-LGR sections in a different order than the EGRID grids. Post-processors (ResInsight) pair the INIT/restart LGR sections to the EGRID LGR grids positionally, so the mismatch makes a grid's active-cell (PORV) array line up with the wrong grid and trips ecl_grid_get_global_size(grid) == activeCellsForGrid.size(). Iterate the LGR grids through getLGRCell(index) (identical to save_children) so the section order matches the EGRID, and address the simulator-provided, deck-ordered per-LGR solution data via the label's deck index (get_lgr_cell_index). EGRID, INIT and UNRST now list the LGR grids in the same order with matching per-grid sizes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
INIT integer maps such as MPI_RANK were written only for the main grid via writeIntegerMaps(), so the array was absent on refined LGR cells and did not appear on the refined region in post-processors (ResInsight). Mirror the integer maps onto each LGR section in writeLGRLocalProperties: every refined cell inherits its father coarse cell's value (filterArray on global_fathers, the same mechanism already used for EQLNUM/FIPNUM), which for rank-interior LGR boxes equals the box's owning rank. int_data is now reused after writeIntegerMaps() instead of being moved-from. Verified: CARFIN1 np=2 INIT now has MPI_RANK in all three grid sections (main 300, each LGR 324, matching PORV/EQLNUM); main grid carries ranks 0/1, each box uniformly its owning rank. Serial output unchanged (no MPI_RANK); parallel UNRST matches serial. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
Context for reviewers: OPM/opm-simulators#7245 enables ECL summary/FIP output for serial LGR runs, which today produce all-zero summaries. That is what makes this ordering fix observable end-to-end — the two are complementary but independent, and neither needs the other to build or merge. |
Member
|
jenkins build this please |
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.
Two LGR output fixes. This changes the order of the per-LGR sections in INIT and UNRST — that is the fix, not a side effect.
1. Write INIT/restart LGR sections in EGRID grid order
EclipseGrid::save_children()writes the LGR grids to the EGRID by applying the print-order permutation to the father-sorted child-cell storage (getLGRCell(index)).WriteInit::writeLGRLocalProperties()andRestartIO::writeLGRRestart()applied that same father-sorted permutation index toget_all_lgr_labels(), which is in deck order.When deck order and father (host-cell) order differ — a CARFIN box with a low host-cell index declared after one with a high host-cell index — INIT and UNRST emit their per-LGR sections in a different order than the EGRID grids.
Post-processors pair the INIT/restart LGR sections to the EGRID LGR grids positionally, so the mismatch lines a grid's PORV array up with the wrong grid. In ResInsight it trips
Both writers now iterate through
getLGRCell(index), identical tosave_children, so the section order matches the EGRID; the simulator-provided, deck-ordered per-LGR data is addressed via the label's deck index (get_lgr_cell_index).EGRID, INIT and UNRST now list the LGR grids in the same order with matching per-grid sizes.
Compatibility: any deck whose CARFIN declaration order already matches host-cell order is byte-identical. Only decks that were previously being written inconsistently change — and for those the old output was not loadable.
2. Write simulator integer maps (MPI_RANK) per LGR grid
INIT integer maps such as
MPI_RANKwere written only for the main grid viawriteIntegerMaps(), so the array was simply absent on refined cells and did not show up on the refined region in post-processors.Each integer map is now mirrored onto every LGR section in
writeLGRLocalProperties: a refined cell inherits its father coarse cell's value viafilterArrayonglobal_fathers, the same mechanism already used for EQLNUM/FIPNUM.int_datais reused afterwriteIntegerMaps()rather than being moved-from.Verified on
SPE1CASE1_CARFIN1atnp=2: INIT now carriesMPI_RANKin all three grid sections (main 300, each LGR 324, matching PORV/EQLNUM), the main grid carries ranks 0/1, and each box is uniformly its owning rank. Serial output is unchanged, since serial runs have no integer maps.This one is additive rather than a bug fix — happy to split it out if you would rather take (1) alone.
Testing
test_RestartLGR,test_EclipseIO_LGR,test_HeadersLGRandtest_AggregateWellDataLGRall pass. Built against opm-grid master.