Skip to content

Commit fc62e47

Browse files
authored
Merge branch 'main' into dev
2 parents ce0ed1d + 995f182 commit fc62e47

File tree

15 files changed

+599
-14
lines changed

15 files changed

+599
-14
lines changed

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Asciicast = "2600d445-abca-43b9-92aa-ce144ac0b05b"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
5+
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
56
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
67
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
78

docs/literate/src/tut_packing.jl

Lines changed: 367 additions & 0 deletions
Large diffs are not rendered by default.

docs/make.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using TrixiParticles
33
using TrixiParticles.TrixiBase
44
using TrixiParticles.PointNeighbors
55
using Asciicast: Asciicast
6+
using Literate: Literate
67

78
# Get TrixiParticles.jl root directory
89
trixiparticles_root_dir = dirname(@__DIR__)
@@ -83,6 +84,9 @@ replace_with_code(joinpath("docs", "src", "tutorials_template", "tut_dam_break.m
8384
replace_with_code(joinpath("docs", "src", "tutorials_template", "tut_beam.md"))
8485
replace_with_code(joinpath("docs", "src", "tutorials_template", "tut_falling.md"))
8586

87+
Literate.markdown(joinpath("docs", "literate", "src", "tut_packing.jl"),
88+
joinpath("docs", "src", "tutorials"))
89+
8690
copy_file("AUTHORS.md",
8791
"in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)")
8892
copy_file("CONTRIBUTING.md",

docs/src/preprocessing/preprocessing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ Pages = [joinpath("preprocessing", "geometries", "io.jl")]
302302
```
303303

304304
# [Particle Packing](@id particle_packing)
305-
To obtain a body-fitted and isotropic particle distribution, an initial configuration (see [Sampling of Geometries](@ref sampling_of_geometries)) is first generated. This configuration is then packed using a [`ParticlePackingSystem`](@ref).
305+
To obtain a body-fitted and isotropic particle distribution, an initial configuration (see [Sampling of Geometries](@ref sampling_of_geometries)) is first generated. This configuration is then packed using a [`ParticlePackingSystem`](@ref) following the steps introduced in [neher2025robustefficientpreprocessingtechniques](@cite).
306+
For a hands-on tutorial with complete examples, see the particle packing tutorial.
306307
The preprocessing pipeline consists of the following steps:
307308

308309
- Load geometry: Fig. 1, [`load_geometry`](@ref).

docs/src/refs.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ @Article{Negi2022
587587
publisher = {AIP Publishing},
588588
}
589589

590+
@misc{neher2025robustefficientpreprocessingtechniques,
591+
title={Robust and efficient pre-processing techniques for particle-based methods including dynamic boundary generation},
592+
author={Niklas S. Neher and Erik Faulhaber and Sven Berger and Christian Weißenfels and Gregor J. Gassner and Michael Schlottke-Lakemper},
593+
year={2025},
594+
eprint={2506.21206},
595+
archivePrefix={arXiv},
596+
primaryClass={math.NA},
597+
url={https://arxiv.org/abs/2506.21206},
598+
}
599+
590600
@Article{O’Connor2021,
591601
author = {O’Connor, Joseph and Rogers, Benedict D.},
592602
journal = {Journal of Fluids and Structures},

docs/src/tutorial.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tutorial
1+
# Tutorials
22

33

44
## Fluid
@@ -11,3 +11,6 @@
1111

1212
## Fluid-Structure Interaction
1313
- [Setting up a falling structure](tutorials/tut_falling.md)
14+
15+
## Preprocessing
16+
- [Particle packing](tutorials/tut_packing.md)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ASCII
2+
1.14991 -0.00561128 0
3+
0.512738 -0.0262819 0
4+
0.18511 -0.134802 0
5+
0.00682607 -0.357011 0
6+
0.126199 -0.549764 0
7+
0.404735 -0.687223 0
8+
0.805744 -0.699626 0
9+
1.26308 -0.934754 0
10+
1.60518 -0.940955 0
11+
1.94779 -0.809697 0
12+
1.9943 -0.532194 0
13+
1.8031 -0.271745 0
14+
1.56642 -0.131702 0
15+
1.14991 -0.00561128 0

src/TrixiParticles.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ include("callbacks/callbacks.jl")
5656
include("general/semidiscretization.jl")
5757
include("general/gpu.jl")
5858
include("io/io.jl")
59-
include("visualization/recipes_plots.jl")
6059
include("preprocessing/preprocessing.jl")
60+
include("visualization/recipes_plots.jl")
6161

6262
export Semidiscretization, semidiscretize, restart_with!
6363
export InitialCondition

src/callbacks/steady_state_reached.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ end
2626

2727
function SteadyStateReachedCallback(; interval::Integer=0, dt=0.0,
2828
interval_size::Integer=10, abstol=1.0e-8, reltol=1.0e-6)
29+
ELTYPE = eltype(abstol)
2930
abstol, reltol = promote(abstol, reltol)
3031

3132
if dt > 0 && interval > 0
3233
throw(ArgumentError("setting both `interval` and `dt` is not supported"))
3334
end
3435

3536
if dt > 0
36-
interval = Float64(dt)
37+
interval = convert(ELTYPE, dt)
3738
end
3839

39-
steady_state_callback = SteadyStateReachedCallback(interval, abstol, reltol, [Inf64],
40+
steady_state_callback = SteadyStateReachedCallback(interval, abstol, reltol,
41+
[convert(ELTYPE, Inf)],
4042
interval_size)
4143

4244
if dt > 0

src/general/custom_quantities.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ Returns the total kinetic energy of all particles in a system.
66
function kinetic_energy(system, v_ode, u_ode, semi, t)
77
v = wrap_v(v_ode, system, semi)
88

9-
# If `each_moving_particle` is empty (no moving particles), return zero
10-
return sum(each_moving_particle(system), init=zero(eltype(system))) do particle
11-
velocity = current_velocity(v, system, particle)
12-
return 0.5 * system.mass[particle] * dot(velocity, velocity)
9+
# TODO: `current_velocity` should only contain active particles
10+
# (see https://github.com/trixi-framework/TrixiParticles.jl/issues/850)
11+
velocity = reinterpret(reshape, SVector{ndims(system), eltype(v)},
12+
view(current_velocity(v, system), :, active_particles(system)))
13+
mass = view(system.mass, active_particles(system))
14+
15+
return mapreduce(+, velocity, mass) do v_i, m_i
16+
return m_i * dot(v_i, v_i) / 2
1317
end
1418
end
1519

20+
kinetic_energy(system::BoundarySystem, v_ode, u_ode, semi, t) = zero(eltype(system))
21+
1622
"""
1723
total_mass
1824
1925
Returns the total mass of all particles in a system.
2026
"""
2127
function total_mass(system, v_ode, u_ode, semi, t)
22-
return sum(eachparticle(system)) do particle
23-
return system.mass[particle]
24-
end
28+
return sum(system.mass)
2529
end
2630

2731
function total_mass(system::BoundarySystem, v_ode, u_ode, semi, t)

0 commit comments

Comments
 (0)