When importing a grid with the opm-common reader, MAPAXES and the cell corner coordinates can end up in different length units.
opm-common EGrid.cpp scales MAPAXES to metres when MAPUNITS is present (FEET -> 0.3048, CM -> 0.01), while getCellCorners applies no unit factor, so COORD/ZCORN stay in GRIDUNIT units.
RigMainGrid::mapAxisTransform builds the transform from normalized axes plus an origin translation taken from m_mapAxes[2], m_mapAxes[3]. The rotation is unaffected by the scaling, but the translation is not: for a deck with GRIDUNIT FEET and MAPUNITS FEET, the origin shift is in metres while the nodes are in feet, displacing the grid by origin * (1 - 0.3048). The problem is invisible when the MAPAXES origin is (0, 0), which is likely why it has not been noticed.
Affected, as duplicated blocks:
ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp:344-370
ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp:225-251
RigResdataGridConverter.cpp:69 writes mapAxesF() back out, so export is affected as well.
Suggested fix: factor the duplicated block into a shared helper on RifReaderOpmCommon and scale the map axes into grid units before use, by dividing out the grid unit length in metres. The MAPUNITS comparison must mirror EGrid.cpp exactly, since the point is to know what opm-common did rather than what the file says. When MAPUNITS is absent or unrecognized, opm-common leaves the values raw and no scaling should be applied.
| MAPUNITS |
GRIDUNIT |
opm-common gives |
scale |
result |
| (absent) |
FEET |
raw feet |
1.0 |
feet |
| FEET |
FEET |
metres |
1/0.3048 |
feet |
| METRES |
METRES |
metres |
1.0 |
metres |
| FEET |
METRES |
metres |
1.0 |
metres |
Note that ecl_grid_init_mapaxes in ThirdParty/Ert/lib/ecl/ecl_grid.cpp:2065-2090 ignores MAPUNITS entirely, so matching the resdata reader is not a valid acceptance criterion when MAPUNITS and GRIDUNIT differ.
When importing a grid with the opm-common reader, MAPAXES and the cell corner coordinates can end up in different length units.
opm-common
EGrid.cppscales MAPAXES to metres whenMAPUNITSis present (FEET-> 0.3048,CM-> 0.01), whilegetCellCornersapplies no unit factor, soCOORD/ZCORNstay inGRIDUNITunits.RigMainGrid::mapAxisTransformbuilds the transform from normalized axes plus an origin translation taken fromm_mapAxes[2], m_mapAxes[3]. The rotation is unaffected by the scaling, but the translation is not: for a deck withGRIDUNIT FEETandMAPUNITS FEET, the origin shift is in metres while the nodes are in feet, displacing the grid byorigin * (1 - 0.3048). The problem is invisible when the MAPAXES origin is(0, 0), which is likely why it has not been noticed.Affected, as duplicated blocks:
ApplicationLibCode/FileInterface/RifReaderOpmCommon.cpp:344-370ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp:225-251RigResdataGridConverter.cpp:69writesmapAxesF()back out, so export is affected as well.Suggested fix: factor the duplicated block into a shared helper on
RifReaderOpmCommonand scale the map axes into grid units before use, by dividing out the grid unit length in metres. TheMAPUNITScomparison must mirrorEGrid.cppexactly, since the point is to know what opm-common did rather than what the file says. WhenMAPUNITSis absent or unrecognized, opm-common leaves the values raw and no scaling should be applied.Note that
ecl_grid_init_mapaxesinThirdParty/Ert/lib/ecl/ecl_grid.cpp:2065-2090ignoresMAPUNITSentirely, so matching the resdata reader is not a valid acceptance criterion whenMAPUNITSandGRIDUNITdiffer.