Path: blob/main/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible ideal GLM-MHD equations56equations = IdealGlmMhdEquations2D(5 / 3)78function initial_condition_shifted_weak_blast_wave(x, t, equations::IdealGlmMhdEquations2D)9# Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3)10# Shift blastwave to center of domain11inicenter = (sqrt(2) / 2, sqrt(2) / 2)12x_norm = x[1] - inicenter[1]13y_norm = x[2] - inicenter[2]14r = sqrt(x_norm^2 + y_norm^2)15phi = atan(y_norm, x_norm)1617# Calculate primitive variables18rho = r > 0.5 ? 1.0 : 1.169119v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi)20v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi)21p = r > 0.5 ? 1.0 : 1.2452223return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations)24end2526initial_condition = initial_condition_shifted_weak_blast_wave2728# Get the DG approximation space29volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)30solver = DGSEM(polydeg = 6,31surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell),32volume_integral = VolumeIntegralFluxDifferencing(volume_flux))3334# Get the unstructured quad mesh from a file (downloads the file if not available locally)35mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh",36joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh"))3738mesh = UnstructuredMesh2D(mesh_file, periodicity = true)3940# create the semi discretization object41semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)4243###############################################################################44# ODE solvers, callbacks etc.4546tspan = (0.0, 2.0)47ode = semidiscretize(semi, tspan)4849summary_callback = SummaryCallback()5051analysis_interval = 10052analysis_callback = AnalysisCallback(semi, interval = analysis_interval,53save_analysis = false,54extra_analysis_integrals = (entropy, energy_total,55energy_kinetic,56energy_internal,57energy_magnetic,58cross_helicity))5960alive_callback = AliveCallback(analysis_interval = analysis_interval)6162save_solution = SaveSolutionCallback(interval = 100,63save_initial_solution = true,64save_final_solution = true,65solution_variables = cons2prim)66cfl = 1.067stepsize_callback = StepsizeCallback(cfl = cfl)6869glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)7071callbacks = CallbackSet(summary_callback,72analysis_callback,73alive_callback,74save_solution,75stepsize_callback,76glm_speed_callback)7778###############################################################################79# run the simulation8081sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);82dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback83ode_default_options()..., callback = callbacks);848586