Skip to content
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
03807a2
Refactor SPH system initialization to use keyword arguments
svchb Apr 16, 2026
0707dc4
Merge branch 'dev' into api/unify-fluid-constructors
svchb Apr 17, 2026
be971d9
fix test
svchb Apr 17, 2026
e63edb9
Update docs/literate/src/tut_setup.jl
svchb Apr 21, 2026
ac5bdfd
Merge branch 'dev' into api/unify-fluid-constructors
svchb Apr 21, 2026
b88cae3
remove unneeded named arguments
svchb Apr 21, 2026
664e602
more fixes
svchb Apr 21, 2026
927fcdd
Refactor constructors to use keyword arguments for DEM and SPH systems
svchb Apr 22, 2026
d30cb69
Refactor constructors in DEM, SPH, and TotalLagrangian systems to use…
svchb Apr 22, 2026
7526800
fix tests
svchb Apr 22, 2026
5148a1d
Merge branch 'dev' into api/unify-fluid-constructors
svchb Apr 22, 2026
da12eb9
better fix for included parameters
svchb Apr 23, 2026
0cf74ae
another pass to reduce unreqed named args
svchb Apr 23, 2026
c8ddbf0
even more unreq named keyword use
svchb Apr 23, 2026
e0c6124
format
svchb Apr 23, 2026
d7eafc2
typo
svchb Apr 23, 2026
c979bce
fix tests
svchb Apr 23, 2026
c8ead74
fix tests
svchb Apr 23, 2026
6968828
fix tests
svchb Apr 23, 2026
c699853
fix tests
svchb Apr 23, 2026
ae2c7b0
format
svchb Apr 27, 2026
2170226
Merge branch 'api/unify-fluid-constructors' of https://github.com/svc…
svchb Apr 27, 2026
b6b01fe
format
svchb Apr 27, 2026
1ddba07
fix
svchb Apr 28, 2026
9ff9e82
format
svchb Apr 28, 2026
08e2a86
Apply suggestion from @efaulhaber
svchb Apr 28, 2026
d03a88c
Update examples/fluid/dam_break_oil_film_2d.jl
svchb Apr 28, 2026
b14fe41
Update examples/fluid/falling_water_spheres_2d.jl
svchb Apr 28, 2026
d941a56
Update examples/fluid/falling_water_spheres_2d.jl
svchb Apr 28, 2026
bfd5087
Update test/systems/tlsph_system.jl
svchb Apr 28, 2026
7851285
Update test/systems/tlsph_system.jl
svchb Apr 28, 2026
6c31252
Update test/systems/edac_system.jl
svchb Apr 28, 2026
104980b
Update test/schemes/structure/total_lagrangian_sph/rhs.jl
svchb Apr 28, 2026
ce4d33c
Update examples/fluid/poiseuille_flow_3d.jl
svchb Apr 28, 2026
de04134
Update examples/fsi/dam_break_gate_2d.jl
svchb Apr 28, 2026
c6455de
Update examples/fsi/dam_break_plate_2d.jl
svchb Apr 28, 2026
75b4076
Update examples/fsi/hydrostatic_water_column_2d.jl
svchb Apr 28, 2026
ab8d1bc
Update examples/structure/oscillating_beam_2d.jl
svchb Apr 28, 2026
556bd94
Update src/schemes/boundary/dem_boundary/system.jl
svchb Apr 28, 2026
ec946f8
Update src/schemes/fluid/entropically_damped_sph/system.jl
svchb Apr 28, 2026
efe949b
Update src/schemes/fluid/implicit_incompressible_sph/system.jl
svchb Apr 28, 2026
00b2f1f
Update src/schemes/fluid/weakly_compressible_sph/system.jl
svchb Apr 28, 2026
3d0e81b
Update src/schemes/structure/discrete_element_method/system.jl
svchb Apr 28, 2026
265b562
Update test/general/custom_quantities.jl
svchb Apr 28, 2026
7aa8654
Update test/general/interpolation.jl
svchb Apr 28, 2026
9832bee
Update test/general/interpolation.jl
svchb Apr 28, 2026
1ae0b3f
Update test/schemes/boundary/dummy_particles/rhs.jl
svchb Apr 28, 2026
4c5ad19
Update test/schemes/fluid/rhs.jl
svchb Apr 28, 2026
687698c
Update test/schemes/boundary/dummy_particles/dummy_particles.jl
svchb Apr 28, 2026
2144c9b
Update test/schemes/boundary/dummy_particles/dummy_particles.jl
svchb Apr 28, 2026
46ece3a
fix doc strings
svchb Apr 28, 2026
2196584
Merge branch 'api/unify-fluid-constructors' of github.com:svchb/Trixi…
svchb Apr 28, 2026
ea41299
review
svchb Apr 28, 2026
27278c0
format
svchb Apr 28, 2026
cf51f6a
Merge remote-tracking branch 'upstream/dev' into api/unify-fluid-cons…
svchb Apr 28, 2026
cb2a640
fix test
svchb Apr 28, 2026
df825a0
fix NEWS.md
svchb Apr 28, 2026
297e6e6
add news section
svchb Apr 28, 2026
79f701f
Update src/schemes/fluid/implicit_incompressible_sph/system.jl
svchb Apr 28, 2026
188f4fa
review comments
svchb Apr 28, 2026
74f02b6
Merge branch 'api/unify-fluid-constructors' of github.com:svchb/Trixi…
svchb Apr 28, 2026
3ca4955
Update NEWS.md
svchb Apr 28, 2026
9277de1
Update NEWS.md
svchb Apr 28, 2026
91e054c
Merge branch 'dev' into api/unify-fluid-constructors
efaulhaber Apr 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ You can find the documentation for the latest release
[![arXiv:2506.21206](https://img.shields.io/badge/arXiv-2506.21206-yellow)](https://arxiv.org/abs/2506.21206)
[![doi:10.1016/j.cpc.2025.109898](https://zenodo.org/badge/doi/10.1016/j.cpc.2025.109898.svg)](https://doi.org/10.1016/j.cpc.2025.109898)
[![reproduce me!](https://img.shields.io/badge/reproduce-me!-brightgreen)](https://github.com/trixi-framework/paper-2025-particle-based_preprocessing)

## Cite Us

If you use TrixiParticles.jl in your own research or write a paper using results obtained
Expand Down
9 changes: 4 additions & 5 deletions docs/literate/src/tut_custom_kernel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ nothing # hide
# `examples/fluid/dam_break_2d.jl` with our custom kernel and the corresponding
# smoothing length.
# ```@cast @__NAME__; width=100, height=50, delay=0, loop=true, loop_delay=5
# trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
# trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl");
# smoothing_kernel=MyGaussianKernel(),
# smoothing_length=smoothing_length);
# smoothing_length);
# ```
trixi_include(joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), #!md
smoothing_kernel=MyGaussianKernel(), #!md
smoothing_length=smoothing_length) #!md
trixi_include(joinpath(examples_dir(), "fluid", "dam_break_2d.jl"); #!md
smoothing_kernel=MyGaussianKernel(), smoothing_length) #!md

# See [Visualization](@ref) for how to visualize the final solution.
# For the simplest visualization, we can use [Plots.jl](https://docs.juliaplots.org/stable/):
Expand Down
86 changes: 32 additions & 54 deletions docs/literate/src/tut_packing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ signed_distance_field = SignedDistanceField(geometry, particle_spacing;

# We can also visualize the SDF by simply creating an `InitialCondition` from the sampled points and plot it.
# The color coding represents the signed distance to the geometry surface.
sdf_ic = InitialCondition(; coordinates=stack(signed_distance_field.positions),
density=1.0, particle_spacing=particle_spacing)
sdf_ic = InitialCondition(; coordinates=stack(signed_distance_field.positions), density=1.0,
particle_spacing)

plot(sdf_ic, zcolor=signed_distance_field.distances, label=nothing, color=:coolwarm)
plot!(geometry, linestyle=:dash, label=nothing, showaxis=false, color=:black,
Expand All @@ -63,8 +63,8 @@ signed_distance_field = SignedDistanceField(geometry, particle_spacing;
max_signed_distance=boundary_thickness)

# We can see in the plot that the SDF has been extended outwards to twice `max_signed_distance`.
sdf_ic = InitialCondition(; coordinates=stack(signed_distance_field.positions),
density=1.0, particle_spacing=particle_spacing)
sdf_ic = InitialCondition(; coordinates=stack(signed_distance_field.positions), density=1.0,
particle_spacing)

plot(sdf_ic, zcolor=signed_distance_field.distances, label=nothing, color=:coolwarm)

Expand Down Expand Up @@ -105,7 +105,7 @@ point_in_geometry_algorithm = WindingNumberJacobson(; geometry)
# This function creates an [`InitialCondition`](@ref InitialCondition) for the interior particles.
# Here, we need to specify `particle_spacing` and `density`. For further arguments, please refer to
# the documentation of [ComplexShape](@ref ComplexShape) or [InitialCondition](@ref InitialCondition).
shape_sampled = ComplexShape(geometry; particle_spacing, density=density,
shape_sampled = ComplexShape(geometry; particle_spacing, density,
point_in_geometry_algorithm)

# If we want to assign the mass of each sampled particle consistently with its density,
Expand Down Expand Up @@ -146,9 +146,7 @@ smoothing_length = 0.8 * particle_spacing

# Now we can create the packing system. For learning purposes, let’s first try
# passing no signed distance field (SDF) and see what happens.
packing_system = ParticlePackingSystem(shape_sampled;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
packing_system = ParticlePackingSystem(shape_sampled; smoothing_kernel, smoothing_length,
signed_distance_field=nothing, background_pressure)

# We now proceed with the familiar steps
Expand All @@ -163,8 +161,7 @@ maxiters = 100
callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol = solve(ode, time_integrator;
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters=maxiters,
sol = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters,
callback=callbacks)

packed_ic = InitialCondition(sol, packing_system, semi)
Expand All @@ -176,11 +173,8 @@ plot!(geometry, seriestype=:path, linewidth=2, color=:black, label=nothing)
# geometric surface.

# We therefore add an SDF for the geometry and repeat the same procedure.
packing_system = ParticlePackingSystem(shape_sampled;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
signed_distance_field,
background_pressure)
packing_system = ParticlePackingSystem(shape_sampled; smoothing_kernel, smoothing_length,
signed_distance_field, background_pressure)

# Again, we follow the same steps for semidiscretization and time integration.
semi = Semidiscretization(packing_system)
Expand All @@ -192,8 +186,7 @@ maxiters = 1000
callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol = solve(ode, time_integrator;
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters=maxiters,
sol = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters,
callback=callbacks)

packed_ic = InitialCondition(sol, packing_system, semi)
Expand All @@ -214,12 +207,10 @@ plot!(geometry, seriestype=:path, color=:black, label=nothing, linewidth=2)
# A `boundary_compress_factor` of `0.8` or `0.9` works well for most shapes.
# Since we have a relatively large particle spacing compared to the
# geometry size in this example, we will choose `0.7`.
boundary_system = ParticlePackingSystem(boundary_sampled;
is_boundary=true,
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
boundary_compress_factor=0.7,
signed_distance_field, background_pressure)
boundary_system = ParticlePackingSystem(boundary_sampled; is_boundary=true,
smoothing_kernel, smoothing_length,
boundary_compress_factor=0.7, signed_distance_field,
background_pressure)

# We can now couple the boundary system with the interior system:
semi = Semidiscretization(packing_system, boundary_system)
Expand All @@ -231,8 +222,7 @@ maxiters = 1000
callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol = solve(ode, time_integrator;
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters=maxiters,
sol = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters,
callback=callbacks)

packed_ic = InitialCondition(sol, packing_system, semi)
Expand All @@ -254,11 +244,8 @@ plot!(geometry, seriestype=:path, color=:black, linestyle=:dash, linewidth=2, la
# Because we are satisfied with this particle distribution, we want it to remain unchanged.
# Therefore, we set `fixed_system=true` so that this system is not integrated further
# but instead serves as a static boundary for the packing of other domains.
fixed_system = ParticlePackingSystem(packed_ic;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
signed_distance_field=nothing,
background_pressure,
fixed_system = ParticlePackingSystem(packed_ic; smoothing_kernel, smoothing_length,
signed_distance_field=nothing, background_pressure,
fixed_system=true)

# Now we define a rectangular domain that we want to pack.
Expand All @@ -273,10 +260,8 @@ sampled_outer_domain = setdiff(tank_domain.fluid, packed_ic)
plot(sampled_outer_domain, packed_ic)

# Next, we create a packing system for the outer domain.
packing_system = ParticlePackingSystem(sampled_outer_domain;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
signed_distance_field=nothing,
packing_system = ParticlePackingSystem(sampled_outer_domain; smoothing_kernel,
smoothing_length, signed_distance_field=nothing,
background_pressure)

# Since we do not want to sample a boundary for the outer domain,
Expand All @@ -293,8 +278,8 @@ maxiters = 1000
callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol_1 = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4,
save_everystep=false, maxiters=maxiters, callback=callbacks)
sol_1 = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4, save_everystep=false,
maxiters, callback=callbacks)

packed_outer_domain = InitialCondition(sol_1, packing_system, semi)

Expand Down Expand Up @@ -323,24 +308,17 @@ plot(pack_domain, fixed_domain, packed_ic)

# We can now treat the particles outside the window, along with the already
# finalized configuration of the complex geometry, as fixed systems:
fixed_system_1 = ParticlePackingSystem(fixed_domain;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
signed_distance_field=nothing,
background_pressure, fixed_system=true)

fixed_system_2 = ParticlePackingSystem(packed_ic;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
signed_distance_field=nothing,
background_pressure, fixed_system=true)
fixed_system_1 = ParticlePackingSystem(fixed_domain; smoothing_kernel, smoothing_length,
signed_distance_field=nothing, background_pressure,
fixed_system=true)

fixed_system_2 = ParticlePackingSystem(packed_ic; smoothing_kernel, smoothing_length,
signed_distance_field=nothing, background_pressure,
fixed_system=true)

# The window that we want to pack is passed to a moving packing system:
packing_system = ParticlePackingSystem(pack_domain;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
signed_distance_field=nothing,
background_pressure)
packing_system = ParticlePackingSystem(pack_domain; smoothing_kernel, smoothing_length,
signed_distance_field=nothing, background_pressure)

semi = Semidiscretization(packing_system, fixed_system_1, fixed_system_2)

Expand All @@ -351,8 +329,8 @@ maxiters = 1000
callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol_2 = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4,
save_everystep=false, maxiters=maxiters, callback=callbacks)
sol_2 = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4, save_everystep=false,
maxiters, callback=callbacks)

packed_fluid_domain = InitialCondition(sol_2, packing_system, semi)

Expand Down
61 changes: 25 additions & 36 deletions docs/literate/src/tut_rigid_body_fsi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ sound_speed = 100.0
state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density,
exponent=1)

tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density,
n_layers=boundary_layers, spacing_ratio=spacing_ratio,
faces=(true, true, true, false),
acceleration=(0.0, -gravity), state_equation=state_equation)
tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density;
n_layers=boundary_layers, spacing_ratio,
faces=(true, true, true, false), acceleration=(0.0, -gravity),
state_equation)
nothing # hide

# ## Rigid body geometry
Expand Down Expand Up @@ -97,10 +97,11 @@ fluid_density_calculator = ContinuityDensity()
viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)

fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, fluid_smoothing_kernel,
fluid_smoothing_length, viscosity=viscosity,
density_diffusion=density_diffusion,
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid;
smoothing_kernel=fluid_smoothing_kernel,
smoothing_length=fluid_smoothing_length,
density_calculator=fluid_density_calculator,
state_equation, viscosity, density_diffusion,
acceleration=(0.0, -gravity))
nothing # hide

Expand Down Expand Up @@ -166,10 +167,10 @@ nothing # hide
boundary_density_calculator = AdamiPressureExtrapolation()
tank_boundary_model = BoundaryModelDummyParticles(tank.boundary.density,
tank.boundary.mass,
state_equation=state_equation,
boundary_density_calculator,
fluid_smoothing_kernel,
fluid_smoothing_length)
fluid_smoothing_length;
state_equation)

boundary_system = WallBoundarySystem(tank.boundary, tank_boundary_model)
nothing # hide
Expand All @@ -180,10 +181,10 @@ function rigid_body_boundary_model(shape)
structure_particle_spacing^ndims(fluid_system)

return BoundaryModelDummyParticles(hydrodynamic_densities, hydrodynamic_masses,
state_equation=state_equation,
boundary_density_calculator,
fluid_smoothing_kernel,
fluid_smoothing_length)
fluid_smoothing_length;
state_equation)
end

square1_boundary_model = rigid_body_boundary_model(square1)
Expand Down Expand Up @@ -234,15 +235,11 @@ contact_model = RigidContactModel(; normal_stiffness=2.0e5,
contact_distance=2.0 * structure_particle_spacing)
nothing # hide

rigid_body_system_1_step3 = RigidBodySystem(square1;
boundary_model=square1_boundary_model,
contact_model=contact_model,
acceleration=(0.0, -gravity),
rigid_body_system_1_step3 = RigidBodySystem(square1; boundary_model=square1_boundary_model,
contact_model, acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
rigid_body_system_2_step3 = RigidBodySystem(square2;
boundary_model=square2_boundary_model,
contact_model=contact_model,
acceleration=(0.0, -gravity),
rigid_body_system_2_step3 = RigidBodySystem(square2; boundary_model=square2_boundary_model,
contact_model, acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
nothing # hide

Expand Down Expand Up @@ -301,15 +298,11 @@ circle1_boundary_model = rigid_body_boundary_model(circle1)
circle2_boundary_model = rigid_body_boundary_model(circle2)
nothing # hide

rigid_body_system_1_step4 = RigidBodySystem(circle1;
boundary_model=circle1_boundary_model,
contact_model=contact_model,
acceleration=(0.0, -gravity),
rigid_body_system_1_step4 = RigidBodySystem(circle1; boundary_model=circle1_boundary_model,
contact_model, acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
rigid_body_system_2_step4 = RigidBodySystem(circle2;
boundary_model=circle2_boundary_model,
contact_model=contact_model,
acceleration=(0.0, -gravity),
rigid_body_system_2_step4 = RigidBodySystem(circle2; boundary_model=circle2_boundary_model,
contact_model, acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
nothing # hide

Expand Down Expand Up @@ -359,10 +352,8 @@ small_spheres = [SphereShape(structure_particle_spacing, small_sphere_radius,

small_sphere_systems = [begin
sphere_boundary_model = rigid_body_boundary_model(sphere)
RigidBodySystem(sphere;
boundary_model=sphere_boundary_model,
contact_model=contact_model,
acceleration=(0.0, -gravity),
RigidBodySystem(sphere; boundary_model=sphere_boundary_model,
contact_model, acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
end
for sphere in small_spheres]
Expand Down Expand Up @@ -418,10 +409,8 @@ hexagon_shape = TrixiParticles.@set hexagon_shape.particle_spacing = structure_p
# just like the other shapes in this tutorial.
hexagon_boundary_model = rigid_body_boundary_model(hexagon_shape)

hexagon_system = RigidBodySystem(hexagon_shape;
boundary_model=hexagon_boundary_model,
contact_model=contact_model,
acceleration=(0.0, -gravity),
hexagon_system = RigidBodySystem(hexagon_shape; boundary_model=hexagon_boundary_model,
contact_model, acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
#
# You can then create a semidiscretization with this new system.
Expand Down
Loading
Loading