Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/t8code_3d_dgsem/elixir_advection_cubed_sphere.jl
2055 views
1
using OrdinaryDiffEqLowStorageRK
2
using Trixi
3
4
###############################################################################
5
# semidiscretization of the linear advection equation
6
7
advection_velocity = (0.2, -0.7, 0.5)
8
equations = LinearScalarAdvectionEquation3D(advection_velocity)
9
10
# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
11
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)
12
13
initial_condition = initial_condition_convergence_test
14
15
boundary_condition = BoundaryConditionDirichlet(initial_condition)
16
boundary_conditions = Dict(:inside => boundary_condition,
17
:outside => boundary_condition)
18
19
trees_per_face_dimension = 5 # Number of trees per patch in longitudinal and latitudinal direction
20
layers = 3 # Number of layers of the shell
21
inner_radius = 0.5 # Radius of the inner side of the shell
22
thickness = 0.5 # Thickness of the shell. The outer radius will be `inner_radius + thickness`
23
mesh = Trixi.T8codeMeshCubedSphere(trees_per_face_dimension, layers,
24
inner_radius, thickness;
25
polydeg = 3, initial_refinement_level = 0)
26
27
# A semidiscretization collects data structures and functions for the spatial discretization
28
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
29
boundary_conditions = boundary_conditions)
30
31
###############################################################################
32
# ODE solvers, callbacks etc.
33
34
# Create ODE problem with time span from 0.0 to 1.0
35
tspan = (0.0, 1.0)
36
ode = semidiscretize(semi, tspan)
37
38
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
39
# and resets the timers
40
summary_callback = SummaryCallback()
41
42
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
43
analysis_callback = AnalysisCallback(semi, interval = 100)
44
45
# The SaveSolutionCallback allows to save the solution to a file in regular intervals
46
save_solution = SaveSolutionCallback(interval = 100,
47
solution_variables = cons2prim)
48
49
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
50
stepsize_callback = StepsizeCallback(cfl = 1.2)
51
52
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
53
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,
54
stepsize_callback)
55
56
###############################################################################
57
# run the simulation
58
59
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
60
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
61
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
62
ode_default_options()..., callback = callbacks);
63
64