From d6349b6092b05696071ca260b8c2af36e17fa86d Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 22 May 2025 14:10:43 +0200 Subject: [PATCH 1/2] add header --- examples/dem/collapsing_sand_pile_3d.jl | 10 +++++--- examples/dem/rectangular_tank_2d.jl | 10 ++++---- examples/fluid/accelerated_tank_2d.jl | 8 +++++-- examples/fluid/dam_break_2d.jl | 17 ++++++++++---- examples/fluid/dam_break_2d_gpu.jl | 23 +++++++++++++++---- examples/fluid/dam_break_2phase_2d.jl | 7 +++++- examples/fluid/dam_break_3d.jl | 7 ++++++ examples/fluid/dam_break_oil_film_2d.jl | 8 ++++++- examples/fluid/falling_water_column_2d.jl | 6 +++++ examples/fluid/falling_water_spheres_2d.jl | 10 ++++++-- examples/fluid/falling_water_spheres_3d.jl | 9 ++++++++ examples/fluid/hydrostatic_water_column_2d.jl | 7 ++++++ examples/fluid/hydrostatic_water_column_3d.jl | 7 ++++++ examples/fluid/lid_driven_cavity_2d.jl | 20 ++++++++++++---- examples/fluid/moving_wall_2d.jl | 7 ++++++ examples/fluid/oscillating_drop_2d.jl | 16 +++++++++---- .../fluid/periodic_array_of_cylinders_2d.jl | 18 +++++++++++---- examples/fluid/periodic_channel_2d.jl | 9 ++++++++ examples/fluid/pipe_flow_2d.jl | 9 +++++++- examples/fluid/pipe_flow_3d.jl | 7 +++++- examples/fluid/sphere_surface_tension_2d.jl | 10 ++++++-- examples/fluid/sphere_surface_tension_3d.jl | 11 +++++++-- .../fluid/sphere_surface_tension_wall_2d.jl | 9 ++++++++ examples/fluid/taylor_green_vortex_2d.jl | 16 +++++++++---- examples/fsi/dam_break_gate_2d.jl | 22 ++++++++++++------ examples/fsi/dam_break_plate_2d.jl | 16 +++++++++---- examples/fsi/falling_sphere_2d.jl | 6 +++++ examples/fsi/falling_sphere_3d.jl | 6 +++++ examples/fsi/falling_spheres_2d.jl | 7 ++++++ examples/fsi/falling_water_column_2d.jl | 8 +++++++ examples/n_body/n_body_benchmark_reference.jl | 2 ++ .../n_body_benchmark_reference_faster.jl | 2 ++ examples/n_body/n_body_benchmark_trixi.jl | 5 ++-- examples/n_body/n_body_solar_system.jl | 5 ++-- .../postprocessing/interpolation_plane.jl | 10 ++++++-- .../interpolation_point_line.jl | 10 ++++++-- examples/postprocessing/postprocessing.jl | 9 ++++++++ examples/preprocessing/complex_shape_2d.jl | 13 +++++++++++ examples/preprocessing/complex_shape_3d.jl | 12 ++++++++++ examples/preprocessing/packing_2d.jl | 14 +++++++++++ examples/preprocessing/packing_3d.jl | 9 ++++++++ examples/solid/oscillating_beam_2d.jl | 8 +++++++ 42 files changed, 355 insertions(+), 70 deletions(-) diff --git a/examples/dem/collapsing_sand_pile_3d.jl b/examples/dem/collapsing_sand_pile_3d.jl index feb2510fd5..aa9ba7a56b 100644 --- a/examples/dem/collapsing_sand_pile_3d.jl +++ b/examples/dem/collapsing_sand_pile_3d.jl @@ -1,3 +1,10 @@ +# ========================================================================================== +# === 3D Collapsing Sand Pile Simulation +# +# This example simulates the collapse of a cylindrical pile of sand under gravity +# within a confined container using the Discrete Element Method (DEM). +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq @@ -5,9 +12,6 @@ using OrdinaryDiffEq gravity = -9.81 acceleration = (0.0, 0.0, gravity) -# ========================================================================================== -# ==== Collapsing Sand Pile Simulation - # Resolution particle_spacing = 0.1 diff --git a/examples/dem/rectangular_tank_2d.jl b/examples/dem/rectangular_tank_2d.jl index 44514aa479..cba7974cce 100644 --- a/examples/dem/rectangular_tank_2d.jl +++ b/examples/dem/rectangular_tank_2d.jl @@ -1,8 +1,3 @@ -using TrixiParticles -using OrdinaryDiffEq - -gravity = -9.81 - # ========================================================================================== # ==== Falling Rocks Simulation Setup # @@ -11,6 +6,11 @@ gravity = -9.81 # a "fluid" region (containing the rock particles) and a "boundary" region (representing walls). # ========================================================================================== +using TrixiParticles +using OrdinaryDiffEq + +gravity = -9.81 + particle_spacing = 0.1 rock_width = 2.0 diff --git a/examples/fluid/accelerated_tank_2d.jl b/examples/fluid/accelerated_tank_2d.jl index dbbecfc7e8..26a408520e 100644 --- a/examples/fluid/accelerated_tank_2d.jl +++ b/examples/fluid/accelerated_tank_2d.jl @@ -1,6 +1,10 @@ -# This setup is identical to `hydrostatic_water_column_2d.jl`, except that now there is +# ========================================================================================== +# 2D Accelerated Tank Example +# +# This setup is identical to `hydrostatic_water_column_2d.jl`, except that there is # no gravity, and the tank is accelerated upwards instead. -# Note that the two setups are physically identical, but produce different numerical errors. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/dam_break_2d.jl b/examples/fluid/dam_break_2d.jl index 35493a8c2b..2e7017f8c2 100644 --- a/examples/fluid/dam_break_2d.jl +++ b/examples/fluid/dam_break_2d.jl @@ -1,9 +1,16 @@ -# 2D dam break simulation based on +# ========================================================================================== +# 2D Dam Break Simulation (δ-SPH Model) +# +# Based on: +# S. Marrone, M. Antuono, A. Colagrossi, G. Colicchio, D. le Touzé, G. Graziani. +# "δ-SPH model for simulating violent impact flows". +# Computer Methods in Applied Mechanics and Engineering, Volume 200, Issues 13–16 (2011), +# pages 1526–1542. +# https://doi.org/10.1016/J.CMA.2010.12.016 # -# S. Marrone, M. Antuono, A. Colagrossi, G. Colicchio, D. le Touzé, G. Graziani. -# "δ-SPH model for simulating violent impact flows". -# In: Computer Methods in Applied Mechanics and Engineering, Volume 200, Issues 13–16 (2011), pages 1526–1542. -# https://doi.org/10.1016/J.CMA.2010.12.016 +# This example sets up a 2D dam break simulation using a weakly compressible SPH scheme +# with a δ-SPH formulation for density calculation. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/dam_break_2d_gpu.jl b/examples/fluid/dam_break_2d_gpu.jl index c1966d09e0..52e317838b 100644 --- a/examples/fluid/dam_break_2d_gpu.jl +++ b/examples/fluid/dam_break_2d_gpu.jl @@ -1,8 +1,21 @@ -# This example file demonstrates how to run an existing example file on a GPU. -# We simply define a GPU-compatible neighborhood search and `trixi_include` the example -# file with this neighborhood search. -# To run this example on a GPU, `parallelization_backend` needs to be changed to the -# backend for the installed GPU. See the docs on GPU support for more information. +# ========================================================================================== +# 2D Dam Break Simulation on GPU +# +# This example file demonstrates how to adapt an existing CPU-based example +# for execution on a GPU. It involves: +# 1. Including the base CPU example to load common parameters and object definitions +# (without running the simulation by setting `sol=nothing`). +# 2. Defining a GPU-compatible neighborhood search. +# 3. Re-including the base example, overriding the neighborhood search and specifying +# a GPU-compatible parallelization backend. +# +# Note: To run this example on an actual GPU, the `parallelization_backend` +# needs to be changed to a GPU-specific backend like `CUDABackend()` (for NVIDIA GPUs) +# or `AMDGPUBackend()` (for AMD GPUs), and the corresponding GPU packages +# (e.g., `CUDA.jl`) must be installed. +# See the TrixiParticles.jl documentation on GPU support for more details. +# ========================================================================================== + using TrixiParticles # Load setup from dam break example diff --git a/examples/fluid/dam_break_2phase_2d.jl b/examples/fluid/dam_break_2phase_2d.jl index de99a5f397..f86bf2a536 100644 --- a/examples/fluid/dam_break_2phase_2d.jl +++ b/examples/fluid/dam_break_2phase_2d.jl @@ -1,4 +1,9 @@ -# 2D dam break simulation with an air layer on top +# ========================================================================================== +# 2D Two-Phase Dam Break Simulation (Water and Air) +# +# This example simulates a 2D dam break with an air layer above the water. +# It demonstrates how to set up a multi-fluid simulation in TrixiParticles.jl. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/dam_break_3d.jl b/examples/fluid/dam_break_3d.jl index 04795986ce..fcfce8dbb4 100644 --- a/examples/fluid/dam_break_3d.jl +++ b/examples/fluid/dam_break_3d.jl @@ -1,3 +1,10 @@ +# ========================================================================================== +# 3D Dam Break Simulation +# +# This example sets up a 3D dam break simulation using a weakly compressible SPH scheme. +# It is analogous to the 2D dam break (`dam_break_2d.jl`) but extended to three dimensions. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/dam_break_oil_film_2d.jl b/examples/fluid/dam_break_oil_film_2d.jl index 320f185092..377b9bfc88 100644 --- a/examples/fluid/dam_break_oil_film_2d.jl +++ b/examples/fluid/dam_break_oil_film_2d.jl @@ -1,4 +1,10 @@ -# 2D dam break simulation with an oil film on top +# ========================================================================================== +# 2D Dam Break Simulation with an Oil Film +# +# This example simulates a 2D dam break where a layer of oil sits on top of the water. +# It demonstrates a multi-fluid simulation with two immiscible fluids. +# The base water setup is loaded from the `dam_break_2d.jl` example. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/falling_water_column_2d.jl b/examples/fluid/falling_water_column_2d.jl index 8174ce117b..c4eaab6777 100644 --- a/examples/fluid/falling_water_column_2d.jl +++ b/examples/fluid/falling_water_column_2d.jl @@ -1,3 +1,9 @@ +# ========================================================================================== +# 2D Falling Water Column Simulation +# +# This example simulates a column of water falling under gravity within a closed tank. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/falling_water_spheres_2d.jl b/examples/fluid/falling_water_spheres_2d.jl index a59d25e259..79e8c63489 100644 --- a/examples/fluid/falling_water_spheres_2d.jl +++ b/examples/fluid/falling_water_spheres_2d.jl @@ -1,5 +1,11 @@ -# In this example two circles of water drop to the floor demonstrating the difference -# between the behavior with and without surface tension modelling. +# ========================================================================================== +# 2D Falling Water Spheres Simulation (With and Without Surface Tension) +# +# This example simulates two circular water "spheres" falling under gravity. +# One sphere includes a surface tension model (Akinci et al.), while the other does not. +# This demonstrates the effect of surface tension on fluid behavior. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/falling_water_spheres_3d.jl b/examples/fluid/falling_water_spheres_3d.jl index 5aefc96b79..fe2c85c66b 100644 --- a/examples/fluid/falling_water_spheres_3d.jl +++ b/examples/fluid/falling_water_spheres_3d.jl @@ -1,3 +1,12 @@ +# ========================================================================================== +# 3D Falling Water Spheres Simulation (With and Without Surface Tension) +# +# This example extends `falling_water_spheres_2d.jl` to three dimensions. +# It simulates two spherical volumes of water falling under gravity. +# One sphere includes a surface tension model, while the other does not, +# demonstrating the effect of surface tension in 3D. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/hydrostatic_water_column_2d.jl b/examples/fluid/hydrostatic_water_column_2d.jl index b492290756..6cf4517ad2 100644 --- a/examples/fluid/hydrostatic_water_column_2d.jl +++ b/examples/fluid/hydrostatic_water_column_2d.jl @@ -1,3 +1,10 @@ +# ========================================================================================== +# 2D Hydrostatic Water Column Simulation +# +# This example simulates a column of water at rest in a tank under gravity. +# It is a basic test case to verify hydrostatic pressure distribution and stability. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/hydrostatic_water_column_3d.jl b/examples/fluid/hydrostatic_water_column_3d.jl index 7168b05579..16054a6b7c 100644 --- a/examples/fluid/hydrostatic_water_column_3d.jl +++ b/examples/fluid/hydrostatic_water_column_3d.jl @@ -1,3 +1,10 @@ +# ========================================================================================== +# 3D Hydrostatic Water Column Simulation +# +# This example sets up a 3D hydrostatic water column by including and modifying +# the 2D `hydrostatic_water_column_2d.jl` setup. +# ========================================================================================== + using TrixiParticles trixi_include(@__MODULE__, diff --git a/examples/fluid/lid_driven_cavity_2d.jl b/examples/fluid/lid_driven_cavity_2d.jl index 86b2ad315b..9b7d7a0892 100644 --- a/examples/fluid/lid_driven_cavity_2d.jl +++ b/examples/fluid/lid_driven_cavity_2d.jl @@ -1,9 +1,19 @@ -# Lid-driven cavity +# ========================================================================================== +# 2D Lid-Driven Cavity Simulation +# +# Based on: +# S. Adami, X. Y. Hu, N. A. Adams. +# "A transport-velocity formulation for smoothed particle hydrodynamics". +# Journal of Computational Physics, Volume 241 (2013), pages 292-307. +# https://doi.org/10.1016/j.jcp.2013.01.043 # -# S. Adami et al -# "A transport-velocity formulation for smoothed particle hydrodynamics". -# In: Journal of Computational Physics, Volume 241 (2013), pages 292-307. -# https://doi.org/10.1016/j.jcp.2013.01.043 +# This example simulates a 2D lid-driven cavity flow using SPH with a +# transport velocity formulation. The top lid moves horizontally, driving the +# fluid motion within a square cavity. +# +# The simulation can be run with either a Weakly Compressible SPH (WCSPH) +# or an Entropically Damped SPH (EDSPH) formulation for the fluid. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/moving_wall_2d.jl b/examples/fluid/moving_wall_2d.jl index ff31aca859..44265a2b99 100644 --- a/examples/fluid/moving_wall_2d.jl +++ b/examples/fluid/moving_wall_2d.jl @@ -1,3 +1,10 @@ +# ========================================================================================== +# 2D Moving Wall Simulation +# +# This example simulates a column of water in a tank where one of the vertical walls +# moves horizontally, pushing the fluid. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/oscillating_drop_2d.jl b/examples/fluid/oscillating_drop_2d.jl index 434d76aadc..fb96050f42 100644 --- a/examples/fluid/oscillating_drop_2d.jl +++ b/examples/fluid/oscillating_drop_2d.jl @@ -1,9 +1,15 @@ -# Oscillating drop in a central force field, based on +# ========================================================================================== +# 2D Oscillating Drop Simulation +# +# Based on: +# J. J. Monaghan, Ashkan Rafiee. +# "A Simple SPH Algorithm for Multi-Fluid Flow with High Density Ratios." +# International Journal for Numerical Methods in Fluids, 71(5) (2013), pp. 537-561. +# https://doi.org/10.1002/fld.3671. # -# J. J. Monaghan, Ashkan Rafiee. -# "A Simple SPH Algorithm for Multi-Fluid Flow with High Density Ratios." -# In: International Journal for Numerical Methods in Fluids 71, no. 5 (2013), pages 537-61. -# https://doi.org/10.1002/fld.3671. +# This example simulates a 2D elliptical drop of fluid oscillating under a central +# force field. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/periodic_array_of_cylinders_2d.jl b/examples/fluid/periodic_array_of_cylinders_2d.jl index a8ecb035ce..0bbeae30ae 100644 --- a/examples/fluid/periodic_array_of_cylinders_2d.jl +++ b/examples/fluid/periodic_array_of_cylinders_2d.jl @@ -1,9 +1,17 @@ -# Channel flow through periodic array of cylinders +# ========================================================================================== +# 2D Channel Flow Through a Periodic Array of Cylinders +# +# Based on: +# S. Adami, X. Y. Hu, N. A. Adams. +# "A transport-velocity formulation for smoothed particle hydrodynamics". +# Journal of Computational Physics, Volume 241 (2013), pages 292-307. +# https://doi.org/10.1016/J.JCP.2013.01.043 # -# S. Adami et al. -# "A transport-velocity formulation for smoothed particle hydrodynamics". -# In: Journal of Computational Physics, Volume 241 (2013), pages 292-307. -# https://doi.org/10.1016/j.jcp.2013.01.043 +# This example simulates fluid flow driven by a body force through a channel +# containing a periodic array of cylinders. Due to periodicity, only one cylinder +# within a representative channel segment is simulated. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/periodic_channel_2d.jl b/examples/fluid/periodic_channel_2d.jl index efc7e9eb37..74770c318b 100644 --- a/examples/fluid/periodic_channel_2d.jl +++ b/examples/fluid/periodic_channel_2d.jl @@ -1,3 +1,12 @@ +# ========================================================================================== +# 2D Periodic Channel Flow Simulation +# +# This example simulates fluid flow in a 2D channel with periodic boundary +# conditions in the flow direction (x-axis) and solid walls at the top and bottom. +# The fluid is initialized with a uniform velocity. +# This setup can be used to study Poiseuille flow or turbulent channel flow characteristics. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/pipe_flow_2d.jl b/examples/fluid/pipe_flow_2d.jl index 40aee237cf..d978c99416 100644 --- a/examples/fluid/pipe_flow_2d.jl +++ b/examples/fluid/pipe_flow_2d.jl @@ -1,4 +1,11 @@ -# 2D channel flow simulation with open boundaries. +# ========================================================================================== +# 2D Pipe Flow Simulation with Open Boundaries (Inflow/Outflow) +# +# This example simulates fluid flow through a 2D pipe (channel) with an inflow +# boundary condition on one end and an outflow boundary condition on the other. +# Solid walls form the top and bottom of the pipe. +# The simulation demonstrates the use of open boundary conditions in TrixiParticles.jl. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/pipe_flow_3d.jl b/examples/fluid/pipe_flow_3d.jl index fb2cc7f0aa..2eecbb7ca8 100644 --- a/examples/fluid/pipe_flow_3d.jl +++ b/examples/fluid/pipe_flow_3d.jl @@ -1,4 +1,9 @@ -# 3D channel flow simulation with open boundaries. +# ========================================================================================== +# 3D Pipe Flow Simulation with Open Boundaries (Inflow/Outflow) +# +# This example extends the 2D pipe flow simulation (`pipe_flow_2d.jl`) to three +# dimensions. +# ========================================================================================== using TrixiParticles diff --git a/examples/fluid/sphere_surface_tension_2d.jl b/examples/fluid/sphere_surface_tension_2d.jl index d03f64006f..ca33941ee3 100644 --- a/examples/fluid/sphere_surface_tension_2d.jl +++ b/examples/fluid/sphere_surface_tension_2d.jl @@ -1,5 +1,11 @@ -# In this example we can observe that the `SurfaceTensionAkinci` surface tension model correctly leads to a -# surface minimization of the water square and approaches a sphere. +# ========================================================================================== +# 2D Sphere Formation via Surface Tension +# +# This example demonstrates how surface tension models in TrixiParticles.jl +# can cause an initially square patch of fluid to minimize its surface area, +# ideally forming a circular (2D sphere) shape. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/sphere_surface_tension_3d.jl b/examples/fluid/sphere_surface_tension_3d.jl index 222999ba1c..77eacb0ece 100644 --- a/examples/fluid/sphere_surface_tension_3d.jl +++ b/examples/fluid/sphere_surface_tension_3d.jl @@ -1,5 +1,12 @@ -# In this example we can observe that the `SurfaceTensionAkinci` surface tension model correctly leads to a -# surface minimization of the water cube and approaches a sphere. +# ========================================================================================== +# 3D Sphere Formation via Surface Tension +# +# This example extends the 2D sphere formation simulation (`sphere_surface_tension_2d.jl`) +# to three dimensions. It demonstrates how an initially cubical patch of fluid +# minimizes its surface area under the influence of a surface tension model, +# ideally forming a spherical shape. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/sphere_surface_tension_wall_2d.jl b/examples/fluid/sphere_surface_tension_wall_2d.jl index 6ec6ba2fa1..3df25ae986 100644 --- a/examples/fluid/sphere_surface_tension_wall_2d.jl +++ b/examples/fluid/sphere_surface_tension_wall_2d.jl @@ -1,3 +1,12 @@ +# ========================================================================================== +# 2D Sphere with Surface Tension Interacting with a Wall (Wetting Phenomena) +# +# This example simulates a 2D circular drop of fluid (sphere) under gravity, +# influenced by surface tension, as it interacts with a solid horizontal wall. +# The setup is designed to observe wetting phenomena (e.g., spreading or beading) +# by adjusting surface tension and adhesion parameters. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fluid/taylor_green_vortex_2d.jl b/examples/fluid/taylor_green_vortex_2d.jl index c1f0f72fd4..e6e74fbc4b 100644 --- a/examples/fluid/taylor_green_vortex_2d.jl +++ b/examples/fluid/taylor_green_vortex_2d.jl @@ -1,9 +1,15 @@ -# Taylor Green vortex +# ========================================================================================== +# 2D Taylor-Green Vortex Simulation +# +# Based on: +# P. Ramachandran, K. Puri. +# "Entropically damped artificial compressibility for SPH". +# Computers and Fluids, Volume 179 (2019), pages 579-594. +# https://doi.org/10.1016/j.compfluid.2018.11.023 # -# P. Ramachandran, K. Puri -# "Entropically damped artificial compressibility for SPH". -# In: Computers and Fluids, Volume 179 (2019), pages 579-594. -# https://doi.org/10.1016/j.compfluid.2018.11.023 +# This example simulates the Taylor-Green vortex, a classic benchmark case for +# incompressible viscous flow, characterized by an array of decaying vortices. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fsi/dam_break_gate_2d.jl b/examples/fsi/dam_break_gate_2d.jl index 487857c05b..f3f8e5179a 100644 --- a/examples/fsi/dam_break_gate_2d.jl +++ b/examples/fsi/dam_break_gate_2d.jl @@ -1,12 +1,20 @@ -# 2D dam break flow against an elastic plate based on +# ========================================================================================== +# 2D Dam Break Flow Against an Elastic Gate with Opening Motion +# +# Based on: +# P.N. Sun, D. Le Touzé, A.-M. Zhang. +# "Study of a complex fluid-structure dam-breaking benchmark problem using a multi-phase SPH method with APR". +# Engineering Analysis with Boundary Elements, 104 (2019), pp. 240-258. +# https://doi.org/10.1016/j.enganabound.2019.03.033 # -# P.N. Sun, D. Le Touzé, A.-M. Zhang. -# "Study of a complex fluid-structure dam-breaking benchmark problem using a multi-phase SPH method with APR". -# In: Engineering Analysis with Boundary Elements 104 (2019), pages 240-258. -# https://doi.org/10.1016/j.enganabound.2019.03.033 +# This example simulates a 2D dam break where the water column collapses and flows +# towards a vertically moving gate and a flexible elastic plate (beam) positioned +# behind the gate. # -# Use a higher resolution and see the comments below regarding plate thickness -# to reproduce the results from the paper. +# Note: To accurately reproduce results from the reference paper, a significantly +# higher fluid resolution and a plate thickness closer to the paper's value (0.004m) +# are required. This example uses a coarser resolution and thicker plate for tractability. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fsi/dam_break_plate_2d.jl b/examples/fsi/dam_break_plate_2d.jl index 4ac1a4a085..f5b42ecaa0 100644 --- a/examples/fsi/dam_break_plate_2d.jl +++ b/examples/fsi/dam_break_plate_2d.jl @@ -1,9 +1,15 @@ -# 2D dam break flow against an elastic plate based on Section 6.5 of +# ========================================================================================== +# 2D Dam Break Flow Against an Elastic Plate +# +# Based on Section 6.5 of: +# L. Zhan, C. Peng, B. Zhang, W. Wu. +# "A stabilized TL–WC SPH approach with GPU acceleration for three-dimensional fluid–structure interaction". +# Journal of Fluids and Structures, 86 (2019), pp. 329-353. +# https://doi.org/10.1016/j.jfluidstructs.2019.02.002 # -# L. Zhan, C. Peng, B. Zhang, W. Wu. -# "A stabilized TL–WC SPH approach with GPU acceleration for three-dimensional fluid–structure interaction". -# In: Journal of Fluids and Structures 86 (2019), pages 329-353. -# https://doi.org/10.1016/j.jfluidstructs.2019.02.002 +# This example simulates a 2D dam break where the collapsing water column impacts +# a flexible elastic plate fixed at its base. +# ========================================================================================== using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fsi/falling_sphere_2d.jl b/examples/fsi/falling_sphere_2d.jl index 99a69bc2c1..aa5363b7c3 100644 --- a/examples/fsi/falling_sphere_2d.jl +++ b/examples/fsi/falling_sphere_2d.jl @@ -1,3 +1,9 @@ +# ========================================================================================== +# 2D Single Falling Sphere in Fluid (FSI) +# +# This example simulates a single elastic sphere falling through a fluid in a tank. +# ========================================================================================== + using TrixiParticles trixi_include(@__MODULE__, diff --git a/examples/fsi/falling_sphere_3d.jl b/examples/fsi/falling_sphere_3d.jl index d44911409e..6276af5d52 100644 --- a/examples/fsi/falling_sphere_3d.jl +++ b/examples/fsi/falling_sphere_3d.jl @@ -1,3 +1,9 @@ +# ========================================================================================== +# 3D Single Falling Sphere in Fluid (FSI) +# +# This example simulates a single elastic sphere falling through a fluid in a 3D tank. +# ========================================================================================== + using TrixiParticles trixi_include(@__MODULE__, diff --git a/examples/fsi/falling_spheres_2d.jl b/examples/fsi/falling_spheres_2d.jl index 0c3213c983..b1b5eb57b8 100644 --- a/examples/fsi/falling_spheres_2d.jl +++ b/examples/fsi/falling_spheres_2d.jl @@ -1,3 +1,10 @@ +# ========================================================================================== +# 2D Falling Spheres in Fluid (FSI) - Base Setup +# +# This file provides a base setup for simulating one or two elastic spheres +# falling through a fluid in a tank. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/fsi/falling_water_column_2d.jl b/examples/fsi/falling_water_column_2d.jl index 430512e07d..cd6357386c 100644 --- a/examples/fsi/falling_water_column_2d.jl +++ b/examples/fsi/falling_water_column_2d.jl @@ -1,3 +1,11 @@ +# ========================================================================================== +# 2D Falling Water Column on an Elastic Beam (FSI) +# +# This example simulates a column of water falling under gravity and impacting +# an elastic beam, which is fixed at one end (cantilever). +# It demonstrates Fluid-Structure Interaction where the fluid deforms the solid structure. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/n_body/n_body_benchmark_reference.jl b/examples/n_body/n_body_benchmark_reference.jl index be13d15113..c44de58233 100644 --- a/examples/n_body/n_body_benchmark_reference.jl +++ b/examples/n_body/n_body_benchmark_reference.jl @@ -1,9 +1,11 @@ +# ========================================================================================== # The Computer Language Benchmarks Game # https://salsa.debian.org/benchmarksgame-team/benchmarksgame/ # # Contributed by Andrei Fomiga, Stefan Karpinski, Viral B. Shah, Jeff # Bezanson, and Adam Beckmeyer. # Based on Mark C. Lewis's Java version. +# ========================================================================================== using Printf diff --git a/examples/n_body/n_body_benchmark_reference_faster.jl b/examples/n_body/n_body_benchmark_reference_faster.jl index b0a5ed2566..bf6019d0ce 100644 --- a/examples/n_body/n_body_benchmark_reference_faster.jl +++ b/examples/n_body/n_body_benchmark_reference_faster.jl @@ -1,3 +1,4 @@ +# ========================================================================================== # The Computer Language Benchmarks Game # https://salsa.debian.org/benchmarksgame-team/benchmarksgame/ # @@ -10,6 +11,7 @@ # unroll them. To convince llvm to do so, this script should be run # with the environment variable: # JULIA_LLVM_ARGS='-unroll-threshold=500'. +# ========================================================================================== using Base.Cartesian diff --git a/examples/n_body/n_body_benchmark_trixi.jl b/examples/n_body/n_body_benchmark_trixi.jl index 167c5e2d7b..925f6283d9 100644 --- a/examples/n_body/n_body_benchmark_trixi.jl +++ b/examples/n_body/n_body_benchmark_trixi.jl @@ -1,8 +1,9 @@ -# +# ========================================================================================== # An n-body benchmark from "The Computer Language Benchmarks Game" translated to TrixiParticles. # This example does not benefit from using multiple threads. # Multithreading is disabled below. -# +# ========================================================================================== + using TrixiParticles using Printf using Polyester diff --git a/examples/n_body/n_body_solar_system.jl b/examples/n_body/n_body_solar_system.jl index 158b5b7246..060eab5330 100644 --- a/examples/n_body/n_body_solar_system.jl +++ b/examples/n_body/n_body_solar_system.jl @@ -1,7 +1,8 @@ -# +# ========================================================================================== # An n-body simulation of the solar system. # This example does not benefit from using multiple threads due to the small problem size. -# +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq using Printf diff --git a/examples/postprocessing/interpolation_plane.jl b/examples/postprocessing/interpolation_plane.jl index 2473cd7ae6..e30f114c59 100644 --- a/examples/postprocessing/interpolation_plane.jl +++ b/examples/postprocessing/interpolation_plane.jl @@ -1,5 +1,11 @@ -# Example for using interpolation -####################################################################################### +# ========================================================================================== +# 2D and 3D Plane Interpolation Example +# +# This example demonstrates how to interpolate SPH particle data (e.g., pressure) +# onto a regular 2D or 3D plane using TrixiParticles.jl.# +# A hydrostatic water column simulation is used as the base for generating particle data. +# ========================================================================================== + using TrixiParticles using Plots using Plots.PlotMeasures diff --git a/examples/postprocessing/interpolation_point_line.jl b/examples/postprocessing/interpolation_point_line.jl index 62d95fe4b5..9447e63aea 100644 --- a/examples/postprocessing/interpolation_point_line.jl +++ b/examples/postprocessing/interpolation_point_line.jl @@ -1,5 +1,11 @@ -# Example for using interpolation -####################################################################################### +# ========================================================================================== +# Point and Line Interpolation Example +# +# This example demonstrates how to interpolate SPH particle data (e.g., density, pressure) +# at specific points or along a line using TrixiParticles.jl. +# A hydrostatic water column simulation is used as the base for generating particle data. +# ========================================================================================== + using TrixiParticles # this needs to be commented out to use PythonPlot using Plots diff --git a/examples/postprocessing/postprocessing.jl b/examples/postprocessing/postprocessing.jl index 9b31bc9b36..58a1e02cbc 100644 --- a/examples/postprocessing/postprocessing.jl +++ b/examples/postprocessing/postprocessing.jl @@ -1,3 +1,12 @@ +# ========================================================================================== +# Postprocessing Callback Example +# +# This example demonstrates how to use the `PostprocessCallback` in TrixiParticles.jl +# to compute and save custom quantities during a simulation, or to execute +# arbitrary user-defined functions at specified intervals. +# A hydrostatic water column simulation is used as the base. +# ========================================================================================== + using TrixiParticles using Plots using CSV diff --git a/examples/preprocessing/complex_shape_2d.jl b/examples/preprocessing/complex_shape_2d.jl index 3d3f836360..fa2b762988 100644 --- a/examples/preprocessing/complex_shape_2d.jl +++ b/examples/preprocessing/complex_shape_2d.jl @@ -1,3 +1,16 @@ +# ========================================================================================== +# 2D Complex Shape Sampling and Winding Number Visualization +# +# This example demonstrates how to: +# 1. Load a 2D geometry from an ASCII file (e.g., a curve). +# 2. Sample particles within this complex geometry using the `ComplexShape` functionality. +# 3. Utilize the Winding Number algorithm to determine if points are inside or outside. +# 4. Visualize the sampled particles and the winding number field. +# +# The example uses an "inverted_open_curve" geometry, where standard inside/outside +# definitions might be ambiguous without a robust point-in-polygon test like winding numbers. +# ========================================================================================== + using TrixiParticles using Plots diff --git a/examples/preprocessing/complex_shape_3d.jl b/examples/preprocessing/complex_shape_3d.jl index e8542a7294..02766ce4b7 100644 --- a/examples/preprocessing/complex_shape_3d.jl +++ b/examples/preprocessing/complex_shape_3d.jl @@ -1,3 +1,15 @@ +# ========================================================================================== +# 3D Complex Shape Sampling (e.g., from STL) +# +# This example demonstrates how to: +# 1. Load a 3D geometry from an STL file (e.g., a sphere). +# 2. Sample particles either as a fluid volume within this geometry or as a boundary layer. +# 3. Optionally create a Signed Distance Field (SDF) from the geometry. +# 4. Export the results to VTK files for visualization. +# +# The Winding Number algorithm is typically used for robust point-in-volume tests for 3D. +# ========================================================================================== + using TrixiParticles particle_spacing = 0.05 diff --git a/examples/preprocessing/packing_2d.jl b/examples/preprocessing/packing_2d.jl index b26f950573..fc8b330269 100644 --- a/examples/preprocessing/packing_2d.jl +++ b/examples/preprocessing/packing_2d.jl @@ -1,3 +1,17 @@ +# ========================================================================================== +# 2D Particle Packing within a Complex Geometry +# +# This example demonstrates how to: +# 1. Load a 2D geometry (e.g., a circle defined by a boundary curve). +# 2. Generate an initial, potentially overlapping, distribution of "fluid" particles +# inside the geometry and "boundary" particles forming a layer around it. +# 3. Use the `ParticlePackingSystem` to run a pseudo-SPH simulation that relaxes +# the particle positions, achieving a more uniform and non-overlapping distribution. +# 4. Visualize the initial and packed particle configurations. +# +# This is a common preprocessing step to create stable initial conditions for SPH simulations. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq, Plots diff --git a/examples/preprocessing/packing_3d.jl b/examples/preprocessing/packing_3d.jl index 0331d3c0a0..cb15a255b2 100644 --- a/examples/preprocessing/packing_3d.jl +++ b/examples/preprocessing/packing_3d.jl @@ -1,3 +1,12 @@ +# ========================================================================================== +# 3D Particle Packing within a Complex Geometry (e.g., Sphere STL) +# +# This example demonstrates 3D particle packing by leveraging the 2D packing script +# (`packing_2d.jl`). It loads a 3D geometry (STL file), sets 3D-specific parameters, +# and then includes the 2D script, which will perform the packing logic adapted +# for 3D. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq diff --git a/examples/solid/oscillating_beam_2d.jl b/examples/solid/oscillating_beam_2d.jl index 15ad8c99e7..830eaeff76 100644 --- a/examples/solid/oscillating_beam_2d.jl +++ b/examples/solid/oscillating_beam_2d.jl @@ -1,3 +1,11 @@ +# ========================================================================================== +# 2D Oscillating Elastic Beam (Cantilever) Simulation +# +# This example simulates the oscillation of a 2D elastic beam (cantilever) +# fixed at one end and subjected to gravity. It uses the Total Lagrangian SPH (TLSPH) +# method for solid mechanics. +# ========================================================================================== + using TrixiParticles using OrdinaryDiffEq From be279338464cfad28322eb75c477eee9de45d729 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Thu, 22 May 2025 14:12:44 +0200 Subject: [PATCH 2/2] format --- examples/fluid/periodic_array_of_cylinders_2d.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/fluid/periodic_array_of_cylinders_2d.jl b/examples/fluid/periodic_array_of_cylinders_2d.jl index 0bbeae30ae..850c9f2ff9 100644 --- a/examples/fluid/periodic_array_of_cylinders_2d.jl +++ b/examples/fluid/periodic_array_of_cylinders_2d.jl @@ -12,7 +12,6 @@ # within a representative channel segment is simulated. # ========================================================================================== - using TrixiParticles using OrdinaryDiffEq