Skip to content
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

Mixed kernel gradient #261

Merged
merged 106 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
57382e2
add gradient correction stuff
svchb Nov 1, 2023
81449fb
impl
svchb Nov 1, 2023
63f5ac9
up
svchb Nov 2, 2023
cfaf96c
finish impl
svchb Nov 2, 2023
4bf647e
update
svchb Nov 2, 2023
e937e15
fix testcases
svchb Nov 3, 2023
7c131db
fix
svchb Nov 3, 2023
1f53431
fix tests
svchb Nov 3, 2023
af8af78
format
svchb Nov 3, 2023
901d189
Merge branch 'main' into mixed-kernel-gradient
svchb Nov 3, 2023
182a872
working
svchb Nov 22, 2023
3cf34f4
format
svchb Nov 22, 2023
2e67efe
Merge branch 'main'
svchb Nov 22, 2023
027b1a4
format
svchb Nov 22, 2023
5f4a925
fix
svchb Nov 22, 2023
ad42394
working trixi_include
svchb Nov 24, 2023
8612c82
Merge branch 'main'
svchb Nov 24, 2023
09a1ea4
fix
svchb Nov 24, 2023
cadbbba
cleanup
svchb Nov 28, 2023
01a4173
format
svchb Nov 28, 2023
b506359
fix
svchb Nov 28, 2023
89cb149
fix tests
svchb Nov 28, 2023
f1537c4
Merge branch 'main'
svchb Nov 28, 2023
2cae13f
fix
svchb Nov 28, 2023
36ee614
Merge branch 'main' into mixed-kernel-gradient
svchb Nov 28, 2023
1cffc70
ups
svchb Nov 28, 2023
5d57d97
Merge branch 'mixed-kernel-gradient' of github.com:svchb/TrixiParticl…
svchb Nov 28, 2023
0e75ef2
typo
svchb Nov 28, 2023
2b03fe9
up
svchb Nov 29, 2023
1548433
fix
svchb Nov 30, 2023
ae78667
format
svchb Nov 30, 2023
54e7c16
update fix errors
svchb Dec 4, 2023
47ed721
fix
svchb Dec 5, 2023
57c55f1
update
svchb Dec 6, 2023
76aefea
up
svchb Dec 6, 2023
5c4d20d
fix tests
svchb Dec 6, 2023
c7976f9
fix tests
svchb Dec 6, 2023
aa66268
np
svchb Dec 6, 2023
369cbc9
remove comment
svchb Dec 6, 2023
7799f62
revert some changes
svchb Dec 6, 2023
d7932ca
up
svchb Dec 6, 2023
cc075f5
Merge branch 'main'
svchb Dec 6, 2023
e5e1ed9
up
svchb Dec 6, 2023
001668a
Merge branch 'main' into mixed-kernel-gradient
svchb Dec 6, 2023
40c567f
update
svchb Dec 7, 2023
95dcc62
format
svchb Dec 7, 2023
c8a67e7
Merge branch 'mixed-kernel-gradient' of github.com:svchb/TrixiParticl…
svchb Dec 7, 2023
30f7c32
cleanup
svchb Dec 7, 2023
ac76b86
revert
svchb Dec 7, 2023
67ea62d
revert
svchb Dec 7, 2023
ae6b3eb
implement correction on wall
svchb Dec 11, 2023
057adbe
fix tests
svchb Dec 11, 2023
bc9b87e
fix pressure_acceleration for summation
svchb Dec 12, 2023
21b83d5
format
svchb Dec 12, 2023
96b18c9
revert
svchb Dec 13, 2023
10d1a47
fix
svchb Dec 13, 2023
ca7f106
Merge branch 'main'
svchb Dec 13, 2023
7126cce
fixes
svchb Dec 13, 2023
f5469da
fix
svchb Dec 13, 2023
47f824d
fix pressure_acceleration dispatches
svchb Dec 14, 2023
3af1309
typo
svchb Dec 14, 2023
1b5d137
fix
svchb Dec 14, 2023
acafbe1
rename
svchb Dec 14, 2023
6ae8528
Merge branch 'main' into mixed-kernel-gradient
svchb Dec 22, 2023
1e47bc9
Merge branch 'main' into mixed-kernel-gradient
svchb Jan 2, 2024
d9d9562
some review fixes
svchb Jan 3, 2024
be802d4
review
svchb Jan 3, 2024
9278edb
more fixes
svchb Jan 3, 2024
f54c891
add solid system type
svchb Jan 3, 2024
3ed56be
review
svchb Jan 3, 2024
72d293f
fix tlsph call
svchb Jan 3, 2024
7b0c438
fix comment
svchb Jan 3, 2024
1a4803c
review
svchb Jan 3, 2024
3aea7ae
review
svchb Jan 3, 2024
2316101
format
svchb Jan 3, 2024
b4c3ad6
review
svchb Jan 3, 2024
2ab5853
move
svchb Jan 3, 2024
49b72f3
fix doc
svchb Jan 3, 2024
e2b9574
review fix
svchb Jan 3, 2024
148c0e9
more review
svchb Jan 3, 2024
2c86a03
review fix
svchb Jan 4, 2024
54b3fa0
format
svchb Jan 4, 2024
26e90b1
change parameter list
svchb Jan 4, 2024
824a054
reorder params
svchb Jan 4, 2024
76a5673
Merge branch 'main' into mixed-kernel-gradient
svchb Jan 4, 2024
390e0ed
format
svchb Jan 4, 2024
b3d3924
fix
svchb Jan 4, 2024
33ce59a
fix
svchb Jan 4, 2024
3346c63
Merge branch 'mixed-kernel-gradient' of github.com:svchb/TrixiParticl…
svchb Jan 4, 2024
22a6ff5
fix
svchb Jan 4, 2024
40805b5
remove dispatched functions
svchb Jan 4, 2024
ea17c79
format
svchb Jan 4, 2024
9e162ca
fix comments
svchb Jan 4, 2024
ae069d2
fix
svchb Jan 4, 2024
8fb3323
remove system
svchb Jan 4, 2024
c5803fd
format
svchb Jan 4, 2024
4f5223f
change parameter list
svchb Jan 4, 2024
111c53c
review
svchb Jan 4, 2024
be15f26
unused variable
svchb Jan 4, 2024
7886cf9
break
svchb Jan 4, 2024
2a332b9
edit todo
svchb Jan 4, 2024
240f1c8
remove breaks
svchb Jan 4, 2024
0b98a52
format
svchb Jan 4, 2024
2e6fcd7
Merge branch 'main' into mixed-kernel-gradient
svchb Jan 4, 2024
451f3d4
rename grad_kernel to W_a
svchb Jan 5, 2024
1c152c9
Merge branch 'mixed-kernel-gradient' of github.com:svchb/TrixiParticl…
svchb Jan 5, 2024
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
13 changes: 8 additions & 5 deletions examples/fluid/dam_break_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using OrdinaryDiffEq
fluid_particle_spacing = 0.02

# Change spacing ratio to 3 and boundary layers to 1 when using Monaghan-Kajtar boundary model
boundary_layers = 4
boundary_layers = 3
spacing_ratio = 1

boundary_particle_spacing = fluid_particle_spacing / spacing_ratio
Expand All @@ -31,7 +31,8 @@ fluid_density = 1000.0
atmospheric_pressure = 100000.0
sound_speed = 20 * sqrt(gravity * initial_fluid_size[2])
state_equation = StateEquationCole(sound_speed, 7, fluid_density, atmospheric_pressure,
background_pressure=atmospheric_pressure)
background_pressure=atmospheric_pressure,
clip_negative_pressure=false)

tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density,
n_layers=boundary_layers, spacing_ratio=spacing_ratio,
Expand All @@ -45,6 +46,7 @@ smoothing_kernel = WendlandC2Kernel{2}()
fluid_density_calculator = ContinuityDensity()
viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
#density_diffusion = DensityDiffusionAntuono(tank.fluid, delta=0.1)
svchb marked this conversation as resolved.
Show resolved Hide resolved

fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, smoothing_kernel,
Expand All @@ -58,7 +60,8 @@ boundary_density_calculator = AdamiPressureExtrapolation()
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass,
state_equation=state_equation,
boundary_density_calculator,
smoothing_kernel, smoothing_length)
smoothing_kernel, smoothing_length,
correction=nothing)

boundary_system = BoundarySPHSystem(tank.boundary, boundary_model)

Expand All @@ -68,7 +71,7 @@ semi = Semidiscretization(fluid_system, boundary_system,
neighborhood_search=GridNeighborhoodSearch)
ode = semidiscretize(semi, tspan)

info_callback = InfoCallback(interval=100)
info_callback = InfoCallback(interval=250)
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")

use_reinit = false
Expand All @@ -87,5 +90,5 @@ callbacks = CallbackSet(info_callback, saving_callback, density_reinit_cb)
sol = solve(ode, RDPK3SpFSAL49(),
abstol=1e-6, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration)
reltol=1e-5, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration)
dtmax=1e-2, # Limit stepsize to prevent crashing
dtmax=1e-3, # Limit stepsize to prevent crashing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe also be moved to be passed as a kwarg to trixi_include in the corrections example, as it is only needed with corrections and might affect the runtime of the uncorrected example?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its 4% slower with the smaller dtmax.

save_everystep=false, callback=callbacks);
74 changes: 56 additions & 18 deletions examples/fluid/dam_break_2d_corrections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,35 @@ using TrixiParticles
fluid_density = 1000.0

particle_spacing = 0.05
smoothing_length = 1.15 * particle_spacing

boundary_density_calculator = SummationDensity()

gravity = 9.81
tspan = (0.0, 5.7 / sqrt(gravity))
tspan = (0.0, 5.7 / sqrt(9.81))

correction_dict = Dict(
"no_correction" => Nothing(),
"shepard_kernel_correction" => ShepardKernelCorrection(),
"akinci_free_surf_correction" => AkinciFreeSurfaceCorrection(fluid_density),
"kernel_gradient_summation_correction" => KernelGradientCorrection(),
"kernel_gradient_continuity_correction" => KernelGradientCorrection(),
"kernel_gradient_summation_correction" => KernelCorrection(),
"kernel_gradient_continuity_correction" => KernelCorrection(),
"blended_gradient_summation_correction" => BlendedGradientCorrection(0.5),
"blended_gradient_continuity_correction" => BlendedGradientCorrection(0.2),
"gradient_summation_correction" => GradientCorrection(),
"mixed_kernel_gradient_summation_correction" => MixedKernelGradientCorrection(),
# "gradient_continuity_correction" => GradientCorrection(),
# "mixed_kernel_gradient_continuity_correction" => MixedKernelGradientCorrection(),
)

smoothing_length_dict = Dict(
"no_correction" => 3.0 * particle_spacing,
"shepard_kernel_correction" => 3.0 * particle_spacing,
"akinci_free_surf_correction" => 3.0 * particle_spacing,
"kernel_gradient_summation_correction" => 4.0 * particle_spacing,
"kernel_gradient_continuity_correction" => 3.5 * particle_spacing,
"blended_gradient_summation_correction" => 3.0 * particle_spacing,
"blended_gradient_continuity_correction" => 4.0 * particle_spacing,
"gradient_summation_correction" => 3.5 * particle_spacing,
"mixed_kernel_gradient_summation_correction" => 3.5 * particle_spacing,
"gradient_continuity_correction" => 4.5 * particle_spacing,
"mixed_kernel_gradient_continuity_correction" => 4.0 * particle_spacing,
)

density_calculator_dict = Dict(
Expand All @@ -24,33 +40,55 @@ density_calculator_dict = Dict(
"akinci_free_surf_correction" => SummationDensity(),
"kernel_gradient_summation_correction" => SummationDensity(),
"kernel_gradient_continuity_correction" => ContinuityDensity(),
"blended_gradient_summation_correction" => SummationDensity(),
"blended_gradient_continuity_correction" => ContinuityDensity(),
"gradient_summation_correction" => SummationDensity(),
"gradient_continuity_correction" => ContinuityDensity(),
"mixed_kernel_gradient_summation_correction" => SummationDensity(),
"mixed_kernel_gradient_continuity_correction" => ContinuityDensity(),
)

smoothing_kernel_dict = Dict(
"no_correction" => WendlandC2Kernel{2}(),
"shepard_kernel_correction" => WendlandC2Kernel{2}(),
"akinci_free_surf_correction" => WendlandC2Kernel{2}(),
"kernel_gradient_summation_correction" => WendlandC6Kernel{2}(),
"kernel_gradient_continuity_correction" => WendlandC6Kernel{2}(),
"blended_gradient_summation_correction" => WendlandC2Kernel{2}(),
"blended_gradient_continuity_correction" => WendlandC6Kernel{2}(),
"gradient_summation_correction" => WendlandC6Kernel{2}(),
"gradient_continuity_correction" => WendlandC6Kernel{2}(),
"mixed_kernel_gradient_summation_correction" => WendlandC6Kernel{2}(),
"mixed_kernel_gradient_continuity_correction" => WendlandC6Kernel{2}(),
)

trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
fluid_particle_spacing=particle_spacing, smoothing_length=smoothing_length,
fluid_particle_spacing=particle_spacing,
smoothing_length=3.0 * particle_spacing,
boundary_density_calculator=ContinuityDensity(),
fluid_density_calculator=ContinuityDensity(),
correction=Nothing(), use_reinit=true,
prefix="continuity_reinit", tspan=tspan)

# Clip negative pressure to be able to use `SummationDensity`
state_equation = StateEquationCole(sound_speed, 7, fluid_density, atmospheric_pressure,
background_pressure=atmospheric_pressure,
clip_negative_pressure=true)
correction=nothing, use_reinit=true,
prefix="continuity_reinit", tspan=tspan,
fluid_density=fluid_density, density_diffusion=nothing)

for correction_name in keys(correction_dict)
local fluid_density_calculator = density_calculator_dict[correction_name]
local correction = correction_dict[correction_name]
local smoothing_kernel = smoothing_kernel_dict[correction_name]
local smoothing_length = smoothing_length_dict[correction_name]

println("="^100)
println("fluid/dam_break_2d.jl with ", correction_name)

trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
fluid_particle_spacing=particle_spacing,
smoothing_length=smoothing_length,
boundary_density_calculator=boundary_density_calculator,
boundary_density_calculator=SummationDensity(),
fluid_density_calculator=fluid_density_calculator,
correction=correction, use_reinit=false,
state_equation=state_equation,
prefix="$(correction_name)", tspan=tspan)
clip_negative_pressure=(fluid_density_calculator isa SummationDensity),
smoothing_kernel=smoothing_kernel,
prefix="$(correction_name)", tspan=tspan,
fluid_density=fluid_density, density_diffusion=Nothing(),
svchb marked this conversation as resolved.
Show resolved Hide resolved
boundary_layers=5)
end
5 changes: 3 additions & 2 deletions src/TrixiParticles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Reexport: @reexport
using Dates
using DiffEqCallbacks: PeriodicCallback, PeriodicCallbackAffect
using FastPow: @fastpow
using LinearAlgebra: norm, dot, I, tr
using LinearAlgebra: norm, dot, I, tr, inv, pinv, det
using Morton: cartesian2morton
using MuladdMacro: @muladd
using Polyester: Polyester, @batch
Expand Down Expand Up @@ -55,7 +55,8 @@ export examples_dir, trixi_include
export trixi2vtk
export RectangularTank, RectangularShape, SphereShape
export VoxelSphere, RoundSphere, reset_wall!
export ShepardKernelCorrection, KernelGradientCorrection, AkinciFreeSurfaceCorrection
export ShepardKernelCorrection, KernelCorrection, AkinciFreeSurfaceCorrection,
GradientCorrection, BlendedGradientCorrection, MixedKernelGradientCorrection
export nparticles

end # module
Loading
Loading