-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathdam_break_3d.jl
More file actions
91 lines (74 loc) · 4.39 KB
/
dam_break_3d.jl
File metadata and controls
91 lines (74 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# ==========================================================================================
# 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
# ==========================================================================================
# ==== Resolution
fluid_particle_spacing = 0.08
# Change spacing ratio to 3 and boundary layers to 1 when using Monaghan-Kajtar boundary model
boundary_layers = 4
spacing_ratio = 1
boundary_particle_spacing = fluid_particle_spacing / spacing_ratio
# ==========================================================================================
# ==== Experiment Setup
gravity = 9.81
tspan = (0.0, 5.7 / sqrt(gravity))
# Boundary geometry and initial fluid particle positions
initial_fluid_size = (2.0, 1.0, 1.0)
tank_size = (floor(5.366 / boundary_particle_spacing) * boundary_particle_spacing, 4.0, 1.0)
fluid_density = 1000.0
# We use an adaptive state equation to reduce runtime
state_equation = StateEquationAdaptiveCole(; reference_density=fluid_density,
exponent=7)
tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density,
n_layers=boundary_layers, spacing_ratio=spacing_ratio,
acceleration=(0.0, -gravity, 0.0), state_equation=state_equation,
coordinates_eltype=Float64)
# ==========================================================================================
# ==== Fluid
smoothing_length = 1.5 * fluid_particle_spacing
smoothing_kernel = WendlandC2Kernel{3}()
fluid_density_calculator = ContinuityDensity()
viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, smoothing_kernel,
smoothing_length, viscosity=viscosity,
density_diffusion=density_diffusion,
acceleration=(0.0, -gravity, 0.0))
# ==========================================================================================
# ==== Boundary
boundary_density_calculator = AdamiPressureExtrapolation()
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass,
state_equation=state_equation,
boundary_density_calculator,
smoothing_kernel, smoothing_length)
boundary_system = WallBoundarySystem(tank.boundary, boundary_model)
# ==========================================================================================
# ==== Simulation
semi = Semidiscretization(fluid_system, boundary_system,
neighborhood_search=GridNeighborhoodSearch{3}(),
parallelization_backend=PolyesterBackend())
ode = semidiscretize(semi, tspan)
info_callback = InfoCallback(interval=100)
saving_callback = SolutionSavingCallback(dt=0.1, prefix="")
extra_callback = nothing
callbacks = CallbackSet(info_callback, saving_callback, extra_callback)
# Use a Runge-Kutta method with automatic (error based) time step size control.
# Limiting of the maximum stepsize is necessary to prevent crashing.
# When particles are approaching a wall in a uniform way, they can be advanced
# with large time steps. Close to the wall, the stepsize has to be reduced drastically.
# Sometimes, the method fails to do so because forces become extremely large when
# fluid particles are very close to boundary particles, and the time integration method
# interprets this as an instability.
time_integration_scheme = RDPK3SpFSAL35()
sol = solve(ode, time_integration_scheme,
abstol=1e-5, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration)
reltol=1e-4, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration)
dtmax=1e-2, # Limit stepsize to prevent crashing
dt=1.0,
save_everystep=false, callback=callbacks);