Scale MAPAXES to grid units in the opm-common grid reader - #14528
Open
magnesj wants to merge 2 commits into
Open
Scale MAPAXES to grid units in the opm-common grid reader#14528magnesj wants to merge 2 commits into
magnesj wants to merge 2 commits into
Conversation
opm-common scales MAPAXES to meter based on the MAPUNITS keyword, while COORD and ZCORN are left in the units given by GRIDUNIT. The map axis transform uses normalized axes plus an origin translation, so the origin must be in grid units to match the node coordinates. Scale the map axes accordingly, and use with_mapaxes() as the guard, as get_mapaxes() returns a fixed size array that is only assigned when the MAPAXES keyword is present. The duplicated map axes handling in the two readers is moved into a shared function.
RivSingleCellPartGenerator-Test.cpp and RivIjkIntersectionGeometryGenerator-Test.cpp both define buildBoxGrid in an anonymous namespace. The definitions do not collide as long as the two files end up in different unity build chunks, but adding a test file repartitions the chunks and the build then fails with a redefinition error.
kriben
reviewed
Aug 14, 2026
kriben
left a comment
Collaborator
There was a problem hiding this comment.
The MAPAXES unit correction and shared helper look sound. I have one minor const-correctness suggestion.
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RifReaderOpmCommon::applyMapAxes( Opm::EclIO::EGrid& opmGrid, RigMainGrid* mainGrid ) |
Collaborator
There was a problem hiding this comment.
applyMapAxes() only uses const accessors on opmGrid. Could this parameter be changed to const Opm::EclIO::EGrid&, including in the header? That would make the helper’s non-mutating contract explicit.
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 #14527
opm-common scales MAPAXES to meter based on the MAPUNITS keyword, while
COORD/ZCORNare left in the units given byGRIDUNIT.RigMainGrid::mapAxisTransformbuilds the transform from normalized axes plus an origin translation, so the origin must be in grid units to match the node coordinates. For a deck withGRIDUNIT FEETandMAPUNITS FEETthe grid was displaced byorigin * (1 - 0.3048).The map axes are now scaled into grid units before use. The
MAPUNITSstring comparison mirrorsEGrid.cppexactly, since the intention is to detect what opm-common did rather than what the file says. WhenMAPUNITSis absent or unrecognized, opm-common leaves the values raw and no scaling is applied.The duplicated map axes block in
RifReaderOpmCommonandRifReaderOpmCommonActiveis moved into a sharedapplyMapAxes.The guard is changed from
get_mapaxes().size() == 6towith_mapaxes(). The former is always true, asget_mapaxes()returns astd::array<double, 6>&, andEGrid::m_mapaxesis never zero initialized and only assigned when the MAPAXES keyword is present. A file without MAPAXES could therefore transform all nodes by uninitialized values.