Skip to content

Commit 38a1e2f

Browse files
svchbLasNikas
authored andcommitted
Rename 'tlsph' to 'place_on_shell' (#814)
* rename * format * forgot some * format * naming * forgot some more * fix test * incorporate review comments * format --------- Co-authored-by: Niklas Neher <73897120+LasNikas@users.noreply.github.com>
1 parent 995f182 commit 38a1e2f

17 files changed

+128
-110
lines changed

examples/dem/collapsing_sand_pile_3d.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ min_coords_floor = (min_boundary[1] - boundary_thickness,
5555
floor_particles = RectangularShape(particle_spacing,
5656
(n_particles_floor_x, n_particles_floor_y,
5757
n_particles_floor_z),
58-
min_coords_floor; density=boundary_density, tlsph=true)
58+
min_coords_floor; density=boundary_density,
59+
place_on_shell=true)
5960
boundary_particles = floor_particles
6061

6162
# ==========================================================================================

examples/fsi/dam_break_gate_2d.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ solid_particle_spacing = thickness / (n_particles_x - 1)
8383
n_particles_y = round(Int, length_beam / solid_particle_spacing) + 1
8484

8585
# The bottom layer is sampled separately below. Note that the `RectangularShape` puts the
86-
# first particle half a particle spacing away from the boundary, which is correct for fluids,
87-
# but not for solids. We therefore need to pass `tlsph=true`.
86+
# first particle half a particle spacing away from the shell of the shape, which is
87+
# correct for fluids, but not for solids. We therefore need to pass `place_on_shell=true`.
8888
#
8989
# The right end of the plate is 0.2 from the right end of the tank.
9090
plate_position = 0.6 - n_particles_x * solid_particle_spacing
9191
plate = RectangularShape(solid_particle_spacing,
9292
(n_particles_x, n_particles_y - 1),
9393
(plate_position, solid_particle_spacing),
94-
density=solid_density, tlsph=true)
94+
density=solid_density, place_on_shell=true)
9595
fixed_particles = RectangularShape(solid_particle_spacing,
9696
(n_particles_x, 1), (plate_position, 0.0),
97-
density=solid_density, tlsph=true)
97+
density=solid_density, place_on_shell=true)
9898

9999
solid = union(plate, fixed_particles)
100100

examples/fsi/dam_break_plate_2d.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ solid_particle_spacing = thickness / (n_particles_x - 1)
5757
n_particles_y = round(Int, length_beam / solid_particle_spacing) + 1
5858

5959
# The bottom layer is sampled separately below. Note that the `RectangularShape` puts the
60-
# first particle half a particle spacing away from the boundary, which is correct for fluids,
61-
# but not for solids. We therefore need to pass `tlsph=true`.
60+
# first particle half a particle spacing away from the shell of the shape, which is
61+
# correct for fluids, but not for solids. We therefore need to pass `place_on_shell=true`.
6262
plate = RectangularShape(solid_particle_spacing,
6363
(n_particles_x, n_particles_y - 1),
6464
(2initial_fluid_size[1], solid_particle_spacing),
65-
density=solid_density, tlsph=true)
65+
density=solid_density, place_on_shell=true)
6666
fixed_particles = RectangularShape(solid_particle_spacing,
6767
(n_particles_x, 1), (2initial_fluid_size[1], 0.0),
68-
density=solid_density, tlsph=true)
68+
density=solid_density, place_on_shell=true)
6969

7070
solid = union(plate, fixed_particles)
7171

examples/preprocessing/packing_2d.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ file = pkgdir(TrixiParticles, "examples", "preprocessing", "data", filename * ".
2020

2121
# ==========================================================================================
2222
# ==== Packing parameters
23-
tlsph = false
23+
place_on_shell = false
2424

2525
# ==========================================================================================
2626
# ==== Resolution
@@ -50,7 +50,7 @@ shape_sampled = ComplexShape(geometry; particle_spacing, density,
5050

5151
# Returns `InitialCondition`
5252
boundary_sampled = sample_boundary(signed_distance_field; boundary_density=density,
53-
boundary_thickness, tlsph=tlsph)
53+
boundary_thickness, place_on_shell=place_on_shell)
5454

5555
trixi2vtk(shape_sampled)
5656
trixi2vtk(boundary_sampled, filename="boundary")
@@ -66,12 +66,13 @@ background_pressure = 1.0
6666

6767
smoothing_length = 0.8 * particle_spacing
6868
packing_system = ParticlePackingSystem(shape_sampled; smoothing_length=smoothing_length,
69-
signed_distance_field, tlsph=tlsph,
69+
signed_distance_field, place_on_shell=place_on_shell,
7070
background_pressure)
7171

7272
boundary_system = ParticlePackingSystem(boundary_sampled; smoothing_length=smoothing_length,
7373
is_boundary=true, signed_distance_field,
74-
tlsph=tlsph, boundary_compress_factor=0.8,
74+
place_on_shell=place_on_shell,
75+
boundary_compress_factor=0.8,
7576
background_pressure)
7677

7778
# ==========================================================================================

examples/preprocessing/packing_3d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ boundary_thickness = 8 * particle_spacing
2424

2525
trixi_include(joinpath(examples_dir(), "preprocessing", "packing_2d.jl"),
2626
density=1000.0, particle_spacing=particle_spacing, file=file,
27-
boundary_thickness=boundary_thickness, tlsph=true,
27+
boundary_thickness=boundary_thickness, place_on_shell=true,
2828
save_intervals=false)

examples/solid/oscillating_beam_2d.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fixed_particles = SphereShape(particle_spacing, clamp_radius + particle_spacing
3838
(0.0, elastic_beam.thickness / 2), material.density,
3939
cutout_min=(0.0, 0.0),
4040
cutout_max=(clamp_radius, elastic_beam.thickness),
41-
tlsph=true)
41+
place_on_shell=true)
4242

4343
n_particles_clamp_x = round(Int, clamp_radius / particle_spacing)
4444

@@ -48,9 +48,9 @@ n_particles_per_dimension = (round(Int, elastic_beam.length / particle_spacing)
4848

4949
# Note that the `RectangularShape` puts the first particle half a particle spacing away
5050
# from the boundary, which is correct for fluids, but not for solids.
51-
# We therefore need to pass `tlsph=true`.
51+
# We therefore need to pass `place_on_shell=true`.
5252
beam = RectangularShape(particle_spacing, n_particles_per_dimension,
53-
(0.0, 0.0), density=material.density, tlsph=true)
53+
(0.0, 0.0), density=material.density, place_on_shell=true)
5454

5555
solid = union(beam, fixed_particles)
5656

src/general/interpolation.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ function interpolate_plane_2d(min_corner, max_corner, resolution, semi, ref_syst
191191
x_range = range(min_corner[1], max_corner[1], length=n_points_per_dimension[1])
192192
y_range = range(min_corner[2], max_corner[2], length=n_points_per_dimension[2])
193193

194-
# Generate points within the plane. Use `tlsph=true` to generate points on the boundary
194+
# Generate points within the plane. Use `place_on_shell=true` to generate points
195+
# on the shell of the geometry.
195196
point_coords = rectangular_shape_coords(resolution, n_points_per_dimension, min_corner,
196-
tlsph=true)
197+
place_on_shell=true)
197198

198199
results = interpolate_points(point_coords, semi, ref_system, v_ode, u_ode,
199200
smoothing_length=smoothing_length,

src/preprocessing/particle_packing/signed_distance.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function SignedDistanceField(geometry, particle_spacing;
5959
particle_spacing))
6060

6161
grid = rectangular_shape_coords(particle_spacing, n_particles_per_dimension,
62-
min_corner; tlsph=true)
62+
min_corner; place_on_shell=true)
6363

6464
points = reinterpret(reshape, SVector{NDIMS, ELTYPE}, grid)
6565
end

src/preprocessing/particle_packing/system.jl

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
smoothing_length_interpolation=smoothing_length,
77
is_boundary=false, boundary_compress_factor=1,
88
neighborhood_search=GridNeighborhoodSearch{ndims(shape)}(),
9-
background_pressure, tlsph=false, fixed_system=false)
9+
background_pressure, place_on_shell=false, fixed_system=false)
1010
1111
System to generate body-fitted particles for complex shapes.
1212
For more information on the methods, see [particle packing](@ref particle_packing).
@@ -18,10 +18,11 @@ For more information on the methods, see [particle packing](@ref particle_packin
1818
- `background_pressure`: Constant background pressure to physically pack the particles.
1919
A large `background_pressure` can cause high accelerations
2020
which requires a properly adjusted time step.
21-
- `tlsph`: With the [`TotalLagrangianSPHSystem`](@ref), particles need to be placed
22-
on the boundary of the shape and not half a particle spacing away,
23-
as for fluids. When `tlsph=true`, particles will be placed
24-
on the boundary of the shape.
21+
- `place_on_shell`: If `place_on_shell=true`, particles will be placed
22+
on the shell of the geometry. For example,
23+
the [`TotalLagrangianSPHSystem`](@ref) requires particles to be placed
24+
on the shell of the geometry and not half a particle spacing away,
25+
as for fluids.
2526
- `is_boundary`: When `shape` is inside the geometry that was used to create
2627
`signed_distance_field`, set `is_boundary=false`.
2728
Otherwise (`shape` is the sampled boundary), set `is_boundary=true`.
@@ -64,7 +65,7 @@ struct ParticlePackingSystem{S, F, NDIMS, ELTYPE <: Real, PR, C, AV,
6465
smoothing_kernel :: K
6566
smoothing_length_interpolation :: ELTYPE
6667
background_pressure :: ELTYPE
67-
tlsph :: Bool
68+
place_on_shell :: Bool
6869
signed_distance_field :: S
6970
is_boundary :: Bool
7071
shift_length :: ELTYPE
@@ -79,7 +80,8 @@ struct ParticlePackingSystem{S, F, NDIMS, ELTYPE <: Real, PR, C, AV,
7980
# See the comments in general/gpu.jl for more details.
8081
function ParticlePackingSystem(initial_condition, mass, density, particle_spacing,
8182
smoothing_kernel, smoothing_length_interpolation,
82-
background_pressure, tlsph, signed_distance_field,
83+
background_pressure, place_on_shell,
84+
signed_distance_field,
8385
is_boundary, shift_length, neighborhood_search,
8486
signed_distances, particle_refinement, buffer,
8587
update_callback_used, fixed_system, cache,
@@ -93,7 +95,7 @@ struct ParticlePackingSystem{S, F, NDIMS, ELTYPE <: Real, PR, C, AV,
9395
mass, density, particle_spacing,
9496
smoothing_kernel,
9597
smoothing_length_interpolation,
96-
background_pressure, tlsph,
98+
background_pressure, place_on_shell,
9799
signed_distance_field, is_boundary,
98100
shift_length, neighborhood_search,
99101
signed_distances, particle_refinement,
@@ -108,7 +110,8 @@ function ParticlePackingSystem(shape::InitialCondition;
108110
smoothing_length_interpolation=smoothing_length,
109111
is_boundary=false, boundary_compress_factor=1,
110112
neighborhood_search=GridNeighborhoodSearch{ndims(shape)}(),
111-
background_pressure, tlsph=false, fixed_system=false)
113+
background_pressure, place_on_shell=false,
114+
fixed_system=false)
112115
NDIMS = ndims(shape)
113116
ELTYPE = eltype(shape)
114117
mass = copy(shape.mass)
@@ -147,12 +150,12 @@ function ParticlePackingSystem(shape::InitialCondition;
147150
# Its value is negative if the particle is inside the geometry.
148151
# Otherwise (if outside), the value is positive.
149152
if is_boundary
150-
offset = tlsph ? shape.particle_spacing : shape.particle_spacing / 2
153+
offset = place_on_shell ? shape.particle_spacing : shape.particle_spacing / 2
151154

152155
shift_length = -boundary_compress_factor *
153156
signed_distance_field.max_signed_distance - offset
154157
else
155-
shift_length = tlsph ? zero(ELTYPE) : shape.particle_spacing / 2
158+
shift_length = place_on_shell ? zero(ELTYPE) : shape.particle_spacing / 2
156159
end
157160

158161
cache = (; create_cache_refinement(shape, particle_refinement, smoothing_length)...)
@@ -161,7 +164,7 @@ function ParticlePackingSystem(shape::InitialCondition;
161164

162165
return ParticlePackingSystem(shape, mass, density, shape.particle_spacing,
163166
smoothing_kernel, smoothing_length_interpolation,
164-
background_pressure, tlsph, signed_distance_field,
167+
background_pressure, place_on_shell, signed_distance_field,
165168
is_boundary, shift_length, nhs,
166169
fill(zero(ELTYPE), nparticles(shape)), particle_refinement,
167170
nothing, Ref(false), fixed_system, cache,
@@ -187,7 +190,7 @@ function Base.show(io::IO, ::MIME"text/plain", system::ParticlePackingSystem)
187190
system.neighborhood_search |> typeof |> nameof)
188191
summary_line(io, "#particles", nparticles(system))
189192
summary_line(io, "smoothing kernel", system.smoothing_kernel |> typeof |> nameof)
190-
summary_line(io, "tlsph", system.tlsph ? "yes" : "no")
193+
summary_line(io, "place_on_shell", system.place_on_shell ? "yes" : "no")
191194
summary_line(io, "boundary", system.is_boundary ? "yes" : "no")
192195
summary_footer(io)
193196
end
@@ -349,8 +352,8 @@ function constrain_particle!(u, system, particle, distance_signed, normal_vector
349352
(; shift_length) = system
350353

351354
# For fluid particles:
352-
# - `tlsph = true`: `shift_length = 0`
353-
# - `tlsph = false`: `shift_length = particle_spacing / 2`
355+
# - `place_on_shell = true`: `shift_length = 0`
356+
# - `place_on_shell = false`: `shift_length = particle_spacing / 2`
354357
# For boundary particles:
355358
# `shift_length` is the thickness of the boundary.
356359
if distance_signed >= -shift_length
@@ -365,7 +368,7 @@ function constrain_particle!(u, system, particle, distance_signed, normal_vector
365368
system.is_boundary || return u
366369

367370
particle_spacing = system.initial_condition.particle_spacing
368-
shift_length_inner = system.tlsph ? particle_spacing : particle_spacing / 2
371+
shift_length_inner = system.place_on_shell ? particle_spacing : particle_spacing / 2
369372

370373
if distance_signed < shift_length_inner
371374
shift = (distance_signed - shift_length_inner) * normal_vector

src/setups/complex_shape.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ end
7979

8080
"""
8181
sample_boundary(signed_distance_field;
82-
boundary_density, boundary_thickness, tlsph=true)
82+
boundary_density, boundary_thickness, place_on_shell=true)
8383
8484
Sample boundary particles of a complex geometry by using the [`SignedDistanceField`](@ref)
8585
of the geometry.
@@ -90,9 +90,9 @@ of the geometry.
9090
# Keywords
9191
- `boundary_thickness`: Thickness of the boundary
9292
- `boundary_density`: Density of each boundary particle.
93-
- `tlsph` : When `tlsph=true`, boundary particles will be placed
93+
- `place_on_shell`: When `place_on_shell=true`, boundary particles will be placed
9494
one particle spacing from the surface of the geometry.
95-
Otherwise when `tlsph=true` (simulating fluid particles),
95+
Otherwise when `place_on_shell=true` (simulating fluid particles),
9696
boundary particles will be placed half particle spacing away from the surface.
9797
9898
@@ -118,7 +118,7 @@ boundary_sampled = sample_boundary(signed_distance_field; boundary_density=1.0,
118118
```
119119
"""
120120
function sample_boundary(signed_distance_field;
121-
boundary_density, boundary_thickness, tlsph=true)
121+
boundary_density, boundary_thickness, place_on_shell=true)
122122
(; max_signed_distance, boundary_packing,
123123
positions, distances, particle_spacing) = signed_distance_field
124124

@@ -158,6 +158,6 @@ function particle_grid(geometry, particle_spacing;
158158
end
159159

160160
grid = rectangular_shape_coords(particle_spacing, n_particles_per_dimension,
161-
min_corner; tlsph=true)
161+
min_corner; place_on_shell=true)
162162
return reinterpret(reshape, SVector{ndims(geometry), eltype(geometry)}, grid)
163163
end

0 commit comments

Comments
 (0)