Skip to content

Commit 62ac80f

Browse files
efaulhabersvchbLasNikas
authored
Validate against dam break results from De Courcy (#934)
* fix * improve plot * improve plot * change comment * update * update files * format * suppress warnings * update with reference files on 1 thread * format * update files again with new Julia 1.11 release * update error bounds * review comments * format * Validate against dam break results from De Courcy * Fix * Update validation files * Update JSON validation files * Clean up timer output * Update dam break validation files * Explicitly list reference files * Split plot file * Update README and validation files * Remove comment in dam break example file * Add thread pinning comment * Delete old CSV files * Change example tests * Reformat * Fix example file * Fix EDAC validation * Add more validation JSON files * Reset resolution in validation file * Fix viscosity of dam break setups * Shorten dam break validation test in CI * Fix symplectic position verlet tests * Only run validation tests for now * Use x86 files * Update x86 validation files again * Fix tests and add high res files * Re-enable tests * Add last file to plot * Reformat * Fix tests * Ignore warnings * Reformat * Fix GPU tests * Fix comment * Fix GPU tests * Fix GPU tests * Update examples/fluid/dam_break_2d.jl Co-authored-by: Niklas Neher <[email protected]> * Clarify README * Fix comment about no-slip BC --------- Co-authored-by: Sven Berger <[email protected]> Co-authored-by: Niklas Neher <[email protected]>
1 parent 0c554cd commit 62ac80f

36 files changed

+53493
-6403
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ docs/src/news.md
1212
docs/src/tutorials
1313
*_replaced.md
1414
run
15-
*.json
1615
!.zenodo.json
1716
*.png
1817
*.jpg

examples/fluid/dam_break_2d.jl

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ boundary_particle_spacing = fluid_particle_spacing / spacing_ratio
3333
# ==== Experiment Setup
3434
gravity = 9.81
3535

36-
tspan = (0.0, 5.7 / sqrt(gravity))
36+
tspan = (0.0, 5.7 / sqrt(gravity / H))
3737

3838
# Boundary geometry and initial fluid particle positions
3939
initial_fluid_size = (W, H)
@@ -50,29 +50,19 @@ tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fl
5050

5151
# ==========================================================================================
5252
# ==== Fluid
53-
smoothing_length = 1.75 * fluid_particle_spacing
53+
smoothing_length = 2 * fluid_particle_spacing
5454
smoothing_kernel = WendlandC2Kernel{2}()
5555

5656
fluid_density_calculator = ContinuityDensity()
57+
5758
alpha = 0.02
5859
viscosity_fluid = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0)
59-
# A typical formula to convert Artificial viscosity to a
60-
# kinematic viscosity is provided by Monaghan as
61-
# nu = alpha * smoothing_length * sound_speed/8
62-
63-
# Alternatively a kinematic viscosity for water can be set
64-
# nu = 1.0e-6
6560

66-
# This allows the use of a physical viscosity model like:
67-
# viscosity_fluid = ViscosityAdami(nu=nu)
68-
# or with additional dissipation through a Smagorinsky model
69-
# viscosity_fluid = ViscosityAdamiSGS(nu=nu)
70-
# For more details see the documentation "Viscosity model overview".
71-
72-
# Alternatively the density diffusion model by Molteni & Colagrossi can be used,
73-
# which will run faster.
74-
# density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
75-
density_diffusion = DensityDiffusionAntuono(tank.fluid, delta=0.1)
61+
# The density diffusion model by Molteni and Colagrossi shows unphysical effects at the
62+
# free surface in long-running simulations, but is significantly faster than the model
63+
# by Antuono. This simulation is short enough to use the faster model.
64+
density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
65+
# density_diffusion = DensityDiffusionAntuono(tank.fluid, delta=0.1)
7666

7767
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
7868
state_equation, smoothing_kernel,
@@ -86,9 +76,8 @@ fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
8676
# ==== Boundary
8777
boundary_density_calculator = AdamiPressureExtrapolation()
8878
viscosity_wall = nothing
89-
# For a no-slip condition the corresponding wall viscosity without SGS can be set
90-
# viscosity_wall = ViscosityAdami(nu=nu)
91-
# viscosity_wall = ViscosityMorris(nu=nu)
79+
# For a no-slip boundary condition, define a wall viscosity:
80+
# viscosity_wall = viscosity_fluid
9281
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass,
9382
state_equation=state_equation,
9483
boundary_density_calculator,
@@ -114,15 +103,9 @@ info_callback = InfoCallback(interval=100)
114103
solution_prefix = ""
115104
saving_callback = SolutionSavingCallback(dt=0.02, prefix=solution_prefix)
116105

117-
# Save at certain timepoints which allows comparison to the results of Marrone et al.,
118-
# i.e. (1.5, 2.36, 3.0, 5.7, 6.45).
119-
# Please note that the images in Marrone et al. are obtained at a particle_spacing = H/320,
120-
# which takes between 2 and 4 hours.
121-
saving_paper = SolutionSavingCallback(save_times=[0.0, 0.371, 0.584, 0.743, 1.411, 1.597],
122-
prefix="marrone_times")
123-
124106
# This can be overwritten with `trixi_include`
125107
extra_callback = nothing
108+
extra_callback2 = nothing
126109

127110
use_reinit = false
128111
density_reinit_cb = use_reinit ?
@@ -131,7 +114,7 @@ density_reinit_cb = use_reinit ?
131114
stepsize_callback = StepsizeCallback(cfl=0.9)
132115

133116
callbacks = CallbackSet(info_callback, saving_callback, stepsize_callback, extra_callback,
134-
density_reinit_cb, saving_paper)
117+
extra_callback2, density_reinit_cb)
135118

136119
time_integration_scheme = CarpenterKennedy2N54(williamson_condition=false)
137120
sol = solve(ode, time_integration_scheme,

examples/fluid/dam_break_2d_gpu.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ trixi_include(@__MODULE__,
3636
joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
3737
neighborhood_search=neighborhood_search,
3838
fluid_particle_spacing=fluid_particle_spacing,
39-
tspan=tspan,
39+
tspan=tspan, smoothing_length=smoothing_length,
4040
density_diffusion=density_diffusion,
4141
boundary_layers=boundary_layers, spacing_ratio=spacing_ratio,
4242
boundary_model=boundary_model,

src/TrixiParticles.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using Adapt: Adapt
66
using Base: @propagate_inbounds
77
using CSV: CSV
88
using Dates
9-
using DataFrames: DataFrame
9+
using DataFrames: DataFrames, DataFrame
1010
using DelimitedFiles: DelimitedFiles
1111
using DiffEqCallbacks: PeriodicCallback, PeriodicCallbackAffect, PresetTimeCallback
1212
using FastPow: @fastpow

src/callbacks/post_process.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ function (pp::PostprocessCallback)(integrator; from_initialize=false)
238238
# comes AFTER the `PostprocessCallback` in the `CallbackSet`.
239239
dv_ode, du_ode = zero(vu_ode).x
240240
else
241-
dv_ode, du_ode = get_du(integrator).x
241+
# Depending on the time integration scheme, this might call the RHS function
242+
@trixi_timeit timer() "update du" begin
243+
# Don't create sub-timers here to avoid cluttering the timer output
244+
@notimeit timer() dv_ode, du_ode = get_du(integrator).x
245+
end
242246
end
243247
v_ode, u_ode = vu_ode.x
244248
semi = integrator.p

test/examples/examples_fluid.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@
589589
@trixi_test_nowarn trixi_include(@__MODULE__,
590590
joinpath(examples_dir(), "fluid",
591591
"dam_break_2d.jl"),
592-
tspan=(0, 0.1), sol=nothing) [
592+
tspan=(0, 0.3), sol=nothing) [
593593
r"┌ Info: The desired tank length in y-direction .*\n",
594594
r"└ New tank length in y-direction.*\n"]
595595

@@ -607,7 +607,7 @@
607607
@trixi_test_nowarn trixi_include(@__MODULE__,
608608
joinpath(examples_dir(), "fluid",
609609
"dam_break_2d.jl"),
610-
tspan=(0, 0.1), sol=nothing,
610+
tspan=(0, 0.3), sol=nothing,
611611
cfl=0.25) [
612612
r"┌ Info: The desired tank length in y-direction .*\n",
613613
r"└ New tank length in y-direction.*\n"]

test/examples/gpu.jl

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -505,19 +505,19 @@ end
505505
cut_off_bnd=false)
506506

507507
@test isapprox(Array(result.computed_density),
508-
Float32[500.33255, 893.09766, 997.7032, 1001.14355, 1001.234,
509-
1001.0098, 1000.4352, 999.7572, 999.1139, 989.6319])
508+
Float32[500.96387, 859.06744, 989.0479, 1001.3735,
509+
1001.30927, 1001.0831, 1000.7325, 1000.3575,
510+
999.8011, 975.98553])
510511

511512
@test isapprox(Array(result.density),
512-
Float32[1002.3152, 1002.19653, 1001.99915, 1001.7685,
513-
1001.5382,
514-
1001.3093, 1001.0836, 1000.8649, 1000.635,
515-
1000.4053])
513+
Float32[1002.1891, 1002.0748, 1001.8913, 1001.67126,
514+
1001.4529, 1001.2382, 1001.0298, 1000.81964,
515+
1000.594, 1000.3878])
516516

517517
@test isapprox(Array(result.pressure),
518-
Float32[5450.902, 5171.2856, 4706.551, 4163.9185, 3621.5042,
519-
3082.6948, 2551.5725, 2036.1208, 1494.8608,
520-
954.14355])
518+
Float32[5154.1177, 4885.1, 4452.6533, 3934.9075, 3420.5737,
519+
2915.0933, 2424.0908, 1929.7888, 1398.8309,
520+
913.2089])
521521
end
522522

523523
@testset verbose=true "Plane" begin
@@ -527,22 +527,19 @@ end
527527

528528
result = interpolate_plane_2d(interpolation_start, interpolation_end,
529529
resolution, semi_new, semi_new.systems[1],
530-
sol;
531-
cut_off_bnd=false)
530+
sol; cut_off_bnd=false)
532531

533532
@test isapprox(Array(result.computed_density),
534-
Float32[250.18625, 500.34482, 499.77225, 254.3632, 499.58026,
535-
999.1413, 998.6351, 503.0122])
533+
Float32[250.47523, 500.98248, 500.49924, 253.77109,
534+
500.0491, 1000.0818, 999.6527, 503.08704])
536535

537536
@test isapprox(Array(result.density),
538-
Float32[1002.34467, 1002.3365, 1001.5021, 999.7109,
539-
1000.84863,
540-
1000.8373, 1000.3423, 1000.20734])
537+
Float32[1002.2373, 1002.22516, 1001.4339, 999.3567,
538+
1000.8318, 1000.80237, 1000.3408, 999.92017])
541539

542540
@test isapprox(Array(result.pressure),
543-
Float32[5520.0513, 5501.1846, 3536.2256, -680.5194,
544-
1997.7814,
545-
1971.0717, 805.8584, 488.4068])
541+
Float32[5267.867, 5239.2466, 3376.045, -1514.4237,
542+
1958.2637, 1888.739, 802.3146, -187.81871])
546543
end
547544
end
548545
end

test/validation/validation.jl

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,66 @@
3838
end
3939

4040
@trixi_testset "dam_break_2d" begin
41+
# Use `SerialUpdate()` to obtain consistent results when using multiple
42+
# threads and a shorter tspan to speed up CI tests.
4143
@trixi_test_nowarn trixi_include(@__MODULE__,
4244
joinpath(validation_dir(), "dam_break_2d",
43-
"validation_dam_break_2d.jl")) [
45+
"validation_dam_break_2d.jl"),
46+
update_strategy=SerialUpdate(),
47+
tspan=(0.0, 4 / sqrt(9.81 / 0.6))) [
4448
r"┌ Info: The desired tank length in y-direction.*\n",
45-
r"└ New tank length in y-direction is set to.*\n"
49+
r"└ New tank length in y-direction is set to.*\n",
50+
r"WARNING: Method definition max_x_coord.*\n",
51+
r"WARNING: Method definition interpolated_pressure.*\n"
4652
]
4753
@test sol.retcode == ReturnCode.Success
4854
@test count_rhs_allocations(sol, semi) == 0
4955

5056
if Sys.ARCH === :aarch64
5157
# MacOS ARM produces slightly different pressure values than x86.
5258
# Note that pressure values are in the order of 1e5.
53-
@test isapprox(error_edac_P1, 0, atol=5e-6)
54-
@test isapprox(error_edac_P2, 0, atol=4e-11)
55-
@test isapprox(error_wcsph_P1, 0, atol=400.0)
56-
@test isapprox(error_wcsph_P2, 0, atol=0.03)
59+
@test isapprox(error_edac_P1, 0, atol=eps(1e5))
60+
@test isapprox(error_edac_P2, 0, atol=eps(1e5))
61+
@test isapprox(error_wcsph_P1, 0, atol=eps(1e5))
62+
@test isapprox(error_wcsph_P2, 0, atol=eps(1e5))
5763
elseif VERSION < v"1.11"
58-
# 1.10 produces slightly different pressure values than 1.11.
59-
# This is most likely due to muladd and FMA instructions in the
60-
# density diffusion update (inside the StaticArrays matrix-vector product).
61-
# Note that pressure values are in the order of 1e5.
62-
@test isapprox(error_edac_P1, 0, atol=eps())
63-
@test isapprox(error_edac_P2, 0, atol=eps())
64-
@test isapprox(error_wcsph_P1, 0, atol=8.0)
65-
@test isapprox(error_wcsph_P2, 0, atol=5e-4)
64+
# 1.10 produces slightly different pressure values than 1.11
65+
@test isapprox(error_edac_P1, 0, atol=eps(1e5))
66+
@test isapprox(error_edac_P2, 0, atol=eps(1e5))
67+
@test isapprox(error_wcsph_P1, 0, atol=eps(1e5))
68+
@test isapprox(error_wcsph_P2, 0, atol=eps(1e5))
6669
else
67-
# Reference values are computed with 1.11
68-
@test isapprox(error_edac_P1, 0, atol=5e-7)
69-
@test isapprox(error_edac_P2, 0, atol=4e-11)
70+
# Reference values are computed with 1.11 on x86
7071
@test isapprox(error_wcsph_P1, 0, atol=eps())
7172
@test isapprox(error_wcsph_P2, 0, atol=eps())
73+
# Why are these errors not zero?
74+
@test isapprox(error_edac_P1, 0, atol=eps(1e5))
75+
@test isapprox(error_edac_P2, 0, atol=eps(1e5))
7276
end
7377

7478
# Ignore method redefinitions from duplicate `include("../validation_util.jl")`
7579
@trixi_test_nowarn trixi_include(@__MODULE__,
7680
joinpath(validation_dir(), "dam_break_2d",
77-
"plot_dam_break_results.jl")) [
81+
"plot_pressure_sensors.jl")) [
7882
r"WARNING: Method definition linear_interpolation.*\n",
7983
r"WARNING: Method definition interpolated_mse.*\n",
80-
r"WARNING: Method definition extract_number_from_filename.*\n",
81-
r"WARNING: Method definition extract_resolution_from_filename.*\n"
84+
r"WARNING: Method definition extract_number_from_filename.*\n"
85+
]
86+
# Verify number of plots
87+
@test length(axs_edac[1].scene.plots) >= 2
88+
@test length(axs_wcsph[1].scene.plots) >= 2
89+
90+
# Ignore method redefinitions from duplicate `include("../validation_util.jl")`
91+
@trixi_test_nowarn trixi_include(@__MODULE__,
92+
joinpath(validation_dir(), "dam_break_2d",
93+
"plot_surge_front.jl")) [
94+
r"WARNING: Method definition linear_interpolation.*\n",
95+
r"WARNING: Method definition interpolated_mse.*\n",
96+
r"WARNING: Method definition extract_number_from_filename.*\n"
8297
]
8398
# Verify number of plots
8499
@test length(axs_edac[1].scene.plots) >= 2
100+
@test length(axs_wcsph[1].scene.plots) >= 2
85101
end
86102

87103
@trixi_testset "TGV_2D" begin

validation/dam_break_2d/README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
1+
The files in this folder provide a 2D dam break validation case for TrixiParticles.jl
2+
based on the following references:
3+
1. J. J. De Courcy, T. C. S. Rendall, L. Constantin, B. Titurus, J. E. Cooper.
4+
"Incompressible δ-SPH via artificial compressibility".
5+
In: Computer Methods in Applied Mechanics and Engineering, Volume 420 (2024),
6+
https://doi.org/10.1016/j.cma.2023.116700
7+
2. S. Marrone, M. Antuono, A. Colagrossi, G. Colicchio, D. le Touzé, G. Graziani.
8+
"δ-SPH model for simulating violent impact flows".
9+
In: Computer Methods in Applied Mechanics and Engineering, Volume 200, Issues 13–16 (2011), pages 1526–1542.
10+
https://doi.org/10.1016/J.CMA.2010.12.016
11+
3. J. C. Martin, W. J. Moyce, William George Penney, A. T. Price, C. K. Thornhill.
12+
"Part IV. An experimental study of the collapse of liquid columns on a rigid horizontal plane", Phil. Tran. R. Soc. London, Volume 244, Issue 882 (1952).
13+
https://doi.org/10.1098/rsta.1952.0006
14+
115
The following files are provided here:
216

3-
1) Validation simulation: validation_dam_break_2d.jl
4-
2) Comparison with TrixiParticles.jl and literature reference: plot_dam_break_results.jl
5-
3) TrixiParticles.jl reference files: validation_reference_[0015, 00075, 0001875].j (0025 is the default CI resolution. Note that resolution 0015 takes around 2-5 minutes, 00075 around 5-10 minutes, 0001875 around 2-4 hours).
6-
4) exp_surge_front.csv was manually extracted from Martin and Moyce, "Part IV. An experimental study of the collapse of liquid columns on a rigid horizontal plane", Phil. Tran. R. Soc. London, 1952, doi: https://doi.org/10.1098/rsta.1952.0006
7-
5) exp_pressure_sensor_P*.csv was manually extracted from B. Buchner, "Green Water on Ship-type Offshore Structures", Ph.D. Thesis, Delft University of Technology, 2002.
8-
6) sim_pressure_sensor_P*.csv was manually extracted from S. Marrone et al., "δ-SPH model for simulating violent impact flows", Computer Methods in Applied Mechanics and Engineering, 2011, doi: https://doi.org/10.1016/j.cma.2010.12.016
17+
1. `setup_marrone_2011.jl`: Setup file for the dam break simulation based on Marrone et al. (2011).
18+
This can be used to reproduce the images of the breaking wave in Marrone et al. (2011).
19+
2. `validation_dam_break_2d.jl`: Script to run the dam break simulation
20+
based on De Courcy et al. (2024) and extract pressure sensor data.
21+
**Note**: This paper used particle shifting, which is not yet implemented
22+
in TrixiParticles.jl for free surface simulations.
23+
3. `plot_pressure_sensors.jl`: Script to plot the pressure sensor data and compare with
24+
De Courcy et al. (2024). This script can plot both the reference data included
25+
in this folder and simulation results from the `out` folder (if available).
26+
4. `plot_surge_front.jl`: Script to plot the surge front position and compare with
27+
Martin et al. (1952). This script can plot both the reference data included
28+
in this folder and simulation results from the `out` folder (if available).
29+
30+
Note that the reference files for resolutions 40 and 80 were obtained with `SerialUpdate()`
31+
and `--check-bounds=yes` on an x86 CPU.
32+
The reference file for resolution 400 was obtained with `update_strategy=nothing`
33+
and `--check-bounds=auto`, also on an x86 CPU.

0 commit comments

Comments
 (0)