-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into subcell-limiting-positivity-nonlinear
- Loading branch information
Showing
26 changed files
with
1,865 additions
and
364 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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
name = "Trixi" | ||
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb" | ||
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"] | ||
version = "0.6.4-pre" | ||
version = "0.6.5-pre" | ||
|
||
[deps] | ||
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" | ||
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" | ||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def" | ||
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949" | ||
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" | ||
|
@@ -52,6 +53,7 @@ TrixiMakieExt = "Makie" | |
[compat] | ||
CodeTracking = "1.0.5" | ||
ConstructionBase = "1.3" | ||
DataStructures = "0.18.15" | ||
DiffEqCallbacks = "2.25" | ||
EllipsisNotation = "1.0" | ||
FillArrays = "0.13.2, 1" | ||
|
85 changes: 85 additions & 0 deletions
85
examples/tree_1d_dgsem/elixir_euler_quasi_1d_discontinuous.jl
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,85 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# Semidiscretization of the quasi 1d compressible Euler equations | ||
# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details | ||
|
||
equations = CompressibleEulerEquationsQuasi1D(1.4) | ||
|
||
""" | ||
initial_condition_discontinuity(x, t, equations::CompressibleEulerEquations1D) | ||
A discontinuous initial condition taken from | ||
- Jesse Chan, Khemraj Shukla, Xinhui Wu, Ruofeng Liu, Prani Nalluri (2023) | ||
High order entropy stable schemes for the quasi-one-dimensional | ||
shallow water and compressible Euler equations | ||
[DOI: 10.48550/arXiv.2307.12089](https://doi.org/10.48550/arXiv.2307.12089) | ||
""" | ||
function initial_condition_discontinuity(x, t, | ||
equations::CompressibleEulerEquationsQuasi1D) | ||
rho = (x[1] < 0) ? 3.4718 : 2.0 | ||
v1 = (x[1] < 0) ? -2.5923 : -3.0 | ||
p = (x[1] < 0) ? 5.7118 : 2.639 | ||
a = (x[1] < 0) ? 1.0 : 1.5 | ||
|
||
return prim2cons(SVector(rho, v1, p, a), equations) | ||
end | ||
|
||
initial_condition = initial_condition_discontinuity | ||
|
||
surface_flux = (flux_lax_friedrichs, flux_nonconservative_chan_etal) | ||
volume_flux = (flux_chan_etal, flux_nonconservative_chan_etal) | ||
|
||
basis = LobattoLegendreBasis(3) | ||
indicator_sc = IndicatorHennemannGassner(equations, basis, | ||
alpha_max = 0.5, | ||
alpha_min = 0.001, | ||
alpha_smooth = true, | ||
variable = density_pressure) | ||
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; | ||
volume_flux_dg = volume_flux, | ||
volume_flux_fv = surface_flux) | ||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
coordinates_min = (-1.0,) | ||
coordinates_max = (1.0,) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 6, | ||
n_cells_max = 10_000) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 2.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
|
||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 100, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
solution_variables = cons2prim) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 0.5) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
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,73 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# Semidiscretization of the quasi 1d compressible Euler equations with a discontinuous nozzle width function. | ||
# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details | ||
|
||
equations = CompressibleEulerEquationsQuasi1D(1.4) | ||
|
||
# Setup a truly discontinuous density function and nozzle width for | ||
# this academic testcase of entropy conservation. The errors from the analysis | ||
# callback are not important but the entropy error for this test case | ||
# `∑∂S/∂U ⋅ Uₜ` should be around machine roundoff. | ||
# Works as intended for TreeMesh1D with `initial_refinement_level=6`. If the mesh | ||
# refinement level is changed the initial condition below may need changed as well to | ||
# ensure that the discontinuities lie on an element interface. | ||
function initial_condition_ec(x, t, equations::CompressibleEulerEquationsQuasi1D) | ||
v1 = 0.1 | ||
rho = 2.0 + 0.1 * x[1] | ||
p = 3.0 | ||
a = 2.0 + x[1] | ||
|
||
return prim2cons(SVector(rho, v1, p, a), equations) | ||
end | ||
|
||
initial_condition = initial_condition_ec | ||
|
||
surface_flux = (flux_chan_etal, flux_nonconservative_chan_etal) | ||
volume_flux = surface_flux | ||
solver = DGSEM(polydeg = 4, surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
coordinates_min = (-1.0,) | ||
coordinates_max = (1.0,) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 6, | ||
n_cells_max = 10_000) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 0.4) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
|
||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 100, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
solution_variables = cons2prim) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 0.8) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
60 changes: 60 additions & 0 deletions
60
examples/tree_1d_dgsem/elixir_euler_quasi_1d_source_terms.jl
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,60 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
using ForwardDiff | ||
|
||
############################################################################### | ||
# Semidiscretization of the quasi 1d compressible Euler equations | ||
# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details | ||
|
||
equations = CompressibleEulerEquationsQuasi1D(1.4) | ||
|
||
initial_condition = initial_condition_convergence_test | ||
|
||
surface_flux = (flux_chan_etal, flux_nonconservative_chan_etal) | ||
volume_flux = surface_flux | ||
solver = DGSEM(polydeg = 4, surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
coordinates_min = -1.0 | ||
coordinates_max = 1.0 | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 4, | ||
n_cells_max = 10_000) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
source_terms = source_terms_convergence_test) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 2.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, | ||
extra_analysis_errors = (:l2_error_primitive, | ||
:linf_error_primitive)) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 100, | ||
save_initial_solution = true, | ||
save_final_solution = true, | ||
solution_variables = cons2prim) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 0.8) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
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,69 @@ | ||
|
||
using Downloads: download | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the linear advection equation | ||
|
||
advection_velocity = (0.2, -0.7) | ||
equations = LinearScalarAdvectionEquation2D(advection_velocity) | ||
|
||
############################################################################### | ||
# Get the FDSBP approximation operator | ||
|
||
D_SBP = derivative_operator(SummationByPartsOperators.MattssonAlmquistVanDerWeide2018Accurate(), | ||
derivative_order = 1, accuracy_order = 4, | ||
xmin = -1.0, xmax = 1.0, N = 15) | ||
solver = FDSBP(D_SBP, | ||
surface_integral = SurfaceIntegralStrongForm(flux_lax_friedrichs), | ||
volume_integral = VolumeIntegralStrongForm()) | ||
|
||
############################################################################### | ||
# Get the curved quad mesh from a file (downloads the file if not available locally) | ||
|
||
default_mesh_file = joinpath(@__DIR__, "mesh_periodic_square_with_twist.mesh") | ||
isfile(default_mesh_file) || | ||
download("https://gist.githubusercontent.com/andrewwinters5000/12ce661d7c354c3d94c74b964b0f1c96/raw/8275b9a60c6e7ebbdea5fc4b4f091c47af3d5273/mesh_periodic_square_with_twist.mesh", | ||
default_mesh_file) | ||
mesh_file = default_mesh_file | ||
|
||
mesh = UnstructuredMesh2D(mesh_file, periodicity = true) | ||
|
||
############################################################################### | ||
# create the semidiscretization object | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, | ||
solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
# Create ODE problem with time span from 0.0 to 1.0 | ||
ode = semidiscretize(semi, (0.0, 1.0)) | ||
|
||
# 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 = 100) | ||
|
||
# The SaveSolutionCallback allows to save the solution to a file in regular intervals | ||
save_solution = SaveSolutionCallback(interval = 100, | ||
solution_variables = cons2prim) | ||
|
||
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step | ||
stepsize_callback = StepsizeCallback(cfl = 1.6) | ||
|
||
# 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 | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
77 changes: 77 additions & 0 deletions
77
examples/unstructured_2d_fdsbp/elixir_euler_free_stream.jl
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,77 @@ | ||
|
||
using Downloads: download | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
|
||
equations = CompressibleEulerEquations2D(1.4) | ||
|
||
# Free-stream initial condition | ||
initial_condition = initial_condition_constant | ||
|
||
# Boundary conditions for free-stream testing | ||
boundary_condition_free_stream = BoundaryConditionDirichlet(initial_condition) | ||
boundary_conditions = Dict(:Body => boundary_condition_free_stream, | ||
:Button1 => boundary_condition_free_stream, | ||
:Button2 => boundary_condition_free_stream, | ||
:Eye1 => boundary_condition_free_stream, | ||
:Eye2 => boundary_condition_free_stream, | ||
:Smile => boundary_condition_free_stream, | ||
:Bowtie => boundary_condition_free_stream) | ||
|
||
############################################################################### | ||
# Get the FDSBP approximation space | ||
|
||
D_SBP = derivative_operator(SummationByPartsOperators.MattssonAlmquistVanDerWeide2018Accurate(), | ||
derivative_order = 1, accuracy_order = 4, | ||
xmin = -1.0, xmax = 1.0, N = 12) | ||
solver = FDSBP(D_SBP, | ||
surface_integral = SurfaceIntegralStrongForm(flux_hll), | ||
volume_integral = VolumeIntegralStrongForm()) | ||
|
||
############################################################################### | ||
# Get the curved quad mesh from a file (downloads the file if not available locally) | ||
|
||
default_mesh_file = joinpath(@__DIR__, "mesh_gingerbread_man.mesh") | ||
isfile(default_mesh_file) || | ||
download("https://gist.githubusercontent.com/andrewwinters5000/2c6440b5f8a57db131061ad7aa78ee2b/raw/1f89fdf2c874ff678c78afb6fe8dc784bdfd421f/mesh_gingerbread_man.mesh", | ||
default_mesh_file) | ||
mesh_file = default_mesh_file | ||
|
||
mesh = UnstructuredMesh2D(mesh_file) | ||
|
||
############################################################################### | ||
# create the semi discretization object | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 5.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 100, | ||
save_initial_solution = true, | ||
save_final_solution = true) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, | ||
alive_callback, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# set small tolerances for the free-stream preservation test | ||
sol = solve(ode, SSPRK43(), abstol = 1.0e-12, reltol = 1.0e-12, | ||
save_everystep = false, callback = callbacks) | ||
summary_callback() # print the timer summary |
Oops, something went wrong.