Skip to content

Commit 23ade7e

Browse files
Copilotefaulhaber
andcommitted
Apply transfer2cpu before calling custom_quantity in PostprocessCallback
- Added transfer2cpu calls for dv_ode, du_ode, v_ode, and u_ode before passing them to custom_quantity - This matches the pattern used in write_vtk.jl - Users no longer need to handle GPU arrays in their custom_quantity functions Co-authored-by: efaulhaber <44124897+efaulhaber@users.noreply.github.com>
1 parent 30facd8 commit 23ade7e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/callbacks/post_process.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ function (pp::PostprocessCallback)(integrator; from_initialize=false)
257257
@notimeit timer() update_systems_and_nhs(v_ode, u_ode, semi, t)
258258
end
259259

260+
# Transfer to CPU if data is on the GPU. Do nothing if already on CPU.
261+
dv_ode_cpu, du_ode_cpu = transfer2cpu(dv_ode, du_ode)
262+
v_ode_cpu, u_ode_cpu = transfer2cpu(v_ode, u_ode)
263+
260264
foreach_system(semi) do system
261265
if system isa AbstractBoundarySystem && pp.exclude_boundary
262266
return
@@ -265,7 +269,8 @@ function (pp::PostprocessCallback)(integrator; from_initialize=false)
265269
system_index = system_indices(system, semi)
266270

267271
for (key, f) in pp.func
268-
result_ = custom_quantity(f, system, dv_ode, du_ode, v_ode, u_ode, semi, t)
272+
result_ = custom_quantity(f, system, dv_ode_cpu, du_ode_cpu, v_ode_cpu,
273+
u_ode_cpu, semi, t)
269274
if result_ !== nothing
270275
# Transfer to CPU if data is on the GPU. Do nothing if already on CPU.
271276
result = transfer2cpu(result_)

0 commit comments

Comments
 (0)