Skip to content

Commit

Permalink
Merge pull request AMReX-Codes#107 from AMReX-Codes/fix_pAMReX_MF_exa…
Browse files Browse the repository at this point in the history
…mple

fix the pyAMReX MultiFab tutorial initialization
  • Loading branch information
ax3l authored Dec 14, 2023
2 parents 58fff18 + b69117e commit 2297e43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GuidedTutorials/HeatEquation/Source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main(n_cell, max_grid_size, nsteps, plot_int, dt):
time = 0.

# Ghost cells
ng = phi_old.nGrowVect
ng = phi_old.n_grow_vect
ngx = ng[0]
ngy = ng[1]
ngz = ng[2]
Expand Down
6 changes: 4 additions & 2 deletions GuidedTutorials/MultiFab/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def load_cupy():
dx = geom.data().CellSize() # dx[0]=dx dx[1]=dy dx[2]=dz

# Fill a MultiFab with data
mf_val = 0.
for mfi in mf:
bx = mfi.validbox()
# Preferred way to fill array using fast ranged operations:
Expand All @@ -102,7 +101,10 @@ def load_cupy():
v = (x[xp.newaxis,xp.newaxis,:]
+ y[xp.newaxis,:,xp.newaxis]*0.1
+ z[:,xp.newaxis,xp.newaxis]*0.01)
mf_array = 1. + xp.exp(-v)
rsquared = ((z[xp.newaxis, xp.newaxis, :] - 0.5)**2
+ (y[xp.newaxis, :, xp.newaxis] - 0.5)**2
+ (x[ :, xp.newaxis, xp.newaxis] - 0.5)**2) / 0.01
mf_array[:, :, :, 0] = 1. + xp.exp(-rsquared)

# Plot MultiFab data
plotfile = amr.concatenate(root="plt", num=1, mindigits=3)
Expand Down

0 comments on commit 2297e43

Please sign in to comment.