Skip to content

Add simple SGS to Adami and Morris Viscosity #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9657150
add sgs
svchb Apr 9, 2025
f3dde2b
Merge remote-tracking branch 'origin/main' into sgs
svchb Apr 9, 2025
639be87
update
svchb Apr 9, 2025
365c160
fix
svchb Apr 9, 2025
1c9e306
remove
svchb Apr 9, 2025
19451d8
fix doc
svchb Apr 9, 2025
22d62ea
fix
svchb Apr 9, 2025
6d7bec4
fixes
svchb Apr 9, 2025
5f90bf7
typo
svchb Apr 9, 2025
2963202
tpo
svchb Apr 9, 2025
82c9e9b
format
svchb Apr 9, 2025
183d413
Merge branch 'main' into sgs
svchb Apr 11, 2025
cbdadd5
Merge branch 'main' into sgs
svchb Apr 17, 2025
4f208f9
Merge branch 'main' into sgs
svchb May 6, 2025
5ff0c74
add explanation
svchb May 6, 2025
77bf5ef
adjust tests
svchb May 6, 2025
a288da5
Merge remote-tracking branch 'upstream/main' into sgs
svchb May 12, 2025
bad1954
add to validation setup for wcsph
svchb May 13, 2025
a48ca7d
Merge branch 'main' into sgs
svchb May 13, 2025
bea7af6
review fixes
svchb May 13, 2025
fa6df69
Update taylor_green_vortex_2d.jl
svchb May 14, 2025
0458976
Update validation_taylor_green_vortex_2d.jl
svchb May 14, 2025
de606e1
Update dam_break_2d.jl
svchb May 14, 2025
c45fdb6
fix and add citations
svchb May 14, 2025
a1920a5
Merge branch 'main' into sgs
svchb May 14, 2025
41938af
add news
svchb May 14, 2025
1716f99
Merge branch 'sgs' of https://github.com/svchb/TrixiParticles.jlOpen …
svchb May 14, 2025
8e83d5b
Merge branch 'main' into sgs
svchb May 16, 2025
af656b6
implement suggestions
svchb May 21, 2025
6a14443
format
svchb May 21, 2025
646b496
Merge branch 'main' into sgs
svchb May 21, 2025
639a5a4
Merge branch 'main' into sgs
svchb May 21, 2025
0ee856e
rename viscosity
svchb May 22, 2025
df12585
Merge branch 'main' into sgs
svchb May 22, 2025
f038002
too much renaming
svchb May 22, 2025
5643d86
Merge branch 'sgs' of https://github.com/svchb/TrixiParticles.jlOpen …
svchb May 22, 2025
2e9c7ff
Merge branch 'main' into sgs
svchb May 22, 2025
9c9186f
implement suggestions
svchb May 23, 2025
507138a
Merge branch 'main' into sgs
svchb May 26, 2025
7436332
Merge branch 'main' into sgs
efaulhaber May 28, 2025
1f72f09
Merge branch 'main' into sgs
svchb May 28, 2025
2f3bbbb
Update validation_taylor_green_vortex_2d.jl
svchb May 28, 2025
1d19cef
Merge branch 'main' into sgs
LasNikas Jun 12, 2025
1188a9a
Merge branch 'main' into sgs
svchb Jun 13, 2025
6a83b83
fix tests again
svchb Jun 13, 2025
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: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ used in the Julia ecosystem. Notable changes will be documented in this file for

### Features

- New viscosity models `ViscosityMorrisSGS` and `ViscosityAdamiSGS` were added, which use a simplified Smagorinsky-type SGS (#753).

- With all CPU backends, a new array type is used for the integration array, which defines
broadcasting to be multithreaded, leading to speedups of up to 5x with large thread counts
when combined with thread pinning (#722).
Expand Down
24 changes: 23 additions & 1 deletion docs/src/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ @article{MeloEspinosa2014
journal = {Energy Conversion and Management},
volume = {84},
pages = {50--60},
doi = {https://doi.org/10.1016/j.enconman.2014.08.004},
doi = {10.1016/j.enconman.2014.08.004},
year = {2014}
}

Expand All @@ -736,6 +736,28 @@ @book{Poling2001
address = {New York}
}

@article{Smagorinsky1963,
author = {Smagorinsky, Joseph},
title = {General Circulation Experiments with the Primitive Equations. I. The Basic Experiment},
journal = {Monthly Weather Review},
volume = {91},
number = {3},
pages = {99--164},
year = {1963},
doi = {10.1175/1520-0493(1963)091<0099:GCEWTP>2.3.CO;2}
}

@inproceedings{Lilly1967,
author = {Lilly, Douglas K.},
title = {The Representation of Small‑Scale Turbulence in Numerical Simulation Experiments},
booktitle = {Proceedings of the {IBM} Scientific Computing Symposium on Environmental Sciences},
editor = {Goldstine, Herman H.},
address = {Yorktown Heights, New York},
pages = {195--210},
year = {1967},
doi = {10.5065/D62R3PMM}
}

@article{Zhu2021,
author = {Zhu, Yujie and Zhang, Chi and Yu, Yongchuan and Hu, Xiangyu},
journal = {Journal of Hydrodynamics},
Expand Down
28 changes: 22 additions & 6 deletions examples/fluid/dam_break_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,29 @@ smoothing_length = 1.75 * fluid_particle_spacing
smoothing_kernel = WendlandC2Kernel{2}()

fluid_density_calculator = ContinuityDensity()
viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
# nu = 0.02 * smoothing_length * sound_speed/8
# viscosity = ViscosityMorris(nu=nu)
# viscosity = ViscosityAdami(nu=nu)
alpha = 0.02
viscosity_fluid = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0)
# A typical formula to convert Artificial viscosity to a
# kinematic viscosity is provided by Monaghan as
# nu = alpha * smoothing_length * sound_speed/8

# Alternatively a kinematic viscosity for water can be set
# nu = 1.0e-6

# This allows the use of a physical viscosity model like:
# viscosity_fluid = ViscosityAdami(nu=nu)
# or with additional dissipation through a Smagorinsky model
# viscosity_fluid = ViscosityAdamiSGS(nu=nu)
# For more details see the documentation "Viscosity model overview".

# Alternatively the density diffusion model by Molteni & Colagrossi can be used,
# which will run faster.
# density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
density_diffusion = DensityDiffusionAntuono(tank.fluid, delta=0.1)

fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, smoothing_kernel,
smoothing_length, viscosity=viscosity,
smoothing_length, viscosity=viscosity_fluid,
density_diffusion=density_diffusion,
acceleration=(0.0, -gravity), correction=nothing,
surface_tension=nothing,
Expand All @@ -67,12 +78,17 @@ fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
# ==========================================================================================
# ==== Boundary
boundary_density_calculator = AdamiPressureExtrapolation()
viscosity_wall = nothing
# For a no-slip condition the corresponding wall viscosity without SGS can be set
# viscosity_wall = ViscosityAdami(nu=nu)
# viscosity_wall = ViscosityMorris(nu=nu)
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass,
state_equation=state_equation,
boundary_density_calculator,
smoothing_kernel, smoothing_length,
correction=nothing,
reference_particle_spacing=0)
reference_particle_spacing=0,
viscosity=viscosity_wall)

boundary_system = BoundarySPHSystem(tank.boundary, boundary_model, adhesion_coefficient=0.0)

Expand Down
2 changes: 1 addition & 1 deletion examples/fluid/dam_break_2phase_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ water_viscosity = ViscosityMorris(nu=nu_sim_water)

trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
sol=nothing, fluid_particle_spacing=fluid_particle_spacing,
viscosity=water_viscosity, smoothing_length=smoothing_length,
viscosity_fluid=water_viscosity, smoothing_length=smoothing_length,
gravity=gravity, tspan=tspan, density_diffusion=nothing,
sound_speed=sound_speed, exponent=7,
tank_size=(floor(5.366 * H / fluid_particle_spacing) * fluid_particle_spacing,
Expand Down
3 changes: 2 additions & 1 deletion examples/fluid/dam_break_oil_film_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ oil_viscosity = ViscosityMorris(nu=nu_sim_oil)
# TODO: broken if both systems use surface tension
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
sol=nothing, fluid_particle_spacing=fluid_particle_spacing, tspan=tspan,
viscosity=ViscosityMorris(nu=nu_sim_water), smoothing_length=smoothing_length,
viscosity_fluid=ViscosityMorris(nu=nu_sim_water),
smoothing_length=smoothing_length,
gravity=gravity, density_diffusion=nothing, sound_speed=sound_speed,
prefix="", reference_particle_spacing=fluid_particle_spacing)

Expand Down
4 changes: 2 additions & 2 deletions examples/fluid/hydrostatic_water_column_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ smoothing_length = 1.2 * fluid_particle_spacing
smoothing_kernel = SchoenbergCubicSplineKernel{2}()

alpha = 0.02
viscosity = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0)
viscosity_fluid = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0)

fluid_density_calculator = ContinuityDensity()

# This is to set acceleration with `trixi_include`
system_acceleration = (0.0, -gravity)
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, smoothing_kernel,
smoothing_length, viscosity=viscosity,
smoothing_length, viscosity=viscosity_fluid,
acceleration=system_acceleration,
source_terms=nothing)

Expand Down
2 changes: 1 addition & 1 deletion examples/fluid/taylor_green_vortex_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# 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
# https://doi.org/10.1016/j.compfluid.2018.11.023

using TrixiParticles
using OrdinaryDiffEq
Expand Down
3 changes: 2 additions & 1 deletion src/TrixiParticles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export SchoenbergCubicSplineKernel, SchoenbergQuarticSplineKernel,
SchoenbergQuinticSplineKernel, GaussianKernel, WendlandC2Kernel, WendlandC4Kernel,
WendlandC6Kernel, SpikyKernel, Poly6Kernel
export StateEquationCole, StateEquationIdealGas
export ArtificialViscosityMonaghan, ViscosityAdami, ViscosityMorris
export ArtificialViscosityMonaghan, ViscosityAdami, ViscosityMorris, ViscosityAdamiSGS,
ViscosityMorrisSGS
export DensityDiffusion, DensityDiffusionMolteniColagrossi, DensityDiffusionFerrari,
DensityDiffusionAntuono
export tensile_instability_control
Expand Down
4 changes: 3 additions & 1 deletion src/io/write_vtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ end

write2vtk!(vtk, viscosity::Nothing) = vtk

function write2vtk!(vtk, viscosity::Union{ViscosityAdami, ViscosityMorris})
function write2vtk!(vtk,
viscosity::Union{ViscosityAdami, ViscosityMorris, ViscosityAdamiSGS,
ViscosityMorrisSGS})
vtk["viscosity_nu"] = viscosity.nu
vtk["viscosity_epsilon"] = viscosity.epsilon
end
Expand Down
Loading
Loading