Skip to content
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

von-Karman Vortex Street #2246

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
115 changes: 115 additions & 0 deletions examples/p4est_2d_dgsem/elixir_navierstokes_vortex_street.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# Semidiscretization of the compressible Euler equations

# Fluid parameters
gamma() = 5 / 3
prandtl_number() = 0.72

# Parameters for compressible von-Karman vortex street
Re() = 500
Ma() = 0.5f0
D() = 1 # Diameter of the cylinder as in the mesh file

# Parameters that can be freely chosen
v_in() = 1
p_in() = 1

# Parameters that follow from Reynolds and Mach number + adiabatic index gamma
mu() = v_in() * D() / Re()

c() = v_in() / Ma()
p_over_rho() = c()^2 / gamma()
rho_in() = p_in() / p_over_rho()

# Equations for this configuration
equations = CompressibleEulerEquations2D(gamma())
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(),
Prandtl = prandtl_number(),
gradient_variables = GradientVariablesPrimitive())

# Freestream configuration
@inline function initial_condition(x, t, equations::CompressibleEulerEquations2D)
rho = rho_in()
v1 = v_in()
v2 = 0.0
p = p_in()

prim = SVector(rho, v1, v2, p)
return prim2cons(prim, equations)
end

# Mesh which is refined around the cylinder and the wake region
mesh_file = Trixi.download("https://gist.githubusercontent.com/DanielDoehring/7312faba9a50ef506b13f01716b4ec26/raw/8e68f9006e634905544207ca322bc0a03a9313ad/cylinder_vortex_street.inp",
joinpath(@__DIR__, "cylinder_vortex_street.inp"))
mesh = P4estMesh{2}(mesh_file)

bc_freestream = BoundaryConditionDirichlet(initial_condition)

# Boundary names follow from the mesh file
boundary_conditions = Dict(:Bottom => bc_freestream,
:Circle => boundary_condition_slip_wall,
:Top => bc_freestream,
:Right => bc_freestream,
:Left => bc_freestream)

# Parabolic boundary conditions
velocity_bc_free = NoSlip((x, t, equations) -> SVector(v_in(), 0))
# Use adiabatic also on the boundaries to "copy" temperature from the domain
heat_bc_free = Adiabatic((x, t, equations) -> 0)
boundary_condition_free = BoundaryConditionNavierStokesWall(velocity_bc_free, heat_bc_free)

velocity_bc_cylinder = NoSlip((x, t, equations) -> SVector(0, 0))
heat_bc_cylinder = Adiabatic((x, t, equations) -> 0)
boundary_condition_cylinder = BoundaryConditionNavierStokesWall(velocity_bc_cylinder,
heat_bc_cylinder)

boundary_conditions_para = Dict(:Bottom => boundary_condition_free,
:Circle => boundary_condition_cylinder,
:Top => boundary_condition_free,
:Right => boundary_condition_free,
:Left => boundary_condition_free)
# Standard DGSEM sufficient here
solver = DGSEM(polydeg = 3, surface_flux = flux_hll)

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, solver,
boundary_conditions = (boundary_conditions,
boundary_conditions_para))

###############################################################################
# Setup an ODE problem
tspan = (0, 100)
ode = semidiscretize(semi, tspan)

# Callbacks
summary_callback = SummaryCallback()

analysis_interval = 1000
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = analysis_interval,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

callbacks = CallbackSet(summary_callback,
analysis_callback,
alive_callback,
save_solution)

###############################################################################
# run the simulation

time_int_tol = 1e-6
sol = solve(ode,
# Moderate number of threads (e.g. 4) advisable to speed things up
RDPK3SpFSAL49(thread = OrdinaryDiffEq.True());
dt = 1e-3, abstol = time_int_tol, reltol = time_int_tol,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting dt required here?

ode_default_options()..., callback = callbacks)

summary_callback() # print the timer summary
1 change: 0 additions & 1 deletion src/equations/compressible_navier_stokes_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ end
t,
operator_type::Divergence,
equations::CompressibleNavierStokesDiffusion1D{GradientVariablesPrimitive})
# rho, v1, v2, _ = u_inner
normal_heat_flux = boundary_condition.boundary_condition_heat_flux.boundary_value_normal_flux_function(x,
t,
equations)
Expand Down
1 change: 0 additions & 1 deletion src/equations/compressible_navier_stokes_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ end
t,
operator_type::Divergence,
equations::CompressibleNavierStokesDiffusion2D{GradientVariablesPrimitive})
# rho, v1, v2, _ = u_inner
normal_heat_flux = boundary_condition.boundary_condition_heat_flux.boundary_value_normal_flux_function(x,
t,
equations)
Expand Down
1 change: 0 additions & 1 deletion src/equations/compressible_navier_stokes_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ end
t,
operator_type::Divergence,
equations::CompressibleNavierStokesDiffusion3D{GradientVariablesPrimitive})
# rho, v1, v2, v3, _ = u_inner
normal_heat_flux = boundary_condition.boundary_condition_heat_flux.boundary_value_normal_flux_function(x,
t,
equations)
Expand Down
26 changes: 26 additions & 0 deletions test/test_parabolic_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,32 @@ end
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end

@trixi_testset "elixir_navierstokes_vortex_street.jl" begin
@test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem",
"elixir_navierstokes_vortex_street.jl"),
l2=[
0.005069706928574108,
0.011627798047777405,
0.009242702790766983,
0.02646416294015243
],
linf=[
0.21307118247870704,
0.5365731661670426,
0.29315320855786453,
0.9453411793625751
],
tspan=(0.0, 1.0))
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

# Clean up afterwards: delete Trixi.jl output directory
Expand Down
Loading