Path: blob/main/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the compressible ideal GLM-MHD equations5gamma = 5 / 36equations = IdealGlmMhdEquations2D(gamma)78initial_condition = initial_condition_convergence_test910volume_flux = (flux_central, flux_nonconservative_powell)11solver = DGSEM(polydeg = 7,12surface_flux = (flux_hlle,13flux_nonconservative_powell),14volume_integral = VolumeIntegralFluxDifferencing(volume_flux))1516# Get the unstructured quad mesh from a file (downloads the file if not available locally)17mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh",18joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh"))1920mesh = UnstructuredMesh2D(mesh_file, periodicity = true)2122semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver;23boundary_conditions = boundary_condition_periodic)2425###############################################################################26# ODE solvers, callbacks etc.2728tspan = (0.0, 2.0)29ode = semidiscretize(semi, tspan)3031summary_callback = SummaryCallback()3233analysis_interval = 10034analysis_callback = AnalysisCallback(semi, interval = analysis_interval,35save_analysis = false,36extra_analysis_integrals = (entropy, energy_total,37energy_kinetic,38energy_internal,39energy_magnetic,40cross_helicity))4142alive_callback = AliveCallback(analysis_interval = analysis_interval)4344save_solution = SaveSolutionCallback(interval = 100,45save_initial_solution = true,46save_final_solution = true,47solution_variables = cons2prim)48cfl = 0.949stepsize_callback = StepsizeCallback(cfl = cfl)5051glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)5253callbacks = CallbackSet(summary_callback,54analysis_callback,55alive_callback,56save_solution,57stepsize_callback,58glm_speed_callback)5960###############################################################################61# run the simulation6263sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);64dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback65ode_default_options()..., callback = callbacks);666768