Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ used in the Julia ecosystem. Notable changes will be documented in this file for

## Version 0.5.4

### API Changes
### API Changes

- Replaced the experimental `MechanicalWorkCalculatorCallback` with
`MechanicalWorkCalculator`, which can be passed as a custom quantity to
`PostprocessCallback` (#1228).
- The compact support of a `BoundaryModelDummyParticles` of a `TotalLagrangianSPHSystem`
or `RigidBodySystem` must now be the same as the compact support of all fluid systems
in the simulation (#1348).

### Important Bugfixes

Expand All @@ -24,8 +27,10 @@ used in the Julia ecosystem. Notable changes will be documented in this file for
- Fixed the custom quantities `kinetic_energy`, `total_mass`, `max_pressure`, `min_pressure`,
`avg_pressure`, `max_density`, `min_density` and `avg_density` to only take active particles
into account (#1184).
- Fixed the IISPH pressure solver to clear stale density error contributions of
zero-pressure particles instead of retaining them in the termination condition (#1215).
- Fixed the IISPH pressure solver to clear stale density error contributions of
zero-pressure particles instead of retaining them in the termination condition (#1215).
- Fixed the viscous force on structures in fluid-structure interaction, which had the wrong
sign (#1348).

## Version 0.5.3

Expand Down
2 changes: 1 addition & 1 deletion examples/fsi/hydrostatic_water_column_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ boundary_model_structure = BoundaryModelDummyParticles(hydrodynamic_densities,
hydrodynamic_masses,
boundary_density_calculator,
smoothing_kernel,
smoothing_length_structure;
smoothing_length_fluid;
state_equation)
structure_system = TotalLagrangianSPHSystem(structure_geometry;
smoothing_kernel,
Expand Down
3 changes: 3 additions & 0 deletions src/schemes/boundary/wall_boundary/dummy_particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Boundary model for [`WallBoundarySystem`](@ref).
See [the docs](@ref boundary_models) for more information.
- `smoothing_kernel`: Smoothing kernel should be the same as for the adjacent fluid system.
- `smoothing_length`: Smoothing length should be the same as for the adjacent fluid system.
For a [`TotalLagrangianSPHSystem`](@ref) or a [`RigidBodySystem`](@ref),
the compact support of `smoothing_kernel` and `smoothing_length`
must be the same as for all fluid systems in the simulation.

# Keywords
- `state_equation`: This should be the same as for the adjacent fluid system
Expand Down
99 changes: 63 additions & 36 deletions src/schemes/fluid/entropically_damped_sph/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ function interact!(dv, v_particle_system, u_particle_system,
system_coords = current_coordinates(u_particle_system, particle_system)
neighbor_coords = current_coordinates(u_neighbor_system, neighbor_system)

surface_tension_a = surface_tension_model(particle_system)
surface_tension_b = surface_tension_model(neighbor_system)

h = initial_smoothing_length(particle_system)

# Loop over all pairs of particles and neighbors within the kernel cutoff
Expand Down Expand Up @@ -42,31 +39,21 @@ function interact!(dv, v_particle_system, u_particle_system,
p_a = @inbounds current_pressure(v_particle_system, particle_system, particle)
p_b = @inbounds current_pressure(v_neighbor_system, neighbor_system, neighbor)

# This technique by Basa et al. 2017 (10.1002/fld.1927) aims to reduce numerical
# errors due to large pressures by subtracting the average pressure of neighboring
# particles.
# It results in significant improvement for EDAC, especially with TVF,
# but not for WCSPH, according to Ramachandran & Puri (2019), Section 3.2.
# Note that the return value is zero when not using average pressure reduction.
p_avg = @inbounds average_pressure(particle_system, particle)

m_a = @inbounds hydrodynamic_mass(particle_system, particle)
m_b = @inbounds hydrodynamic_mass(neighbor_system, neighbor)

dv_pressure = pressure_acceleration(particle_system, neighbor_system,
particle, neighbor,
m_a, m_b, p_a - p_avg, p_b - p_avg, rho_a,
rho_b, pos_diff, distance, grad_kernel,
correction)

dv_particle = @inbounds add_dv_viscosity(dv_pressure, particle_system,
neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor, pos_diff, distance,
sound_speed, m_a, m_b, rho_a, rho_b,
v_a, v_b, grad_kernel)

# Extra terms in the momentum equation when using a shifting technique
# Propagate `@inbounds` to the momentum equation, which accesses particle data
dv_particle = @inbounds add_momentum_equation(zero(v_a), particle_system,
neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor,
pos_diff, distance, grad_kernel,
sound_speed, m_a, m_b, p_a, p_b,
rho_a, rho_b, v_a, v_b)

# Extra terms in the momentum equation when using a shifting technique.
# These are not included in `add_momentum_equation` because they must not be
# applied to structures (see `interact_structure_fluid!`).
dv_particle = @inbounds add_dv_shifting(dv_particle,
shifting_technique(particle_system),
particle_system, neighbor_system,
Expand All @@ -75,17 +62,6 @@ function interact!(dv, v_particle_system, u_particle_system,
v_a, v_b,
pos_diff, distance, grad_kernel, correction)

dv_particle = @inbounds add_dv_surface_tension(dv_particle,
surface_tension_a, surface_tension_b,
particle_system, neighbor_system,
particle, neighbor,
pos_diff, distance,
rho_a, rho_b, grad_kernel, 1)

dv_particle = @inbounds add_dv_adhesion(dv_particle, surface_tension_a,
particle_system, neighbor_system,
particle, neighbor, pos_diff, distance)

for i in 1:ndims(particle_system)
@inbounds dv[i, particle] += dv_particle[i]
end
Expand Down Expand Up @@ -114,6 +90,57 @@ function interact!(dv, v_particle_system, u_particle_system,
return dv
end

# Add the acceleration of `particle` due to `neighbor` to `dv_particle`.
# `particle` must be in `particle_system` and `neighbor` must be in `neighbor_system`.
# This includes pressure, viscosity, surface tension and adhesion, but not the extra terms
# from shifting techniques (see `interact_structure_fluid!`).
# Note that this function is also used for the structure-fluid interaction to compute
# the exact opposite pair force. When adding new terms here, make sure that they are
# also valid for structure neighbors.
@propagate_inbounds function add_momentum_equation(dv_particle,
particle_system::EntropicallyDampedSPHSystem,
neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor, pos_diff, distance,
grad_kernel, sound_speed, m_a, m_b,
p_a, p_b, rho_a, rho_b, v_a, v_b)
(; correction) = particle_system

surface_tension_a = surface_tension_model(particle_system)
surface_tension_b = surface_tension_model(neighbor_system)

# This technique by Basa et al. 2017 (10.1002/fld.1927) aims to reduce numerical
# errors due to large pressures by subtracting the average pressure of neighboring
# particles.
# It results in significant improvement for EDAC, especially with TVF,
# but not for WCSPH, according to Ramachandran & Puri (2019), Section 3.2.
# Note that the return value is zero when not using average pressure reduction.
p_avg = average_pressure(particle_system, particle)

dv_particle += pressure_acceleration(particle_system, neighbor_system,
particle, neighbor,
m_a, m_b, p_a - p_avg, p_b - p_avg, rho_a,
rho_b, pos_diff, distance, grad_kernel,
correction)

dv_particle = add_dv_viscosity(dv_particle, particle_system, neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor, pos_diff, distance,
sound_speed, m_a, m_b, rho_a, rho_b,
v_a, v_b, grad_kernel)

dv_particle = add_dv_surface_tension(dv_particle, surface_tension_a, surface_tension_b,
particle_system, neighbor_system,
particle, neighbor, pos_diff, distance,
rho_a, rho_b, grad_kernel, 1)

dv_particle = add_dv_adhesion(dv_particle, surface_tension_a,
particle_system, neighbor_system,
particle, neighbor, pos_diff, distance)

return dv_particle
end

@inline function pressure_evolution!(dv, particle_system, neighbor_system, v_diff,
grad_kernel, particle, neighbor,
pos_diff, distance, sound_speed, m_a, m_b,
Expand Down
48 changes: 35 additions & 13 deletions src/schemes/fluid/implicit_incompressible_sph/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,44 @@ function interact!(dv, v_particle_system, u_particle_system,
p_b = @inbounds neighbor_pressure(v_neighbor_system, neighbor_system,
neighbor, p_a)

dv_pressure = pressure_acceleration(particle_system, neighbor_system,
particle, neighbor,
m_a, m_b, p_a, p_b, rho_a, rho_b, pos_diff,
distance, grad_kernel, nothing)

# Propagate `@inbounds` to the viscosity function, which accesses particle data
dv_viscosity_ = @inbounds add_dv_viscosity(zero(pos_diff), particle_system,
neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor, pos_diff, distance,
sound_speed, m_a, m_b, rho_a, rho_b,
v_a, v_b, grad_kernel)
# Propagate `@inbounds` to the momentum equation, which accesses particle data.
dv_particle = @inbounds add_momentum_equation(zero(v_a), particle_system,
neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor,
pos_diff, distance, grad_kernel,
sound_speed, m_a, m_b, p_a, p_b,
rho_a, rho_b, v_a, v_b)

for i in 1:ndims(particle_system)
@inbounds dv[i, particle] += dv_pressure[i] + dv_viscosity_[i]
@inbounds dv[i, particle] += dv_particle[i]
end
end
return dv
end

# Add the acceleration of `particle` due to `neighbor` to `dv_particle`.
# `particle` must be in `particle_system` and `neighbor` must be in `neighbor_system`.
# Note that this function is also used for the structure-fluid interaction to compute
# the exact opposite pair force. When adding new terms here, make sure that they are
# also valid for structure neighbors.
@propagate_inbounds function add_momentum_equation(dv_particle,
particle_system::ImplicitIncompressibleSPHSystem,
neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor, pos_diff, distance,
grad_kernel, sound_speed, m_a, m_b,
p_a, p_b, rho_a, rho_b, v_a, v_b)
dv_particle += pressure_acceleration(particle_system, neighbor_system,
particle, neighbor,
m_a, m_b, p_a, p_b, rho_a, rho_b, pos_diff,
distance, grad_kernel, nothing)

dv_particle = add_dv_viscosity(dv_particle, particle_system, neighbor_system,
v_particle_system, v_neighbor_system,
particle, neighbor, pos_diff, distance,
sound_speed, m_a, m_b, rho_a, rho_b,
v_a, v_b, grad_kernel)

return dv_particle
end
Loading
Loading