Skip to content

Commit 367e80a

Browse files
author
LasNikas
committed
Merge branch 'main' into oriented-bbox
2 parents ea4bf06 + 08ecf7f commit 367e80a

85 files changed

Lines changed: 1645 additions & 859 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/Documenter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
os: [ubuntu-latest, windows-latest]
3232
steps:
3333
- name: Check out project
34-
uses: actions/checkout@v5
34+
uses: actions/checkout@v6
3535
- name: Set up Julia
3636
uses: julia-actions/setup-julia@v2
3737
with:

.github/workflows/FormatCheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out project
16-
uses: actions/checkout@v5
16+
uses: actions/checkout@v6
1717
- name: Set up Julia
1818
uses: julia-actions/setup-julia@v2
1919
with:

.github/workflows/Invalidations.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
with:
2121
# TODO: Is broken in 1.11 revert to 1 after fix
2222
version: '1.10'
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424
- uses: julia-actions/julia-buildpkg@v1
2525
- uses: julia-actions/julia-invalidations@v1
2626
id: invs_pr
2727

28-
- uses: actions/checkout@v5
28+
- uses: actions/checkout@v6
2929
with:
3030
ref: ${{ github.event.repository.default_branch }}
3131
- uses: julia-actions/julia-buildpkg@v1

.github/workflows/SpellCheck.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout Actions Repository
11-
uses: actions/checkout@v5
11+
uses: actions/checkout@v6
1212
- name: Check spelling
13-
uses: crate-ci/typos@v1.39.0
13+
uses: crate-ci/typos@v1.40.0

.github/workflows/TriggerGPUTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Trigger Buildkite Pipeline
14-
uses: "buildkite/trigger-pipeline-action@v2.4.0"
14+
uses: "buildkite/trigger-pipeline-action@v2.4.1"
1515
with:
1616
buildkite_api_access_token: ${{ secrets.TRIGGER_BK_BUILD_TOKEN }}
1717
pipeline: "julialang/trixiparticles"

.github/workflows/ci.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060

6161
steps:
6262
- name: Check out project
63-
uses: actions/checkout@v5
63+
uses: actions/checkout@v6
6464

6565
- name: Set up Julia
6666
uses: julia-actions/setup-julia@v2
@@ -80,20 +80,20 @@ jobs:
8080
with:
8181
annotate: true
8282
# Only run coverage in one Job (Ubuntu and latest Julia version)
83-
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.version == '1' }}
83+
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.version == '1.11' }}
8484
env:
8585
TRIXIPARTICLES_TEST: unit
8686

87-
- name: Process coverage results
87+
- name: Process unit coverage results
8888
# Only run coverage in one Job (Ubuntu and latest Julia version)
89-
if: matrix.os == 'ubuntu-latest' && matrix.version == '1'
89+
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.11'
9090
uses: julia-actions/julia-processcoverage@v1
9191
with:
9292
directories: src,test
9393

94-
- name: Upload coverage report to Codecov
94+
- name: Upload unit coverage report to Codecov
9595
# Only run coverage in one Job (Ubuntu and latest Julia version)
96-
if: matrix.os == 'ubuntu-latest' && matrix.version == '1'
96+
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.11'
9797
uses: codecov/codecov-action@v5
9898
with:
9999
files: lcov.info
@@ -106,6 +106,25 @@ jobs:
106106
uses: julia-actions/julia-runtest@v1
107107
with:
108108
annotate: true
109-
coverage: false
109+
# Only run coverage in one Job (Ubuntu and latest Julia version)
110+
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.version == '1.11' }}
110111
env:
111112
TRIXIPARTICLES_TEST: examples
113+
114+
- name: Process total coverage results
115+
# Only run coverage in one Job (Ubuntu and latest Julia version)
116+
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.11'
117+
uses: julia-actions/julia-processcoverage@v1
118+
with:
119+
directories: src,test
120+
121+
- name: Upload total coverage report to Codecov
122+
# Only run coverage in one Job (Ubuntu and latest Julia version)
123+
if: matrix.os == 'ubuntu-latest' && matrix.version == '1.11'
124+
uses: codecov/codecov-action@v5
125+
with:
126+
files: lcov.info
127+
fail_ci_if_error: true
128+
flags: total
129+
env:
130+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TrixiParticles"
22
uuid = "66699cd8-9c01-4e9d-a059-b96c86d16b3a"
3-
authors = ["erik.faulhaber <44124897+efaulhaber@users.noreply.github.com>"]
43
version = "0.4.2"
4+
authors = ["erik.faulhaber <44124897+efaulhaber@users.noreply.github.com>"]
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -55,7 +55,7 @@ KernelAbstractions = "0.9"
5555
MuladdMacro = "0.2"
5656
OrdinaryDiffEq = "6.91"
5757
OrdinaryDiffEqCore = "1"
58-
PointNeighbors = "0.6.3"
58+
PointNeighbors = "0.6.4"
5959
Polyester = "0.7.10"
6060
ReadVTK = "0.2"
6161
RecipesBase = "1"

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
22
Asciicast = "2600d445-abca-43b9-92aa-ce144ac0b05b"
3+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
34
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
45
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
56
DocumenterMermaid = "a078cd44-4d9c-4618-b545-3ab9d77f9177"
@@ -9,6 +10,7 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
910

1011
[compat]
1112
Asciicast = "0.1.3"
13+
CairoMakie = "0.15"
1214
Documenter = "1"
1315
DocumenterCitations = "1"
1416
DocumenterMermaid = "0.2"
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# # Modifying or extending components of TrixiParticles.jl within a simulation file
2+
3+
# In this tutorial, we will show how to replace components
4+
# of TrixiParticles.jl by custom implementations from within a simulation file,
5+
# without ever cloning the repository.
6+
7+
# First, we import TrixiParticles.jl and
8+
# [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl), which we will
9+
# use at the very end for the time integration.
10+
using TrixiParticles
11+
using OrdinaryDiffEq
12+
13+
# ## Load a simulation file
14+
15+
# Instead of setting up the simulation from scratch, we run a pre-defined
16+
# simulation file that implements a 2D dam break problem with
17+
# Weakly Compressible Smoothed Particle Hydrodynamics (WCSPH).
18+
# This tutorial works with any other simulation file as well, as long as
19+
# it contains an assignment `smoothing_kernel = ...`.
20+
# By using [`trixi_include`](@ref), we can overwrite variables defined
21+
# in the simulation file.
22+
# Here, we pass `sol=nothing` to overwrite the line that defines the variable `sol`,
23+
# which is the line that runs the actual simulation.
24+
# This way, we can import all variables and definitions from the simulation file
25+
# without running the simulation right away.
26+
# In this tutorial, we only need the definition of the particle spacing,
27+
# but this approach works for any variable defined in the simulation file
28+
# and is used in many pre-defined example simulation files.
29+
# See [the tutorial on setting up a simulation](@ref tut_setup) for details on the
30+
# general structure of a simulation file.
31+
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
32+
sol=nothing)
33+
34+
# ## Replacing components with custom implementations
35+
36+
# In this tutorial, we want to replace the smoothing kernel used in the simulation
37+
# by a custom implementation.
38+
# A good starting point is to check out the available implementations in
39+
# TrixiParticles.jl, then copy the relevant functions to the simulation file
40+
# and modify them as needed.
41+
42+
# ### Custom smoothing kernel
43+
44+
# To implement a custom smoothing kernel, we define a struct extending
45+
# `TrixiParticles.AbstractSmoothingKernel`.
46+
# This abstract struct has a type parameter for the number of dimensions,
47+
# which we set to 2 in this case.
48+
struct MyGaussianKernel <: TrixiParticles.AbstractSmoothingKernel{2} end
49+
# This kernel is going to be an implementation of the Gaussian kernel with
50+
# a cutoff for compact support, which reads
51+
# ```math
52+
# W(r, h) =
53+
# \begin{cases}
54+
# \frac{1}{\pi h^2} \exp(-(r/h)^2) & \text{for } r < 2h\\
55+
# 0 & \text{for } r \geq 2h.
56+
# \end{cases}
57+
# ```
58+
# Note that the same kernel in a more optimized version and with a cutoff at ``3``
59+
# is already implemented in TrixiParticles.jl as [`GaussianKernel`](@ref).
60+
61+
# By looking at the implementation of existing kernels in TrixiParticles.jl,
62+
# we can see that a kernel implementation requires three functions.
63+
# `TrixiParticles.kernel`, which is the kernel function itself,
64+
# `TrixiParticles.kernel_deriv`, which is the derivative of the kernel function,
65+
# and `TrixiParticles.compact_support`, which defines the compact support of the
66+
# kernel in relation to the smoothing length.
67+
# The latter is relevant for determining the search radius of the neighborhood search.
68+
function TrixiParticles.kernel(kernel::MyGaussianKernel, r, h)
69+
q = r / h
70+
71+
if q < 2
72+
return 1 / (pi * h^2) * exp(-q^2)
73+
end
74+
75+
return 0.0
76+
end
77+
78+
function TrixiParticles.kernel_deriv(kernel::MyGaussianKernel, r, h)
79+
q = r / h
80+
81+
if q < 2
82+
return 1 / (pi * h^2) * (-2 * q) * exp(-q^2) / h
83+
end
84+
85+
return 0.0
86+
end
87+
88+
TrixiParticles.compact_support(::MyGaussianKernel, h) = 2 * h
89+
90+
# For this kernel, we use a smoothing length of 1.2 times the particle spacing,
91+
# which yields a similar kernel shape as the commonly used Wendland C2 kernel
92+
# with a smoothing length of 1.59 times the particle spacing.
93+
smoothing_length = 1.2 * fluid_particle_spacing
94+
smoothing_length_wendland = 1.59 * fluid_particle_spacing
95+
nothing # hide
96+
# We can compare these kernels in a plot.
97+
using Plots
98+
plot(r -> TrixiParticles.kernel(WendlandC2Kernel{2}(), abs(r), smoothing_length_wendland),
99+
-3 * fluid_particle_spacing, 3 * fluid_particle_spacing,
100+
label="WendlandC2Kernel", xlabel="r")
101+
plot!(r -> TrixiParticles.kernel(MyGaussianKernel(), abs(r), smoothing_length),
102+
label="MyGaussianKernel")
103+
plot!(dpi=200) # hide
104+
savefig("tut_custom_kernel_plot2.png"); # hide
105+
# ![plot](tut_custom_kernel_plot2.png)
106+
107+
# This is all we need to use our custom kernel implementation in a simulation.
108+
# We only need to replace the definition above by
109+
smoothing_kernel = MyGaussianKernel()
110+
nothing # hide
111+
# and run the simulation file again.
112+
113+
# In order to use our kernel in a pre-defined example file, we can use the function
114+
# [`trixi_include`](@ref) to replace the definition of the variable `smoothing_kernel`.
115+
# The following will run the example simulation
116+
# `examples/fluid/dam_break_2d.jl` with our custom kernel and the corresponding
117+
# smoothing length.
118+
# ```@cast @__NAME__; width=100, height=50, delay=0, loop=true, loop_delay=5
119+
# trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
120+
# smoothing_kernel=MyGaussianKernel(),
121+
# smoothing_length=smoothing_length);
122+
# ```
123+
trixi_include(joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), #!md
124+
smoothing_kernel=MyGaussianKernel(), #!md
125+
smoothing_length=smoothing_length) #!md
126+
127+
# See [Visualization](@ref) for how to visualize the final solution.
128+
# For the simplest visualization, we can use [Plots.jl](https://docs.juliaplots.org/stable/):
129+
using Plots
130+
plot(sol, ylims=(-Inf, 1))
131+
plot!(dpi=200) # hide
132+
savefig("tut_custom_kernel_plot.png"); # hide
133+
# ![plot](tut_custom_kernel_plot.png)

docs/literate/src/tut_packing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# # Particle Packing Tutorial
1+
# # [Particle Packing Tutorial](@id tut_packing)
22

33
# In this tutorial, we will guide you through the complete particle packing pipeline.
44
# The algorithmic background is explained in [Particle Packing](@ref particle_packing).
@@ -152,7 +152,7 @@ packing_system = ParticlePackingSystem(shape_sampled;
152152
signed_distance_field=nothing, background_pressure)
153153

154154
# We now proceed with the familiar steps
155-
# "Semidiscretization" and "Time integration" from the fluid tutorials.
155+
# "Semidiscretization" and "Time integration" from the [basic tutorial](@ref tut_setup).
156156
semi = Semidiscretization(packing_system)
157157

158158
## Use a high `tspan` to guarantee that the simulation runs for at least `maxiters`

0 commit comments

Comments
 (0)