@@ -41,11 +41,11 @@ function update_shifting!(system, shifting, v, u, v_ode, u_ode, semi)
4141end
4242
4343# Additional term in the momentum equation due to the shifting technique
44- @inline function dv_shifting ( shifting, system, neighbor_system,
45- v_system, v_neighbor_system, particle, neighbor,
46- m_a, m_b, rho_a, rho_b, pos_diff, distance,
47- grad_kernel, correction)
48- return zero (grad_kernel)
44+ @inline function dv_shifting! (dv_particle, shifting, system, neighbor_system,
45+ v_system, v_neighbor_system, particle, neighbor,
46+ m_a, m_b, rho_a, rho_b, pos_diff, distance,
47+ grad_kernel, correction)
48+ return dv_particle
4949end
5050
5151# Additional term(s) in the continuity equation due to the shifting technique
@@ -324,31 +324,35 @@ See [`ParticleShiftingTechnique`](@ref).
324324struct MomentumEquationTermSun2019 end
325325
326326# Additional term in the momentum equation due to the shifting technique
327- @propagate_inbounds function dv_shifting (shifting:: ParticleShiftingTechnique , system,
328- neighbor_system,
329- v_system, v_neighbor_system, particle, neighbor,
330- m_a, m_b, rho_a, rho_b, pos_diff, distance,
331- grad_kernel, correction)
332- return dv_shifting (shifting. momentum_equation_term, system, neighbor_system,
333- v_system, v_neighbor_system, particle, neighbor,
334- m_a, m_b, rho_a, rho_b, pos_diff, distance,
335- grad_kernel, correction)
327+ @propagate_inbounds function dv_shifting! (dv_particle,
328+ shifting:: ParticleShiftingTechnique ,
329+ system, neighbor_system,
330+ v_system, v_neighbor_system, particle, neighbor,
331+ m_a, m_b, rho_a, rho_b, pos_diff, distance,
332+ grad_kernel, correction)
333+ return dv_shifting! (dv_particle, shifting. momentum_equation_term, system,
334+ neighbor_system, v_system, v_neighbor_system,
335+ particle, neighbor, m_a, m_b, rho_a, rho_b,
336+ pos_diff, distance, grad_kernel, correction)
336337end
337338
338- @propagate_inbounds function dv_shifting ( :: MomentumEquationTermSun2019 ,
339- system, neighbor_system,
340- v_system, v_neighbor_system,
341- particle, neighbor, m_a, m_b, rho_a, rho_b,
342- pos_diff, distance, grad_kernel, correction)
339+ @propagate_inbounds function dv_shifting! (dv_particle, :: MomentumEquationTermSun2019 ,
340+ system, neighbor_system,
341+ v_system, v_neighbor_system,
342+ particle, neighbor, m_a, m_b, rho_a, rho_b,
343+ pos_diff, distance, grad_kernel, correction)
343344 delta_v_a = delta_v (system, particle)
344345 delta_v_b = delta_v (neighbor_system, neighbor)
345346
346347 v_a = current_velocity (v_system, system, particle)
347348 v_b = current_velocity (v_neighbor_system, neighbor_system, neighbor)
348349
349350 tensor_product = v_a * delta_v_a' + v_b * delta_v_b'
350- return m_b / rho_b *
351- (tensor_product * grad_kernel + v_a * dot (delta_v_a - delta_v_b, grad_kernel))
351+ dv_particle[] += m_b / rho_b *
352+ (tensor_product * grad_kernel +
353+ v_a * dot (delta_v_a - delta_v_b, grad_kernel))
354+
355+ return dv_particle
352356end
353357
354358# `ParticleShiftingTechnique{<:Any, <:Any, true}` means `modify_continuity_equation=true`
@@ -568,10 +572,11 @@ struct TransportVelocityAdami{modify_continuity_equation, T <: Real} <:
568572 end
569573end
570574
571- @propagate_inbounds function dv_shifting (:: TransportVelocityAdami , system, neighbor_system,
572- v_system, v_neighbor_system, particle, neighbor,
573- m_a, m_b, rho_a, rho_b, pos_diff, distance,
574- grad_kernel, correction)
575+ @propagate_inbounds function dv_shifting! (dv_particle, :: TransportVelocityAdami ,
576+ system, neighbor_system,
577+ v_system, v_neighbor_system, particle, neighbor,
578+ m_a, m_b, rho_a, rho_b, pos_diff, distance,
579+ grad_kernel, correction)
575580 v_a = current_velocity (v_system, system, particle)
576581 delta_v_a = delta_v (system, particle)
577582
588593 # m_b * (A_a + A_b) / (ρ_a * ρ_b) * ∇W_ab.
589594 # In order to obtain this, we pass `p_a = A_a` and `p_b = A_b` to the
590595 # `pressure_acceleration` function.
591- return pressure_acceleration (system, neighbor_system, particle, neighbor,
592- m_a, m_b, A_a, A_b, rho_a, rho_b, pos_diff,
593- distance, grad_kernel, correction)
596+ dv_particle[] += pressure_acceleration (system, neighbor_system, particle, neighbor,
597+ m_a, m_b, A_a, A_b, rho_a, rho_b,
598+ pos_diff, distance, grad_kernel, correction)
599+
600+ return dv_particle
594601end
595602
596603# The function above misuses the pressure acceleration function by passing a Matrix as `p_a`.
0 commit comments