Skip to content

Commit

Permalink
Update moment_kinetics/src/em_fields.jl
Browse files Browse the repository at this point in the history
Avoid allocating an intermediate array for -Epar.

Co-authored-by: John Omotani <[email protected]>
  • Loading branch information
mrhardman and johnomotani authored Jan 13, 2025
1 parent 25ad9f2 commit c0f9982
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion moment_kinetics/src/em_fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ function calculate_phi_from_Epar!(phi, Epar, r, z, z_spectral)
# calculate phi on each local rank, up to a constant
# phi[1,:] = 0.0 by convention here
@loop_r ir begin
@views indefinite_integral!(phi[:,ir], -Epar[:,ir], z, z_spectral)
@views @. z.scratch = -Epar[:,ir]
@views indefinite_integral!(phi[:,ir], z.scratch, z, z_spectral)
end

# Restore the constant offset from the lower boundary
Expand Down

0 comments on commit c0f9982

Please sign in to comment.