4949end
5050
5151# Additional term(s) in the continuity equation due to the shifting technique
52- function continuity_equation_shifting! (dv, shifting ,
53- particle_system, neighbor_system,
54- particle, neighbor, grad_kernel, rho_a, rho_b, m_b )
55- return dv
52+ @inline function continuity_equation_shifting_term (shifting, particle_system ,
53+ neighbor_system,
54+ particle, neighbor, rho_a, rho_b)
55+ return zero (SVector{ ndims (particle_system), eltype (particle_system)})
5656end
5757
5858@doc raw """
@@ -324,10 +324,11 @@ See [`ParticleShiftingTechnique`](@ref).
324324struct MomentumEquationTermSun2019 end
325325
326326# Additional term in the momentum equation due to the shifting technique
327- @inline function dv_shifting (shifting:: ParticleShiftingTechnique , system, neighbor_system,
328- v_system, v_neighbor_system, particle, neighbor,
329- m_a, m_b, rho_a, rho_b, pos_diff, distance,
330- grad_kernel, correction)
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)
331332 return dv_shifting (shifting. momentum_equation_term, system, neighbor_system,
332333 v_system, v_neighbor_system, particle, neighbor,
333334 m_a, m_b, rho_a, rho_b, pos_diff, distance,
@@ -351,21 +352,19 @@ end
351352end
352353
353354# `ParticleShiftingTechnique{<:Any, <:Any, true}` means `modify_continuity_equation=true`
354- function continuity_equation_shifting! (dv,
355- shifting:: ParticleShiftingTechnique {<: Any , <: Any ,
356- true },
357- system, neighbor_system,
358- particle, neighbor, grad_kernel, rho_a, rho_b, m_b)
359- delta_v_diff = delta_v (system, particle) -
360- delta_v (neighbor_system, neighbor)
361-
362- dv[end , particle] += rho_a / rho_b * m_b * dot (delta_v_diff, grad_kernel)
363-
364- second_continuity_equation_term! (dv, shifting. second_continuity_equation_term,
365- system, neighbor_system,
366- particle, neighbor, grad_kernel, rho_a, rho_b, m_b)
355+ @propagate_inbounds function continuity_equation_shifting_term (shifting:: ParticleShiftingTechnique {<: Any ,
356+ <: Any ,
357+ true },
358+ system, neighbor_system,
359+ particle, neighbor,
360+ rho_a, rho_b)
361+ delta_v_a = delta_v (system, particle)
362+ delta_v_b = delta_v (neighbor_system, neighbor)
363+ delta_v_diff = delta_v_a - delta_v_b
367364
368- return dv
365+ second_term = second_continuity_equation_term (shifting. second_continuity_equation_term,
366+ delta_v_a, delta_v_b, rho_a, rho_b)
367+ return delta_v_diff + second_term
369368end
370369
371370"""
@@ -378,29 +377,23 @@ See [`ParticleShiftingTechnique`](@ref).
378377"""
379378struct ContinuityEquationTermSun2019 end
380379
381- @inline function second_continuity_equation_term! (dv,
382- :: ContinuityEquationTermSun2019 ,
383- system, neighbor_system,
384- particle, neighbor, grad_kernel,
385- rho_a, rho_b, m_b)
386- rho_v = rho_a * delta_v (system, particle) + rho_b * delta_v (neighbor_system, neighbor)
387-
388- dv[end , particle] += m_b / rho_b * dot (rho_v, grad_kernel)
389-
390- return dv
380+ @propagate_inbounds function second_continuity_equation_term (:: ContinuityEquationTermSun2019 ,
381+ delta_v_a, delta_v_b,
382+ rho_a, rho_b)
383+ return delta_v_a + rho_b / rho_a * delta_v_b
391384end
392385
393- @inline function second_continuity_equation_term! (dv, second_continuity_equation_term,
394- system, neighbor_system,
395- particle, neighbor, grad_kernel,
396- rho_a, rho_b, m_b)
397- return dv
386+ @inline function second_continuity_equation_term (second_continuity_equation_term,
387+ delta_v_a, delta_v_b, rho_a, rho_b)
388+ return zero (delta_v_a)
398389end
399390
400391# `ParticleShiftingTechnique{<:Any, true}` means `update_everystage=true`
401392function update_shifting! (system, shifting:: ParticleShiftingTechnique{<:Any, true} ,
402393 v, u, v_ode, u_ode, semi)
403- update_shifting_inner! (system, shifting, v, u, v_ode, u_ode, semi)
394+ @trixi_timeit timer () " update shifting" begin
395+ update_shifting_inner! (system, shifting, v, u, v_ode, u_ode, semi)
396+ end
404397end
405398
406399# `ParticleShiftingTechnique{<:Any, false}` means `update_everystage=false`
@@ -506,10 +499,10 @@ end
506499function particle_shifting_from_callback! (u_ode,
507500 shifting:: ParticleShiftingTechnique{<:Any, false} ,
508501 system, v_ode, semi, integrator)
509- @trixi_timeit timer () " particle shifting" begin
510- # Update the shifting velocity
511- update_shifting_from_callback! (system, shifting, v_ode, u_ode, semi)
502+ # Update the shifting velocity
503+ update_shifting_from_callback! (system, shifting, v_ode, u_ode, semi)
512504
505+ @trixi_timeit timer () " apply particle shifting" begin
513506 # Update the particle positions with the shifting velocity
514507 apply_particle_shifting! (u_ode, shifting, system, semi, integrator. dt)
515508 end
@@ -604,18 +597,18 @@ end
604597# The function above misuses the pressure acceleration function by passing a Matrix as `p_a`.
605598# This doesn't work with `tensile_instability_control`, so we disable TIC in this case.
606599@inline function tensile_instability_control (m_a, m_b, rho_a, rho_b, p_a:: SMatrix , p_b, W_a)
607- return pressure_acceleration_continuity_density (m_a, m_b, rho_a, rho_b, p_a, A_b , W_a)
600+ return pressure_acceleration_continuity_density (m_a, m_b, rho_a, rho_b, p_a, p_b , W_a)
608601end
609602
610- function continuity_equation_shifting! (dv, shifting:: TransportVelocityAdami{true} ,
611- particle_system, neighbor_system,
612- particle, neighbor, grad_kernel, rho_a, rho_b, m_b)
603+ @propagate_inbounds function continuity_equation_shifting_term (:: TransportVelocityAdami{true} ,
604+ particle_system,
605+ neighbor_system,
606+ particle, neighbor,
607+ rho_a, rho_b)
613608 delta_v_diff = delta_v (particle_system, particle) -
614609 delta_v (neighbor_system, neighbor)
615610
616- dv[end , particle] += rho_a / rho_b * m_b * dot (delta_v_diff, grad_kernel)
617-
618- return dv
611+ return delta_v_diff
619612end
620613
621614function update_shifting! (system, shifting:: TransportVelocityAdami , v, u, v_ode,
0 commit comments