Skip to content

Commit b65cd6e

Browse files
efaulhaberLasNikas
authored andcommitted
Combine PST and TVF into a unified framework (#884)
* Combine PST and TVF into a unified framework * Require update callback for PST * Fix WCSPH * Update PST only in callback * Fix EDAC * Update docs * Fix alle example files * Fix tests * Fix periodic channel * Fix docs * Update news * Fix tests * Fix example file
1 parent 1f8d909 commit b65cd6e

25 files changed

Lines changed: 479 additions & 461 deletions

NEWS.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@ TrixiParticles.jl follows the interpretation of
44
[semantic versioning (semver)](https://julialang.github.io/Pkg.jl/dev/compatibility/#Version-specifier-format-1)
55
used in the Julia ecosystem. Notable changes will be documented in this file for human readability.
66

7+
## Version 0.4
8+
9+
### API Changes
10+
11+
- Combined transport velocity formulation (TVF) and particle shifting technique (PST) into
12+
one unified framework.
13+
The keyword argument `transport_velocity` now changed to `shifting_technique`.
14+
The `ParticleShiftingCallback` has been removed. To use PST, use the `UpdateCallback`
15+
instead, and pass `shifting_technique=ParticleShiftingTechnique()` to the system.
16+
17+
- Renamed the keyword argument `tlsph` to `place_on_shell` for `ParticlePackingSystem`,
18+
`sample_boundary`, `extrude_geometry`, `RectangularShape`, and `SphereShape`.
19+
720
## Version 0.3.1
821

922
### Features
1023

11-
- **Simplified SGS Viscosity Models**: Added ViscosityMorrisSGS and ViscosityAdamiSGS,
24+
- **Simplified SGS Viscosity Models**: Added ViscosityMorrisSGS and ViscosityAdamiSGS,
1225
which implement a simplified Smagorinsky-type sub-grid-scale viscosity. (#753)
1326

14-
- **Multithreaded Integration Array**: Introduced a new array type for CPU backends
27+
- **Multithreaded Integration Array**: Introduced a new array type for CPU backends
1528
that enables multithreaded broadcasting, delivering speed-ups of up to 5× on systems
1629
with many threads when combined with thread pinning. (#722)
1730

@@ -21,17 +34,17 @@ used in the Julia ecosystem. Notable changes will be documented in this file for
2134
- **DXF file format support**: Import complex geometries using the DXF file format. (#821)
2235

2336
- **Improved Plane interpolation**: Massively improved interpolation performance for planes (#763).
24-
37+
2538
### GPU
2639

2740
- Make PST GPU-compatible (#813).
28-
41+
2942
- Make open boundaries GPU-compatible (#773).
30-
43+
3144
- Make interpolation GPU-compatible (#812).
3245

3346
### Important Bugfixes
34-
47+
3548
- Fix validation setups (#801).
3649

3750
- Calculate interpolated density instead of computed density when using interpolation (#808).

docs/src/systems/entropically_damped_sph.md

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -45,64 +45,3 @@ is a good choice for a wide range of Reynolds numbers (0.0125 to 10000).
4545
Modules = [TrixiParticles]
4646
Pages = [joinpath("schemes", "fluid", "entropically_damped_sph", "system.jl")]
4747
```
48-
49-
## [Transport Velocity Formulation (TVF)](@id transport_velocity_formulation)
50-
Standard SPH suffers from problems like tensile instability or the creation of void regions in the flow.
51-
To address these problems, [Adami (2013)](@cite Adami2013) modified the advection velocity and added an extra term to the momentum equation.
52-
The authors introduced the so-called Transport Velocity Formulation (TVF) for WCSPH. [Ramachandran (2019)](@cite Ramachandran2019) applied the TVF
53-
also for the [EDAC](@ref edac) scheme.
54-
55-
The transport velocity ``\tilde{v}_a`` of particle ``a`` is used to evolve the position of the particle ``r_a`` from one time step to the next by
56-
57-
```math
58-
\frac{\mathrm{d} r_a}{\mathrm{d}t} = \tilde{v}_a
59-
```
60-
61-
and is obtained at every time-step ``\Delta t`` from
62-
63-
```math
64-
\tilde{v}_a (t + \Delta t) = v_a (t) + \Delta t \left(\frac{\tilde{\mathrm{d}} v_a}{\mathrm{d}t} - \frac{1}{\rho_a} \nabla p_{\text{background}} \right),
65-
```
66-
67-
where ``\rho_a`` is the density of particle ``a`` and ``p_{\text{background}}`` is a constant background pressure field.
68-
The tilde in the second term of the right hand side indicates that the material derivative has an advection part.
69-
70-
The discretized form of the last term is
71-
72-
```math
73-
-\frac{1}{\rho_a} \nabla p_{\text{background}} \approx -\frac{p_{\text{background}}}{m_a} \sum_b \left(V_a^2 + V_b^2 \right) \nabla_a W_{ab},
74-
```
75-
76-
where ``V_a``, ``V_b`` denote the volume of particles ``a`` and ``b`` respectively.
77-
Note that although in the continuous case ``\nabla p_{\text{background}} = 0``, the discretization is not 0th-order consistent for **non**-uniform particle distribution,
78-
which means that there is a non-vanishing contribution only when particles are disordered.
79-
That also means that ``p_{\text{background}}`` occurs as prefactor to correct the trajectory of a particle resulting in uniform pressure distributions.
80-
Suggested is a background pressure which is in the order of the reference pressure but can be chosen arbitrarily large when the time-step criterion is adjusted.
81-
82-
The inviscid momentum equation with an additional convection term for a particle moving with ``\tilde{v}`` is
83-
84-
```math
85-
\frac{\tilde{\mathrm{d}} \left( \rho v \right)}{\mathrm{d}t} = -\nabla p + \nabla \cdot \bm{A},
86-
```
87-
88-
where the tensor ``\bm{A} = \rho v\left(\tilde{v}-v\right)^T`` is a consequence of the modified
89-
advection velocity and can be interpreted as the convection of momentum with the relative velocity ``\tilde{v}-v``.
90-
91-
The discretized form of the momentum equation for a particle ``a`` reads as
92-
93-
```math
94-
\frac{\tilde{\mathrm{d}} v_a}{\mathrm{d}t} = \frac{1}{m_a} \sum_b \left(V_a^2 + V_b^2 \right) \left[ -\tilde{p}_{ab} \nabla_a W_{ab} + \frac{1}{2} \left(\bm{A}_a + \bm{A}_b \right) \cdot \nabla_a W_{ab} \right].
95-
```
96-
97-
Here, ``\tilde{p}_{ab}`` is the density-weighted pressure
98-
99-
```math
100-
\tilde{p}_{ab} = \frac{\rho_b p_a + \rho_a p_b}{\rho_a + \rho_b},
101-
```
102-
103-
with the density ``\rho_a``, ``\rho_b`` and the pressure ``p_a``, ``p_b`` of particles ``a`` and ``b`` respectively. ``\bm{A}_a`` and ``\bm{A}_b`` are the convection tensors for particle ``a`` and ``b`` respectively and are given, e.g. for particle ``a``, as ``\bm{A}_a = \rho v_a\left(\tilde{v}_a-v_a\right)^T``.
104-
105-
```@autodocs
106-
Modules = [TrixiParticles]
107-
Pages = [joinpath("schemes", "fluid", "transport_velocity.jl")]
108-
```

docs/src/systems/weakly_compressible_sph.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,74 @@ as explained in [Sun2018](@cite Sun2018) on page 29, right above Equation 9.
152152
The ``\delta``-SPH method (WCSPH with density diffusion) together with this formulation
153153
of PST is commonly referred to as ``\delta^+``-SPH.
154154

155-
The Particle Shifting Technique can be applied in form
156-
of the [`ParticleShiftingCallback`](@ref).
155+
To apply particle shifting, use the keyword argument `shifting_technique` in the constructor
156+
of a system that supports it.
157+
158+
159+
## [Transport Velocity Formulation (TVF)](@id transport_velocity_formulation)
160+
161+
An alternative formulation is the so-called Transport Velocity Formulation (TVF)
162+
by [Adami (2013)](@cite Adami2013).
163+
[Ramachandran (2019)](@cite Ramachandran2019) applied the TVF also for the [EDAC](@ref edac)
164+
scheme.
165+
166+
The transport velocity ``\tilde{v}_a`` of particle ``a`` is used to evolve the position
167+
of the particle ``r_a`` from one time step to the next by
168+
```math
169+
\frac{\mathrm{d} r_a}{\mathrm{d}t} = \tilde{v}_a
170+
```
171+
and is obtained at every time step ``\Delta t`` from
172+
```math
173+
\tilde{v}_a (t + \Delta t) = v_a (t) + \Delta t \left(\frac{\tilde{\mathrm{d}} v_a}{\mathrm{d}t} - \frac{1}{\rho_a} \nabla p_{\text{background}} \right),
174+
```
175+
where ``\rho_a`` is the density of particle ``a`` and ``p_{\text{background}}``
176+
is a constant background pressure field.
177+
The tilde in the second term of the right-hand side indicates that the material derivative
178+
has an advection part.
179+
180+
The discretized form of the last term is
181+
```math
182+
-\frac{1}{\rho_a} \nabla p_{\text{background}} \approx -\frac{p_{\text{background}}}{m_a} \sum_b \left(V_a^2 + V_b^2 \right) \nabla_a W_{ab},
183+
```
184+
where ``V_a``, ``V_b`` denote the volume of particles ``a`` and ``b`` respectively.
185+
Note that although in the continuous case ``\nabla p_{\text{background}} = 0``,
186+
the discretization is not 0th-order consistent for **non**-uniform particle distribution,
187+
which means that there is a non-vanishing contribution only when particles are disordered.
188+
That also means that ``p_{\text{background}}`` occurs as pre-factor to correct
189+
the trajectory of a particle resulting in uniform pressure distributions.
190+
Suggested is a background pressure which is in the order of the reference pressure,
191+
but it can be chosen arbitrarily large when the time-step criterion is adjusted.
192+
193+
The inviscid momentum equation with an additional convection term for a particle
194+
moving with ``\tilde{v}`` is
195+
```math
196+
\frac{\tilde{\mathrm{d}} \left( \rho v \right)}{\mathrm{d}t} = -\nabla p + \nabla \cdot \bm{A},
197+
```
198+
where the tensor ``\bm{A} = \rho v\left(\tilde{v}-v\right)^T`` is a consequence
199+
of the modified advection velocity and can be interpreted as the convection of momentum
200+
with the relative velocity ``\tilde{v}-v``.
201+
202+
The discretized form of the momentum equation for a particle ``a`` reads as
203+
```math
204+
\frac{\tilde{\mathrm{d}} v_a}{\mathrm{d}t} = \frac{1}{m_a} \sum_b \left(V_a^2 + V_b^2 \right) \left[ -\tilde{p}_{ab} \nabla_a W_{ab} + \frac{1}{2} \left(\bm{A}_a + \bm{A}_b \right) \cdot \nabla_a W_{ab} \right].
205+
```
206+
Here, ``\tilde{p}_{ab}`` is the density-weighted pressure
207+
```math
208+
\tilde{p}_{ab} = \frac{\rho_b p_a + \rho_a p_b}{\rho_a + \rho_b},
209+
```
210+
with the density ``\rho_a``, ``\rho_b`` and the pressure ``p_a``, ``p_b`` of particles ``a``
211+
and ``b``, respectively. ``\bm{A}_a`` and ``\bm{A}_b`` are the convection tensors
212+
for particle ``a`` and ``b``, respectively, and are given, e.g., for particle ``a``,
213+
as ``\bm{A}_a = \rho v_a\left(\tilde{v}_a-v_a\right)^T``.
214+
215+
To apply the TVF, use the keyword argument `shifting_technique` in the constructor
216+
of a system that supports it.
217+
218+
```@autodocs
219+
Modules = [TrixiParticles]
220+
Pages = [joinpath("schemes", "fluid", "shifting_techniques.jl")]
221+
```
222+
157223

158224
## [Tensile Instability Control](@id tic)
159225

examples/fluid/lid_driven_cavity_2d.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ if wcsph
6565
state_equation, smoothing_kernel,
6666
pressure_acceleration=TrixiParticles.inter_particle_averaged_pressure,
6767
smoothing_length, viscosity=viscosity,
68-
transport_velocity=TransportVelocityAdami(pressure))
68+
shifting_technique=TransportVelocityAdami(pressure))
6969
else
7070
state_equation = nothing
7171
density_calculator = ContinuityDensity()
7272
fluid_system = EntropicallyDampedSPHSystem(cavity.fluid, smoothing_kernel,
7373
smoothing_length,
7474
density_calculator=density_calculator,
7575
sound_speed, viscosity=viscosity,
76-
transport_velocity=TransportVelocityAdami(pressure))
76+
shifting_technique=TransportVelocityAdami(pressure))
7777
end
7878

7979
# ==========================================================================================

examples/fluid/periodic_array_of_cylinders_2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ smoothing_length = 1.2 * particle_spacing
6060
smoothing_kernel = SchoenbergQuarticSplineKernel{2}()
6161
fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length,
6262
sound_speed, viscosity=ViscosityAdami(; nu),
63-
transport_velocity=TransportVelocityAdami(pressure),
63+
shifting_technique=TransportVelocityAdami(pressure),
6464
acceleration=(acceleration_x, 0.0))
6565

6666
# ==========================================================================================

examples/fluid/periodic_channel_2d.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ initial_fluid_size = tank_size
2828
initial_velocity = (1.0, 0.0)
2929

3030
fluid_density = 1000.0
31-
sound_speed = initial_velocity[1]
31+
sound_speed = 10 * initial_velocity[1]
3232
state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density,
3333
exponent=7)
3434

@@ -48,6 +48,7 @@ viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
4848
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
4949
state_equation, smoothing_kernel,
5050
smoothing_length, viscosity=viscosity,
51+
shifting_technique=nothing,
5152
pressure_acceleration=nothing)
5253

5354
# ==========================================================================================

examples/fluid/pipe_flow_2d.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ viscosity = ViscosityAdami(nu=kinematic_viscosity)
7474
fluid_system = EntropicallyDampedSPHSystem(pipe.fluid, smoothing_kernel, smoothing_length,
7575
sound_speed, viscosity=viscosity,
7676
density_calculator=fluid_density_calculator,
77+
shifting_technique=ParticleShiftingTechnique(),
7778
buffer_size=n_buffer_particles)
7879

7980
# Alternatively the WCSPH scheme can be used
@@ -86,6 +87,7 @@ if wcsph
8687
fluid_system = WeaklyCompressibleSPHSystem(pipe.fluid, fluid_density_calculator,
8788
state_equation, smoothing_kernel,
8889
smoothing_length, viscosity=viscosity,
90+
shifting_technique=ParticleShiftingTechnique(),
8991
buffer_size=n_buffer_particles)
9092
end
9193

@@ -159,12 +161,10 @@ ode = semidiscretize(semi, tspan)
159161

160162
info_callback = InfoCallback(interval=100)
161163
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")
162-
particle_shifting = ParticleShiftingCallback()
163164

164165
extra_callback = nothing
165166

166-
callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback(),
167-
particle_shifting, extra_callback)
167+
callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback(), extra_callback)
168168

169169
sol = solve(ode, RDPK3SpFSAL35(),
170170
abstol=1e-5, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration)

examples/fluid/taylor_green_vortex_2d.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ if wcsph
8686
pressure_acceleration=TrixiParticles.inter_particle_averaged_pressure,
8787
smoothing_length,
8888
viscosity=ViscosityAdami(; nu),
89-
transport_velocity=TransportVelocityAdami(background_pressure))
89+
shifting_technique=TransportVelocityAdami(background_pressure))
9090
else
9191
density_calculator = SummationDensity()
9292
fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length,
9393
sound_speed,
9494
density_calculator=density_calculator,
95-
transport_velocity=TransportVelocityAdami(background_pressure),
95+
shifting_technique=TransportVelocityAdami(background_pressure),
9696
viscosity=ViscosityAdami(; nu))
9797
end
9898

src/TrixiParticles.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ export WeaklyCompressibleSPHSystem, EntropicallyDampedSPHSystem, TotalLagrangian
6565
BoundarySPHSystem, DEMSystem, BoundaryDEMSystem, OpenBoundarySPHSystem
6666
export BoundaryZone, InFlow, OutFlow, BidirectionalFlow
6767
export InfoCallback, SolutionSavingCallback, DensityReinitializationCallback,
68-
PostprocessCallback, StepsizeCallback, UpdateCallback, SteadyStateReachedCallback,
69-
ParticleShiftingCallback
68+
PostprocessCallback, StepsizeCallback, UpdateCallback, SteadyStateReachedCallback
7069
export ContinuityDensity, SummationDensity
71-
export PenaltyForceGanzenmueller, TransportVelocityAdami
70+
export PenaltyForceGanzenmueller, TransportVelocityAdami, ParticleShiftingTechnique
7271
export SchoenbergCubicSplineKernel, SchoenbergQuarticSplineKernel,
7372
SchoenbergQuinticSplineKernel, GaussianKernel, WendlandC2Kernel, WendlandC4Kernel,
7473
WendlandC6Kernel, SpikyKernel, Poly6Kernel

src/callbacks/callbacks.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ include("post_process.jl")
3232
include("stepsize.jl")
3333
include("update.jl")
3434
include("steady_state_reached.jl")
35-
include("particle_shifting.jl")

0 commit comments

Comments
 (0)