forked from trixi-framework/Trixi.jl
-
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.
Merge pull request #116 from amrueda/subcell_positivity_nonconservative
Add support for non nonconservative equations to subcell-limiting
- Loading branch information
Showing
104 changed files
with
15,507 additions
and
9,608 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,7 +1,7 @@ | ||
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.5.47-pre" | ||
version = "0.5.48-pre" | ||
|
||
[deps] | ||
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" | ||
|
110 changes: 110 additions & 0 deletions
110
examples/tree_2d_dgsem/elixir_mhd_shockcapturing_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,110 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the compressible ideal GLM-MHD equations | ||
|
||
equations = IdealGlmMhdEquations2D(1.4) | ||
|
||
""" | ||
initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations2D) | ||
An MHD blast wave modified from: | ||
- Dominik Derigs, Gregor J. Gassner, Stefanie Walch & Andrew R. Winters (2018) | ||
Entropy Stable Finite Volume Approximations for Ideal Magnetohydrodynamics | ||
[doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) | ||
This setup needs a positivity limiter for the density. | ||
""" | ||
function initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations2D) | ||
# setup taken from Derigs et al. DMV article (2018) | ||
# domain must be [-0.5, 0.5] x [-0.5, 0.5], γ = 1.4 | ||
r = sqrt(x[1]^2 + x[2]^2) | ||
|
||
pmax = 10.0 | ||
pmin = 0.01 | ||
rhomax = 1.0 | ||
rhomin = 0.01 | ||
if r <= 0.09 | ||
p = pmax | ||
rho = rhomax | ||
elseif r >= 0.1 | ||
p = pmin | ||
rho = rhomin | ||
else | ||
p = pmin + (0.1 - r) * (pmax - pmin) / 0.01 | ||
rho = rhomin + (0.1 - r) * (rhomax - rhomin) / 0.01 | ||
end | ||
v1 = 0.0 | ||
v2 = 0.0 | ||
v3 = 0.0 | ||
B1 = 1.0/sqrt(4.0*pi) | ||
B2 = 0.0 | ||
B3 = 0.0 | ||
psi = 0.0 | ||
return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) | ||
end | ||
initial_condition = initial_condition_blast_wave | ||
|
||
surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell_local_symmetric) | ||
volume_flux = (flux_derigs_etal, flux_nonconservative_powell_local_symmetric) | ||
basis = LobattoLegendreBasis(3) | ||
|
||
limiter_idp = SubcellLimiterIDP(equations, basis; | ||
positivity_variables_cons=[1], | ||
positivity_variables_nonlinear=[pressure], | ||
positivity_correction_factor=0.1, | ||
bar_states=false) | ||
volume_integral = VolumeIntegralSubcellLimiting(limiter_idp; | ||
volume_flux_dg=volume_flux, | ||
volume_flux_fv=surface_flux) | ||
solver = DGSEM(basis, surface_flux, volume_integral) | ||
|
||
coordinates_min = (-0.5, -0.5) | ||
coordinates_max = ( 0.5, 0.5) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level=4, | ||
n_cells_max=10_000) | ||
|
||
|
||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 0.1) | ||
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) | ||
|
||
cfl = 0.4 | ||
stepsize_callback = StepsizeCallback(cfl=cfl) | ||
|
||
glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, | ||
alive_callback, | ||
save_solution, | ||
stepsize_callback, | ||
glm_speed_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
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,93 @@ | ||
|
||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the linear advection equation | ||
|
||
advection_velocity = (0.2, -0.7, 0.5) | ||
equations = LinearScalarAdvectionEquation3D(advection_velocity) | ||
|
||
diffusivity() = 5.0e-4 | ||
equations_parabolic = LaplaceDiffusion3D(diffusivity(), equations) | ||
|
||
solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) | ||
|
||
coordinates_min = (-1.0, -1.0, -1.0) | ||
coordinates_max = ( 1.0, 1.0, 1.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level=4, | ||
n_cells_max=80_000) | ||
|
||
# Define initial condition | ||
function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation3D) | ||
# Store translated coordinate for easy use of exact solution | ||
x_trans = x - equation.advection_velocity * t | ||
|
||
nu = diffusivity() | ||
c = 1.0 | ||
A = 0.5 | ||
L = 2 | ||
f = 1/L | ||
omega = 2 * pi * f | ||
scalar = c + A * sin(omega * sum(x_trans)) * exp(-2 * nu * omega^2 * t) | ||
return SVector(scalar) | ||
end | ||
initial_condition = initial_condition_diffusive_convergence_test | ||
|
||
# define periodic boundary conditions everywhere | ||
boundary_conditions = boundary_condition_periodic | ||
boundary_conditions_parabolic = boundary_condition_periodic | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolicParabolic(mesh, | ||
(equations, equations_parabolic), | ||
initial_condition, solver; | ||
boundary_conditions=(boundary_conditions, | ||
boundary_conditions_parabolic)) | ||
|
||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 0.2) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 100 | ||
analysis_callback = AnalysisCallback(semi, interval=analysis_interval, | ||
extra_analysis_integrals=(entropy,)) | ||
|
||
alive_callback = AliveCallback(analysis_interval=analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval=100, | ||
save_initial_solution=true, | ||
save_final_solution=true, | ||
solution_variables=cons2prim) | ||
|
||
amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), | ||
base_level=3, | ||
med_level=4, med_threshold=1.2, | ||
max_level=5, max_threshold=1.45) | ||
amr_callback = AMRCallback(semi, amr_controller, | ||
interval=5, | ||
adapt_initial_condition=true, | ||
adapt_initial_condition_only_refine=true) | ||
|
||
stepsize_callback = StepsizeCallback(cfl=1.0) | ||
|
||
callbacks = CallbackSet(summary_callback, | ||
analysis_callback, | ||
alive_callback, | ||
save_solution, | ||
amr_callback, | ||
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 |
Oops, something went wrong.