Skip to content

Commit 1f8d909

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 a724d36 commit 1f8d909

17 files changed

Lines changed: 128 additions & 110 deletions

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
@@ -78,7 +79,8 @@ struct ParticlePackingSystem{S, F, NDIMS, ELTYPE <: Real, PR, C, AV,
7879
# See the comments in general/gpu.jl for more details.
7980
function ParticlePackingSystem(initial_condition, mass, density, particle_spacing,
8081
smoothing_kernel, smoothing_length_interpolation,
81-
background_pressure, tlsph, signed_distance_field,
82+
background_pressure, place_on_shell,
83+
signed_distance_field,
8284
is_boundary, shift_length, neighborhood_search,
8385
signed_distances, particle_refinement, buffer,
8486
fixed_system, cache, advection_velocity)
@@ -90,7 +92,7 @@ struct ParticlePackingSystem{S, F, NDIMS, ELTYPE <: Real, PR, C, AV,
9092
mass, density, particle_spacing,
9193
smoothing_kernel,
9294
smoothing_length_interpolation,
93-
background_pressure, tlsph,
95+
background_pressure, place_on_shell,
9496
signed_distance_field, is_boundary,
9597
shift_length, neighborhood_search,
9698
signed_distances, particle_refinement,
@@ -105,7 +107,8 @@ function ParticlePackingSystem(shape::InitialCondition;
105107
smoothing_length_interpolation=smoothing_length,
106108
is_boundary=false, boundary_compress_factor=1,
107109
neighborhood_search=GridNeighborhoodSearch{ndims(shape)}(),
108-
background_pressure, tlsph=false, fixed_system=false)
110+
background_pressure, place_on_shell=false,
111+
fixed_system=false)
109112
NDIMS = ndims(shape)
110113
ELTYPE = eltype(shape)
111114
mass = copy(shape.mass)
@@ -144,12 +147,12 @@ function ParticlePackingSystem(shape::InitialCondition;
144147
# Its value is negative if the particle is inside the geometry.
145148
# Otherwise (if outside), the value is positive.
146149
if is_boundary
147-
offset = tlsph ? shape.particle_spacing : shape.particle_spacing / 2
150+
offset = place_on_shell ? shape.particle_spacing : shape.particle_spacing / 2
148151

149152
shift_length = -boundary_compress_factor *
150153
signed_distance_field.max_signed_distance - offset
151154
else
152-
shift_length = tlsph ? zero(ELTYPE) : shape.particle_spacing / 2
155+
shift_length = place_on_shell ? zero(ELTYPE) : shape.particle_spacing / 2
153156
end
154157

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

159162
return ParticlePackingSystem(shape, mass, density, shape.particle_spacing,
160163
smoothing_kernel, smoothing_length_interpolation,
161-
background_pressure, tlsph, signed_distance_field,
164+
background_pressure, place_on_shell, signed_distance_field,
162165
is_boundary, shift_length, nhs,
163166
fill(zero(ELTYPE), nparticles(shape)), particle_refinement,
164167
nothing, fixed_system, cache, advection_velocity)
@@ -183,7 +186,7 @@ function Base.show(io::IO, ::MIME"text/plain", system::ParticlePackingSystem)
183186
system.neighborhood_search |> typeof |> nameof)
184187
summary_line(io, "#particles", nparticles(system))
185188
summary_line(io, "smoothing kernel", system.smoothing_kernel |> typeof |> nameof)
186-
summary_line(io, "tlsph", system.tlsph ? "yes" : "no")
189+
summary_line(io, "place_on_shell", system.place_on_shell ? "yes" : "no")
187190
summary_line(io, "boundary", system.is_boundary ? "yes" : "no")
188191
summary_footer(io)
189192
end
@@ -330,8 +333,8 @@ function constrain_particle!(u, system, particle, distance_signed, normal_vector
330333
(; shift_length) = system
331334

332335
# For fluid particles:
333-
# - `tlsph = true`: `shift_length = 0`
334-
# - `tlsph = false`: `shift_length = particle_spacing / 2`
336+
# - `place_on_shell = true`: `shift_length = 0`
337+
# - `place_on_shell = false`: `shift_length = particle_spacing / 2`
335338
# For boundary particles:
336339
# `shift_length` is the thickness of the boundary.
337340
if distance_signed >= -shift_length
@@ -346,7 +349,7 @@ function constrain_particle!(u, system, particle, distance_signed, normal_vector
346349
system.is_boundary || return u
347350

348351
particle_spacing = system.initial_condition.particle_spacing
349-
shift_length_inner = system.tlsph ? particle_spacing : particle_spacing / 2
352+
shift_length_inner = system.place_on_shell ? particle_spacing : particle_spacing / 2
350353

351354
if distance_signed < shift_length_inner
352355
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)