Path: blob/main/examples/p4est_2d_dgsem/elixir_advection_basic_gpu.jl
2055 views
# The same setup as tree_2d_dgsem/elixir_advection_basic.jl1# to verify GPU support and Adapt.jl support.23using OrdinaryDiffEqLowStorageRK4using Trixi56###############################################################################7# semidiscretization of the linear advection equation89advection_velocity = (0.2, -0.7)10equations = LinearScalarAdvectionEquation2D(advection_velocity)1112# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux13solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)1415coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y))16coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y))1718trees_per_dimension = (8, 8)1920# Create P4estMesh with 8 x 8 trees and 16 x 16 elements21mesh = P4estMesh(trees_per_dimension, polydeg = 3,22coordinates_min = coordinates_min, coordinates_max = coordinates_max,23initial_refinement_level = 1)2425# A semidiscretization collects data structures and functions for the spatial discretization26semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,27solver)2829###############################################################################30# ODE solvers, callbacks etc.3132# Create ODE problem with time span from 0.0 to 1.033ode = semidiscretize(semi, (0.0, 1.0); real_type = nothing, storage_type = nothing)3435# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup36# and resets the timers37summary_callback = SummaryCallback()3839# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results40analysis_callback = AnalysisCallback(semi, interval = 100)4142# The SaveSolutionCallback allows to save the solution to a file in regular intervals43save_solution = SaveSolutionCallback(interval = 100,44solution_variables = cons2prim)4546# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step47stepsize_callback = StepsizeCallback(cfl = 1.6)4849# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver50callbacks = CallbackSet(summary_callback, stepsize_callback)51# TODO: GPU. The `analysis_callback` needs to be updated for GPU support52# analysis_callback, save_solution, stepsize_callback)5354###############################################################################55# run the simulation5657# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks58sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);59dt = 1e-2, # solve needs some value here but it will be overwritten by the stepsize_callback60ode_default_options()..., callback = callbacks);616263