Skip to content

Commit

Permalink
Validation TVF (#640)
Browse files Browse the repository at this point in the history
* add `density_calculator` to example

* add perturbation option

* fix typo

* implement suggestions

---------

Co-authored-by: Sven Berger <[email protected]>
  • Loading branch information
LasNikas and svchb authored Nov 22, 2024
1 parent 06a9352 commit 231e2e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion examples/fluid/taylor_green_vortex_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ background_pressure = sound_speed^2 * fluid_density
smoothing_length = 1.0 * particle_spacing
smoothing_kernel = SchoenbergQuinticSplineKernel{2}()

# To be set via `trixi_include`
perturb_coordinates = true
fluid = RectangularShape(particle_spacing, (n_particles_xy, n_particles_xy), (0.0, 0.0),
coordinates_perturbation=0.2, # To avoid stagnant streamlines when not using TVF.
# Perturb particle coordinates to avoid stagnant streamlines without TVF
coordinates_perturbation=perturb_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF.
density=fluid_density, pressure=initial_pressure_function,
velocity=initial_velocity_function)

density_calculator = SummationDensity()
fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length,
sound_speed,
density_calculator=density_calculator,
transport_velocity=TransportVelocityAdami(background_pressure),
viscosity=ViscosityAdami(; nu))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ particle_spacings = [0.02, 0.01, 0.005]
tspan = (0.0, 5.0)
reynolds_number = 100.0

density_calculators = [SummationDensity(), ContinuityDensity()]
perturb_coordinates = [false, true]

function compute_l1v_error(v, u, t, system)
v_analytical_avg = 0.0
v_avg = 0.0
Expand Down Expand Up @@ -60,10 +63,16 @@ function diff_p_loc_p_avg(v, u, t, system)
return v[end, :] .- p_avg_tot
end

for particle_spacing in particle_spacings
for density_calculator in density_calculators, perturbation in perturb_coordinates,
particle_spacing in particle_spacings

n_particles_xy = round(Int, 1.0 / particle_spacing)

output_directory = joinpath("out_tgv",
name_density_calculator = density_calculator isa SummationDensity ?
"summation_density" : "continuity_density"
name_perturbation = perturbation ? "perturbed" : ""

output_directory = joinpath("out_tgv", "$(name_density_calculator)_$name_perturbation",
"validation_run_taylor_green_vortex_2d_nparticles_$(n_particles_xy)x$(n_particles_xy)")
saving_callback = SolutionSavingCallback(dt=0.02,
output_directory=output_directory,
Expand All @@ -79,6 +88,8 @@ for particle_spacing in particle_spacings
# Import variables into scope
trixi_include(@__MODULE__,
joinpath(examples_dir(), "fluid", "taylor_green_vortex_2d.jl"),
density_calculator=density_calculator,
perturb_coordinates=perturbation,
particle_spacing=particle_spacing, reynolds_number=reynolds_number,
tspan=tspan, saving_callback=saving_callback, pp_callback=pp_callback)
end

0 comments on commit 231e2e0

Please sign in to comment.