Skip to content

Fix Validation Setups #801

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 31 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ba238d2
fix
svchb May 13, 2025
c86401b
Merge branch 'main' into fix_validation
svchb May 13, 2025
d308c72
format
svchb May 13, 2025
9bea7f2
suppress warnings
svchb May 14, 2025
4a0969e
update
svchb May 14, 2025
07ba242
Merge branch 'main' into fix_validation
svchb May 14, 2025
b8db99e
Merge branch 'main' into fix_validation
svchb May 16, 2025
08a4b8d
Merge branch 'main' into fix_validation
LasNikas May 19, 2025
8914329
review
svchb May 19, 2025
145a5e1
revert
svchb May 19, 2025
84de051
Update validation_taylor_green_vortex_2d.jl
svchb May 21, 2025
f672f78
Merge branch 'main' into fix_validation
svchb May 21, 2025
8db29c1
Update validation_taylor_green_vortex_2d.jl
svchb May 21, 2025
a083889
add LDC to test
svchb May 21, 2025
944232b
update
svchb May 22, 2025
195624d
Merge branch 'trixi-framework:main' into fix_validation
svchb May 22, 2025
2f0290b
format
svchb May 22, 2025
adaff1a
Merge branch 'fix_validation' of github.com:svchb/TrixiParticles.jlOp…
svchb May 22, 2025
c36ddb7
fix test
svchb May 22, 2025
0666b5c
Merge branch 'main' into fix_validation
svchb May 22, 2025
134fde1
fix test
svchb May 22, 2025
874306f
Merge branch 'fix_validation' of github.com:svchb/TrixiParticles.jlOp…
svchb May 22, 2025
5462f46
fix test
svchb May 23, 2025
85ecb29
format
svchb May 23, 2025
4d929aa
suppress warnings
svchb May 23, 2025
8a92279
Update validation_lid_driven_cavity_2d.jl
svchb May 23, 2025
c19d8bc
implement suggestions
svchb May 23, 2025
b1a1cfe
missing rename
svchb May 26, 2025
e4dc7c9
Merge branch 'main' into fix_validation
svchb May 26, 2025
35cdff6
weird autocompletion from vscode...
svchb May 26, 2025
fb689b3
Merge branch 'main' into fix_validation
svchb May 26, 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
29 changes: 29 additions & 0 deletions test/validation/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,33 @@
# Verify number of plots
@test length(axs_edac[1].scene.plots) >= 2
end

@trixi_testset "TGV_2D" begin
@trixi_test_nowarn trixi_include(@__MODULE__,
joinpath(validation_dir(),
"taylor_green_vortex_2d",
"validation_taylor_green_vortex_2d.jl"),
tspan=(0.0, 0.01)) [
r"WARNING: Method definition pressure_function.*\n",
r"WARNING: Method definition initial_pressure_function.*\n",
r"WARNING: Method definition velocity_function.*\n",
r"WARNING: Method definition initial_velocity_function.*\n"
]
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end

@trixi_testset "LDC_2D" begin
@trixi_test_nowarn trixi_include(@__MODULE__,
joinpath(validation_dir(),
"lid_driven_cavity_2d",
"validation_lid_driven_cavity_2d.jl"),
tspan=(0.0, 0.02), dt=0.01,
SENSOR_CAPTURE_TIME=0.01) [
r"WARNING: Method definition lid_movement_function.*\n",
r"WARNING: Method definition is_moving.*\n"
]
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0
end
end
20 changes: 13 additions & 7 deletions validation/lid_driven_cavity_2d/validation_lid_driven_cavity_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ using TrixiParticles

# ==========================================================================================
# ==== Resolution
particle_spacings = [0.02, 0.01, 0.005]
# The paper provides reference data for particle spacings particle_spacings = [0.02, 0.01, 0.005]
particle_spacing = 0.02

# ==========================================================================================
# ==== Experiment Setup
tspan = (0.0, 25.0)
reynolds_numbers = [100.0, 1000.0, 10_000.0]

interpolated_velocity(v, u, t, system) = nothing
const SENSOR_CAPTURE_TIME = 24.8
const CAPTURE_STARTED = Ref(false)

function interpolated_velocity(v, u, t, system::TrixiParticles.FluidSystem)
if t < 24.8
interpolated_velocity(system, v, u, semi, t) = nothing

function interpolated_velocity(system::TrixiParticles.FluidSystem, v, u, semi, t)
if t < SENSOR_CAPTURE_TIME
return nothing
end

Expand All @@ -32,7 +36,7 @@ function interpolated_velocity(v, u, t, system::TrixiParticles.FluidSystem)

file = joinpath(output_directory, "interpolated_velocities.csv")

if isfile(file)
if CAPTURE_STARTED[]
data = TrixiParticles.CSV.read(file, TrixiParticles.DataFrame)
vy_y_ = (data.vy_y .+ vy_y)
vy_x_ = (data.vy_x .+ vy_x)
Expand All @@ -50,12 +54,13 @@ function interpolated_velocity(v, u, t, system::TrixiParticles.FluidSystem)
counter=1, vy_y=vy_y, vy_x=vy_x, vx_y=vx_y, vx_x=vx_x)

TrixiParticles.CSV.write(output_directory * "/interpolated_velocities.csv", df)
CAPTURE_STARTED[] = true
end

return nothing
end

for particle_spacing in particle_spacings, reynolds_number in reynolds_numbers,
for reynolds_number in reynolds_numbers,
density_calculator in [SummationDensity(), ContinuityDensity()], wcsph in [false, true]
n_particles_xy = round(Int, 1.0 / particle_spacing)

Expand All @@ -68,8 +73,9 @@ for particle_spacing in particle_spacings, reynolds_number in reynolds_numbers,
name_density_calculator,
"validation_run_lid_driven_cavity_2d_nparticles_$(n_particles_xy)x$(n_particles_xy)_Re_$Re")

saving_callback = SolutionSavingCallback(dt=0.1, output_directory=output_directory)
saving_callback = SolutionSavingCallback(dt=0.02, output_directory=output_directory)

CAPTURE_STARTED[] = false
pp_callback = PostprocessCallback(; dt=0.02,
interpolated_velocity=interpolated_velocity,
filename="interpolated_velocities",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ using TrixiParticles

# ==========================================================================================
# ==== Resolution
particle_spacings = [0.02, 0.01, 0.005]
# The paper provides reference data for particle spacings particle_spacings = [0.02, 0.01, 0.005]
particle_spacing = 0.02

# ==========================================================================================
# ==== Experiment Setup
Expand All @@ -12,10 +13,13 @@ reynolds_number = 100.0
density_calculators = [ContinuityDensity(), SummationDensity()]
perturb_coordinates = [false, true]

function compute_l1v_error(v, u, t, system)
function compute_l1v_error(system, v_ode, u_ode, semi, t)
v_analytical_avg = 0.0
v_avg = 0.0

v = TrixiParticles.wrap_v(v_ode, system, semi)
u = TrixiParticles.wrap_u(u_ode, system, semi)

for particle in TrixiParticles.eachparticle(system)
position = TrixiParticles.current_coords(u, system, particle)

Expand All @@ -32,11 +36,14 @@ function compute_l1v_error(v, u, t, system)
return v_avg /= v_analytical_avg
end

function compute_l1p_error(v, u, t, system)
function compute_l1p_error(system, v_ode, u_ode, semi, t)
p_max_exact = 0.0

L1p = 0.0

v = TrixiParticles.wrap_v(v_ode, system, semi)
u = TrixiParticles.wrap_u(u_ode, system, semi)

for particle in TrixiParticles.eachparticle(system)
position = TrixiParticles.current_coords(u, system, particle)

Expand All @@ -57,14 +64,14 @@ end

# The pressure plotted in the paper is the difference of the local pressure minus
# the average of the pressure of all particles.
function diff_p_loc_p_avg(v, u, t, system)
p_avg_tot = avg_pressure(v, u, t, system)
function diff_p_loc_p_avg(system, v, u, semi, t)
p_avg_tot = avg_pressure(system, v, u, semi, t)

return v[end, :] .- p_avg_tot
end

for density_calculator in density_calculators, perturbation in perturb_coordinates,
particle_spacing in particle_spacings, wcsph in [false, true]
wcsph in [false, true]
n_particles_xy = round(Int, 1.0 / particle_spacing)

name_density_calculator = density_calculator isa SummationDensity ?
Expand Down
Loading