@@ -32,7 +32,7 @@ function particle_shifting!(integrator)
3232 v_ode, u_ode = integrator. u. x
3333 dt = integrator. dt
3434 # Internal cache vector, which is safe to use as temporary array
35- u_cache = first (get_tmp_cache (integrator))
35+ vu_cache = first (get_tmp_cache (integrator))
3636
3737 # Update quantities that are stored in the systems. These quantities (e.g. pressure)
3838 # still have the values from the last stage of the previous step if not updated here.
@@ -41,7 +41,7 @@ function particle_shifting!(integrator)
4141 @trixi_timeit timer () " particle shifting" foreach_system (semi) do system
4242 u = wrap_u (u_ode, system, semi)
4343 v = wrap_v (v_ode, system, semi)
44- particle_shifting! (u, v, system, v_ode, u_ode, semi, u_cache , dt)
44+ particle_shifting! (u, v, system, v_ode, u_ode, semi, vu_cache , dt)
4545 end
4646
4747 # Tell OrdinaryDiffEq that `u` has been modified
@@ -55,14 +55,18 @@ function particle_shifting!(u, v, system, v_ode, u_ode, semi, u_cache, dt)
5555end
5656
5757function particle_shifting! (u, v, system:: FluidSystem , v_ode, u_ode, semi,
58- u_cache , dt)
58+ vu_cache , dt)
5959 # Wrap the cache vector to an NDIMS x NPARTICLES matrix.
6060 # We need this buffer because we cannot safely update `u` while iterating over it.
61+ _, u_cache = vu_cache. x
6162 delta_r = wrap_u (u_cache, system, semi)
6263 set_zero! (delta_r)
6364
64- v_max = maximum (particle -> norm (current_velocity (v, system, particle)),
65- eachparticle (system))
65+ # This has similar performance to `maximum(..., eachparticle(system))`,
66+ # but is GPU-compatible.
67+ v_max = maximum (x -> sqrt (dot (x, x)),
68+ reinterpret (reshape, SVector{ndims (system), eltype (v)},
69+ current_velocity (v, system)))
6670
6771 # TODO this needs to be adapted to multi-resolution.
6872 # Section 3.2 explains what else needs to be changed.
@@ -88,7 +92,7 @@ function particle_shifting!(u, v, system::FluidSystem, v_ode, u_ode, semi,
8892 grad_kernel = smoothing_kernel_grad (system, pos_diff, distance, particle)
8993
9094 # According to p. 29 below Eq. 9
91- R = 0.2
95+ R = 2 // 10
9296 n = 4
9397
9498 # Eq. 7 in Sun et al. (2017).
0 commit comments