Skip to content

Optimize 2D rho grid memory use#13425

Open
dafeda wants to merge 1 commit intoequinor:mainfrom
dafeda:calc-rho-memory
Open

Optimize 2D rho grid memory use#13425
dafeda wants to merge 1 commit intoequinor:mainfrom
dafeda:calc-rho-memory

Conversation

@dafeda
Copy link
Copy Markdown
Collaborator

@dafeda dafeda commented Apr 28, 2026

Use NumPy broadcasting in calc_rho_for_2d_grid_layer instead of
flattened mesh arrays. This preserves the result while avoiding large
intermediate allocations.

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

 Use NumPy broadcasting in `calc_rho_for_2d_grid_layer` instead of
 flattened mesh arrays. This preserves the result while avoiding large
 intermediate allocations.
@dafeda dafeda self-assigned this Apr 28, 2026
@dafeda dafeda added the release-notes:skip If there should be no mention of this in release notes label Apr 28, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.03%. Comparing base (5d35e74) to head (8e899c1).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13425      +/-   ##
==========================================
- Coverage   90.03%   90.03%   -0.01%     
==========================================
  Files         459      459              
  Lines       31992    31992              
==========================================
- Hits        28804    28803       -1     
- Misses       3188     3189       +1     
Flag Coverage Δ
cli-tests 37.49% <100.00%> (ø)
fuzz 44.24% <0.00%> (ø)
gui-tests 66.94% <0.00%> (+0.02%) ⬆️
performance-and-unit-tests 78.05% <100.00%> (-0.01%) ⬇️
test 45.86% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/ert/field_utils/field_utils.py 93.56% <100.00%> (ø)

... and 2 files with indirect coverage changes

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 28, 2026

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing dafeda:calc-rho-memory (8e899c1) with main (5d35e74)

Open in CodSpeed

obs_anisotropy_angle = obs_anisotropy_angle[np.newaxis, np.newaxis, :]

# Center points of each grid cell in field parameter grid
x_local = (np.arange(nx) + 0.5) * xinc
Copy link
Copy Markdown
Contributor

@xjules xjules Apr 28, 2026

Choose a reason for hiding this comment

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

Wondering whether this shift (+0.5) is necessary at all? Since thus we need to reflect this in the observations too (ie. like in heat equation).
I guess the increment can vary and thus it makes sense.....

@larsevj
Copy link
Copy Markdown
Collaborator

larsevj commented May 7, 2026

Could you rebase to ensure the snapshot test passes?

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

Labels

release-notes:skip If there should be no mention of this in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants