Path: blob/main/examples/t8code_3d_dgsem/elixir_advection_cubed_sphere.jl
2055 views
using OrdinaryDiffEqLowStorageRK1using Trixi23###############################################################################4# semidiscretization of the linear advection equation56advection_velocity = (0.2, -0.7, 0.5)7equations = LinearScalarAdvectionEquation3D(advection_velocity)89# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux10solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)1112initial_condition = initial_condition_convergence_test1314boundary_condition = BoundaryConditionDirichlet(initial_condition)15boundary_conditions = Dict(:inside => boundary_condition,16:outside => boundary_condition)1718trees_per_face_dimension = 5 # Number of trees per patch in longitudinal and latitudinal direction19layers = 3 # Number of layers of the shell20inner_radius = 0.5 # Radius of the inner side of the shell21thickness = 0.5 # Thickness of the shell. The outer radius will be `inner_radius + thickness`22mesh = Trixi.T8codeMeshCubedSphere(trees_per_face_dimension, layers,23inner_radius, thickness;24polydeg = 3, initial_refinement_level = 0)2526# A semidiscretization collects data structures and functions for the spatial discretization27semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,28boundary_conditions = boundary_conditions)2930###############################################################################31# ODE solvers, callbacks etc.3233# Create ODE problem with time span from 0.0 to 1.034tspan = (0.0, 1.0)35ode = semidiscretize(semi, tspan)3637# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup38# and resets the timers39summary_callback = SummaryCallback()4041# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results42analysis_callback = AnalysisCallback(semi, interval = 100)4344# The SaveSolutionCallback allows to save the solution to a file in regular intervals45save_solution = SaveSolutionCallback(interval = 100,46solution_variables = cons2prim)4748# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step49stepsize_callback = StepsizeCallback(cfl = 1.2)5051# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver52callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,53stepsize_callback)5455###############################################################################56# run the simulation5758# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks59sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);60dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback61ode_default_options()..., callback = callbacks);626364