Path: blob/main/examples/unstructured_2d_fdsbp/elixir_advection_basic.jl
5586 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the linear advection equation56advection_velocity = (0.2, -0.7)7equations = LinearScalarAdvectionEquation2D(advection_velocity)89###############################################################################10# Get the FDSBP approximation operator1112D_SBP = derivative_operator(SummationByPartsOperators.MattssonAlmquistVanDerWeide2018Accurate(),13derivative_order = 1, accuracy_order = 4,14xmin = -1.0, xmax = 1.0, N = 15)15solver = FDSBP(D_SBP,16surface_integral = SurfaceIntegralStrongForm(flux_lax_friedrichs),17volume_integral = VolumeIntegralStrongForm())1819###############################################################################20# Get the curved quad mesh from a file (downloads the file if not available locally)21mesh_file = Trixi.download("https://gist.githubusercontent.com/andrewwinters5000/12ce661d7c354c3d94c74b964b0f1c96/raw/8275b9a60c6e7ebbdea5fc4b4f091c47af3d5273/mesh_periodic_square_with_twist.mesh",22joinpath(@__DIR__, "mesh_periodic_square_with_twist.mesh"))2324mesh = UnstructuredMesh2D(mesh_file, periodicity = true)2526###############################################################################27# create the semidiscretization object2829semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,30solver;31boundary_conditions = boundary_condition_periodic)3233###############################################################################34# ODE solvers, callbacks etc.3536# Create ODE problem with time span from 0.0 to 1.037ode = semidiscretize(semi, (0.0, 1.0))3839# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup40# and resets the timers41summary_callback = SummaryCallback()4243# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results44analysis_callback = AnalysisCallback(semi, interval = 100)4546# The SaveSolutionCallback allows to save the solution to a file in regular intervals47save_solution = SaveSolutionCallback(interval = 100,48solution_variables = cons2prim)4950# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step51stepsize_callback = StepsizeCallback(cfl = 1.6)5253# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver54callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,55stepsize_callback)5657###############################################################################58# run the simulation5960sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);61dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback62ode_default_options()..., callback = callbacks);636465