-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9c3591
commit 9c720dd
Showing
6 changed files
with
203 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
############################################################################### | ||
# DGSEM for the shallow water equations on the cubed sphere | ||
############################################################################### | ||
|
||
using OrdinaryDiffEq, Trixi, TrixiAtmo | ||
|
||
############################################################################### | ||
# Parameters | ||
|
||
initial_condition = initial_condition_geostrophic_balance | ||
polydeg = 3 | ||
cells_per_dimension = 5 | ||
n_saves = 10 | ||
|
||
############################################################################### | ||
# Spatial discretization | ||
|
||
tspan = (0.0, 1.0 * SECONDS_PER_DAY) | ||
|
||
mesh = P4estMeshCubedSphere2D(cells_per_dimension, EARTH_RADIUS, polydeg = polydeg, | ||
initial_refinement_level = 0, | ||
element_local_mapping = true) | ||
|
||
equations = CovariantShallowWaterEquations2D(EARTH_GRAVITATIONAL_ACCELERATION, | ||
EARTH_ROTATION_RATE, | ||
global_coordinate_system = GlobalSphericalCoordinates()) | ||
|
||
# Create DG solver with polynomial degree = p | ||
volume_flux = (flux_split_covariant, flux_nonconservative_split_covariant) | ||
surface_flux = (flux_split_covariant, flux_nonconservative_split_covariant) | ||
|
||
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
initial_condition_transformed = transform_initial_condition(initial_condition, equations) | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_transformed, solver, | ||
source_terms = source_terms_split_covariant) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
# Create ODE problem with time span from 0 to T | ||
ode = semidiscretize(semi, tspan) | ||
|
||
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup | ||
# and resets the timers | ||
summary_callback = SummaryCallback() | ||
|
||
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results | ||
analysis_callback = AnalysisCallback(semi, interval = 50, | ||
save_analysis = true, | ||
extra_analysis_errors = (:conservation_error,)) | ||
|
||
# The SaveSolutionCallback allows to save the solution to a file in regular intervals | ||
save_solution = SaveSolutionCallback(dt = (tspan[2] - tspan[1]) / n_saves, | ||
solution_variables = cons2cons) | ||
|
||
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step | ||
stepsize_callback = StepsizeCallback(cfl = 0.4) | ||
|
||
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver | ||
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks | ||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 100.0, save_everystep = false, callback = callbacks); | ||
|
||
# Print the timer summary | ||
summary_callback() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.