Skip to content

Commit

Permalink
Add TLSPH benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber committed Jun 20, 2024
1 parent 4c06a79 commit 300ee56
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion benchmarks/smoothed_particle_hydrodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ using BenchmarkTools

const TrivialNeighborhoodSearch = PointNeighbors.TrivialNeighborhoodSearch
const GridNeighborhoodSearch = PointNeighbors.GridNeighborhoodSearch
const PrecomputedNeighborhoodSearch = PointNeighbors.PrecomputedNeighborhoodSearch

"""
benchmark_wcsph(neighborhood_search, coordinates; parallel = true)
A benchmark of the right-hand side of a full real-life Weakly Compressible
Smoothed Particle Hydrodynamics (WCSPH) simulation with TrixiParticles.jl.
This method is used to simulate an incompressible fluid.
"""
function benchmark_wcsph(neighborhood_search, coordinates; parallel = true)
density = 1000.0
fluid = InitialCondition(; coordinates, density, mass = 0.1)

# Compact support == smoothing length for the Wendland kernel
smoothing_length = neighborhood_search.search_radius
if neighborhood_search isa PrecomputedNeighborhoodSearch
smoothing_length = neighborhood_search.neighborhood_search.search_radius
else
smoothing_length = neighborhood_search.search_radius
end
smoothing_kernel = WendlandC2Kernel{ndims(neighborhood_search)}()

sound_speed = 10.0
Expand All @@ -39,3 +45,33 @@ function benchmark_wcsph(neighborhood_search, coordinates; parallel = true)
return @belapsed TrixiParticles.interact!($dv, $v, $u, $v, $u, $neighborhood_search,
$fluid_system, $fluid_system)
end

"""
benchmark_tlsph(neighborhood_search, coordinates; parallel = true)
A benchmark of the right-hand side of a full real-life Total Lagrangian
Smoothed Particle Hydrodynamics (TLSPH) simulation with TrixiParticles.jl.
This method is used to simulate an elastic structure.
"""
function benchmark_tlsph(neighborhood_search, coordinates; parallel = true)
material = (density = 1000.0, E = 1.4e6, nu = 0.4)
solid = InitialCondition(; coordinates, density = material.density, mass = 0.1)

# Compact support == smoothing length for the Wendland kernel
if neighborhood_search isa PrecomputedNeighborhoodSearch
smoothing_length = neighborhood_search.neighborhood_search.search_radius
else
smoothing_length = neighborhood_search.search_radius
end
smoothing_kernel = WendlandC2Kernel{ndims(neighborhood_search)}()

solid_system = TotalLagrangianSPHSystem(solid, smoothing_kernel, smoothing_length,
material.E, material.nu)

v = copy(solid.velocity)
u = copy(solid.coordinates)
dv = zero(v)

return @belapsed TrixiParticles.interact!($dv, $v, $u, $v, $u, $neighborhood_search,
$solid_system, $solid_system)
end

0 comments on commit 300ee56

Please sign in to comment.