Skip to content

Commit 23bc964

Browse files
Arpit-BabbarranochaDanielDoehringJoshuaLampert
authored
Add passive tracers (#2364)
* Add passive tracers * Add missing tests * Fix in IC, improve coverage * Coverage for new functions * Revert accidental changes to an elixir * Some functions were actually untested * Apply suggestions from code review Co-authored-by: Hendrik Ranocha <[email protected]> Co-authored-by: Daniel Doehring <[email protected]> * Suggestions from code review * Remove FluxUpwind for now * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * Apply suggestions from code review * Propogate non-conservative terms * Mention non-conservative equations support * Apply suggestions from code review Co-authored-by: Hendrik Ranocha <[email protected]> * Remove redundant code from suggestion * Update examples/tree_1d_dgsem/elixir_euler_density_wave_tracers.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> --------- Co-authored-by: Hendrik Ranocha <[email protected]> Co-authored-by: Daniel Doehring <[email protected]> Co-authored-by: Joshua Lampert <[email protected]>
1 parent 537a275 commit 23bc964

15 files changed

+633
-9
lines changed

NEWS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ for human readability.
1212

1313
- Added the three-dimensional multi-ion magneto-hydrodynamics (MHD) equations with a
1414
generalized Lagrange multipliers (GLM) divergence cleaning technique ([#2215]).
15-
- New time integrator `PairedExplicitRK4`, implementing the fourth-order
15+
- New time integrator `PairedExplicitRK4`, implementing the fourth-order
1616
paired explicit Runge-Kutta method with [Convex.jl](https://github.com/jump-dev/Convex.jl)
1717
and [ECOS.jl](https://github.com/jump-dev/ECOS.jl) ([#2147])
18+
- Passive tracers for arbitrary equations with density and flow variables ([#2364])
1819

1920

2021
## Changes when updating to v0.11 from v0.10.x
@@ -29,9 +30,9 @@ for human readability.
2930
instructions for Trixi.jl have been updated accordingly.
3031
- The output of the `SummaryCallback` will automatically be printed after the simulation
3132
is finished. Therefore, manually calling `summary_callback()` is not necessary anymore ([#2275]).
32-
- The two performance numbers (local `time/DOF/rhs!` and performance index `PID`)
33-
are now computed taking into account the number of threads ([#2292]). This allows
34-
for a better comparison of shared memory (threads) and hybrid (MPI + threads) simulations
33+
- The two performance numbers (local `time/DOF/rhs!` and performance index `PID`)
34+
are now computed taking into account the number of threads ([#2292]). This allows
35+
for a better comparison of shared memory (threads) and hybrid (MPI + threads) simulations
3536
with serial simulations.
3637

3738
#### Deprecated
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK
2+
using Trixi
3+
4+
###############################################################################
5+
# semidiscretization of the compressible Euler equations
6+
# with two additional passive tracer variables
7+
gamma = 1.4
8+
flow_equations = CompressibleEulerEquations2D(gamma)
9+
equations = PassiveTracerEquations(flow_equations, n_tracers = 2)
10+
11+
initial_condition = initial_condition_density_wave
12+
13+
solver = DGSEM(polydeg = 5, surface_flux = FluxTracerEquationsCentral(flux_ranocha))
14+
15+
coordinates_min = (-1.0, -1.0)
16+
coordinates_max = (1.0, 1.0)
17+
trees_per_dimension = (4, 4)
18+
19+
mesh = P4estMesh(trees_per_dimension, polydeg = 3,
20+
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
21+
initial_refinement_level = 0)
22+
23+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
24+
25+
###############################################################################
26+
# ODE solvers, callbacks etc.
27+
28+
tspan = (0.0, 2.0)
29+
ode = semidiscretize(semi, tspan)
30+
31+
summary_callback = SummaryCallback()
32+
33+
analysis_interval = 100
34+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
35+
36+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
37+
38+
save_solution = SaveSolutionCallback(interval = 100,
39+
save_initial_solution = true,
40+
save_final_solution = true,
41+
solution_variables = cons2prim)
42+
43+
stepsize_callback = StepsizeCallback(cfl = 1.6)
44+
45+
callbacks = CallbackSet(summary_callback,
46+
analysis_callback, alive_callback,
47+
save_solution,
48+
stepsize_callback)
49+
50+
###############################################################################
51+
# run the simulation
52+
53+
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
54+
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
55+
ode_default_options()..., callback = callbacks);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK
2+
using Trixi
3+
4+
###############################################################################
5+
# semidiscretization of the compressible Euler equations
6+
# with two additional passive tracer variables
7+
flow_equations = CompressibleEulerEquations1D(1.4)
8+
equations = PassiveTracerEquations(flow_equations, n_tracers = 2)
9+
10+
initial_condition = initial_condition_density_wave
11+
12+
volume_flux = FluxTracerEquationsCentral(flux_ranocha)
13+
14+
solver = DGSEM(polydeg = 3,
15+
surface_flux = flux_lax_friedrichs,
16+
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
17+
18+
coordinates_min = -1.0
19+
coordinates_max = 1.0
20+
mesh = TreeMesh(coordinates_min, coordinates_max,
21+
initial_refinement_level = 2,
22+
n_cells_max = 30_000)
23+
24+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
25+
26+
###############################################################################
27+
# ODE solvers, callbacks etc.
28+
29+
tspan = (0.0, 2.0)
30+
ode = semidiscretize(semi, tspan)
31+
32+
summary_callback = SummaryCallback()
33+
34+
analysis_interval = 2000
35+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
36+
37+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
38+
39+
save_solution = SaveSolutionCallback(interval = 100,
40+
save_initial_solution = true,
41+
save_final_solution = true,
42+
solution_variables = cons2prim)
43+
44+
stepsize_callback = StepsizeCallback(cfl = 0.8)
45+
46+
callbacks = CallbackSet(summary_callback,
47+
analysis_callback, alive_callback,
48+
save_solution,
49+
stepsize_callback)
50+
51+
###############################################################################
52+
# run the simulation
53+
54+
sol = solve(ode,
55+
CarpenterKennedy2N54(williamson_condition = false);
56+
dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback
57+
ode_default_options()..., callback = callbacks);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK
2+
using Trixi
3+
4+
###############################################################################
5+
# semidiscretization of the compressible Euler equations
6+
# with two additional passive tracer variables
7+
gamma = 1.4
8+
flow_equations = CompressibleEulerEquations2D(gamma)
9+
equations = PassiveTracerEquations(flow_equations, n_tracers = 2)
10+
11+
initial_condition = initial_condition_density_wave
12+
13+
solver = DGSEM(polydeg = 5, surface_flux = FluxTracerEquationsCentral(flux_ranocha))
14+
15+
coordinates_min = (-1.0, -1.0)
16+
coordinates_max = (1.0, 1.0)
17+
mesh = TreeMesh(coordinates_min, coordinates_max,
18+
initial_refinement_level = 2,
19+
n_cells_max = 30_000)
20+
21+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
22+
23+
###############################################################################
24+
# ODE solvers, callbacks etc.
25+
26+
tspan = (0.0, 2.0)
27+
ode = semidiscretize(semi, tspan)
28+
29+
summary_callback = SummaryCallback()
30+
31+
analysis_interval = 100
32+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
33+
34+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
35+
36+
save_solution = SaveSolutionCallback(interval = 100,
37+
save_initial_solution = true,
38+
save_final_solution = true,
39+
solution_variables = cons2prim)
40+
41+
stepsize_callback = StepsizeCallback(cfl = 1.6)
42+
43+
callbacks = CallbackSet(summary_callback,
44+
analysis_callback, alive_callback,
45+
save_solution,
46+
stepsize_callback)
47+
48+
###############################################################################
49+
# run the simulation
50+
51+
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false);
52+
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
53+
ode_default_options()..., callback = callbacks);

src/Trixi.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ export AcousticPerturbationEquations2D,
170170
LinearizedEulerEquations1D, LinearizedEulerEquations2D, LinearizedEulerEquations3D,
171171
PolytropicEulerEquations2D,
172172
TrafficFlowLWREquations1D,
173-
MaxwellEquations1D
173+
MaxwellEquations1D,
174+
PassiveTracerEquations
174175

175176
export LaplaceDiffusion1D, LaplaceDiffusion2D, LaplaceDiffusion3D,
176177
CompressibleNavierStokesDiffusion1D, CompressibleNavierStokesDiffusion2D,
@@ -197,7 +198,8 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle,
197198
FluxRotated,
198199
flux_shima_etal_turbo, flux_ranocha_turbo,
199200
FluxHydrostaticReconstruction,
200-
FluxUpwind
201+
FluxUpwind,
202+
FluxTracerEquationsCentral
201203

202204
export splitting_steger_warming, splitting_vanleer_haenel,
203205
splitting_coirier_vanleer, splitting_lax_friedrichs,

src/equations/compressible_euler_1d.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,10 @@ function flux_hllc(u_ll, u_rr, orientation::Integer,
894894
end
895895

896896
# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that
897-
# the normal component is incorporated into the numerical flux.
897+
# the normal component is incorporated into the numerical flux.
898898
#
899-
# The HLLC flux along a 1D "normal" can be evaluated by scaling the velocity/momentum by
900-
# the normal for the 1D HLLC flux, then scaling the resulting momentum flux again.
899+
# The HLLC flux along a 1D "normal" can be evaluated by scaling the velocity/momentum by
900+
# the normal for the 1D HLLC flux, then scaling the resulting momentum flux again.
901901
# Moreover, the 2D HLLC flux reduces to this if the normal vector is [n, 0].
902902
function flux_hllc(u_ll, u_rr, normal_direction::AbstractVector,
903903
equations::CompressibleEulerEquations1D)
@@ -1040,6 +1040,11 @@ end
10401040
return rho
10411041
end
10421042

1043+
@inline function velocity(u, orientation_or_normal,
1044+
equations::CompressibleEulerEquations1D)
1045+
return velocity(u, equations)
1046+
end
1047+
10431048
@inline function velocity(u, equations::CompressibleEulerEquations1D)
10441049
rho = u[1]
10451050
v1 = u[2] / rho

src/equations/equations.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <:
563563
AbstractEquations{NDIMS, NVARS} end
564564
include("polytropic_euler_2d.jl")
565565

566+
# Passive tracer equations
567+
include("passive_tracers.jl")
568+
566569
# Retrieve number of components from equation instance for the multicomponent case
567570
@inline function ncomponents(::AbstractCompressibleEulerMulticomponentEquations{NDIMS,
568571
NVARS,

0 commit comments

Comments
 (0)