Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCSPH Pressure eq consistency #185

Merged
merged 67 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
cc713b4
working
svchb Jun 20, 2023
923c71c
combine
svchb Jun 20, 2023
3de3008
format
svchb Jun 20, 2023
da9e34a
write values
svchb Jun 20, 2023
479b5f6
Merge branch 'main' into save_intermediate_values
svchb Jun 20, 2023
3c0d1b2
fix
svchb Jun 20, 2023
05fae66
add consistent form of pressure eq
svchb Jun 21, 2023
b4c3f35
typo
svchb Jun 21, 2023
b10683c
Merge remote-tracking branch 'refs/remotes/origin/main'
svchb Jun 27, 2023
53d8b2d
optimize
svchb Jun 27, 2023
c2f00c8
remove global dv arrays
svchb Jun 28, 2023
0c1792b
add example for debugging
svchb Jun 29, 2023
056d07d
format
svchb Jun 29, 2023
f90f017
Merge remote-tracking branch 'origin/main' into main
svchb Sep 5, 2023
82943b8
Merge branch 'main'
svchb Sep 6, 2023
82f79f8
fix
svchb Sep 6, 2023
5d47233
remove @unpack
svchb Sep 6, 2023
372d67c
Merge branch 'trixi-framework:main' into main
svchb Sep 7, 2023
f564478
Merge branch 'main' of github.com:svchb/TrixiParticles.jl
svchb Sep 20, 2023
9c9e182
Merge branch 'trixi-framework:main' into main
svchb Sep 25, 2023
6cc7bdf
Merge remote-tracking branch 'refs/remotes/origin/main'
svchb Sep 25, 2023
bab4ca8
format
svchb Sep 25, 2023
20e652b
Merge branch 'save_intermediate_values'
svchb Sep 25, 2023
f96c6a0
review comments
svchb Sep 26, 2023
a09e39a
rename
svchb Sep 26, 2023
647d22d
Merge branch 'main' into save_intermediate_values
svchb Sep 26, 2023
07a8bb8
Merge branch 'save_intermediate_values' of github.com:svchb/TrixiPart…
svchb Sep 26, 2023
7ad0643
format
svchb Sep 26, 2023
3add639
revert
svchb Sep 26, 2023
960ba24
rename
svchb Sep 26, 2023
56d4d85
format
svchb Sep 26, 2023
cc81ba9
add todo
svchb Sep 26, 2023
6d91669
allow to save multiple files by using a local iter
svchb Sep 26, 2023
efb1707
add todo
svchb Sep 26, 2023
2a9b4f6
format
svchb Sep 26, 2023
82c5705
rename functions
svchb Sep 26, 2023
7d75967
fix
svchb Sep 26, 2023
9a231ad
fix
svchb Sep 26, 2023
c2237b0
mistake
svchb Sep 26, 2023
fbe68d3
fix
svchb Sep 26, 2023
983e128
rename to viscosity_model
svchb Sep 27, 2023
36c82e4
switch param call order
svchb Sep 27, 2023
126a1cf
review comments
svchb Sep 27, 2023
530d504
format
svchb Sep 27, 2023
38657b3
fix
svchb Sep 27, 2023
18b1b36
move viscosity_model
svchb Sep 28, 2023
f840bfe
fix
svchb Sep 28, 2023
82903ed
format
svchb Sep 28, 2023
7e072e0
add comment
svchb Sep 28, 2023
8d6b87b
Merge branch 'save_intermediate_values'
svchb Sep 28, 2023
407951b
fix
svchb Sep 28, 2023
b31f3a1
format
svchb Sep 28, 2023
0d3ca81
add error check
svchb Sep 28, 2023
cd9a8ad
format
svchb Sep 28, 2023
90897f6
Merge branch 'main' of github.com:svchb/TrixiParticles.jl
svchb Sep 29, 2023
cecbda7
Merge branch 'main'
svchb Sep 29, 2023
74c9b8a
fix merge
svchb Sep 29, 2023
e2d3ab7
fix merge
svchb Sep 29, 2023
197b08c
fix merge
svchb Sep 29, 2023
c5d67b1
cleanup constructor
svchb Sep 29, 2023
da5cee7
format
svchb Sep 29, 2023
08a717a
Merge branch 'main' into pressure-eq-consistency
svchb Sep 30, 2023
dc1b4db
review comments
svchb Oct 2, 2023
8ed6ba4
Merge branch 'pressure-eq-consistency' of github.com:svchb/TrixiParti…
svchb Oct 2, 2023
c5c555b
Merge branch 'main' into pressure-eq-consistency
svchb Oct 2, 2023
16584f5
fix review comments
svchb Oct 2, 2023
78fcc0b
Merge branch 'pressure-eq-consistency' of github.com:svchb/TrixiParti…
svchb Oct 2, 2023
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
2 changes: 1 addition & 1 deletion src/callbacks/info.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function initialize_info_callback(discrete_callback, u, t, integrator;
show(io_context, MIME"text/plain"(), semi)
println(io, "\n")
systems = semi.systems
for system in systems
foreach_enumerate(systems) do (system_index, system)
show(io_context, MIME"text/plain"(), system)
println(io, "\n")
end
Expand Down
24 changes: 24 additions & 0 deletions src/general/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ struct Semidiscretization{S, RU, RV, NS, DC}
ranges_v = Tuple((sum(sizes_v[1:(i - 1)]) + 1):sum(sizes_v[1:i])
for i in eachindex(sizes_v))

# Check that the boundary systems are using a state equation if EDAC is not used.
# Other checks might be added here later.
check_configuration(systems)
svchb marked this conversation as resolved.
Show resolved Hide resolved

# Create (and initialize) a tuple of n neighborhood searches for each of the n systems
# We will need one neighborhood search for each pair of systems.
searches = Tuple(Tuple(create_neighborhood_search(system, neighbor,
Expand Down Expand Up @@ -479,3 +483,23 @@ function nhs_coords(system::BoundarySPHSystem,
# Don't update
return nothing
end

function check_configuration(systems)
foreach_enumerate(systems) do (system_index, system)
check_configuration(system, systems)
end
end

check_configuration(system, systems) = nothing

function check_configuration(boundary_system::BoundarySPHSystem, systems)
(; boundary_model) = boundary_system

foreach_enumerate(systems) do (neighbor_index, neighbor)
if neighbor isa WeaklyCompressibleSPHSystem &&
boundary_model isa BoundaryModelDummyParticles &&
isnothing(boundary_model.state_equation)
throw(ArgumentError("`WeaklyCompressibleSPHSystem` cannot be used without setting a `state_equation` for all boundary systems"))
end
end
end
3 changes: 2 additions & 1 deletion src/schemes/boundary/dummy_particles/dummy_particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ end
boundary_system,
v_boundary_system,
boundary_model::BoundaryModelDummyParticles, rho_a,
rho_b, pos_diff, distance, grad_kernel)
rho_b, pos_diff, distance, grad_kernel,
density_calculator)
rho_a = particle_density(v_particle_system, particle_system, particle)
rho_b = particle_density(v_boundary_system, boundary_system, boundary_particle)

Expand Down
3 changes: 2 additions & 1 deletion src/schemes/boundary/monaghan_kajtar/monaghan_kajtar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ end
v_particle_system, neighbor, neighbor_system,
v_neighbor_system,
boundary_model::BoundaryModelMonaghanKajtar, rho_a,
rho_b, pos_diff, distance, grad_kernel)
rho_b, pos_diff, distance, grad_kernel,
density_calculator)
(; smoothing_length) = particle_system
(; K, beta, boundary_particle_spacing) = boundary_model

Expand Down
27 changes: 22 additions & 5 deletions src/schemes/fluid/weakly_compressible_sph/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function interact!(dv, v_particle_system, u_particle_system,
dv_pressure = pressure_acceleration(pressure_correction, m_b, particle,
particle_system, v_particle_system,
neighbor, neighbor_system,
v_neighbor_system, rho_a, rho_b,
pos_diff, distance, grad_kernel)
v_neighbor_system, rho_a, rho_b, pos_diff,
distance, grad_kernel, density_calculator)

dv_viscosity = viscosity_correction *
viscosity(particle_system, neighbor_system,
Expand Down Expand Up @@ -71,11 +71,28 @@ function interact!(dv, v_particle_system, u_particle_system,
return dv
end

# As shown in "Variational and momentum preservation aspects of Smooth
# Particle Hydrodynamic formulations" by Bonet and Lok, 1999 for a consistent formulation
# this form has to be used with ContinuityDensity.
@inline function pressure_acceleration(pressure_correction, m_b, particle, particle_system,
v_particle_system, neighbor,
neighbor_system::WeaklyCompressibleSPHSystem,
v_neighbor_system, rho_a, rho_b, pos_diff, distance,
grad_kernel)
grad_kernel, ::ContinuityDensity)
return (-m_b *
(particle_system.pressure[particle] + neighbor_system.pressure[neighbor]) /
(rho_a * rho_b) * grad_kernel) *
pressure_correction
end

# As shown in "Variational and momentum preservation aspects of Smooth
# Particle Hydrodynamic formulations" by Bonet and Lok, 1999 for a consistent formulation
# this form has to be used with SummationDensity.
@inline function pressure_acceleration(pressure_correction, m_b, particle, particle_system,
v_particle_system, neighbor,
neighbor_system::WeaklyCompressibleSPHSystem,
v_neighbor_system, rho_a, rho_b, pos_diff, distance,
grad_kernel, ::SummationDensity)
return (-m_b *
(particle_system.pressure[particle] / rho_a^2 +
neighbor_system.pressure[neighbor] / rho_b^2) * grad_kernel) *
Expand All @@ -87,13 +104,13 @@ end
neighbor_system::Union{BoundarySPHSystem,
TotalLagrangianSPHSystem},
v_neighbor_system, rho_a, rho_b, pos_diff, distance,
grad_kernel)
grad_kernel, density_calculator)
(; boundary_model) = neighbor_system

return pressure_acceleration(pressure_correction, m_b, particle, particle_system,
v_particle_system, neighbor, neighbor_system,
v_neighbor_system, boundary_model, rho_a, rho_b, pos_diff,
distance, grad_kernel)
distance, grad_kernel, density_calculator)
end

@inline function continuity_equation!(dv, density_calculator::ContinuityDensity,
Expand Down
4 changes: 2 additions & 2 deletions src/schemes/solid/total_lagrangian_sph/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function interact!(dv, v_particle_system, u_particle_system,
particle_system::TotalLagrangianSPHSystem,
neighbor_system::WeaklyCompressibleSPHSystem)
(; boundary_model) = particle_system
(; state_equation, viscosity) = neighbor_system
(; density_calculator, state_equation, viscosity) = neighbor_system
(; sound_speed) = state_equation

system_coords = current_coordinates(u_particle_system, particle_system)
Expand Down Expand Up @@ -103,7 +103,7 @@ function interact!(dv, v_particle_system, u_particle_system,
particle_system, v_particle_system,
boundary_model, rho_a,
rho_b, pos_diff, distance,
grad_kernel)
grad_kernel, density_calculator)
dv_particle = dv_boundary + dv_viscosity

for i in 1:ndims(particle_system)
Expand Down