@@ -30,7 +30,10 @@ See [Entropically Damped Artificial Compressibility for SPH](@ref edac) for more
3030 When set to `nothing`, the pressure acceleration formulation for the
3131 corresponding [density calculator](@ref density_calculator) is chosen.
3232- `density_calculator`: [Density calculator](@ref density_calculator) (default: [`SummationDensity`](@ref))
33- - `transport_velocity`: [Transport Velocity Formulation (TVF)](@ref transport_velocity_formulation). Default is no TVF.
33+ - `transport_velocity`: [Transport Velocity Formulation (TVF)](@ref transport_velocity_formulation).
34+ Default is no TVF.
35+ - `average_pressure_reduction`: Whether to subtract the average pressure of neighboring particles
36+ from the local pressure (default: `true` when using TVF, `false` otherwise).
3437- `buffer_size`: Number of buffer particles.
3538 This is needed when simulating with [`OpenBoundarySPHSystem`](@ref).
3639- `correction`: Correction method used for this system. (default: no correction, see [Corrections](@ref corrections))
@@ -53,7 +56,7 @@ See [Entropically Damped Artificial Compressibility for SPH](@ref edac) for more
5356
5457"""
5558struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real , IC, M, DC, K, V, COR, PF, TV,
56- ST, SRFT, SRFN, B, PR, C} <: FluidSystem{NDIMS}
59+ AVGP, ST, SRFT, SRFN, B, PR, C} <: FluidSystem{NDIMS}
5760 initial_condition :: IC
5861 mass :: M # Vector{ELTYPE}: [particle]
5962 density_calculator :: DC
@@ -65,6 +68,7 @@ struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real, IC, M, DC, K, V, COR,
6568 correction :: COR
6669 pressure_acceleration_formulation :: PF
6770 transport_velocity :: TV
71+ average_pressure_reduction :: AVGP
6872 source_terms :: ST
6973 surface_tension :: SRFT
7074 surface_normal_method :: SRFN
@@ -80,6 +84,7 @@ function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
8084 pressure_acceleration= inter_particle_averaged_pressure,
8185 density_calculator= SummationDensity (),
8286 transport_velocity= nothing ,
87+ average_pressure_reduction= ! isnothing (transport_velocity),
8388 alpha= 0.5 , viscosity= nothing ,
8489 acceleration= ntuple (_ -> 0.0 ,
8590 ndims (smoothing_kernel)),
@@ -127,10 +132,14 @@ function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
127132 NDIMS, ELTYPE,
128133 correction)
129134
135+ avg_pressure_reduction = Val (average_pressure_reduction)
136+
130137 nu_edac = (alpha * smoothing_length * sound_speed) / 8
131138
132139 cache = (; create_cache_density (initial_condition, density_calculator)... ,
133- create_cache_tvf_edac (initial_condition, transport_velocity)... ,
140+ create_cache_tvf (initial_condition, transport_velocity)... ,
141+ create_cache_avg_pressure_reduction (initial_condition,
142+ avg_pressure_reduction)... ,
134143 create_cache_surface_normal (surface_normal_method, ELTYPE, NDIMS,
135144 n_particles)... ,
136145 create_cache_surface_tension (surface_tension, ELTYPE, NDIMS,
@@ -152,19 +161,29 @@ function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
152161 EntropicallyDampedSPHSystem{NDIMS, ELTYPE, typeof (initial_condition), typeof (mass),
153162 typeof (density_calculator), typeof (smoothing_kernel),
154163 typeof (viscosity), typeof (correction),
155- typeof (pressure_acceleration),
156- typeof (transport_velocity ), typeof (source_terms),
164+ typeof (pressure_acceleration), typeof (transport_velocity),
165+ typeof (avg_pressure_reduction ), typeof (source_terms),
157166 typeof (surface_tension), typeof (surface_normal_method),
158167 typeof (buffer), Nothing,
159168 typeof (cache)}(initial_condition, mass, density_calculator,
160169 smoothing_kernel, sound_speed, viscosity,
161170 nu_edac, acceleration_, correction,
162171 pressure_acceleration, transport_velocity,
172+ avg_pressure_reduction,
163173 source_terms, surface_tension,
164174 surface_normal_method, buffer,
165175 particle_refinement, cache)
166176end
167177
178+ create_cache_avg_pressure_reduction (initial_condition, :: Val{false} ) = (;)
179+
180+ function create_cache_avg_pressure_reduction (initial_condition, :: Val{true} )
181+ pressure_average = copy (initial_condition. pressure)
182+ neighbor_counter = Vector {Int} (undef, nparticles (initial_condition))
183+
184+ return (; pressure_average, neighbor_counter)
185+ end
186+
168187function Base. show (io:: IO , system:: EntropicallyDampedSPHSystem )
169188 @nospecialize system # reduce precompilation time
170189
@@ -201,6 +220,8 @@ function Base.show(io::IO, ::MIME"text/plain", system::EntropicallyDampedSPHSyst
201220 summary_line (io, " smoothing kernel" , system. smoothing_kernel |> typeof |> nameof)
202221 summary_line (io, " tansport velocity formulation" ,
203222 system. transport_velocity |> typeof |> nameof)
223+ summary_line (io, " average pressure reduction" ,
224+ typeof (system. average_pressure_reduction). parameters[1 ] ? " yes" : " no" )
204225 summary_line (io, " acceleration" , system. acceleration)
205226 summary_line (io, " surface tension" , system. surface_tension)
206227 summary_line (io, " surface normal method" , system. surface_normal_method)
@@ -252,17 +273,15 @@ end
252273
253274@inline transport_velocity (system:: EntropicallyDampedSPHSystem ) = system. transport_velocity
254275
255- @inline average_pressure (system, particle) = zero (eltype (system))
256-
257276@inline function average_pressure (system:: EntropicallyDampedSPHSystem , particle)
258- average_pressure (system, transport_velocity ( system) , particle)
277+ average_pressure (system, system. average_pressure_reduction , particle)
259278end
260279
261- @inline function average_pressure (system, :: TransportVelocityAdami , particle)
280+ @inline function average_pressure (system, :: Val{true} , particle)
262281 return system. cache. pressure_average[particle]
263282end
264283
265- @inline average_pressure (system, :: Nothing , particle) = zero (eltype (system))
284+ @inline average_pressure (system, :: Val{false} , particle) = zero (eltype (system))
266285
267286@inline function current_density (v, system:: EntropicallyDampedSPHSystem )
268287 return current_density (v, system. density_calculator, system)
@@ -301,18 +320,21 @@ function update_final!(system::EntropicallyDampedSPHSystem, v, u, v_ode, u_ode,
301320 # Surface normal of neighbor and boundary needs to have been calculated already
302321 compute_curvature! (system, surface_tension, v, u, v_ode, u_ode, semi, t)
303322 compute_stress_tensors! (system, surface_tension, v, u, v_ode, u_ode, semi, t)
304- update_average_pressure! (system, transport_velocity ( system) , v_ode, u_ode, semi)
323+ update_average_pressure! (system, system. average_pressure_reduction , v_ode, u_ode, semi)
305324 update_tvf! (system, transport_velocity (system), v, u, v_ode, u_ode, semi, t)
306325end
307326
308- function update_average_pressure! (system, :: Nothing , v_ode, u_ode, semi)
327+ # No average pressure reduction is used
328+ function update_average_pressure! (system, :: Val{false} , v_ode, u_ode, semi)
309329 return system
310330end
311331
312- # This technique is for a more robust `pressure_acceleration` but only with TVF.
313- # It results only in significant improvement for EDAC and not for WCSPH.
314- # See Ramachandran (2019) p. 582.
315- function update_average_pressure! (system, :: TransportVelocityAdami , v_ode, u_ode, semi)
332+ # This technique by Basa et al. 2017 (10.1002/fld.1927) aims to reduce numerical errors
333+ # due to large pressures by subtracting the average pressure of neighboring particles.
334+ # It results in significant improvement for EDAC, especially with TVF,
335+ # but not for WCSPH, according to Ramachandran & Puri (2019), Section 3.2.
336+ # See eq. 16 and 17 in Ramachandran & Puri (2019) for an explanation of the technique.
337+ function update_average_pressure! (system, :: Val{true} , v_ode, u_ode, semi)
316338 (; cache) = system
317339 (; pressure_average, neighbor_counter) = cache
318340
0 commit comments