Path: blob/main/examples/p4est_2d_dgsem/elixir_advection_meshview.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# Most basic p4est mesh view setup where the entire domain5# is part of the single mesh view.67advection_velocity = (0.2, -0.7)8equations = LinearScalarAdvectionEquation2D(advection_velocity)910# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux11solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)1213coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y))14coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y))1516trees_per_dimension = (8, 8)1718# Create parent P4estMesh with 8 x 8 trees and 8 x 8 elements19parent_mesh = P4estMesh(trees_per_dimension, polydeg = 3,20coordinates_min = coordinates_min,21coordinates_max = coordinates_max,22initial_refinement_level = 0)2324# Define the mesh view covering the whole parent mesh.25cell_ids = collect(1:Trixi.ncells(parent_mesh))26mesh = P4estMeshView(parent_mesh, cell_ids)2728# A semidiscretization collects data structures and functions for the spatial discretization29semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,30solver)3132###############################################################################33# ODE solvers, callbacks etc.3435# Create ODE problem with time span from 0.0 to 1.036ode = semidiscretize(semi, (0.0, 1.0))3738# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup39# and resets the timers40summary_callback = SummaryCallback()4142# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results43# We require this definition for the test, even though we don't use it in the CallbackSet.44analysis_callback = AnalysisCallback(semi)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, save_solution,55stepsize_callback)5657###############################################################################58# run the simulation5960# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks61sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);62dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback63ode_default_options()..., callback = callbacks);646566