Skip to content

Modernize Python tutorials#176

Open
ax3l wants to merge 1 commit into
AMReX-Codes:mainfrom
ax3l:topic-python-modernize
Open

Modernize Python tutorials#176
ax3l wants to merge 1 commit into
AMReX-Codes:mainfrom
ax3l:topic-python-modernize

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Jun 5, 2026

  • HeatEquation: read runtime parameters via ParmParse from the C++ inputs file (closes a TODO); forward command line arguments to AMReX so python3 main.py ../Exec/inputs mirrors the C++ binary; use the Array4.to_xp() zero-copy views.
  • MultiFab: use Array4.to_xp(), forward command line arguments, demonstrate global min/max/sum reductions.
  • MPMD Case-2: forward command line arguments.
  • CI: pass the inputs file to the HeatEquation Python runs and add an MPI-parallel (2 ranks) Python run.
  • Docs: rewrite the Python tutorials page with install/run conventions.

- HeatEquation: read runtime parameters via ParmParse from the C++
  inputs file (closes the long-standing TODO); forward command line
  arguments to AMReX so `python3 main.py ../Exec/inputs` mirrors the
  C++ binary; use the `Array4.to_xp()` zero-copy views.
- MultiFab: use `Array4.to_xp()`, forward command line arguments,
  demonstrate global min/max/sum reductions.
- MPMD Case-2: forward command line arguments.
- CI: pass the inputs file to the HeatEquation Python runs and add an
  MPI-parallel (2 ranks) Python run.
- Docs: rewrite the Python tutorials page with install/run conventions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ax3l ax3l added the enhancement New feature or request label Jun 5, 2026
Comment on lines 102 to +127
@@ -121,8 +123,8 @@ def main(n_cell, max_grid_size, nsteps, plot_int, dt):
# new_phi = old_phi + dt * Laplacian(old_phi)
# Loop over boxes
for mfi in phi_old:
phiOld = xp.array(phi_old.array(mfi), copy=False)
phiNew = xp.array(phi_new.array(mfi), copy=False)
phiOld = phi_old.array(mfi).to_xp(copy=False, order="C")
phiNew = phi_new.array(mfi).to_xp(copy=False, order="C")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Could make the below code F-order... looks then more like C++-AMReX with its Fortran-ordered Array4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On the other hand, that will complicate the PR diff here. Can be a follow-up PR.

@ax3l ax3l requested a review from atmyers June 5, 2026 21:03
@ax3l ax3l requested a review from WeiqunZhang June 5, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants