-
Notifications
You must be signed in to change notification settings - Fork 109
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 main-continue
- Loading branch information
Showing
25 changed files
with
1,340 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
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.7.14-pre" | ||
version = "0.7.15-pre" | ||
|
||
[deps] | ||
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" | ||
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" | ||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" | ||
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" | ||
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def" | ||
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" | ||
|
@@ -50,17 +51,23 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | |
|
||
[weakdeps] | ||
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" | ||
Convex = "f65535da-76fb-5f13-bab9-19810c17039a" | ||
ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199" | ||
|
||
[extensions] | ||
TrixiMakieExt = "Makie" | ||
TrixiConvexECOSExt = ["Convex", "ECOS"] | ||
|
||
[compat] | ||
CodeTracking = "1.0.5" | ||
ConstructionBase = "1.3" | ||
Convex = "0.16" | ||
DataStructures = "0.18.15" | ||
DelimitedFiles = "1" | ||
DiffEqBase = "6 - 6.143" | ||
DiffEqCallbacks = "2.25" | ||
Downloads = "1.6" | ||
ECOS = "1.1.2" | ||
EllipsisNotation = "1.0" | ||
FillArrays = "0.13.2, 1" | ||
ForwardDiff = "0.10.24" | ||
|
@@ -103,3 +110,5 @@ julia = "1.8" | |
|
||
[extras] | ||
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" | ||
Convex = "f65535da-76fb-5f13-bab9-19810c17039a" | ||
ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199" |
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
114 changes: 114 additions & 0 deletions
114
examples/structured_2d_dgsem/elixir_euler_sedov_blast_wave_sc_subcell.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,114 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible Euler equations | ||
gamma = 1.4 | ||
equations = CompressibleEulerEquations2D(gamma) | ||
|
||
""" | ||
initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations2D) | ||
The Sedov blast wave setup based on Flash | ||
- https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000 | ||
""" | ||
function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations2D) | ||
# Set up polar coordinates | ||
inicenter = SVector(0.0, 0.0) | ||
x_norm = x[1] - inicenter[1] | ||
y_norm = x[2] - inicenter[2] | ||
r = sqrt(x_norm^2 + y_norm^2) | ||
|
||
# Setup based on https://flash.rochester.edu/site/flashcode/user_support/flash_ug_devel/node187.html#SECTION010114000000000000000 | ||
r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) | ||
# r0 = 0.5 # = more reasonable setup | ||
E = 1.0 | ||
p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) | ||
p0_outer = 1.0e-5 # = true Sedov setup | ||
# p0_outer = 1.0e-3 # = more reasonable setup | ||
|
||
# Calculate primitive variables | ||
rho = 1.0 | ||
v1 = 0.0 | ||
v2 = 0.0 | ||
p = r > r0 ? p0_outer : p0_inner | ||
|
||
return prim2cons(SVector(rho, v1, v2, p), equations) | ||
end | ||
initial_condition = initial_condition_sedov_blast_wave | ||
|
||
boundary_condition = BoundaryConditionDirichlet(initial_condition) | ||
boundary_conditions = (x_neg = boundary_condition, | ||
x_pos = boundary_condition, | ||
y_neg = boundary_condition, | ||
y_pos = boundary_condition) | ||
|
||
surface_flux = flux_lax_friedrichs | ||
volume_flux = flux_ranocha | ||
polydeg = 3 | ||
basis = LobattoLegendreBasis(polydeg) | ||
limiter_idp = SubcellLimiterIDP(equations, basis; | ||
local_twosided_variables_cons = ["rho"], | ||
local_onesided_variables_nonlinear = [(Trixi.entropy_guermond_etal, | ||
min)], | ||
max_iterations_newton = 40, # Default value of 10 iterations is too low to fulfill bounds. | ||
positivity_variables_cons = [], | ||
positivity_variables_nonlinear = []) | ||
# Variables for global limiting (`positivity_variables_cons` and | ||
# `positivity_variables_nonlinear`) are overwritten and used in the tests. | ||
|
||
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp; | ||
volume_flux_dg = volume_flux, | ||
volume_flux_fv = surface_flux) | ||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
# Get the curved quad mesh from a mapping function | ||
# Mapping as described in https://arxiv.org/abs/2012.12040 | ||
function mapping(xi, eta) | ||
y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta)) | ||
|
||
x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y)) | ||
|
||
return SVector(x, y) | ||
end | ||
|
||
cells_per_dimension = (16, 16) | ||
mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = false) | ||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 3.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.7) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, alive_callback, | ||
save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
stage_callbacks = (SubcellLimiterIDPCorrection(), BoundsCheckCallback()) | ||
|
||
sol = Trixi.solve(ode, Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks); | ||
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,66 @@ | ||
|
||
using Convex, ECOS | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the linear advection equation | ||
|
||
advection_velocity = 1.0 | ||
equations = LinearScalarAdvectionEquation1D(advection_velocity) | ||
|
||
# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux | ||
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) | ||
|
||
coordinates_min = -1.0 # minimum coordinate | ||
coordinates_max = 1.0 # maximum coordinate | ||
|
||
# Create a uniformly refined mesh with periodic boundaries | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 4, | ||
n_cells_max = 30_000) # set maximum capacity of tree data structure | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, | ||
solver) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
# Create ODE problem with time span from 0.0 to 20.0 | ||
tspan = (0.0, 20.0) | ||
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_interval = 100 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step | ||
stepsize_callback = StepsizeCallback(cfl = 2.5) | ||
|
||
alive_callback = AliveCallback(alive_interval = analysis_interval) | ||
|
||
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver | ||
callbacks = CallbackSet(summary_callback, | ||
alive_callback, | ||
analysis_callback, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# Construct second order paired explicit Runge-Kutta method with 6 stages for given simulation setup. | ||
# Pass `tspan` to calculate maximum time step allowed for the bisection algorithm used | ||
# in calculating the polynomial coefficients in the ODE algorithm. | ||
ode_algorithm = Trixi.PairedExplicitRK2(6, tspan, semi) | ||
|
||
sol = Trixi.solve(ode, ode_algorithm, | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
|
||
# Print the timer summary | ||
summary_callback() |
Oops, something went wrong.