-
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.
Covariant form as variable-coefficient problem using auxiliary variab…
…les (#47) * linear advection on the sphere * formatter * very preliminary implementation of covariant form with p4est * removed untracked * removed allocations, now 100x faster * add DS_Store to gitignore * add DS_Store to gitignore * made equations actually 2D * integrated upstream changes * analysis callback for covariant form * cleanup * separate Andres's spherical shell containers from main Trixi * Added containers and 2D p4est mesh from my spherical shell implementation in Trixi.jl (cherry-picked from f45378e) Co-authored-by: Tristan Montoya <[email protected]> * Added element container with PtrArray for performance and modified the structure * format * Fixed bug in the definition of init_elements and added nelements(). eltype() and ndims() functions for new struct * integrated Andres's new container type with covariant solver * added flux-differencing kernel for covariant form * integrated Andrés' PR with covariant solver * add tests for spherical advection in Cartesian coords * revert change to moist bubble case * revert change to moist bubble case * covariant weak form with tests * removed shallow water from this branch * reorganize a bit * hard-code dimension of node coordinates to avoid type instability * metric terms for shell of radius != 1 * test for covariant form is now on earth scale * fix name of cartesian test * moved i,j,element,cache into flux signatures for covariant form * added test for flux differencing covariant form * transformation between local coordinate systems now uses latitude-longitude as intermediate state, not Cartesian * format * make compatible with my PR trixi-framework/Trixi.jl#2068 * separate containers to store geometric information specific to covariant form * add element-local mapping from Guba et al. * add reference to Guba et al. to docstring * new mapping works with cartesian solver solver in covariant_form branch * exact metrics for element-local mapping * streamline tests and improve readability * rename default DGSEM mapping * didn't need new analysis cache * improve comments * refactor * remove DiffEqCallbacks for now * add better comments * improve comments * better documentation * add NDIMS_AMBIENT parameter to equations * fix docstring format * make link in docs work * fix link in docs * documentation for the covariant solver * added surface central flux and test * fix trixi_compat * specialize compute_coefficients! to dimension 2 * format * fix spelling * remove initial_condition parameter from rhs * no need to use Float32 for physical constant defaults * incorporate downstream changes * format * standardize test cases * move covariant form max_dt method to callbacks_step * Fix comments * generalize interface between equations and cache * relax relative tolerance on cartesian advection test) * improve docs * streamline initial condition definition and improve docs * tests for cartesian form now use standard and element-local mapping approaches * first attempt at aux vars * works with allocations * fix allocations * clean up docs * format and update comments * move auxvars into own cache field * improve comments * format comments * revert back to without basis matrix inverse * add warning for P4estMeshCubedSphere and rename volume->area element * rename function transforming initial condition * fix elixir and docs * poldeg(solver) -> Trixi.polydeg(solver) * reformat ugly line breaks * modularize covariant basis calculation for easier testing * remove duplicated cons2entropy function --------- Co-authored-by: Andrés Rueda-Ramírez <[email protected]>
- Loading branch information
1 parent
49ec206
commit 40800a6
Showing
28 changed files
with
1,197 additions
and
166 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
############################################################################### | ||
# DGSEM for the linear advection equation on the cubed sphere | ||
############################################################################### | ||
|
||
using OrdinaryDiffEq, Trixi, TrixiAtmo | ||
|
||
############################################################################### | ||
# Spatial discretization | ||
|
||
cells_per_dimension = 5 | ||
initial_condition = initial_condition_gaussian | ||
|
||
equations = CovariantLinearAdvectionEquation2D() | ||
|
||
# Create DG solver with polynomial degree = p and a local Lax-Friedrichs flux | ||
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, | ||
volume_integral = VolumeIntegralWeakForm()) | ||
|
||
# Create a 2D cubed sphere mesh the size of the Earth. For the covariant form to work | ||
# properly, we currently need polydeg to equal that of the solver, | ||
# initial_refinement_level = 0, and element_local_mapping = true. | ||
mesh = P4estMeshCubedSphere2D(cells_per_dimension, EARTH_RADIUS, | ||
polydeg = Trixi.polydeg(solver), | ||
initial_refinement_level = 0, | ||
element_local_mapping = true) | ||
|
||
# Convert initial condition given in terms of zonal and meridional velocity components to | ||
# one given in terms of contravariant velocity components | ||
initial_condition_transformed = transform_to_contravariant(initial_condition, equations) | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_transformed, solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
# Create ODE problem with time span from 0 to T | ||
ode = semidiscretize(semi, (0.0, 12 * SECONDS_PER_DAY)) | ||
|
||
# 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 = 10, | ||
save_analysis = true, | ||
extra_analysis_errors = (:conservation_error,)) | ||
|
||
# The SaveSolutionCallback allows to save the solution to a file in regular intervals | ||
save_solution = SaveSolutionCallback(interval = 10, | ||
solution_variables = cons2cons) | ||
|
||
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step | ||
stepsize_callback = StepsizeCallback(cfl = 0.7) | ||
|
||
# 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 = 1.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
Oops, something went wrong.