@@ -9,7 +9,8 @@ A benchmark of the right-hand side of a full real-life Weakly Compressible
99Smoothed Particle Hydrodynamics (WCSPH) simulation with TrixiParticles.jl.
1010This method is used to simulate an incompressible fluid.
1111"""
12- function benchmark_wcsph (neighborhood_search, coordinates; parallel = true )
12+ function benchmark_wcsph (neighborhood_search, coordinates;
13+ parallelization_backend = default_backend (coordinates))
1314 density = 1000.0
1415 fluid = InitialCondition (; coordinates, density, mass = 0.1 )
1516
@@ -34,19 +35,12 @@ function benchmark_wcsph(neighborhood_search, coordinates; parallel = true)
3435 smoothing_length, viscosity = viscosity,
3536 density_diffusion = density_diffusion)
3637
37- # Note that we cannot just disable parallelism in TrixiParticles.
38- # But passing a different backend like `CUDA.CUDABackend`
39- # allows us to change the type of the array to run the benchmark on the GPU.
40- if parallel isa Bool
41- system = fluid_system
42- nhs = neighborhood_search
43- else
44- system = PointNeighbors. Adapt. adapt (parallel, fluid_system)
45- nhs = PointNeighbors. Adapt. adapt (parallel, neighborhood_search)
46- end
38+ system = PointNeighbors. Adapt. adapt (parallelization_backend, fluid_system)
39+ nhs = PointNeighbors. Adapt. adapt (parallelization_backend, neighborhood_search)
4740
48- v = PointNeighbors. Adapt. adapt (parallel, vcat (fluid. velocity, fluid. density' ))
49- u = PointNeighbors. Adapt. adapt (parallel, coordinates)
41+ v = PointNeighbors. Adapt. adapt (parallelization_backend,
42+ vcat (fluid. velocity, fluid. density' ))
43+ u = PointNeighbors. Adapt. adapt (parallelization_backend, coordinates)
5044 dv = zero (v)
5145
5246 # Initialize the system
6155
6256Like [`benchmark_wcsph`](@ref), but using single precision floating point numbers.
6357"""
64- function benchmark_wcsph_fp32 (neighborhood_search, coordinates_; parallel = true )
58+ function benchmark_wcsph_fp32 (neighborhood_search, coordinates_;
59+ parallelization_backend = default_backend (coordinates_))
6560 coordinates = convert (Matrix{Float32}, coordinates_)
6661 density = 1000.0f0
6762 fluid = InitialCondition (; coordinates, density, mass = 0.1f0 )
@@ -88,19 +83,12 @@ function benchmark_wcsph_fp32(neighborhood_search, coordinates_; parallel = true
8883 acceleration = (0.0f0 , 0.0f0 , 0.0f0 ),
8984 density_diffusion = density_diffusion)
9085
91- # Note that we cannot just disable parallelism in TrixiParticles.
92- # But passing a different backend like `CUDA.CUDABackend`
93- # allows us to change the type of the array to run the benchmark on the GPU.
94- if parallel isa Bool
95- system = fluid_system
96- nhs = neighborhood_search
97- else
98- system = PointNeighbors. Adapt. adapt (parallel, fluid_system)
99- nhs = PointNeighbors. Adapt. adapt (parallel, neighborhood_search)
100- end
86+ system = PointNeighbors. Adapt. adapt (parallelization_backend, fluid_system)
87+ nhs = PointNeighbors. Adapt. adapt (parallelization_backend, neighborhood_search)
10188
102- v = PointNeighbors. Adapt. adapt (parallel, vcat (fluid. velocity, fluid. density' ))
103- u = PointNeighbors. Adapt. adapt (parallel, coordinates)
89+ v = PointNeighbors. Adapt. adapt (parallelization_backend,
90+ vcat (fluid. velocity, fluid. density' ))
91+ u = PointNeighbors. Adapt. adapt (parallelization_backend, coordinates)
10492 dv = zero (v)
10593
10694 # Initialize the system
@@ -117,7 +105,8 @@ A benchmark of the right-hand side of a full real-life Total Lagrangian
117105Smoothed Particle Hydrodynamics (TLSPH) simulation with TrixiParticles.jl.
118106This method is used to simulate an elastic structure.
119107"""
120- function benchmark_tlsph (neighborhood_search, coordinates; parallel = true )
108+ function benchmark_tlsph (neighborhood_search, coordinates;
109+ parallelization_backend = default_backend (coordinates))
121110 material = (density = 1000.0 , E = 1.4e6 , nu = 0.4 )
122111 solid = InitialCondition (; coordinates, density = material. density, mass = 0.1 )
123112
0 commit comments