Skip to content

Commit 02eb6cd

Browse files
committed
Fix tests and add comments
1 parent fde5c59 commit 02eb6cd

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

  • src/schemes/fluid
    • implicit_incompressible_sph
    • weakly_compressible_sph

src/schemes/fluid/implicit_incompressible_sph/rhs.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,14 @@ function interact!(dv, v_particle_system, u_particle_system,
4747
m_a = @inbounds hydrodynamic_mass(particle_system, particle)
4848
m_b = @inbounds hydrodynamic_mass(neighbor_system, neighbor)
4949

50+
p_a = @inbounds current_pressure(v_particle_system, particle_system, particle)
5051
# The following call is equivalent to
51-
# `p_a = particle_pressure(v_particle_system, particle_system, particle)`
52-
# `p_b = particle_pressure(v_neighbor_system, neighbor_system, neighbor)`
53-
# Only when the neighbor system is a `WallBoundarySystem` or a `TotalLagrangianSPHSystem`
54-
# with the boundary model `PressureMirroring`, this will return `p_b = p_a`, which is
55-
# the pressure of the fluid particle.
56-
p_a,
57-
p_b = @inbounds particle_neighbor_pressure(v_particle_system,
58-
v_neighbor_system,
59-
particle_system, neighbor_system,
60-
particle, neighbor)
52+
# `p_b = current_pressure(v_neighbor_system, neighbor_system, neighbor)`
53+
# Only when the neighbor system is a `WallBoundarySystem`
54+
# or a `TotalLagrangianSPHSystem` with the boundary model `PressureMirroring`,
55+
# this will return `p_b = p_a`, which is the pressure of the fluid particle.
56+
p_b = @inbounds neighbor_pressure(v_neighbor_system, neighbor_system,
57+
neighbor, p_a)
6158

6259
dv_pressure = pressure_acceleration(particle_system, neighbor_system,
6360
particle, neighbor,

src/schemes/fluid/weakly_compressible_sph/rhs.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,28 @@ end
147147
return velocity_and_density(v, density_calculator, system, particle)
148148
end
149149

150+
@propagate_inbounds function velocity_and_density(v, system, particle)
151+
# Call the default method below
152+
return velocity_and_density(v, nothing, system, particle)
153+
end
154+
155+
# Default method, which simply calls `current_velocity` and `current_density` separately.
150156
@propagate_inbounds function velocity_and_density(v, _, system, particle)
151157
v_particle = current_velocity(v, system, particle)
152158
rho_particle = current_density(v, system, particle)
153159

154160
return v_particle, rho_particle
155161
end
156162

163+
# Optimized version for WCSPH with `ContinuityDensity` in 3D on GPUs,
164+
# which combines the velocity and density load into one wide load.
157165
@inline function velocity_and_density(v::AbstractGPUArray, ::ContinuityDensity,
158166
::WeaklyCompressibleSPHSystem{3}, particle)
159167
# Since `v` is stored as a 4 x N matrix, this aligned load extracts one column
160168
# of `v` corresponding to `particle`.
161169
# As opposed to `extract_svector`, this will translate to a single wide load instruction
162170
# on the GPU, which is faster than 4 separate loads.
171+
# Note that this doesn't work for 2D because it requires a stride of 2^n.
163172
vrho_a = vloada(Vec{4, eltype(v)}, pointer(v, 4 * (particle - 1) + 1))
164173

165174
# The column of `v` is ordered as (v_x, v_y, v_z, rho)

0 commit comments

Comments
 (0)