Skip to content

Commit

Permalink
test hybrid mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Dec 29, 2024
1 parent 7554aa4 commit 06494ee
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
59 changes: 59 additions & 0 deletions examples/p4est_2d_dgsem/elixir_euler_free_stream_hybrid_mesh.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the compressible Euler equations

equations = CompressibleEulerEquations2D(1.4)

# Test free stream preservation with constant initial condition
initial_condition = initial_condition_constant

solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)

###############################################################################

# Hybrid mesh composed of a second-order and first-order quadrilateral element
mesh_file = Trixi.download("https://gist.githubusercontent.com/DanielDoehring/84d876776e379322c38e9c0bfcadee8e/raw/0068805b853a8faa0fe229280d353016359d8a7d/hybrid_quadmesh.inp",
joinpath(@__DIR__, "hybrid_quadmesh.inp"))

# Refine the given mesh twice
mesh = P4estMesh{2}(mesh_file, initial_refinement_level = 2)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions =
Dict(:all => BoundaryConditionDirichlet(initial_condition)))

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

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

alive_callback = AliveCallback(analysis_interval = analysis_interval)

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

stepsize_callback = StepsizeCallback(cfl = 2.0)

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

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

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
26 changes: 26 additions & 0 deletions test/test_p4est_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,32 @@ end
end
end

@trixi_testset "elixir_euler_free_stream_hybrid_mesh.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_euler_free_stream_hybrid_mesh.jl"),
l2=[
1.0174922714929637e-15,
5.053352600778435e-15,
7.358169131303026e-15,
5.999843977180112e-15
],
linf=[
4.440892098500626e-15,
2.6117996654306808e-14,
4.246603069191224e-14,
5.861977570020827e-14
],
atol=2.0e-12,)
# 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

@trixi_testset "elixir_euler_shockcapturing_ec.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"),
l2=[
Expand Down

0 comments on commit 06494ee

Please sign in to comment.