Path: blob/main/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl
2055 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)2324###############################################################################25# ODE solvers, callbacks etc.2627tspan = (0.0, 2.0)28ode = semidiscretize(semi, tspan)2930summary_callback = SummaryCallback()3132analysis_interval = 10033analysis_callback = AnalysisCallback(semi, interval = analysis_interval,34save_analysis = false,35extra_analysis_integrals = (entropy, energy_total,36energy_kinetic,37energy_internal,38energy_magnetic,39cross_helicity))4041alive_callback = AliveCallback(analysis_interval = analysis_interval)4243save_solution = SaveSolutionCallback(interval = 100,44save_initial_solution = true,45save_final_solution = true,46solution_variables = cons2prim)47cfl = 0.948stepsize_callback = StepsizeCallback(cfl = cfl)4950glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)5152callbacks = CallbackSet(summary_callback,53analysis_callback,54alive_callback,55save_solution,56stepsize_callback,57glm_speed_callback)5859###############################################################################60# run the simulation6162sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);63dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback64ode_default_options()..., callback = callbacks);656667