Skip to content

Commit f858ff4

Browse files
committed
Changes from the latest PR
1 parent 269f2be commit f858ff4

File tree

13 files changed

+69
-260
lines changed

13 files changed

+69
-260
lines changed

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Asciicast = "2600d445-abca-43b9-92aa-ce144ac0b05b"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
5-
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
65
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
76

87
[compat]

examples/fluid/dam_break_2d.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ stepsize_callback = StepsizeCallback(cfl=0.9)
108108

109109
callbacks = CallbackSet(info_callback, saving_callback, stepsize_callback, extra_callback,
110110
density_reinit_cb, saving_paper)
111-
112-
sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false),
111+
solver_function = CarpenterKennedy2N54(williamson_condition=false)
112+
sol = solve(ode, solver_function,
113113
dt=1.0, # This is overwritten by the stepsize callback
114114
save_everystep=false, callback=callbacks);
Lines changed: 30 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,36 @@
1-
# 2D dam break simulation based on
2-
#
3-
# S. Marrone, M. Antuono, A. Colagrossi, G. Colicchio, D. le Touzé, G. Graziani.
4-
# "δ-SPH model for simulating violent impact flows".
5-
# In: Computer Methods in Applied Mechanics and Engineering, Volume 200, Issues 13–16 (2011), pages 1526–1542.
6-
# https://doi.org/10.1016/J.CMA.2010.12.016
7-
1+
# 2D dam break simulation using an ImplicitIncompressible SPH system
82
using TrixiParticles
9-
using OrdinaryDiffEq
10-
11-
# Size parameters
12-
H = 0.8
13-
W = 2 * H
14-
15-
# ==========================================================================================
16-
# ==== Resolution
17-
fluid_particle_spacing = H / 40
18-
19-
# Change spacing ratio to 3 and boundary layers to 1 when using Monaghan-Kajtar boundary model
20-
boundary_layers = 4
21-
spacing_ratio = 1
22-
23-
boundary_particle_spacing = fluid_particle_spacing / spacing_ratio
24-
25-
# ==========================================================================================
26-
# ==== Experiment Setup
27-
gravity = 9.81
283

29-
tspan = (0.0, 5.7 / sqrt(gravity))
4+
# Load setup from dam break example
5+
trixi_include(@__MODULE__,
6+
joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
7+
sol=nothing, ode=nothing)
308

31-
# Boundary geometry and initial fluid particle positions
32-
initial_fluid_size = (W, H)
33-
tank_size = (floor(5.366 * H / boundary_particle_spacing) * boundary_particle_spacing, 3.0)
9+
# Change smoohing kernel and length
10+
smoothing_length = 1.25 * fluid_particle_spacing
11+
smoothing_kernel = GaussianKernel{2}()
3412

35-
fluid_density = 1000.0
36-
sound_speed = 20 * sqrt(gravity * H)
37-
38-
tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density,
39-
n_layers=boundary_layers, spacing_ratio=spacing_ratio)
40-
#acceleration=(0.0, -gravity))
41-
42-
# ==========================================================================================
43-
# ==== Fluid
44-
smoothing_length = 2.1 * fluid_particle_spacing
45-
smoothing_kernel = WendlandC6Kernel{2}()
46-
47-
# viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
13+
# Calculate nu for the viscosity model
4814
nu = 0.02 * smoothing_length * sound_speed/8
49-
# viscosity = ViscosityMorris(nu=nu)
50-
viscosity = ViscosityAdami(nu=nu)
51-
# Alternatively the density diffusion model by Molteni & Colagrossi can be used,
52-
# which will run faster.
53-
# density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
54-
# density_diffusion = DensityDiffusionAntuono(tank.fluid, delta=0.1)
55-
time_step=0.001
56-
fluid_system = ImplicitIncompressibleSPHSystem(tank.fluid, smoothing_kernel,
57-
smoothing_length, fluid_density,
58-
viscosity=viscosity,
59-
acceleration=(0.0, -gravity), omega=0.5,
60-
min_iterations=5, max_iterations=30,
61-
time_step=time_step)
62-
63-
# ==========================================================================================
64-
# ==== Boundary
65-
boundary_density_calculator = PressureMirroring()
66-
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass,
67-
state_equation=nothing,
68-
boundary_density_calculator,
69-
smoothing_kernel, smoothing_length)
7015

71-
boundary_system = BoundarySPHSystem(tank.boundary, boundary_model)
72-
73-
# ==========================================================================================
74-
# ==== Simulation
75-
# `nothing` will automatically choose the best update strategy. This is only to be able
76-
# to change this with `trixi_include`.
77-
# semi = Semidiscretization(fluid_system, boundary_system,
78-
# neighborhood_search=GridNeighborhoodSearch{2}(update_strategy=nothing),
79-
# parallelization_backend=PolyesterBackend())
80-
semi = Semidiscretization(fluid_system, boundary_system)
81-
ode = semidiscretize(semi, tspan)
82-
#=
83-
info_callback = InfoCallback(interval=100)
84-
85-
solution_prefix = ""
86-
saving_callback = SolutionSavingCallback(dt=0.02, prefix=solution_prefix)
87-
88-
# Save at certain timepoints which allows comparison to the results of Marrone et al.,
89-
# i.e. (1.5, 2.36, 3.0, 5.7, 6.45).
90-
# Please note that the images in Marrone et al. are obtained at a particle_spacing = H/320,
91-
# which takes between 2 and 4 hours.
92-
saving_paper = SolutionSavingCallback(save_times=[0.0, 0.371, 0.584, 0.743, 1.411, 1.597],
93-
prefix="marrone_times")
94-
95-
# This can be overwritten with `trixi_include`
96-
extra_callback = nothing
97-
98-
use_reinit = false
99-
density_reinit_cb = use_reinit ?
100-
DensityReinitializationCallback(semi.systems[1], interval=10) :
101-
nothing
102-
stepsize_callback = StepsizeCallback(cfl=0.9)
103-
104-
callbacks = CallbackSet(info_callback, saving_callback, stepsize_callback, extra_callback,
105-
density_reinit_cb, saving_paper)
106-
107-
sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false),
108-
dt=1.0, # This is overwritten by the stepsize callback
109-
save_everystep=false, callback=callbacks);
110-
=#
111-
info_callback = InfoCallback(interval=100)
112-
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")
113-
114-
callbacks = CallbackSet(info_callback, saving_callback)
115-
116-
sol = solve(ode, SymplecticEuler(),
117-
dt=time_step,
118-
save_everystep=false, callback=callbacks);
119-
120-
plot(sol)
16+
# Use IISPH as fluid system
17+
time_step=0.001
18+
min_iterations=10
19+
max_iterations=30
20+
IISPH_system = ImplicitIncompressibleSPHSystem(tank.fluid, smoothing_kernel,
21+
smoothing_length, fluid_density,
22+
viscosity=ViscosityAdami(nu=nu),
23+
acceleration=(0.0, -gravity),
24+
min_iterations=min_iterations,
25+
max_iterations=max_iterations,
26+
time_step=time_step)
27+
28+
# Run the dam break simulation with these changes
29+
trixi_include(@__MODULE__,
30+
joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
31+
viscosity=ViscosityAdami(nu=nu),
32+
fluid_system=IISPH_system,
33+
boundary_density_calculator=PressureZeroing(),
34+
state_equation=nothing,
35+
callbacks=CallbackSet(info_callback, saving_callback),
36+
solver_function=SymplecticEuler(), dt=time_step)

examples/fluid/falling_water_column_2d.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spacing_ratio = 1
1212
# ==========================================================================================
1313
# ==== Experiment Setup
1414
gravity = 9.81
15-
tspan = (0.0, 0.4)
15+
tspan = (0.0, 2.0)
1616

1717
# Boundary geometry and initial fluid particle positions
1818
initial_fluid_size = (0.5, 1.0)
@@ -76,5 +76,3 @@ sol = solve(ode, RDPK3SpFSAL35(),
7676
reltol=1e-3, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration)
7777
dtmax=1e-2, # Limit stepsize to prevent crashing
7878
save_everystep=false, callback=callbacks);
79-
80-
plot(sol)

examples/fluid/falling_water_column_2d_IISPH.jl

Lines changed: 0 additions & 74 deletions
This file was deleted.

examples/fluid/falling_water_spheres_2d.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ spacing_ratio = 1
1313
# ==========================================================================================
1414
# ==== Experiment Setup
1515
gravity = 9.81
16-
tspan = (0.0, 0.03)
16+
tspan = (0.0, 0.3)
1717

1818
# Boundary geometry and initial fluid particle positions
1919
initial_fluid_size = (0.0, 0.0)
@@ -97,5 +97,3 @@ sol = solve(ode, RDPK3SpFSAL35(),
9797
abstol=1e-7, # Default abstol is 1e-6
9898
reltol=1e-4, # Default reltol is 1e-3
9999
save_everystep=false, callback=callbacks);
100-
101-
plot(sol)

src/general/interpolation.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ function interpolate_plane_2d(min_corner, max_corner, resolution, semi, ref_syst
5959
filter_no_neighbors = true
6060
v_ode, u_ode = sol.u[end].x
6161

62-
results, _,
63-
_ = interpolate_plane_2d(min_corner, max_corner, resolution,
64-
semi, ref_system, v_ode, u_ode,
65-
filter_no_neighbors, smoothing_length, cut_off_bnd,
66-
clip_negative_pressure)
6762
results, _,
6863
_ = interpolate_plane_2d(min_corner, max_corner, resolution,
6964
semi, ref_system, v_ode, u_ode,

src/general/semidiscretization.jl

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,11 @@ function update_systems_and_nhs(v_ode, u_ode, semi, t; update_from_callback=fals
488488
v = wrap_v(v_ode, system, semi)
489489
u = wrap_u(u_ode, system, semi)
490490

491-
@trixi_timeit timer() "update positions" update_positions!(system, v, u, v_ode,
492-
u_ode, semi, t)
491+
update_positions!(system, v, u, v_ode, u_ode, semi, t)
493492
end
494493

495494
# Update NHS
496-
@trixi_timeit timer() "update nhs" update_nhs!(semi, u_ode)
495+
update_nhs!(semi, u_ode)
497496

498497
# Second update step.
499498
# This is used to calculate density and pressure of the fluid systems
@@ -503,8 +502,7 @@ function update_systems_and_nhs(v_ode, u_ode, semi, t; update_from_callback=fals
503502
v = wrap_v(v_ode, system, semi)
504503
u = wrap_u(u_ode, system, semi)
505504

506-
@trixi_timeit timer() "update quantities" update_quantities!(system, v, u, v_ode,
507-
u_ode, semi, t)
505+
update_quantities!(system, v, u, v_ode, u_ode, semi, t)
508506
end
509507

510508
# Perform correction and pressure calculation
@@ -520,8 +518,8 @@ function update_systems_and_nhs(v_ode, u_ode, semi, t; update_from_callback=fals
520518
v = wrap_v(v_ode, system, semi)
521519
u = wrap_u(u_ode, system, semi)
522520

523-
@trixi_timeit timer() "update final" update_final!(system, v, u, v_ode, u_ode, semi,
524-
t; update_from_callback)
521+
update_final!(system, v, u, v_ode, u_ode, semi,
522+
t; update_from_callback)
525523
end
526524
end
527525

@@ -917,22 +915,9 @@ function check_configuration(system::TotalLagrangianSPHSystem, systems)
917915
end
918916

919917
function check_configuration(fluid_system::ImplicitIncompressibleSPHSystem, systems)
920-
(; min_iterations) = fluid_system
921-
(; max_iterations) = fluid_system
922-
923-
if (min_iterations < 1)
924-
throw(ArgumentError("'min_iterations' must be a positive number,
925-
otherwise `ImplicitIncompressibleSPHSystem` can not be used"))
926-
end
927-
928-
if (max_iterations < min_iterations)
929-
throw(ArgumentError("`ImplicitIncompressibleSPHSystem` cannot be used if
930-
'min_iterations' is 'larger than 'max_iterations' "))
931-
end
932-
933918
foreach_system(systems) do neighbor
934919
if neighbor isa WeaklyCompressibleSPHSystem
935-
throw(ArgumentError("`ImplicitIncompressibleSPHSystem` cannot be used with
920+
throw(ArgumentError("`ImplicitIncompressibleSPHSystem` cannot be used together with
936921
`WeaklyCompressibleSPHSystem`"))
937922
end
938923
end

src/io/write_vtk.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,8 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true)
319319
vtk["viscosity"] = type2string(system.viscosity)
320320
write2vtk!(vtk, system.viscosity)
321321
vtk["smoothing_kernel"] = type2string(system.smoothing_kernel)
322-
if !(system isa ImplicitIncompressibleSPHSystem)
323-
vtk["smoothing_length_factor"] = system.cache.smoothing_length_factor
324-
vtk["density_calculator"] = type2string(system.density_calculator)
325-
end
322+
vtk["smoothing_length_factor"] = system.cache.smoothing_length_factor
323+
vtk["density_calculator"] = type2string(system.density_calculator)
326324
if system isa WeaklyCompressibleSPHSystem
327325
vtk["solver"] = "WCSPH"
328326

@@ -345,7 +343,7 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true)
345343
vtk["state_equation_c"] = system.state_equation.sound_speed
346344
vtk["solver"] = "WCSPH"
347345
elseif system isa ImplicitIncompressibleSPHSystem
348-
vtk["solver"] = "EDAC" #TODO
346+
vtk["solver"] = "IISPH"
349347
else
350348
vtk["solver"] = "EDAC"
351349
vtk["sound_speed"] = system.sound_speed

0 commit comments

Comments
 (0)