From c6882c7ea2ca6405b53cb0a96da40bf6eda392c3 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 20 Jun 2023 18:17:40 +0200 Subject: [PATCH 01/22] Add Classical and Naive HLL 2 Wave solver to classic Hyperbolic PDEs --- src/equations/compressible_euler_1d.jl | 24 +++- src/equations/compressible_euler_2d.jl | 50 ++++++- src/equations/compressible_euler_3d.jl | 57 +++++++- src/equations/ideal_glm_mhd_1d.jl | 62 ++++++++- src/equations/ideal_glm_mhd_2d.jl | 140 +++++++++++++++++-- src/equations/ideal_glm_mhd_3d.jl | 181 +++++++++++++++++++++++-- src/equations/linearized_euler_2d.jl | 44 ++++++ src/equations/numerical_fluxes.jl | 1 + src/equations/shallow_water_1d.jl | 30 +++- src/equations/shallow_water_2d.jl | 53 +++++++- 10 files changed, 609 insertions(+), 33 deletions(-) diff --git a/src/equations/compressible_euler_1d.jl b/src/equations/compressible_euler_1d.jl index f484f26a588..6f360bb5edd 100644 --- a/src/equations/compressible_euler_1d.jl +++ b/src/equations/compressible_euler_1d.jl @@ -628,7 +628,7 @@ end return SVector(f1m, f2m, f3m) end -# Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the +# Calculate estimates for maximum wave speed for local Lax-Friedrichs-type dissipation as the # maximum velocity magnitude plus the maximum speed of sound @inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations1D) @@ -648,7 +648,7 @@ end λ_max = max(v_mag_ll, v_mag_rr) + max(c_ll, c_rr) end -# Calculate minimum and maximum wave speeds for HLL-type fluxes +# Calculate estimates for minimum and maximum wave speeds for HLL-type fluxes @inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations1D) rho_ll, v1_ll, p_ll = cons2prim(u_ll, equations) @@ -660,6 +660,26 @@ end return λ_min, λ_max end +""" + min_max_speed(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations1D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations1D) + rho_ll, v1_ll, p_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, p_rr = cons2prim(u_rr, equations) + + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + λ_min = min(v1_ll - c_ll, v1_rr - c_rr) + λ_max = max(v1_ll + c_ll, v1_rr + c_rr) + + return λ_min, λ_max +end + + """ flux_hllc(u_ll, u_rr, orientation, equations::CompressibleEulerEquations1D) diff --git a/src/equations/compressible_euler_2d.jl b/src/equations/compressible_euler_2d.jl index 66e3c7bff84..5669ac3a810 100644 --- a/src/equations/compressible_euler_2d.jl +++ b/src/equations/compressible_euler_2d.jl @@ -1032,7 +1032,8 @@ end return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction) end -# Calculate minimum and maximum wave speeds for HLL-type fluxes + +# Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes @inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations2D) rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations) @@ -1065,6 +1066,53 @@ end return λ_min, λ_max end +""" + min_max_speed(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations2D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations2D) + rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr, p_rr = cons2prim(u_rr, equations) + + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + if orientation == 1 # x-direction + λ_min = min(v1_ll - c_ll, v1_rr - c_rr) + λ_max = max(v1_ll + c_ll, v1_rr + c_rr) + else # y-direction + λ_min = min(v2_ll - c_ll, v2_rr - c_rr) + λ_max = max(v2_ll + c_ll, v2_rr + c_rr) + end + + return λ_min, λ_max +end + +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, + equations::CompressibleEulerEquations2D) + rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr, p_rr = cons2prim(u_rr, equations) + + norm_ = norm(normal_direction) + + c_ll = sqrt(equations.gamma * p_ll / rho_ll) * norm_ + c_rr = sqrt(equations.gamma * p_rr / rho_rr) * norm_ + + v_normal_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + v_normal_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # The v_normals are already scaled by the norm + λ_min = min(v_normal_ll - c_ll, v_normal_rr - c_rr) + λ_max = max(v_normal_ll + c_ll, v_normal_rr + c_rr) + + return λ_min, λ_max +end + + # Called inside `FluxRotated` in `numerical_fluxes.jl` so the direction # has been normalized prior to this rotation of the state vector @inline function rotate_to_x(u, normal_vector, equations::CompressibleEulerEquations2D) diff --git a/src/equations/compressible_euler_3d.jl b/src/equations/compressible_euler_3d.jl index c16a454b176..b024cb79bd8 100644 --- a/src/equations/compressible_euler_3d.jl +++ b/src/equations/compressible_euler_3d.jl @@ -1070,7 +1070,7 @@ end return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction) end -# Calculate minimum and maximum wave speeds for HLL-type fluxes +# Calculate estimates for minimum and maximum wave speeds for HLL-type fluxes @inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations3D) rho_ll, v1_ll, v2_ll, v3_ll, p_ll = cons2prim(u_ll, equations) @@ -1108,6 +1108,61 @@ end return λ_min, λ_max end +""" + min_max_speed(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations3D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations3D) + rho_ll, v1_ll, v2_ll, v3_ll, p_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr, v3_rr, p_rr = cons2prim(u_rr, equations) + + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + if orientation == 1 # x-direction + λ_min = min(v1_ll - c_ll, v1_rr - c_rr) + λ_max = max(v1_ll + c_ll, v1_rr + c_rr) + elseif orientation == 2 # y-direction + λ_min = min(v2_ll - c_ll, v2_rr - c_rr) + λ_max = max(v2_ll + c_ll, v2_rr + c_rr) + else # z-direction + λ_min = min(v3_ll - c_ll, v3_rr - c_rr) + λ_max = max(v3_ll + c_ll, v3_rr + c_rr) + end + + return λ_min, λ_max +end + +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, + equations::CompressibleEulerEquations3D) + rho_ll, v1_ll, v2_ll, v3_ll, p_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr, v3_rr, p_rr = cons2prim(u_rr, equations) + + norm_ = norm(normal_direction) + + c_ll = sqrt(equations.gamma * p_ll / rho_ll) * norm_ + c_rr = sqrt(equations.gamma * p_rr / rho_rr) * norm_ + + v_normal_ll = + v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3] + v_normal_rr = + v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3] + + # The v_normals are already scaled by the norm + λ_min = min(v_normal_ll - c_ll, v_normal_rr - c_rr) + λ_max = max(v_normal_ll + c_ll, v_normal_rr + c_rr) + + return λ_min, λ_max +end + # Rotate normal vector to x-axis; normal, tangent1 and tangent2 need to be orthonormal # Called inside `FluxRotated` in `numerical_fluxes.jl` so the directions # has been normalized prior to this rotation of the state vector diff --git a/src/equations/ideal_glm_mhd_1d.jl b/src/equations/ideal_glm_mhd_1d.jl index 4ef593cda53..70a3a493e66 100644 --- a/src/equations/ideal_glm_mhd_1d.jl +++ b/src/equations/ideal_glm_mhd_1d.jl @@ -277,16 +277,70 @@ end λ_max = max(abs(v_ll), abs(v_rr)) + max(cf_ll, cf_rr) end + +# Calculate estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) + rho_ll, rho_v1_ll, _ = u_ll + rho_rr, rho_v1_rr, _ = u_rr + + # Calculate primitive variables + v1_ll = rho_v1_ll / rho_ll + v1_rr = rho_v1_rr / rho_rr + + λ_min = v1_ll - calc_fast_wavespeed(u_ll, orientation, equations) + λ_max = v1_rr + calc_fast_wavespeed(u_rr, orientation, equations) + + return λ_min, λ_max +end + + """ - min_max_speed_naive(u_ll, u_rr, orientation, equations::IdealGlmMhdEquations1D) + min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations1D) + rho_ll, rho_v1_ll, _ = u_ll + rho_rr, rho_v1_rr, _ = u_rr + + # Calculate primitive variables + v1_ll = rho_v1_ll / rho_ll + v1_rr = rho_v1_rr / rho_rr + + # Approximate the left-most and right-most eigenvalues in the Riemann fan + c_f_ll = calc_fast_wavespeed(u_ll, orientation, equations) + c_f_rr = calc_fast_wavespeed(u_rr, orientation, equations) + + λ_min = min(v1_ll - c_f_ll, v1_rr - c_f_rr) + λ_max = max(v1_ll + c_f_ll, v1_rr + c_f_rr) + + return λ_min, λ_max +end + + +""" + min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) Calculate minimum and maximum wave speeds for HLL-type fluxes as in - Li (2005) An HLLC Riemann solver for magneto-hydrodynamics - [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020) + [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020). + +This is the generalization to MHD from the works +- Bernd Einfeldt (1988) + On Godunov-type methods for gas dynamics. + [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) +- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) + On Godunov-type methods near low densities. + [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) + +originally developed for the compressible Euler equations. +A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, - equations::IdealGlmMhdEquations1D) +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations1D) rho_ll, rho_v1_ll, _ = u_ll rho_rr, rho_v1_rr, _ = u_rr diff --git a/src/equations/ideal_glm_mhd_2d.jl b/src/equations/ideal_glm_mhd_2d.jl index fb3048fe883..21d7ac45db5 100644 --- a/src/equations/ideal_glm_mhd_2d.jl +++ b/src/equations/ideal_glm_mhd_2d.jl @@ -585,16 +585,138 @@ end return max(abs(v_ll), abs(v_rr)) + max(cf_ll, cf_rr) end +# Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations2D) + rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr + + # Calculate primitive velocity variables + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + + # Approximate the left-most and right-most eigenvalues in the Riemann fan + if orientation == 1 # x-direction + λ_min = v1_ll - calc_fast_wavespeed(u_ll, orientation, equations) + λ_max = v1_rr + calc_fast_wavespeed(u_rr, orientation, equations) + else # y-direction + λ_min = v2_ll - calc_fast_wavespeed(u_ll, orientation, equations) + λ_max = v2_rr + calc_fast_wavespeed(u_rr, orientation, equations) + end + + return λ_min, λ_max +end + +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations2D) + rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr + + # Calculate primitive velocity variables + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + + v_normal_ll = (v1_ll * normal_direction[1] + v2_ll * normal_direction[2]) + v_normal_rr = (v1_rr * normal_direction[1] + v2_rr * normal_direction[2]) + + c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) + c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) + + # Estimate the min/max eigenvalues in the normal direction + λ_min = min(v_normal_ll - c_f_ll, v_normal_rr - c_f_rr) + λ_max = max(v_normal_rr + c_f_rr, v_normal_rr + c_f_rr) + + return λ_min, λ_max +end + """ - min_max_speed_naive(u_ll, u_rr, orientation, equations::IdealGlmMhdEquations2D) + min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations2D) + rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr + + # Calculate primitive velocity variables + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + + # Approximate the left-most and right-most eigenvalues in the Riemann fan + if orientation == 1 # x-direction + c_f_ll = calc_fast_wavespeed(u_ll, orientation, equations) + c_f_rr = calc_fast_wavespeed(u_rr, orientation, equations) + + λ_min = min(v1_ll - c_f_ll, v1_rr - c_f_rr) + λ_max = max(v1_ll + c_f_ll, v1_rr + c_f_rr) + else # y-direction + c_f_ll = calc_fast_wavespeed(u_ll, orientation, equations) + c_f_rr = calc_fast_wavespeed(u_rr, orientation, equations) + + λ_min = min(v2_ll - c_f_ll, v2_rr - c_f_rr) + λ_max = max(v2_ll + c_f_ll, v1_rr + c_f_rr) + end + + return λ_min, λ_max +end + +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations2D) + rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr + + # Calculate primitive velocity variables + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + + v_normal_ll = (v1_ll * normal_direction[1] + v2_ll * normal_direction[2]) + v_normal_rr = (v1_rr * normal_direction[1] + v2_rr * normal_direction[2]) + + c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) + c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) + + # Estimate the min/max eigenvalues in the normal direction + λ_min = min(v_normal_ll - c_f_ll, v_normal_rr - c_f_rr) + λ_max = max(v_normal_ll + c_f_ll, v_normal_rr + c_f_rr) + + return λ_min, λ_max +end + +""" + min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) Calculate minimum and maximum wave speeds for HLL-type fluxes as in - Li (2005) An HLLC Riemann solver for magneto-hydrodynamics - [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020) + [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020). + +This is the generalization to MHD from the works +- Bernd Einfeldt (1988) + On Godunov-type methods for gas dynamics. + [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) +- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) + On Godunov-type methods near low densities. + [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) + +originally developed for the compressible Euler equations. +A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, - equations::IdealGlmMhdEquations2D) +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -623,8 +745,8 @@ Calculate minimum and maximum wave speeds for HLL-type fluxes as in return λ_min, λ_max end -@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, - equations::IdealGlmMhdEquations2D) +@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -635,10 +757,8 @@ end v1_rr = rho_v1_rr / rho_rr v2_rr = rho_v2_rr / rho_rr - v_normal_ll = (v1_ll * normal_direction[1] + - v2_ll * normal_direction[2]) - v_normal_rr = (v1_rr * normal_direction[1] + - v2_rr * normal_direction[2]) + v_normal_ll = (v1_ll * normal_direction[1] + v2_ll * normal_direction[2]) + v_normal_rr = (v1_rr * normal_direction[1] + v2_rr * normal_direction[2]) c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) diff --git a/src/equations/ideal_glm_mhd_3d.jl b/src/equations/ideal_glm_mhd_3d.jl index 401fcd2daf1..8eb44acc6a7 100644 --- a/src/equations/ideal_glm_mhd_3d.jl +++ b/src/equations/ideal_glm_mhd_3d.jl @@ -670,16 +670,169 @@ end return max(abs(v_ll), abs(v_rr)) + max(cf_ll, cf_rr) end +# Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations3D) + rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr + + # Calculate primitive variables and speed of sound + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + v3_ll = rho_v3_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + v3_rr = rho_v3_rr / rho_rr + + # Approximate the left-most and right-most eigenvalues in the Riemann fan + if orientation == 1 # x-direction + λ_min = v1_ll - calc_fast_wavespeed(u_ll, orientation, equations) + λ_max = v1_rr + calc_fast_wavespeed(u_rr, orientation, equations) + elseif orientation == 2 # y-direction + λ_min = v2_ll - calc_fast_wavespeed(u_ll, orientation, equations) + λ_max = v2_rr + calc_fast_wavespeed(u_rr, orientation, equations) + else # z-direction + λ_min = v3_ll - calc_fast_wavespeed(u_ll, orientation, equations) + λ_max = v3_rr + calc_fast_wavespeed(u_rr, orientation, equations) + end + + return λ_min, λ_max +end + +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations3D) + rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr + + # Calculate primitive velocity variables + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + v3_ll = rho_v3_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + v3_rr = rho_v3_rr / rho_rr + + v_normal_ll = ( + v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3] + ) + v_normal_rr = ( + v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3] + ) + + # Estimate the min/max eigenvalues in the normal direction + λ_min = v_normal_ll - calc_fast_wavespeed(u_ll, normal_direction, equations) + λ_max = v_normal_rr + calc_fast_wavespeed(u_rr, normal_direction, equations) + + return λ_min, λ_max +end + +""" + min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations3D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations3D) + rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr + + # Calculate primitive variables and speed of sound + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + v3_ll = rho_v3_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + v3_rr = rho_v3_rr / rho_rr + + # Approximate the left-most and right-most eigenvalues in the Riemann fan + if orientation == 1 # x-direction + c_f_ll = calc_fast_wavespeed(u_ll, orientation, equations) + c_f_rr = calc_fast_wavespeed(u_rr, orientation, equations) + + λ_min = min(v1_ll - c_f_ll, v1_rr - c_f_rr) + λ_max = max(v1_ll + c_f_ll, v1_rr + c_f_rr) + elseif orientation == 2 # y-direction + c_f_ll = calc_fast_wavespeed(u_ll, orientation, equations) + c_f_rr = calc_fast_wavespeed(u_rr, orientation, equations) + + λ_min = min(v2_ll - c_f_ll, v2_rr - c_f_rr) + λ_max = max(v2_ll + c_f_ll, v2_rr + c_f_rr) + else # z-direction + c_f_ll = calc_fast_wavespeed(u_ll, orientation, equations) + c_f_rr = calc_fast_wavespeed(u_rr, orientation, equations) + + λ_min = min(v3_ll - c_f_ll, v3_rr - c_f_rr) + λ_max = max(v3_ll + c_f_ll, v3_rr + c_f_rr) + end + + return λ_min, λ_max +end + +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations3D) + rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll + rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr + + # Calculate primitive velocity variables + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + v3_ll = rho_v3_ll / rho_ll + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + v3_rr = rho_v3_rr / rho_rr + + v_normal_ll = ( + v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3] + ) + v_normal_rr = ( + v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3] + ) + + c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) + c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) + + # Estimate the min/max eigenvalues in the normal direction + λ_min = min(v_normal_ll - c_f_ll, v_normal_rr - c_f_rr) + λ_max = max(v_normal_ll + c_f_ll, v_normal_rr + c_f_rr) + + return λ_min, λ_max +end + + """ - min_max_speed_naive(u_ll, u_rr, orientation_or_normal_direction, equations::IdealGlmMhdEquations3D) + min_max_speed_einfeldt(u_ll, u_rr, orientation_or_normal_direction, equations::IdealGlmMhdEquations3D) Calculate minimum and maximum wave speeds for HLL-type fluxes as in - Li (2005) An HLLC Riemann solver for magneto-hydrodynamics [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020) -""" -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, - equations::IdealGlmMhdEquations3D) + +This is the generalization to MHD from the works + - Bernd Einfeldt (1988) + On Godunov-type methods for gas dynamics. + [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) + - Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) + On Godunov-type methods near low densities. + [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) + + originally developed for the compressible Euler equations. + A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). + """ +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -716,8 +869,8 @@ Calculate minimum and maximum wave speeds for HLL-type fluxes as in return λ_min, λ_max end -@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, - equations::IdealGlmMhdEquations3D) +@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -730,12 +883,16 @@ end v2_rr = rho_v2_rr / rho_rr v3_rr = rho_v3_rr / rho_rr - v_normal_ll = (v1_ll * normal_direction[1] + - v2_ll * normal_direction[2] + - v3_ll * normal_direction[3]) - v_normal_rr = (v1_rr * normal_direction[1] + - v2_rr * normal_direction[2] + - v3_rr * normal_direction[3]) + v_normal_ll = ( + v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3] + ) + v_normal_rr = ( + v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3] + ) c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) diff --git a/src/equations/linearized_euler_2d.jl b/src/equations/linearized_euler_2d.jl index cd681365cae..3ebd0f736ba 100644 --- a/src/equations/linearized_euler_2d.jl +++ b/src/equations/linearized_euler_2d.jl @@ -143,6 +143,50 @@ end end end +# Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, + equations::LinearizedEulerEquations2D) + min_max_speed(u_ll, u_rr, orientation, equations) +end + +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::LinearizedEulerEquations2D) + min_max_speed(u_ll, u_rr, normal_direction, equations) +end + +""" + min_max_speed(u_ll, u_rr, orientation::Integer, + equations::LinearizedEulerEquations2D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::LinearizedEulerEquations2D) + @unpack v_mean_global, c_mean_global = equations + + λ_min = v_mean_global[orientation] - c_mean_global + λ_max = v_mean_global[orientation] + c_mean_global + + return λ_min, λ_max +end + +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, + equations::LinearizedEulerEquations2D) + @unpack v_mean_global, c_mean_global = equations + + norm_ = norm(normal_direction) + + v_normal = + v_mean_global[1] * normal_direction[1] + v_mean_global[2] * normal_direction[2] + + # The v_normals are already scaled by the norm + λ_min = v_normal - c_mean_global * norm_ + λ_max = v_normal + c_mean_global * norm_ + + return λ_min, λ_max +end + # Convert conservative variables to primitive @inline cons2prim(u, equations::LinearizedEulerEquations2D) = u @inline cons2entropy(u, ::LinearizedEulerEquations2D) = u diff --git a/src/equations/numerical_fluxes.jl b/src/equations/numerical_fluxes.jl index 16a83124d14..e26ea28f869 100644 --- a/src/equations/numerical_fluxes.jl +++ b/src/equations/numerical_fluxes.jl @@ -219,6 +219,7 @@ struct FluxHLL{MinMaxSpeed} min_max_speed::MinMaxSpeed end +# TODO: Change to min_max_speed (Not naive version!) FluxHLL() = FluxHLL(min_max_speed_naive) """ diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index 851cbacdd57..28fc648335d 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -460,8 +460,8 @@ end end end -# Calculate minimum and maximum wave speeds for HLL-type fluxes -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, +# Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations1D) h_ll = waterheight(u_ll, equations) v_ll = velocity(u_ll, equations) @@ -474,6 +474,32 @@ end return λ_min, λ_max end + +""" + min_max_speed(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations1D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations1D) + h_ll = waterheight(u_ll, equations) + v_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v_rr = velocity(u_rr, equations) + + c_ll = sqrt(equations.gravity * h_ll) + c_rr = sqrt(equations.gravity * h_rr) + + λ_min = min(v_ll - c_ll, v_rr - c_rr) + λ_max = max(v_rr + c_rr, v_rr + c_rr) + + return λ_min, λ_max +end + +# TODO: min_max_speed_einfeldt (Requires Roe matrix) + @inline function max_abs_speeds(u, equations::ShallowWaterEquations1D) h = waterheight(u, equations) v = velocity(u, equations) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index f9ebbd597f9..1b95212ad26 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -725,7 +725,7 @@ end end end -# Calculate minimum and maximum wave speeds for HLL-type fluxes +# Calculate estimates for minimum and maximum wave speeds for HLL-type fluxes @inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) @@ -762,6 +762,57 @@ end return λ_min, λ_max end +""" + min_max_speed(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations2D) + +Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) +or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations2D) + h_ll = waterheight(u_ll, equations) + v1_ll, v2_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v1_rr, v2_rr = velocity(u_rr, equations) + + c_ll = sqrt(equations.gravity * h_ll) + c_rr = sqrt(equations.gravity * h_rr) + + if orientation == 1 # x-direction + λ_min = min(v1_ll - c_ll, v1_rr - c_rr) + λ_max = max(v1_ll + c_ll, v1_rr + c_rr) + else # y-direction + λ_min = min(v2_ll - c_ll, v2_rr - c_rr) + λ_max = max(v2_ll + c_ll, v2_rr + c_rr) + end + + return λ_min, λ_max +end + +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquations2D) + h_ll = waterheight(u_ll, equations) + v1_ll, v2_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v1_rr, v2_rr = velocity(u_rr, equations) + + norm_ = norm(normal_direction) + c_ll = sqrt(equations.gravity * h_ll) * norm_ + c_rr = sqrt(equations.gravity * h_rr) * norm_ + + v_normal_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + v_normal_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # The v_normals are already scaled by the norm + λ_min = min(v_normal_ll - c_ll, v_normal_rr - c_rr) + λ_max = max(v_normal_ll + c_ll, v_normal_rr + c_rr) + + return λ_min, λ_max +end + +# TODO: min_max_speed_einfeldt (Requires Roe matrix) + @inline function max_abs_speeds(u, equations::ShallowWaterEquations2D) h = waterheight(u, equations) v1, v2 = velocity(u, equations) From 0b74c5904d1e78956b6e818b3d5da6a262fb0585 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 20 Jun 2023 18:21:19 +0200 Subject: [PATCH 02/22] Format Code --- src/equations/compressible_euler_1d.jl | 4 +- src/equations/compressible_euler_2d.jl | 2 - src/equations/compressible_euler_3d.jl | 14 +++--- src/equations/ideal_glm_mhd_1d.jl | 10 ++--- src/equations/ideal_glm_mhd_2d.jl | 12 ++--- src/equations/ideal_glm_mhd_3d.jl | 61 ++++++++++---------------- src/equations/shallow_water_1d.jl | 5 +-- 7 files changed, 44 insertions(+), 64 deletions(-) diff --git a/src/equations/compressible_euler_1d.jl b/src/equations/compressible_euler_1d.jl index 6f360bb5edd..6cfb7610ebb 100644 --- a/src/equations/compressible_euler_1d.jl +++ b/src/equations/compressible_euler_1d.jl @@ -666,7 +666,8 @@ end Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations1D) +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations1D) rho_ll, v1_ll, p_ll = cons2prim(u_ll, equations) rho_rr, v1_rr, p_rr = cons2prim(u_rr, equations) @@ -679,7 +680,6 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end - """ flux_hllc(u_ll, u_rr, orientation, equations::CompressibleEulerEquations1D) diff --git a/src/equations/compressible_euler_2d.jl b/src/equations/compressible_euler_2d.jl index 5669ac3a810..a72b9557b39 100644 --- a/src/equations/compressible_euler_2d.jl +++ b/src/equations/compressible_euler_2d.jl @@ -1032,7 +1032,6 @@ end return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction) end - # Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes @inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations2D) @@ -1112,7 +1111,6 @@ end return λ_min, λ_max end - # Called inside `FluxRotated` in `numerical_fluxes.jl` so the direction # has been normalized prior to this rotation of the state vector @inline function rotate_to_x(u, normal_vector, equations::CompressibleEulerEquations2D) diff --git a/src/equations/compressible_euler_3d.jl b/src/equations/compressible_euler_3d.jl index b024cb79bd8..ddc3e3b06be 100644 --- a/src/equations/compressible_euler_3d.jl +++ b/src/equations/compressible_euler_3d.jl @@ -1147,14 +1147,12 @@ end c_ll = sqrt(equations.gamma * p_ll / rho_ll) * norm_ c_rr = sqrt(equations.gamma * p_rr / rho_rr) * norm_ - v_normal_ll = - v1_ll * normal_direction[1] + - v2_ll * normal_direction[2] + - v3_ll * normal_direction[3] - v_normal_rr = - v1_rr * normal_direction[1] + - v2_rr * normal_direction[2] + - v3_rr * normal_direction[3] + v_normal_ll = v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3] + v_normal_rr = v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3] # The v_normals are already scaled by the norm λ_min = min(v_normal_ll - c_ll, v_normal_rr - c_rr) diff --git a/src/equations/ideal_glm_mhd_1d.jl b/src/equations/ideal_glm_mhd_1d.jl index 70a3a493e66..c2dbfe2215c 100644 --- a/src/equations/ideal_glm_mhd_1d.jl +++ b/src/equations/ideal_glm_mhd_1d.jl @@ -277,9 +277,9 @@ end λ_max = max(abs(v_ll), abs(v_rr)) + max(cf_ll, cf_rr) end - # Calculate estimates for minimum and maximum wave speeds for HLL-type fluxes -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations1D) rho_ll, rho_v1_ll, _ = u_ll rho_rr, rho_v1_rr, _ = u_rr @@ -293,14 +293,13 @@ end return λ_min, λ_max end - """ min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) rho_ll, rho_v1_ll, _ = u_ll rho_rr, rho_v1_rr, _ = u_rr @@ -319,7 +318,6 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end - """ min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) @@ -339,7 +337,7 @@ This is the generalization to MHD from the works originally developed for the compressible Euler equations. A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) rho_ll, rho_v1_ll, _ = u_ll rho_rr, rho_v1_rr, _ = u_rr diff --git a/src/equations/ideal_glm_mhd_2d.jl b/src/equations/ideal_glm_mhd_2d.jl index 21d7ac45db5..156de15a379 100644 --- a/src/equations/ideal_glm_mhd_2d.jl +++ b/src/equations/ideal_glm_mhd_2d.jl @@ -586,7 +586,7 @@ end end # Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -610,7 +610,7 @@ end return λ_min, λ_max end -@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -641,7 +641,7 @@ end Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -671,7 +671,7 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -715,7 +715,7 @@ This is the generalization to MHD from the works originally developed for the compressible Euler equations. A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -745,7 +745,7 @@ A compact representation can be found in [this lecture notes, eq. (9.28)](https: return λ_min, λ_max end -@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, +@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr diff --git a/src/equations/ideal_glm_mhd_3d.jl b/src/equations/ideal_glm_mhd_3d.jl index 8eb44acc6a7..52227dbde8a 100644 --- a/src/equations/ideal_glm_mhd_3d.jl +++ b/src/equations/ideal_glm_mhd_3d.jl @@ -671,7 +671,7 @@ end end # Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -700,7 +700,7 @@ end return λ_min, λ_max end -@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -714,16 +714,12 @@ end v2_rr = rho_v2_rr / rho_rr v3_rr = rho_v3_rr / rho_rr - v_normal_ll = ( - v1_ll * normal_direction[1] + - v2_ll * normal_direction[2] + - v3_ll * normal_direction[3] - ) - v_normal_rr = ( - v1_rr * normal_direction[1] + - v2_rr * normal_direction[2] + - v3_rr * normal_direction[3] - ) + v_normal_ll = (v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3]) + v_normal_rr = (v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3]) # Estimate the min/max eigenvalues in the normal direction λ_min = v_normal_ll - calc_fast_wavespeed(u_ll, normal_direction, equations) @@ -738,7 +734,7 @@ end Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -776,7 +772,7 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, +@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -790,16 +786,12 @@ end v2_rr = rho_v2_rr / rho_rr v3_rr = rho_v3_rr / rho_rr - v_normal_ll = ( - v1_ll * normal_direction[1] + - v2_ll * normal_direction[2] + - v3_ll * normal_direction[3] - ) - v_normal_rr = ( - v1_rr * normal_direction[1] + - v2_rr * normal_direction[2] + - v3_rr * normal_direction[3] - ) + v_normal_ll = (v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3]) + v_normal_rr = (v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3]) c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) @@ -811,7 +803,6 @@ end return λ_min, λ_max end - """ min_max_speed_einfeldt(u_ll, u_rr, orientation_or_normal_direction, equations::IdealGlmMhdEquations3D) @@ -831,7 +822,7 @@ This is the generalization to MHD from the works originally developed for the compressible Euler equations. A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -869,7 +860,7 @@ This is the generalization to MHD from the works return λ_min, λ_max end -@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, +@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -883,16 +874,12 @@ end v2_rr = rho_v2_rr / rho_rr v3_rr = rho_v3_rr / rho_rr - v_normal_ll = ( - v1_ll * normal_direction[1] + - v2_ll * normal_direction[2] + - v3_ll * normal_direction[3] - ) - v_normal_rr = ( - v1_rr * normal_direction[1] + - v2_rr * normal_direction[2] + - v3_rr * normal_direction[3] - ) + v_normal_ll = (v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] + + v3_ll * normal_direction[3]) + v_normal_rr = (v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] + + v3_rr * normal_direction[3]) c_f_ll = calc_fast_wavespeed(u_ll, normal_direction, equations) c_f_rr = calc_fast_wavespeed(u_rr, normal_direction, equations) diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index 28fc648335d..fd4c8fd5ce4 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -461,7 +461,7 @@ end end # Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations1D) h_ll = waterheight(u_ll, equations) v_ll = velocity(u_ll, equations) @@ -474,7 +474,6 @@ end return λ_min, λ_max end - """ min_max_speed(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations1D) @@ -482,7 +481,7 @@ end Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, +@inline function min_max_speed(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations1D) h_ll = waterheight(u_ll, equations) v_ll = velocity(u_ll, equations) From 0288814091471a16ed05dc67df2c05b5e141d338 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 09:02:59 +0200 Subject: [PATCH 03/22] HLLE wave speeds for SWE --- src/equations/shallow_water_1d.jl | 57 ++++++++++++++- src/equations/shallow_water_2d.jl | 113 +++++++++++++++++++++++++++++- 2 files changed, 168 insertions(+), 2 deletions(-) diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index fd4c8fd5ce4..6984a484547 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -497,7 +497,38 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -# TODO: min_max_speed_einfeldt (Requires Roe matrix) +""" + min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations1D) + +This is the generalization to SWE from the works +- Bernd Einfeldt (1988) + On Godunov-type methods for gas dynamics. + [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) +- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) + On Godunov-type methods near low densities. + [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) + +originally developed for the compressible Euler equations. +A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations1D) + h_ll = waterheight(u_ll, equations) + v_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v_rr = velocity(u_rr, equations) + + c_ll = sqrt(equations.gravity * h_ll) + c_rr = sqrt(equations.gravity * h_rr) + + v_roe, c_roe = calc_wavespeed_roe(u_ll, u_rr, orientation, equations) + + λ_min = min(v_ll - c_ll, v_roe - c_roe) + λ_max = max(v_rr + c_rr, v_roe + c_roe) + + return λ_min, λ_max +end @inline function max_abs_speeds(u, equations::ShallowWaterEquations1D) h = waterheight(u, equations) @@ -572,6 +603,30 @@ end return waterheight(u, equations) * pressure(u, equations) end +""" + calc_wavespeed_roe(u_ll, u_rr, direction::Integer, + equations::ShallowWaterEquations1D) + +Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = \sqrt{g h_roe}` +""" +@inline function calc_wavespeed_roe(u_ll, u_rr, direction::Integer, + equations::ShallowWaterEquations1D) + h_ll = waterheight(u_ll, equations) + v_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v_rr = velocity(u_rr, equations) + + h_roe = 0.5 * (h_ll + h_rr) + c_roe = sqrt(equations.gravity * h_roe) + + h_ll_sqrt = sqrt(h_ll) + h_rr_sqrt = sqrt(h_rr) + + v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr)/(h_ll_sqrt + h_rr_sqrt) + + return v_roe, c_roe +end + # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations1D) energy_total(cons, equations) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index 1b95212ad26..a422a4d10d9 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -811,7 +811,65 @@ end return λ_min, λ_max end -# TODO: min_max_speed_einfeldt (Requires Roe matrix) +""" + min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations2D) + +This is the generalization to SWE from the works +- Bernd Einfeldt (1988) + On Godunov-type methods for gas dynamics. + [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) +- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) + On Godunov-type methods near low densities. + [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) + +originally developed for the compressible Euler equations. +A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +@inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations12D) + h_ll = waterheight(u_ll, equations) + v1_ll, v2_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v1_rr, v2_rr = velocity(u_rr, equations) + + c_ll = sqrt(equations.gravity * h_ll) + c_rr = sqrt(equations.gravity * h_rr) + + if orientation == 1 # x-direction + v_roe, c_roe = calc_wavespeed_roe(u_ll, u_rr, orientation, equations) + λ_min = min(v1_ll - c_ll, v_roe - c_roe) + λ_max = max(v1_rr + c_rr, v_roe + c_roe) + else # y-direction + v_roe, c_roe = calc_wavespeed_roe(u_ll, u_rr, orientation, equations) + λ_min = min(v2_ll - c_ll, v_roe - c_roe) + λ_max = max(v2_rr + c_rr, v_roe + c_roe) + end + + return λ_min, λ_max +end + +@inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquations12D) + h_ll = waterheight(u_ll, equations) + v1_ll, v2_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v1_rr, v2_rr = velocity(u_rr, equations) + + norm_ = norm(normal_direction) + + c_ll = sqrt(equations.gravity * h_ll) * norm_ + c_rr = sqrt(equations.gravity * h_rr) * norm_ + + v_normal_ll = (v1_ll * normal_direction[1] + v2_ll * normal_direction[2]) + v_normal_rr = (v1_rr * normal_direction[1] + v2_rr * normal_direction[2]) + + v_roe, c_roe = calc_wavespeed_roe(u_ll, u_rr, normal_direction, equations) + λ_min = min(v_normal_ll - c_ll, v_roe - c_roe) + λ_max = max(v_normal_rr + c_rr, v_roe + c_roe) + + return λ_min, λ_max +end @inline function max_abs_speeds(u, equations::ShallowWaterEquations2D) h = waterheight(u, equations) @@ -888,6 +946,59 @@ end return waterheight(u, equations) * pressure(u, equations) end +""" + calc_wavespeed_roe(u_ll, u_rr, direction::Integer, + equations::ShallowWaterEquations2D) + +Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = \sqrt{g h_roe}` depending on direction. +See for instance [this slides](https://faculty.washington.edu/rjl/classes/am574w2011/slides/am574lecture20nup3.pdf), +slides 8 and 9. +""" +@inline function calc_wavespeed_roe(u_ll, u_rr, direction::Integer, + equations::ShallowWaterEquations2D) + h_ll = waterheight(u_ll, equations) + v1_ll, v2_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v1_rr, v2_rr = velocity(u_rr, equations) + + h_roe = 0.5 * (h_ll + h_rr) + c_roe = sqrt(equations.gravity * h_roe) + + h_ll_sqrt = sqrt(h_ll) + h_rr_sqrt = sqrt(h_rr) + + if orientation == 1 # x-direction + v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) + else # y-direction + v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) + end + + return v_roe, c_roe +end + +@inline function calc_wavespeed_roe(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquations2D) + h_ll = waterheight(u_ll, equations) + v1_ll, v2_ll = velocity(u_ll, equations) + h_rr = waterheight(u_rr, equations) + v1_rr, v2_rr = velocity(u_rr, equations) + + norm_ = norm(normal_direction) + + h_roe = 0.5 * (h_ll + h_rr) + c_roe = sqrt(equations.gravity * h_roe) * norm_ + + h_ll_sqrt = sqrt(h_ll) + h_rr_sqrt = sqrt(h_rr) + + v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) + v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) + + v_roe = (v1_roe * normal_direction[1] + v2_roe * normal_direction[2]) + + return v_roe, c_roe +end + # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations2D) energy_total(cons, equations) From 1145f9f6722bc5ed5bd2daa6bdf89890fda1948a Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 09:28:15 +0200 Subject: [PATCH 04/22] Fix typos --- src/equations/shallow_water_1d.jl | 2 +- src/equations/shallow_water_2d.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index 6984a484547..d8cf9d51b46 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -607,7 +607,7 @@ end calc_wavespeed_roe(u_ll, u_rr, direction::Integer, equations::ShallowWaterEquations1D) -Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = \sqrt{g h_roe}` +Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` """ @inline function calc_wavespeed_roe(u_ll, u_rr, direction::Integer, equations::ShallowWaterEquations1D) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index a422a4d10d9..957789c9606 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -827,7 +827,7 @@ originally developed for the compressible Euler equations. A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ @inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations12D) + equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) v1_ll, v2_ll = velocity(u_ll, equations) h_rr = waterheight(u_rr, equations) @@ -850,7 +850,7 @@ A compact representation can be found in [this lecture notes, eq. (9.28)](https: end @inline function min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, - equations::ShallowWaterEquations12D) + equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) v1_ll, v2_ll = velocity(u_ll, equations) h_rr = waterheight(u_rr, equations) @@ -950,7 +950,7 @@ end calc_wavespeed_roe(u_ll, u_rr, direction::Integer, equations::ShallowWaterEquations2D) -Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = \sqrt{g h_roe}` depending on direction. +Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` depending on direction. See for instance [this slides](https://faculty.washington.edu/rjl/classes/am574w2011/slides/am574lecture20nup3.pdf), slides 8 and 9. """ From 3ce5b3b7c66c67c61a911315c9560a51ef2505ea Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 10:24:56 +0200 Subject: [PATCH 05/22] Update tests for HLL --- .../dgmulti_1d/elixir_euler_fdsbp_periodic.jl | 2 +- examples/dgmulti_2d/elixir_euler_bilinear.jl | 2 +- examples/dgmulti_2d/elixir_euler_curved.jl | 2 +- .../dgmulti_2d/elixir_euler_fdsbp_periodic.jl | 2 +- ...lixir_euler_rayleigh_taylor_instability.jl | 2 +- .../elixir_euler_triangulate_pkg_mesh.jl | 2 +- examples/dgmulti_2d/elixir_euler_weakform.jl | 2 +- .../elixir_euler_weakform_periodic.jl | 2 +- examples/dgmulti_3d/elixir_euler_curved.jl | 2 +- examples/dgmulti_3d/elixir_euler_weakform.jl | 2 +- .../elixir_euler_weakform_periodic.jl | 2 +- .../elixir_eulergravity_convergence.jl | 2 +- .../p4est_2d_dgsem/elixir_mhd_alfven_wave.jl | 2 +- ..._euler_source_terms_nonconforming_earth.jl | 2 +- .../elixir_mhd_alfven_wave_nonconforming.jl | 2 +- .../elixir_euler_convergence.jl | 2 +- .../elixir_eulergravity_convergence.jl | 2 +- .../elixir_eulergravity_jeans_instability.jl | 2 +- .../elixir_eulergravity_sedov_blast_wave.jl | 2 +- .../elixir_euler_source_terms.jl | 2 +- ...lixir_euler_rayleigh_taylor_instability.jl | 2 +- .../elixir_mhd_alfven_wave.jl | 2 +- .../elixir_euler_source_terms.jl | 2 +- .../elixir_eulergravity_convergence.jl | 2 +- .../elixir_mhd_briowu_shock_tube.jl | 2 +- .../elixir_mhd_ryujones_shock_tube.jl | 2 +- .../elixir_mhd_shu_osher_shock_tube.jl | 2 +- ..._shallowwater_well_balanced_nonperiodic.jl | 2 +- .../elixir_mhd_alfven_wave_mortar.jl | 2 +- .../tree_3d_dgsem/elixir_euler_convergence.jl | 2 +- .../elixir_euler_sedov_blast_wave.jl | 2 +- .../elixir_eulergravity_convergence.jl | 2 +- .../elixir_mhd_alfven_wave_mortar.jl | 2 +- .../elixir_euler_free_stream.jl | 2 +- .../elixir_euler_periodic.jl | 2 +- .../elixir_euler_wall_bc.jl | 2 +- .../elixir_mhd_alfven_wave.jl | 2 +- .../elixir_shallowwater_dirichlet.jl | 2 +- ...xir_shallowwater_wall_bc_shockcapturing.jl | 2 +- src/Trixi.jl | 2 +- src/equations/numerical_fluxes.jl | 35 +++++- test/test_special_elixirs.jl | 2 +- test/test_tree_1d_euler.jl | 2 +- test/test_tree_1d_shallowwater.jl | 4 +- test/test_tree_2d_mhd.jl | 2 +- test/test_tree_2d_shallowwater.jl | 2 +- test/test_tree_3d_mhd.jl | 2 +- test/test_unit.jl | 113 +++++++++++++++++- test/test_unstructured_2d.jl | 2 +- 49 files changed, 192 insertions(+), 52 deletions(-) diff --git a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl index 3566185d110..f5c2a07bd24 100644 --- a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl @@ -4,7 +4,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Line(), approximation_type = periodic_derivative_operator( derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), - surface_flux = flux_hll, + surface_flux = FluxHLL(min_max_speed_naive), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations1D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_bilinear.jl b/examples/dgmulti_2d/elixir_euler_bilinear.jl index beb5c863971..e9f02863c9b 100644 --- a/examples/dgmulti_2d/elixir_euler_bilinear.jl +++ b/examples/dgmulti_2d/elixir_euler_bilinear.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_curved.jl b/examples/dgmulti_2d/elixir_euler_curved.jl index 4f1d613b247..9e773ff7399 100644 --- a/examples/dgmulti_2d/elixir_euler_curved.jl +++ b/examples/dgmulti_2d/elixir_euler_curved.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl index d41ca2c5b34..81cd9224d18 100644 --- a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl @@ -4,7 +4,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Quad(), approximation_type = periodic_derivative_operator( derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), - surface_flux = flux_hll, + surface_flux = FluxHLL(min_max_speed_naive), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl index f5adc7bf83c..e3ced751af4 100644 --- a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl @@ -61,7 +61,7 @@ end # numerical parameters dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(flux_hll), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) num_elements = 16 diff --git a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl index 1f35a11bf8e..150fb769138 100644 --- a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl +++ b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl @@ -1,7 +1,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tri(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_weakform.jl b/examples/dgmulti_2d/elixir_euler_weakform.jl index 1ecc666c8db..a43790a4d5f 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl index 48cc8070857..0bb011bf540 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_3d/elixir_euler_curved.jl b/examples/dgmulti_3d/elixir_euler_curved.jl index 339d6ce0186..56d870f6bf6 100644 --- a/examples/dgmulti_3d/elixir_euler_curved.jl +++ b/examples/dgmulti_3d/elixir_euler_curved.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type=SBP(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) equations = CompressibleEulerEquations3D(1.4) diff --git a/examples/dgmulti_3d/elixir_euler_weakform.jl b/examples/dgmulti_3d/elixir_euler_weakform.jl index 4ad9f045eb6..2a44a7b6c7b 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tet(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations3D(1.4) diff --git a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl index f554167df90..fd4a83a386f 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tet(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL()), + surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations3D(1.4) diff --git a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl index b34c73d2a4e..a99f9110aa8 100644 --- a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl @@ -12,7 +12,7 @@ gamma = 2.0 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 -solver_euler = DGSEM(polydeg, flux_hll) +solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) diff --git a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl index 66bce781f60..22fdae024b0 100644 --- a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -13,7 +13,7 @@ initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=4, surface_flux=(flux_hll, flux_nonconservative_powell), +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0 , 0.0 ) diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl index c5e349934a2..fc5c7da5234 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl @@ -68,7 +68,7 @@ boundary_conditions = Dict( :outside => boundary_condition ) -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_naive) # Note that a free stream is not preserved if N < 2 * N_geo, where N is the # polydeg of the solver and N_geo is the polydeg of the mesh. # However, the FSP error is negligible in this example. diff --git a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl index 8fe96ae3dec..eae7f9f5251 100644 --- a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl @@ -10,7 +10,7 @@ equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hll, flux_nonconservative_powell), +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl index 316f36adc9b..f76ca4f2cdf 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl @@ -8,7 +8,7 @@ equations = CompressibleEulerEquations2D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg=3, surface_flux=flux_hll) +solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl index f2693c89583..8277577f5b9 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl @@ -12,7 +12,7 @@ gamma = 2.0 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 -solver_euler = DGSEM(polydeg, flux_hll) +solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl index 1774e39513d..a23915745df 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl @@ -68,7 +68,7 @@ gamma = 5/3 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 -solver_euler = DGSEM(polydeg, flux_hll) +solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl index f7bb5bbb01c..de8baf2ecdb 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl @@ -85,7 +85,7 @@ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, end boundary_conditions = boundary_condition_sedov_self_gravity -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_naive) volume_flux = flux_chandrashekar polydeg = 3 basis = LobattoLegendreBasis(polydeg) diff --git a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl index cbda7087052..05bf07f59c0 100644 --- a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl @@ -12,7 +12,7 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. -# Using flux_hll instead yields the expected EOC. +# Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) diff --git a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl index bb5870ab9d5..499aea21d9b 100644 --- a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl @@ -61,7 +61,7 @@ end # numerical parameters volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_hll, +solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # The domain is [0, 0.25] x [0, 1] diff --git a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl index f4da8ee9470..fadad7c1800 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl @@ -10,7 +10,7 @@ equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=5, surface_flux=(flux_hll, flux_nonconservative_powell), +solver = DGSEM(polydeg=5, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Create the mesh diff --git a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl index 213206eb9e0..193c6cedc5b 100644 --- a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl @@ -10,7 +10,7 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. -# Using flux_hll instead yields the expected EOC. +# Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = 0.0 diff --git a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl index 42de0e18e51..762ab1c90ca 100644 --- a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl @@ -10,7 +10,7 @@ equations_euler = CompressibleEulerEquations1D(gamma) initial_condition = initial_condition_eoc_test_coupled_euler_gravity polydeg = 3 -solver_euler = DGSEM(polydeg, flux_hll) +solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = 0.0 coordinates_max = 2.0 diff --git a/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl index c5727109d92..0e25ac6ac6c 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl @@ -32,7 +32,7 @@ initial_condition = initial_condition_briowu_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_einfeldt) volume_flux = flux_derigs_etal basis = LobattoLegendreBasis(4) diff --git a/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl index 010788d48f5..0dbb21ad686 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl @@ -39,7 +39,7 @@ initial_condition = initial_condition_ryujones_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_einfeldt) volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(3) diff --git a/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl index 8c60b449e90..860698d7880 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl @@ -60,7 +60,7 @@ initial_condition = initial_condition_shu_osher_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_einfeldt) volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(4) diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl index ef707b803e9..4dff087390d 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl @@ -26,7 +26,7 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal), +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### diff --git a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl index 11dfeacde6a..6632331eb37 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl @@ -10,7 +10,7 @@ equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hll, flux_nonconservative_powell), +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) diff --git a/examples/tree_3d_dgsem/elixir_euler_convergence.jl b/examples/tree_3d_dgsem/elixir_euler_convergence.jl index 2eeb280ae1f..493fef8309b 100644 --- a/examples/tree_3d_dgsem/elixir_euler_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_euler_convergence.jl @@ -9,7 +9,7 @@ equations = CompressibleEulerEquations3D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg=3, surface_flux=flux_hll, +solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), volume_integral=VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) diff --git a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl index 336c09e9212..8e0625dea3a 100644 --- a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -87,7 +87,7 @@ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, end boundary_conditions = boundary_condition_sedov_self_gravity -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_naive) volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) diff --git a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl index 6699ec9a4da..3935a219a96 100644 --- a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl @@ -10,7 +10,7 @@ equations_euler = CompressibleEulerEquations3D(gamma) initial_condition = initial_condition_eoc_test_coupled_euler_gravity polydeg = 3 -solver_euler = DGSEM(polydeg, flux_hll) +solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) diff --git a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl index e23f7ce5460..1d173922391 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl @@ -10,7 +10,7 @@ equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hll, flux_nonconservative_powell), +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) diff --git a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl index 36e119ab794..cb289848039 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl @@ -22,7 +22,7 @@ boundary_conditions = Dict( :Body => boundary_condition_free_stream, ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=6, surface_flux=flux_hll) +solver = DGSEM(polydeg=6, surface_flux=FluxHLL(min_max_speed_naive)) ############################################################################### # Get the curved quad mesh from a file (downloads the file if not available locally) diff --git a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl index 796c99987a2..5f248eb110d 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl @@ -15,7 +15,7 @@ boundary_conditions = boundary_condition_periodic ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=6, surface_flux=FluxRotated(flux_hll)) +solver = DGSEM(polydeg=6, surface_flux=FluxRotated(FluxHLL(min_max_speed_naive))) ############################################################################### # Get the curved quad mesh from a file (downloads the file if not available locally) diff --git a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl index 5bfe1ae4e0e..e300b39c01e 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl @@ -36,7 +36,7 @@ boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=4, surface_flux=flux_hll) +solver = DGSEM(polydeg=4, surface_flux=FluxHLL(min_max_speed_naive)) ############################################################################### # Get the curved quad mesh from a file diff --git a/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl index 6b31776b297..fe7f9851514 100644 --- a/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -11,7 +11,7 @@ equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=7, surface_flux=(flux_hll, flux_nonconservative_powell), +solver = DGSEM(polydeg=7, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl index 044b2549b01..9a8a02feaed 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl @@ -31,7 +31,7 @@ boundary_condition = Dict( :OuterCircle => boundary_condition_constant ) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal), +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl index 4700724c520..ad1471a2d1a 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl @@ -35,7 +35,7 @@ boundary_condition = Dict( :OuterCircle => boundary_condition_slip_wall ) ############################################################################### # Get the DG approximation space -surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), +surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal) volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) polydeg = 6 diff --git a/src/Trixi.jl b/src/Trixi.jl index 66878f4b459..3f2c95bf74b 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -164,7 +164,7 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle, hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, FluxLaxFriedrichs, max_abs_speed_naive, - FluxHLL, min_max_speed_naive, + FluxHLL, min_max_speed_naive, min_max_speed, min_max_speed_einfeldt FluxLMARS, FluxRotated, flux_shima_etal_turbo, flux_ranocha_turbo, diff --git a/src/equations/numerical_fluxes.jl b/src/equations/numerical_fluxes.jl index e26ea28f869..d729f50751f 100644 --- a/src/equations/numerical_fluxes.jl +++ b/src/equations/numerical_fluxes.jl @@ -219,14 +219,13 @@ struct FluxHLL{MinMaxSpeed} min_max_speed::MinMaxSpeed end -# TODO: Change to min_max_speed (Not naive version!) -FluxHLL() = FluxHLL(min_max_speed_naive) +FluxHLL() = FluxHLL(min_max_speed) """ min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations) min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations) -Simple and fast estimate of the minimal and maximal wave speed of the Riemann problem with +Simple and fast estimate(!) of the minimal and maximal wave speed of the Riemann problem with left and right states `u_ll, u_rr`, usually based only on the local wave speeds associated to `u_ll` and `u_rr`. - Amiram Harten, Peter D. Lax, Bram van Leer (1983) @@ -235,6 +234,36 @@ left and right states `u_ll, u_rr`, usually based only on the local wave speeds """ function min_max_speed_naive end +""" + min_max_speed(u_ll, u_rr, orientation::Integer, equations) + min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, equations) + +Simple and fast bounds of the minimal and maximal wave speed of the Riemann problem with +left and right states `u_ll, u_rr`, usually based only on the local wave speeds associated to +`u_ll` and `u_rr`. +- Amiram Harten, Peter D. Lax, Bram van Leer (1983) + On Upstream Differencing and Godunov-Type Schemes for Hyperbolic Conservation Laws + [DOI: 10.1137/1025002](https://doi.org/10.1137/1025002) +""" +function min_max_speed end + +""" + min_max_speed(u_ll, u_rr, orientation::Integer, equations) + min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, equations) + +More advanced mininmal and maximal wave speed computation based on +- Bernd Einfeldt (1988) + On Godunov-type methods for gas dynamics. + [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) +- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) + On Godunov-type methods near low densities. + [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) + +originally developed for the compressible Euler equations. +A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). +""" +function min_max_speed_einfeldt end + @inline function (numflux::FluxHLL)(u_ll, u_rr, orientation_or_normal_direction, equations) λ_min, λ_max = numflux.min_max_speed(u_ll, u_rr, orientation_or_normal_direction, diff --git a/test/test_special_elixirs.jl b/test/test_special_elixirs.jl index 23017059eaa..35f5b5cfbf8 100644 --- a/test/test_special_elixirs.jl +++ b/test/test_special_elixirs.jl @@ -200,7 +200,7 @@ coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", function entropy_at_final_time(k) # k is the wave number of the initial condition equations = CompressibleEulerEquations1D(1.4) mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=3, n_cells_max=10^4) - solver = DGSEM(3, flux_hll, VolumeIntegralFluxDifferencing(flux_ranocha)) + solver = DGSEM(3, FluxHLL(min_max_speed_naive), VolumeIntegralFluxDifferencing(flux_ranocha)) initial_condition = (x, t, equations) -> begin rho = 2 + sinpi(k * sum(x)) v1 = 0.1 diff --git a/test/test_tree_1d_euler.jl b/test/test_tree_1d_euler.jl index 5fb74b80bce..1eda4649f65 100644 --- a/test/test_tree_1d_euler.jl +++ b/test/test_tree_1d_euler.jl @@ -77,7 +77,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") l2 = [0.07852272782240548, 0.10209790867523805, 0.293873048809011], linf = [0.19244768908604093, 0.2515941686151897, 0.7258000837553769], maxiters = 10, - surface_flux = flux_hll, + surface_flux = FluxHLL(min_max_speed_naive), volume_flux = flux_ranocha) end diff --git a/test/test_tree_1d_shallowwater.jl b/test/test_tree_1d_shallowwater.jl index 1c3bac1fab6..c66260c0018 100644 --- a/test/test_tree_1d_shallowwater.jl +++ b/test/test_tree_1d_shallowwater.jl @@ -49,7 +49,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), l2 = [0.0022758146627220154, 0.015864082886204556, 4.436491725585346e-5], linf = [0.008457195427364006, 0.057201667446161064, 9.098379777405796e-5], - tspan = (0.0, 0.025), surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) + tspan = (0.0, 0.025), surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal)) end @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl" begin @@ -63,7 +63,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), l2 = [0.0022956052733432287, 0.015540053559855601, 4.43649172558535e-5], linf = [0.008460440313118323, 0.05720939349382359, 9.098379777405796e-5], - surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), + surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), tspan = (0.0, 0.025)) end diff --git a/test/test_tree_2d_mhd.jl b/test/test_tree_2d_mhd.jl index 3e104da3e91..464a0ae37e9 100644 --- a/test/test_tree_2d_mhd.jl +++ b/test/test_tree_2d_mhd.jl @@ -45,7 +45,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), l2 = [0.10806619664693064, 0.20199136742199922, 0.22984589847526207, 0.0, 0.29950152196422647, 0.15688413207147794, 0.24293641543490646, 0.0, 0.003246181006326598], linf = [0.560316034595759, 0.5095520363866776, 0.6536748458764621, 0.0, 0.9627447086204038, 0.3981375420906146, 0.673472146198816, 0.0, 0.04879208429337193], - tspan = (0.0, 0.06), surface_flux = (flux_hll, flux_nonconservative_powell)) + tspan = (0.0, 0.06), surface_flux = (FluxHLL(min_max_speed_naive), flux_nonconservative_powell)) end @trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin diff --git a/test/test_tree_2d_shallowwater.jl b/test/test_tree_2d_shallowwater.jl index f465a177a67..30893c5ed3a 100644 --- a/test/test_tree_2d_shallowwater.jl +++ b/test/test_tree_2d_shallowwater.jl @@ -55,7 +55,7 @@ EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), l2 = [0.0018957692481057034, 0.016943229710439864, 0.01755623297390675, 6.274146767717414e-5], linf = [0.015156105797771602, 0.07964811135780492, 0.0839787097210376, 0.0001819675955490041], - tspan = (0.0, 0.025), surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) + tspan = (0.0, 0.025), surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal)) end end diff --git a/test/test_tree_3d_mhd.jl b/test/test_tree_3d_mhd.jl index a06d721b525..85f99e2125e 100644 --- a/test/test_tree_3d_mhd.jl +++ b/test/test_tree_3d_mhd.jl @@ -67,7 +67,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") psi = 0.0 return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) end, - surface_flux = (flux_hll, flux_nonconservative_powell), + surface_flux = (FluxHLL(min_max_speed_naive), flux_nonconservative_powell), volume_flux = (flux_central, flux_nonconservative_powell), coordinates_min = (0.0, 0.0, 0.0), coordinates_max = (1.0, 1.0, 1.0), diff --git a/test/test_unit.jl b/test/test_unit.jl index 2156e9bac32..3de2c7da1a3 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -382,7 +382,7 @@ isdir(outdir) && rm(outdir, recursive=true) @timed_testset "HLL flux with vanishing wave speed estimates (#502)" begin equations = CompressibleEulerEquations1D(1.4) u = SVector(1.0, 0.0, 0.0) - @test !any(isnan, FluxHLL()(u, u, 1, equations)) + @test !any(isnan, FluxHLL(min_max_speed_naive)(u, u, 1, equations)) end @timed_testset "DG L2 mortar container debug output" begin @@ -586,6 +586,75 @@ isdir(outdir) && rm(outdir, recursive=true) @test_throws ArgumentError TimeSeriesCallback(semi, [1.0 1.0 1.0; 2.0 2.0 2.0]) end + @timed_testset "Consistency check for HLL flux" begin + # Test HLL flux with min_max_speed_einfeldt + flux_hll = FluxHLL(min_max_speed) + + # Set up equations and dummy conservative variables state + equations = CompressibleEulerEquations1D(1.4) + u = SVector(1.1, 2.34, 5.5) + + orientations = [1] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = CompressibleEulerEquations2D(1.4) + u = SVector(1.1, -0.5, 2.34, 5.5) + + orientations = [1, 2] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = CompressibleEulerEquations3D(1.4) + u = SVector(1.1, -0.5, 2.34, 2.4, 5.5) + + orientations = [1, 2, 3] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = ShallowWaterEquations1D(gravity_constant=9.81) + u = SVector(1, 0.5, 0.0) + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + + equations = ShallowWaterEquations2D(gravity_constant=9.81) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u = SVector(1, 0.5, 0.5, 0.0) + for normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + + equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + + for u in u_values, normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + + equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) + normal_directions = [SVector(1.0, 0.0, 0.0), + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + + for u in u_values, normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + end + @timed_testset "Consistency check for HLLE flux" begin # Set up equations and dummy conservative variables state equations = CompressibleEulerEquations1D(1.4) @@ -611,6 +680,48 @@ isdir(outdir) && rm(outdir, recursive=true) for orientation in orientations @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) end + + # Test HLL flux with min_max_speed_einfeldt + flux_hll = FluxHLL(min_max_speed_einfeldt) + + equations = ShallowWaterEquations1D(gravity_constant=9.81) + u = SVector(1, 0.5, 0.0) + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + + equations = ShallowWaterEquations2D(gravity_constant=9.81) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u = SVector(1, 0.5, 0.5, 0.0) + for normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + + equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + + for u in u_values, normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + + equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) + normal_directions = [SVector(1.0, 0.0, 0.0), + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + + for u in u_values, normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end end @timed_testset "Consistency check for Godunov flux" begin diff --git a/test/test_unstructured_2d.jl b/test/test_unstructured_2d.jl index d4b0d150ca1..5b2ae286b00 100644 --- a/test/test_unstructured_2d.jl +++ b/test/test_unstructured_2d.jl @@ -130,7 +130,7 @@ isdir(outdir) && rm(outdir, recursive=true) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), l2 = [0.0011197139793938152, 0.015430259691310781, 0.017081031802719724, 5.089218476758271e-6], linf = [0.014300809338967824, 0.12783372461225184, 0.17625472321992852, 2.6407324614341476e-5], - surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), + surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), tspan = (0.0, 0.025)) end From 2364017e37c92ce5a0a8849ab368c143dedc57fa Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 10:37:00 +0200 Subject: [PATCH 06/22] Unit test 1D MHD HLL, HLLE --- test/test_unit.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_unit.jl b/test/test_unit.jl index 3de2c7da1a3..4a4aaadeab1 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -629,6 +629,14 @@ isdir(outdir) && rm(outdir, recursive=true) @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end + equations = IdealGlmMhdEquations1D(1.4) + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2),] + + for u in u_values + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + end + equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) normal_directions = [SVector(1.0, 0.0), SVector(0.0, 1.0), @@ -698,6 +706,14 @@ isdir(outdir) && rm(outdir, recursive=true) @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end + equations = IdealGlmMhdEquations1D(1.4) + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2),] + + for u in u_values + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + end + equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) normal_directions = [SVector(1.0, 0.0), SVector(0.0, 1.0), From 6c64eba344d2d689944dd478265ff250de45cf5e Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 10:56:58 +0200 Subject: [PATCH 07/22] Add example for classical HLL 2 wave --- .../elixir_euler_sedov_hll.jl | 94 +++++++++++++++++++ .../elixir_mhd_alfven_wave.jl | 2 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl new file mode 100644 index 00000000000..c9d094ec107 --- /dev/null +++ b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl @@ -0,0 +1,94 @@ + +using OrdinaryDiffEq, Plots +using Trixi + +############################################################################### +# semidiscretization of the compressible Euler equations + +equations = CompressibleEulerEquations1D(1.4) + +""" + initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) + +The Sedov blast wave setup based on Flash +- http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 +""" +function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + p0_outer = 1.0e-5 # = true Sedov setup + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) +end + +initial_condition = initial_condition_sedov_blast_wave +surface_flux = FluxHLL(min_max_speed) +volume_flux = flux_ranocha +basis = LobattoLegendreBasis(3) +shock_indicator_variable = density_pressure +indicator_sc = IndicatorHennemannGassner(equations, basis, + alpha_max=1.0, + alpha_min=0.001, + alpha_smooth=true, + variable=shock_indicator_variable) +volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) +solver = DGSEM(basis, surface_flux, volume_integral) + +cells_per_dimension = (64,) +coordinates_min = (-2.0,) +coordinates_max = ( 2.0,) +mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, periodicity=true) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 12.5) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 1000 +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=stepsize_callback(ode), # 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 +plot(sol) \ No newline at end of file diff --git a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl index fadad7c1800..8d651a2fcf4 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl @@ -10,7 +10,7 @@ equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=5, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_powell), +solver = DGSEM(polydeg=5, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Create the mesh From 9de6fac2080c6d7be9060c9b75d260e46c696de9 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 11:04:58 +0200 Subject: [PATCH 08/22] remove plots --- examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl index c9d094ec107..892a458835f 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl @@ -1,5 +1,5 @@ -using OrdinaryDiffEq, Plots +using OrdinaryDiffEq using Trixi ############################################################################### @@ -90,5 +90,4 @@ callbacks = CallbackSet(summary_callback, sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), dt=stepsize_callback(ode), # 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 -plot(sol) \ No newline at end of file +summary_callback() # print the timer summary \ No newline at end of file From b10b54deb5524a8d5693d1475ecaac54175aede3 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 11:13:41 +0200 Subject: [PATCH 09/22] Use lowercase for flux --- examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl index 892a458835f..230ba92d6b6 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl @@ -35,7 +35,7 @@ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEq end initial_condition = initial_condition_sedov_blast_wave -surface_flux = FluxHLL(min_max_speed) +surface_flux = flux_hll volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure From 2c14c35cf663fe3d4cf87227f2e031a44e985d35 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 11:55:09 +0200 Subject: [PATCH 10/22] Use einfeldt for mhd --- examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl | 2 +- examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl index 22fdae024b0..8b4aee5eec6 100644 --- a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -13,7 +13,7 @@ initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_powell), +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0 , 0.0 ) diff --git a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl index eae7f9f5251..988e9e09ea3 100644 --- a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl @@ -10,7 +10,7 @@ equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_powell), +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) From 85403b1239ea3b734c549924d88024ce9a9ae852 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 12:30:29 +0200 Subject: [PATCH 11/22] Use hlle for mhd tets --- test/test_tree_2d_mhd.jl | 2 +- test/test_tree_3d_mhd.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_tree_2d_mhd.jl b/test/test_tree_2d_mhd.jl index 464a0ae37e9..ad9e913eab9 100644 --- a/test/test_tree_2d_mhd.jl +++ b/test/test_tree_2d_mhd.jl @@ -45,7 +45,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), l2 = [0.10806619664693064, 0.20199136742199922, 0.22984589847526207, 0.0, 0.29950152196422647, 0.15688413207147794, 0.24293641543490646, 0.0, 0.003246181006326598], linf = [0.560316034595759, 0.5095520363866776, 0.6536748458764621, 0.0, 0.9627447086204038, 0.3981375420906146, 0.673472146198816, 0.0, 0.04879208429337193], - tspan = (0.0, 0.06), surface_flux = (FluxHLL(min_max_speed_naive), flux_nonconservative_powell)) + tspan = (0.0, 0.06), surface_flux = (FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell)) end @trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin diff --git a/test/test_tree_3d_mhd.jl b/test/test_tree_3d_mhd.jl index 85f99e2125e..be4ae72caf0 100644 --- a/test/test_tree_3d_mhd.jl +++ b/test/test_tree_3d_mhd.jl @@ -67,7 +67,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") psi = 0.0 return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) end, - surface_flux = (FluxHLL(min_max_speed_naive), flux_nonconservative_powell), + surface_flux = (FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), volume_flux = (flux_central, flux_nonconservative_powell), coordinates_min = (0.0, 0.0, 0.0), coordinates_max = (1.0, 1.0, 1.0), From f068fd051fcb0f81cea21a1ea95e41086acec0ff Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Wed, 21 Jun 2023 15:54:47 +0200 Subject: [PATCH 12/22] Missing comma causes failing tests --- src/Trixi.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 3f2c95bf74b..078b7444dda 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -164,7 +164,7 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle, hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, FluxLaxFriedrichs, max_abs_speed_naive, - FluxHLL, min_max_speed_naive, min_max_speed, min_max_speed_einfeldt + FluxHLL, min_max_speed_naive, min_max_speed, min_max_speed_einfeldt, FluxLMARS, FluxRotated, flux_shima_etal_turbo, flux_ranocha_turbo, From d184578ebfdab6f1e7466a4b36bac3bf5c37c9c0 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Thu, 22 Jun 2023 16:04:36 +0200 Subject: [PATCH 13/22] Correct bug in SWE 2D Roe eigval comp, unit tests --- src/equations/shallow_water_2d.jl | 2 +- test/test_unit.jl | 39 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index 957789c9606..321d923ffbe 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -954,7 +954,7 @@ Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` de See for instance [this slides](https://faculty.washington.edu/rjl/classes/am574w2011/slides/am574lecture20nup3.pdf), slides 8 and 9. """ -@inline function calc_wavespeed_roe(u_ll, u_rr, direction::Integer, +@inline function calc_wavespeed_roe(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) v1_ll, v2_ll = velocity(u_ll, equations) diff --git a/test/test_unit.jl b/test/test_unit.jl index 4a4aaadeab1..bb197d823eb 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -615,6 +615,14 @@ isdir(outdir) && rm(outdir, recursive=true) @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end + equations = LinearizedEulerEquations2D(SVector(1.0, 1.0), 1.0, 1.0) + u = SVector(1.1, -0.5, 2.34, 5.5) + + orientations = [1, 2] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + equations = ShallowWaterEquations1D(gravity_constant=9.81) u = SVector(1, 0.5, 0.0) @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) @@ -642,9 +650,15 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(0.0, 1.0), SVector(0.5, -0.5), SVector(-1.2, 0.3)] + orientations = [1, 2] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + for u in u_values, orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + for u in u_values, normal_direction in normal_directions @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end @@ -655,9 +669,15 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(0.0, 0.0, 1.0), SVector(0.5, -0.5, 0.2), SVector(-1.2, 0.3, 1.4)] + orientations = [1, 2, 3] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + for u in u_values, orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + for u in u_values, normal_direction in normal_directions @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end @@ -701,7 +721,14 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(0.0, 1.0), SVector(0.5, -0.5), SVector(-1.2, 0.3)] + orientations = [1, 2] + u = SVector(1, 0.5, 0.5, 0.0) + + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + for normal_direction in normal_directions @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end @@ -719,9 +746,15 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(0.0, 1.0), SVector(0.5, -0.5), SVector(-1.2, 0.3)] + orientations = [1, 2] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + for u in u_values, orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + for u in u_values, normal_direction in normal_directions @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end @@ -732,9 +765,15 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(0.0, 0.0, 1.0), SVector(0.5, -0.5, 0.2), SVector(-1.2, 0.3, 1.4)] + orientations = [1, 2, 3] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + for u in u_values, orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + for u in u_values, normal_direction in normal_directions @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) end From 047a5e75b4a5ee4a0f58a7979d58b26f15f24334 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 23 Jun 2023 12:58:28 +0200 Subject: [PATCH 14/22] format --- docs/literate/make.jl | 44 +- docs/literate/src/files/DGMulti_1.jl | 67 +- docs/literate/src/files/DGMulti_2.jl | 12 +- docs/literate/src/files/DGSEM_FluxDiff.jl | 46 +- .../src/files/adaptive_mesh_refinement.jl | 35 +- .../src/files/adding_new_parabolic_terms.jl | 79 +- .../src/files/adding_new_scalar_equations.jl | 68 +- .../files/adding_nonconservative_equation.jl | 78 +- .../src/files/differentiable_programming.jl | 140 ++- docs/literate/src/files/hohqmesh_tutorial.jl | 337 +++--- .../src/files/non_periodic_boundaries.jl | 38 +- docs/literate/src/files/parabolic_terms.jl | 41 +- .../src/files/scalar_linear_advection_1d.jl | 102 +- docs/literate/src/files/shock_capturing.jl | 79 +- .../src/files/structured_mesh_mapping.jl | 77 +- docs/literate/src/files/upwind_fdsbp.jl | 8 +- docs/make.jl | 150 ++- .../dgmulti_1d/elixir_advection_gauss_sbp.jl | 13 +- .../dgmulti_1d/elixir_euler_fdsbp_periodic.jl | 23 +- examples/dgmulti_1d/elixir_euler_flux_diff.jl | 12 +- .../dgmulti_2d/elixir_advection_diffusion.jl | 38 +- .../elixir_advection_diffusion_nonperiodic.jl | 54 +- .../elixir_advection_diffusion_periodic.jl | 12 +- examples/dgmulti_2d/elixir_euler_bilinear.jl | 29 +- .../elixir_euler_brown_minion_vortex.jl | 32 +- examples/dgmulti_2d/elixir_euler_curved.jl | 22 +- .../dgmulti_2d/elixir_euler_fdsbp_periodic.jl | 23 +- examples/dgmulti_2d/elixir_euler_hohqmesh.jl | 27 +- ...ixir_euler_kelvin_helmholtz_instability.jl | 35 +- ...lixir_euler_rayleigh_taylor_instability.jl | 58 +- .../dgmulti_2d/elixir_euler_shockcapturing.jl | 27 +- .../elixir_euler_shockcapturing_curved.jl | 31 +- .../elixir_euler_triangulate_pkg_mesh.jl | 12 +- examples/dgmulti_2d/elixir_euler_weakform.jl | 21 +- .../elixir_euler_weakform_periodic.jl | 10 +- .../dgmulti_2d/elixir_mhd_reflective_wall.jl | 94 +- .../dgmulti_2d/elixir_mhd_weak_blast_wave.jl | 20 +- .../elixir_mhd_weak_blast_wave_SBP.jl | 17 +- .../elixir_navierstokes_convergence.jl | 334 +++--- .../elixir_navierstokes_convergence_curved.jl | 341 +++--- .../elixir_navierstokes_lid_driven_cavity.jl | 38 +- .../elixir_shallowwater_source_terms.jl | 19 +- .../elixir_advection_tensor_wedge.jl | 22 +- examples/dgmulti_3d/elixir_euler_curved.jl | 26 +- .../dgmulti_3d/elixir_euler_fdsbp_periodic.jl | 21 +- .../elixir_euler_taylor_green_vortex.jl | 45 +- examples/dgmulti_3d/elixir_euler_weakform.jl | 16 +- .../elixir_euler_weakform_periodic.jl | 10 +- .../elixir_navierstokes_convergence.jl | 410 +++---- .../elixir_navierstokes_convergence_curved.jl | 418 +++---- ...elixir_navierstokes_taylor_green_vortex.jl | 50 +- ...ixir_advection_amr_solution_independent.jl | 149 ++- .../elixir_advection_amr_unstructured_flag.jl | 66 +- .../p4est_2d_dgsem/elixir_advection_basic.jl | 32 +- .../elixir_advection_diffusion_periodic.jl | 30 +- ...xir_advection_diffusion_periodic_curved.jl | 34 +- .../elixir_advection_extended.jl | 50 +- .../elixir_advection_nonconforming_flag.jl | 55 +- .../elixir_advection_restart.jl | 10 +- .../elixir_advection_unstructured_flag.jl | 44 +- .../elixir_euler_blast_wave_amr.jl | 96 +- .../elixir_euler_double_mach_amr.jl | 140 +-- .../elixir_euler_forward_step_amr.jl | 152 +-- .../elixir_euler_free_stream.jl | 70 +- examples/p4est_2d_dgsem/elixir_euler_sedov.jl | 79 +- .../elixir_euler_shockcapturing_ec.jl | 44 +- ...e_terms_nonconforming_unstructured_flag.jl | 70 +- .../elixir_euler_supersonic_cylinder.jl | 103 +- .../elixir_euler_wall_bc_amr.jl | 82 +- .../elixir_eulergravity_convergence.jl | 60 +- .../p4est_2d_dgsem/elixir_mhd_alfven_wave.jl | 31 +- examples/p4est_2d_dgsem/elixir_mhd_rotor.jl | 126 +- .../elixir_shallowwater_source_terms.jl | 31 +- .../p4est_3d_dgsem/elixir_advection_amr.jl | 48 +- ...lixir_advection_amr_unstructured_curved.jl | 103 +- .../p4est_3d_dgsem/elixir_advection_basic.jl | 35 +- .../elixir_advection_cubed_sphere.jl | 31 +- .../elixir_advection_nonconforming.jl | 54 +- .../elixir_advection_restart.jl | 13 +- .../elixir_advection_unstructured_curved.jl | 83 +- .../elixir_euler_baroclinic_instability.jl | 370 +++--- ...lixir_euler_circular_wind_nonconforming.jl | 126 +- examples/p4est_3d_dgsem/elixir_euler_ec.jl | 81 +- .../elixir_euler_free_stream.jl | 104 +- .../elixir_euler_free_stream_extruded.jl | 86 +- examples/p4est_3d_dgsem/elixir_euler_sedov.jl | 86 +- ..._euler_source_terms_nonconforming_earth.jl | 108 +- ...terms_nonconforming_unstructured_curved.jl | 107 +- .../elixir_euler_source_terms_nonperiodic.jl | 52 +- ...euler_source_terms_nonperiodic_hohqmesh.jl | 45 +- .../elixir_mhd_alfven_wave_nonconforming.jl | 60 +- .../elixir_mhd_shockcapturing_amr.jl | 124 +- .../elixir_euler_convergence.jl | 31 +- .../elixir_eulergravity_convergence.jl | 54 +- .../elixir_eulergravity_jeans_instability.jl | 164 +-- .../elixir_eulergravity_sedov_blast_wave.jl | 219 ++-- .../elixir_hypdiff_convergence.jl | 45 +- examples/special_elixirs/elixir_euler_ad.jl | 78 +- .../elixir_advection_basic.jl | 24 +- .../elixir_advection_nonperiodic.jl | 35 +- .../elixir_advection_shockcapturing.jl | 81 +- .../structured_1d_dgsem/elixir_euler_sedov.jl | 81 +- .../elixir_euler_sedov_hll.jl | 83 +- .../elixir_euler_source_terms.jl | 31 +- .../elixir_euler_source_terms_nonperiodic.jl | 39 +- .../elixir_advection_basic.jl | 26 +- .../elixir_advection_coupled.jl | 74 +- .../elixir_advection_extended.jl | 34 +- .../elixir_advection_free_stream.jl | 41 +- .../elixir_advection_nonperiodic.jl | 32 +- .../elixir_advection_parallelogram.jl | 57 +- .../elixir_advection_restart.jl | 8 +- .../elixir_advection_rotated.jl | 69 +- .../elixir_advection_waving_flag.jl | 29 +- .../structured_2d_dgsem/elixir_euler_ec.jl | 38 +- .../elixir_euler_free_stream.jl | 39 +- ...lixir_euler_rayleigh_taylor_instability.jl | 72 +- .../structured_2d_dgsem/elixir_euler_sedov.jl | 85 +- .../elixir_euler_source_terms.jl | 26 +- .../elixir_euler_source_terms_nonperiodic.jl | 41 +- ...elixir_euler_source_terms_parallelogram.jl | 26 +- .../elixir_euler_source_terms_rotated.jl | 105 +- .../elixir_euler_source_terms_waving_flag.jl | 30 +- .../elixir_hypdiff_harmonic_nonperiodic.jl | 72 +- .../elixir_hypdiff_nonperiodic.jl | 57 +- .../elixir_mhd_alfven_wave.jl | 62 +- examples/structured_2d_dgsem/elixir_mhd_ec.jl | 88 +- .../elixir_mhd_ec_shockcapturing.jl | 35 +- .../elixir_shallowwater_source_terms.jl | 31 +- .../elixir_shallowwater_well_balanced.jl | 89 +- .../elixir_advection_basic.jl | 30 +- .../elixir_advection_free_stream.jl | 58 +- .../elixir_advection_nonperiodic_curved.jl | 72 +- .../elixir_advection_restart.jl | 13 +- .../structured_3d_dgsem/elixir_euler_ec.jl | 63 +- .../elixir_euler_free_stream.jl | 69 +- .../structured_3d_dgsem/elixir_euler_sedov.jl | 90 +- .../elixir_euler_source_terms.jl | 28 +- ...r_euler_source_terms_nonperiodic_curved.jl | 85 +- .../elixir_mhd_alfven_wave.jl | 39 +- examples/structured_3d_dgsem/elixir_mhd_ec.jl | 67 +- .../elixir_mhd_ec_shockcapturing.jl | 71 +- .../tree_1d_dgsem/elixir_advection_amr.jl | 47 +- .../elixir_advection_amr_nonperiodic.jl | 53 +- .../tree_1d_dgsem/elixir_advection_basic.jl | 30 +- .../elixir_advection_diffusion.jl | 68 +- .../elixir_advection_extended.jl | 40 +- .../elixir_advection_finite_volume.jl | 21 +- .../tree_1d_dgsem/elixir_burgers_basic.jl | 35 +- .../elixir_burgers_linear_stability.jl | 36 +- .../elixir_burgers_rarefaction.jl | 61 +- .../tree_1d_dgsem/elixir_burgers_shock.jl | 57 +- .../tree_1d_dgsem/elixir_euler_blast_wave.jl | 77 +- ...blast_wave_neuralnetwork_perssonperaire.jl | 89 +- ...r_blast_wave_neuralnetwork_rayhesthaven.jl | 89 +- .../elixir_euler_convergence_pure_fv.jl | 37 +- .../elixir_euler_density_wave.jl | 30 +- examples/tree_1d_dgsem/elixir_euler_ec.jl | 33 +- .../tree_1d_dgsem/elixir_euler_positivity.jl | 101 +- .../elixir_euler_sedov_blast_wave.jl | 100 +- .../elixir_euler_sedov_blast_wave_pure_fv.jl | 86 +- .../elixir_euler_shockcapturing.jl | 43 +- .../elixir_euler_source_terms.jl | 35 +- .../elixir_euler_source_terms_nonperiodic.jl | 43 +- .../elixir_eulergravity_convergence.jl | 54 +- .../elixir_eulermulti_convergence_ec.jl | 37 +- .../elixir_eulermulti_convergence_es.jl | 37 +- .../tree_1d_dgsem/elixir_eulermulti_ec.jl | 38 +- .../tree_1d_dgsem/elixir_eulermulti_es.jl | 42 +- ..._eulermulti_two_interacting_blast_waves.jl | 97 +- .../elixir_hypdiff_harmonic_nonperiodic.jl | 63 +- .../elixir_hypdiff_nonperiodic.jl | 38 +- .../tree_1d_dgsem/elixir_mhd_alfven_wave.jl | 45 +- .../elixir_mhd_briowu_shock_tube.jl | 91 +- examples/tree_1d_dgsem/elixir_mhd_ec.jl | 35 +- .../elixir_mhd_ryujones_shock_tube.jl | 71 +- .../elixir_mhd_shu_osher_shock_tube.jl | 128 +-- .../elixir_mhd_torrilhon_shock_tube.jl | 73 +- .../elixir_mhdmulti_briowu_shock_tube.jl | 122 +- .../elixir_mhdmulti_convergence.jl | 36 +- examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl | 33 +- examples/tree_1d_dgsem/elixir_mhdmulti_es.jl | 37 +- .../tree_1d_dgsem/elixir_shallowwater_ec.jl | 63 +- .../elixir_shallowwater_shock_capturing.jl | 84 +- .../elixir_shallowwater_source_terms.jl | 30 +- ...xir_shallowwater_source_terms_dirichlet.jl | 28 +- ...lixir_shallowwater_twolayer_convergence.jl | 32 +- .../elixir_shallowwater_twolayer_dam_break.jl | 71 +- ...xir_shallowwater_twolayer_well_balanced.jl | 42 +- .../elixir_shallowwater_well_balanced.jl | 57 +- ..._shallowwater_well_balanced_nonperiodic.jl | 50 +- .../tree_1d_fdsbp/elixir_burgers_basic.jl | 40 +- .../elixir_burgers_linear_stability.jl | 39 +- .../tree_1d_fdsbp/elixir_euler_convergence.jl | 40 +- .../elixir_euler_density_wave.jl | 36 +- .../elixir_acoustics_convergence.jl | 31 +- .../tree_2d_dgsem/elixir_acoustics_gauss.jl | 27 +- .../elixir_acoustics_gauss_wall.jl | 40 +- .../elixir_acoustics_gaussian_source.jl | 53 +- .../elixir_acoustics_monopole.jl | 134 +-- .../tree_2d_dgsem/elixir_advection_amr.jl | 47 +- .../elixir_advection_amr_coarsen_twice.jl | 69 +- .../elixir_advection_amr_nonperiodic.jl | 50 +- .../elixir_advection_amr_refine_twice.jl | 69 +- ...ixir_advection_amr_solution_independent.jl | 141 ++- .../elixir_advection_amr_visualization.jl | 60 +- .../tree_2d_dgsem/elixir_advection_basic.jl | 30 +- .../elixir_advection_callbacks.jl | 132 ++- .../elixir_advection_diffusion.jl | 49 +- .../elixir_advection_diffusion_nonperiodic.jl | 48 +- .../elixir_advection_extended.jl | 40 +- .../tree_2d_dgsem/elixir_advection_mortar.jl | 40 +- .../tree_2d_dgsem/elixir_advection_restart.jl | 8 +- .../elixir_advection_timeintegration.jl | 45 +- .../elixir_euler_astro_jet_amr.jl | 119 +- .../tree_2d_dgsem/elixir_euler_blast_wave.jl | 75 +- .../elixir_euler_blast_wave_amr.jl | 93 +- ...ixir_euler_blast_wave_neuralnetwork_cnn.jl | 86 +- ...blast_wave_neuralnetwork_perssonperaire.jl | 86 +- ...r_blast_wave_neuralnetwork_rayhesthaven.jl | 88 +- .../elixir_euler_blast_wave_pure_fv.jl | 63 +- .../tree_2d_dgsem/elixir_euler_blob_amr.jl | 131 ++- .../tree_2d_dgsem/elixir_euler_blob_mortar.jl | 119 +- .../elixir_euler_colliding_flow.jl | 116 +- .../elixir_euler_colliding_flow_amr.jl | 119 +- .../elixir_euler_convergence_pure_fv.jl | 28 +- .../elixir_euler_density_wave.jl | 31 +- examples/tree_2d_dgsem/elixir_euler_ec.jl | 37 +- ...ixir_euler_kelvin_helmholtz_instability.jl | 66 +- ..._euler_kelvin_helmholtz_instability_amr.jl | 88 +- ...bility_amr_neuralnetwork_perssonperaire.jl | 124 +- ...in_helmholtz_instability_fjordholm_etal.jl | 128 ++- .../tree_2d_dgsem/elixir_euler_positivity.jl | 104 +- .../elixir_euler_sedov_blast_wave.jl | 102 +- ...blast_wave_neuralnetwork_perssonperaire.jl | 121 +- .../elixir_euler_shockcapturing.jl | 43 +- .../elixir_euler_source_terms.jl | 30 +- ...r_euler_source_terms_amr_refine_coarsen.jl | 86 +- .../elixir_euler_source_terms_nonperiodic.jl | 47 +- examples/tree_2d_dgsem/elixir_euler_vortex.jl | 98 +- .../tree_2d_dgsem/elixir_euler_vortex_amr.jl | 191 ++-- .../elixir_euler_vortex_mortar.jl | 104 +- ...ixir_euler_vortex_mortar_shockcapturing.jl | 114 +- .../elixir_euler_vortex_mortar_split.jl | 106 +- .../elixir_euler_vortex_shockcapturing.jl | 110 +- ..._euleracoustics_co-rotating_vortex_pair.jl | 377 +++--- .../elixir_eulermulti_convergence_ec.jl | 37 +- .../elixir_eulermulti_convergence_es.jl | 37 +- .../tree_2d_dgsem/elixir_eulermulti_ec.jl | 38 +- .../tree_2d_dgsem/elixir_eulermulti_es.jl | 39 +- .../elixir_eulermulti_shock_bubble.jl | 214 ++-- .../tree_2d_dgsem/elixir_hypdiff_godunov.jl | 88 +- .../elixir_hypdiff_harmonic_nonperiodic.jl | 76 +- .../elixir_hypdiff_lax_friedrichs.jl | 86 +- .../elixir_hypdiff_nonperiodic.jl | 45 +- examples/tree_2d_dgsem/elixir_kpp.jl | 81 +- examples/tree_2d_dgsem/elixir_lbm_constant.jl | 37 +- examples/tree_2d_dgsem/elixir_lbm_couette.jl | 113 +- .../elixir_lbm_lid_driven_cavity.jl | 89 +- .../elixir_linearizedeuler_convergence.jl | 31 +- .../tree_2d_dgsem/elixir_mhd_alfven_wave.jl | 45 +- .../elixir_mhd_alfven_wave_mortar.jl | 51 +- .../tree_2d_dgsem/elixir_mhd_blast_wave.jl | 102 +- examples/tree_2d_dgsem/elixir_mhd_ec.jl | 36 +- .../tree_2d_dgsem/elixir_mhd_orszag_tang.jl | 86 +- examples/tree_2d_dgsem/elixir_mhd_rotor.jl | 113 +- .../elixir_mhdmulti_convergence.jl | 39 +- examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl | 40 +- examples/tree_2d_dgsem/elixir_mhdmulti_es.jl | 40 +- .../tree_2d_dgsem/elixir_mhdmulti_rotor.jl | 121 +- .../elixir_navierstokes_convergence.jl | 354 +++--- .../elixir_navierstokes_lid_driven_cavity.jl | 45 +- .../tree_2d_dgsem/elixir_shallowwater_ec.jl | 100 +- .../elixir_shallowwater_source_terms.jl | 30 +- ...xir_shallowwater_source_terms_dirichlet.jl | 29 +- ...lixir_shallowwater_twolayer_convergence.jl | 31 +- ...xir_shallowwater_twolayer_well_balanced.jl | 55 +- .../elixir_shallowwater_well_balanced.jl | 90 +- .../elixir_shallowwater_well_balanced_wall.jl | 90 +- .../elixir_advection_extended.jl | 28 +- .../tree_2d_fdsbp/elixir_euler_convergence.jl | 41 +- ...ixir_euler_kelvin_helmholtz_instability.jl | 69 +- examples/tree_2d_fdsbp/elixir_euler_vortex.jl | 102 +- .../tree_3d_dgsem/elixir_advection_amr.jl | 46 +- .../tree_3d_dgsem/elixir_advection_basic.jl | 30 +- .../elixir_advection_extended.jl | 40 +- .../tree_3d_dgsem/elixir_advection_mortar.jl | 43 +- .../tree_3d_dgsem/elixir_advection_restart.jl | 8 +- examples/tree_3d_dgsem/elixir_euler_amr.jl | 71 +- .../tree_3d_dgsem/elixir_euler_blob_amr.jl | 137 +-- .../tree_3d_dgsem/elixir_euler_convergence.jl | 33 +- .../elixir_euler_convergence_pure_fv.jl | 33 +- .../elixir_euler_density_pulse.jl | 57 +- examples/tree_3d_dgsem/elixir_euler_ec.jl | 33 +- examples/tree_3d_dgsem/elixir_euler_mortar.jl | 37 +- .../elixir_euler_sedov_blast_wave.jl | 159 ++- .../elixir_euler_shockcapturing.jl | 43 +- .../elixir_euler_shockcapturing_amr.jl | 58 +- .../elixir_euler_source_terms.jl | 33 +- .../elixir_euler_taylor_green_vortex.jl | 61 +- .../elixir_eulergravity_convergence.jl | 56 +- .../elixir_hypdiff_lax_friedrichs.jl | 93 +- .../elixir_hypdiff_nonperiodic.jl | 49 +- examples/tree_3d_dgsem/elixir_lbm_constant.jl | 37 +- .../elixir_lbm_taylor_green_vortex.jl | 60 +- .../tree_3d_dgsem/elixir_mhd_alfven_wave.jl | 38 +- .../elixir_mhd_alfven_wave_mortar.jl | 45 +- examples/tree_3d_dgsem/elixir_mhd_ec.jl | 36 +- .../elixir_mhd_ec_shockcapturing.jl | 38 +- .../elixir_navierstokes_convergence.jl | 439 +++---- ...elixir_navierstokes_taylor_green_vortex.jl | 58 +- .../elixir_advection_extended.jl | 28 +- .../tree_3d_fdsbp/elixir_euler_convergence.jl | 40 +- .../elixir_euler_taylor_green_vortex.jl | 72 +- .../elixir_acoustics_gauss_wall.jl | 45 +- .../elixir_advection_basic.jl | 29 +- .../elixir_euler_basic.jl | 43 +- .../unstructured_2d_dgsem/elixir_euler_ec.jl | 31 +- .../elixir_euler_free_stream.jl | 41 +- .../elixir_euler_periodic.jl | 19 +- .../elixir_euler_restart.jl | 13 +- .../elixir_euler_sedov.jl | 78 +- .../elixir_euler_wall_bc.jl | 64 +- .../elixir_mhd_alfven_wave.jl | 51 +- .../unstructured_2d_dgsem/elixir_mhd_ec.jl | 79 +- .../elixir_shallowwater_dirichlet.jl | 54 +- .../elixir_shallowwater_ec.jl | 101 +- .../elixir_shallowwater_ec_shockcapturing.jl | 104 +- .../elixir_shallowwater_source_terms.jl | 33 +- ...lixir_shallowwater_twolayer_convergence.jl | 34 +- .../elixir_shallowwater_twolayer_dam_break.jl | 139 +-- ...xir_shallowwater_twolayer_well_balanced.jl | 58 +- ...xir_shallowwater_wall_bc_shockcapturing.jl | 83 +- .../elixir_shallowwater_well_balanced.jl | 93 +- src/equations/linearized_euler_2d.jl | 4 +- src/equations/shallow_water_1d.jl | 6 +- src/equations/shallow_water_2d.jl | 16 +- test/coverage/coverage.jl | 48 +- test/runtests.jl | 216 ++-- test/test_dgmulti_1d.jl | 157 ++- test/test_dgmulti_2d.jl | 1010 +++++++++++------ test/test_dgmulti_3d.jl | 405 ++++--- test/test_mpi.jl | 45 +- test/test_mpi_p4est_2d.jl | 126 +- test/test_mpi_p4est_3d.jl | 223 ++-- test/test_mpi_tree.jl | 474 +++++--- test/test_p4est_2d.jl | 421 ++++--- test/test_p4est_3d.jl | 456 +++++--- ...est_paper_self_gravitating_gas_dynamics.jl | 347 ++++-- test/test_parabolic_1d.jl | 21 +- test/test_parabolic_2d.jl | 478 ++++---- test/test_parabolic_3d.jl | 270 +++-- test/test_performance_specializations_2d.jl | 310 ++--- test/test_performance_specializations_3d.jl | 310 ++--- test/test_special_elixirs.jl | 517 +++++---- test/test_structured_1d.jl | 99 +- test/test_structured_2d.jl | 691 ++++++----- test/test_structured_3d.jl | 325 ++++-- test/test_threaded.jl | 294 +++-- test/test_tree_1d.jl | 490 ++++---- test/test_tree_1d_advection.jl | 50 +- test/test_tree_1d_burgers.jl | 46 +- test/test_tree_1d_euler.jl | 390 ++++--- test/test_tree_1d_eulergravity.jl | 18 +- test/test_tree_1d_eulermulti.jl | 116 +- test/test_tree_1d_fdsbp.jl | 157 ++- test/test_tree_1d_hypdiff.jl | 26 +- test/test_tree_1d_mhd.jl | 280 ++++- test/test_tree_1d_mhdmulti.jl | 112 +- test/test_tree_1d_shallowwater.jl | 223 ++-- test/test_tree_1d_shallowwater_twolayer.jl | 90 +- test/test_tree_2d_acoustics.jl | 125 +- test/test_tree_2d_advection.jl | 377 +++--- test/test_tree_2d_euler.jl | 909 ++++++++++----- test/test_tree_2d_euleracoustics.jl | 34 +- test/test_tree_2d_eulermulti.jl | 156 ++- test/test_tree_2d_fdsbp.jl | 129 ++- test/test_tree_2d_hypdiff.jl | 81 +- test/test_tree_2d_kpp.jl | 20 +- test/test_tree_2d_lbm.jl | 149 ++- test/test_tree_2d_linearizedeuler.jl | 21 +- test/test_tree_2d_mhd.jl | 296 ++++- test/test_tree_2d_mhdmulti.jl | 126 +- 383 files changed, 18956 insertions(+), 15875 deletions(-) diff --git a/docs/literate/make.jl b/docs/literate/make.jl index b620f85c975..45240a36d78 100644 --- a/docs/literate/make.jl +++ b/docs/literate/make.jl @@ -3,22 +3,22 @@ using Test: @testset import Pkg # Create markdown and notebook files for `file` -function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder="") +function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder = "") notebook_filename = first(splitext(file)) * ".ipynb" if !isempty(folder) notebook_filename = joinpath(folder, notebook_filename) end - binder_logo = "https://mybinder.org/badge_logo.svg" + binder_logo = "https://mybinder.org/badge_logo.svg" nbviewer_logo = "https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg" download_logo = "https://camo.githubusercontent.com/aea75103f6d9f690a19cb0e17c06f984ab0f472d9e6fe4eadaa0cc438ba88ada/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f776e6c6f61642d6e6f7465626f6f6b2d627269676874677265656e" notebook_path = "tutorials/notebooks/$notebook_filename" - binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path" + binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path" nbviewer_url = "https://nbviewer.jupyter.org/github/trixi-framework/Trixi.jl/blob/tutorial_notebooks/$notebook_path" download_url = "https://raw.githubusercontent.com/trixi-framework/Trixi.jl/tutorial_notebooks/$notebook_path" - binder_badge = "# [![]($binder_logo)]($binder_url)" + binder_badge = "# [![]($binder_logo)]($binder_url)" nbviewer_badge = "# [![]($nbviewer_logo)]($nbviewer_url)" download_badge = "# [![]($download_logo)]($download_url)" @@ -28,43 +28,50 @@ function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder="" # available for the latest stable release of Trixi.jl at the time of caching.\n\n" return string("# # $title\n\n", warning, content) end - Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder); execute=false, preprocess=preprocess_notebook, credit=false) + Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder); + execute = false, preprocess = preprocess_notebook, credit = false) # Generate markdown file function preprocess_docs(content) - return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $download_badge\n\n", content) + return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $download_badge\n\n", + content) end - Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder); preprocess=preprocess_docs,) + Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder); + preprocess = preprocess_docs) end # Create tutorials with Literate.jl function create_tutorials(files) - repo_src = joinpath(@__DIR__, "src", "files") + repo_src = joinpath(@__DIR__, "src", "files") - pages_dir = joinpath(@__DIR__, "..", "src", "tutorials") - notebooks_dir = joinpath(pages_dir, "notebooks") + pages_dir = joinpath(@__DIR__, "..", "src", "tutorials") + notebooks_dir = joinpath(pages_dir, "notebooks") - Sys.rm(pages_dir; recursive=true, force=true) + Sys.rm(pages_dir; recursive = true, force = true) - Sys.rm("out"; recursive=true, force=true) + Sys.rm("out"; recursive = true, force = true) # Run tests on all tutorial files @testset "TrixiTutorials" begin for (i, (title, filename)) in enumerate(files) if filename isa Vector # Several files of one topic for j in eachindex(filename) - @testset "$(filename[j][2][2])" begin include(joinpath(repo_src, filename[j][2][1], filename[j][2][2])) end + @testset "$(filename[j][2][2])" begin + include(joinpath(repo_src, filename[j][2][1], filename[j][2][2])) + end end else # Single files - @testset "$title" begin include(joinpath(repo_src, filename)) end + @testset "$title" begin + include(joinpath(repo_src, filename)) + end end end end # Generate markdown file for introduction page - Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name="introduction") + Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name = "introduction") # Navigation system for makedocs - pages = Any["Introduction" => "tutorials/introduction.md",] + pages = Any["Introduction" => "tutorials/introduction.md"] # Create markdown and notebook files for tutorials for (i, (title, filename)) in enumerate(files) @@ -72,8 +79,9 @@ function create_tutorials(files) if filename isa Vector vector = [] for j in eachindex(filename) - create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2], repo_src, - pages_dir, notebooks_dir; folder=filename[j][2][1]) + create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2], + repo_src, + pages_dir, notebooks_dir; folder = filename[j][2][1]) path = "$(filename[j][2][1])/$(splitext(filename[j][2][2])[1]).md" push!(vector, "$i.$j $(filename[j][1])" => "tutorials/$path") diff --git a/docs/literate/src/files/DGMulti_1.jl b/docs/literate/src/files/DGMulti_1.jl index 0d78e79907c..b50f76225bb 100644 --- a/docs/literate/src/files/DGMulti_1.jl +++ b/docs/literate/src/files/DGMulti_1.jl @@ -30,22 +30,22 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (32, 32) mesh = DGMultiMesh(dg, cells_per_dimension, # initial_refinement_level = 5 - coordinates_min=(-2.0, -2.0), - coordinates_max=( 2.0, 2.0), - periodicity=true) + coordinates_min = (-2.0, -2.0), + coordinates_max = (2.0, 2.0), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions=boundary_condition_periodic) + boundary_conditions = boundary_condition_periodic) tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval=10) -analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) +alive_callback = AliveCallback(alive_interval = 10) +analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) callbacks = CallbackSet(analysis_callback, alive_callback); # Run the simulation with the same time integration algorithm as before. -sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-6, reltol=1.0e-6, - callback=callbacks, save_everystep=false); +sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-6, reltol = 1.0e-6, + callback = callbacks, save_everystep = false); #- using Plots pd = PlotData2D(sol) @@ -60,7 +60,6 @@ plot!(getmesh(pd)) # (2021) provides a nice runtime comparison between the different mesh types. On the other hand, # the functions are more general and thus we have more option we can choose from. - # ## Simulation with Gauss nodes # For instance, we can change the approximation type of our simulation. using Trixi, OrdinaryDiffEq @@ -78,28 +77,27 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (32, 32) mesh = DGMultiMesh(dg, - cells_per_dimension, # initial_refinement_level = 5 - coordinates_min=(-2.0, -2.0), - coordinates_max=( 2.0, 2.0), - periodicity=true) + cells_per_dimension, # initial_refinement_level = 5 + coordinates_min = (-2.0, -2.0), + coordinates_max = (2.0, 2.0), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions=boundary_condition_periodic) + boundary_conditions = boundary_condition_periodic) tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval=10) -analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) +alive_callback = AliveCallback(alive_interval = 10) +analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) callbacks = CallbackSet(analysis_callback, alive_callback); -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); #- using Plots pd = PlotData2D(sol) plot(pd) - # ## Simulation with triangular elements # Also, we can set another element type. We want to use triangles now. using Trixi, OrdinaryDiffEq @@ -119,21 +117,21 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (32, 32) mesh = DGMultiMesh(dg, cells_per_dimension, # initial_refinement_level = 5 - coordinates_min=(-2.0, -2.0), - coordinates_max=( 2.0, 2.0), - periodicity=true) + coordinates_min = (-2.0, -2.0), + coordinates_max = (2.0, 2.0), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions=boundary_condition_periodic) + boundary_conditions = boundary_condition_periodic) tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval=10) -analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) +alive_callback = AliveCallback(alive_interval = 10) +analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) callbacks = CallbackSet(analysis_callback, alive_callback); -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); #- using Plots pd = PlotData2D(sol) @@ -142,7 +140,6 @@ plot(pd) plot(pd["rho"]) plot!(getmesh(pd)) - # ## Triangular meshes on non-Cartesian domains # To use triangular meshes on a non-Cartesian domain, Trixi.jl uses the package [StartUpDG.jl](https://github.com/jlchan/StartUpDG.jl). # The following example is based on [`elixir_euler_triangulate_pkg_mesh.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl) @@ -157,7 +154,7 @@ source_terms = source_terms_convergence_test # We create the solver `DGMulti` with triangular elements (`Tri()`) as before. dg = DGMulti(polydeg = 3, element_type = Tri(), - approximation_type=Polynomial(), + approximation_type = Polynomial(), surface_flux = flux_lax_friedrichs, volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) @@ -168,11 +165,11 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole()); # The pre-defined Triangulate geometry in StartUpDG has integer boundary tags. With [`DGMultiMesh`](@ref) # we assign boundary faces based on these integer boundary tags and create a mesh compatible with Trixi.jl. -mesh = DGMultiMesh(meshIO, dg, Dict(:outer_boundary=>1, :inner_boundary=>2)) +mesh = DGMultiMesh(meshIO, dg, Dict(:outer_boundary => 1, :inner_boundary => 2)) #- boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test, - :inner_boundary => boundary_condition_convergence_test) + :inner_boundary => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -181,12 +178,12 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, tspan = (0.0, 0.2) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval=20) -analysis_callback = AnalysisCallback(semi, interval=200, uEltype=real(dg)) +alive_callback = AliveCallback(alive_interval = 20) +analysis_callback = AnalysisCallback(semi, interval = 200, uEltype = real(dg)) callbacks = CallbackSet(alive_callback, analysis_callback); -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); #- using Plots pd = PlotData2D(sol) diff --git a/docs/literate/src/files/DGMulti_2.jl b/docs/literate/src/files/DGMulti_2.jl index 92dce43cdab..2944f83b309 100644 --- a/docs/literate/src/files/DGMulti_2.jl +++ b/docs/literate/src/files/DGMulti_2.jl @@ -8,8 +8,8 @@ # to the `DGMulti` constructor. For example, the classical second-order FD SBP operator # can be created as using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly -D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=11) +D = derivative_operator(MattssonNordström2004(), derivative_order = 1, accuracy_order = 2, + xmin = 0.0, xmax = 1.0, N = 11) # Here, the arguments `xmin` and `xmax` do not matter beyond setting the real type # used for the operator - they just set a reference element and are rescaled on the # physical elements. The parameter `N` determines the number of finite difference nodes. @@ -20,8 +20,8 @@ D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_o # # You can also use fully periodic single-block FD methods by creating a periodic SBP # operator. For example, a fully periodic FD operator can be constructed as -D = periodic_derivative_operator(derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=11) +D = periodic_derivative_operator(derivative_order = 1, accuracy_order = 2, + xmin = 0.0, xmax = 1.0, N = 11) # An example using such an FD method is implemented in # [`elixir_euler_fdsbp_periodic.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl). # For all parameters and other calling options, please have a look in the @@ -31,8 +31,8 @@ D = periodic_derivative_operator(derivative_order=1, accuracy_order=2, # method with polynomial degree of `3` (`N=4` Legendre Lobatto nodes on `[0, 1]`) coupled continuously # on a uniform mesh with `Nx=10` elements by setting `approximation_type` to using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly -D = couple_continuously(legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4), - UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10)) +D = couple_continuously(legendre_derivative_operator(xmin = 0.0, xmax = 1.0, N = 4), + UniformPeriodicMesh1D(xmin = -1.0, xmax = 1.0, Nx = 10)) # To choose a discontinuous coupling (DGSEM), use `couple_discontinuously()` instead of `couple_continuously()`. diff --git a/docs/literate/src/files/DGSEM_FluxDiff.jl b/docs/literate/src/files/DGSEM_FluxDiff.jl index cf3b0a1dbd4..49463fafa54 100644 --- a/docs/literate/src/files/DGSEM_FluxDiff.jl +++ b/docs/literate/src/files/DGSEM_FluxDiff.jl @@ -20,7 +20,6 @@ # J u_t + f(u)_{\xi} = 0, \qquad t\in \mathbb{R}^+, \xi\in [-1,1] # ``` - # ## The weak form of the DGSEM # We consider the so-called discontinuous Galerkin spectral element method (DGSEM) with collocation. # It results from choosing a nodal DG ansatz using $N+1$ Gauss-Lobatto nodes $\xi_i$ in $[-1,1]$ @@ -77,7 +76,6 @@ # ``` # More information about the equivalence you can find in [Kopriva, Gassner (2010)](https://doi.org/10.1007/s10915-010-9372-3). - # ## DGSEM with flux differencing # When using the diagonal SBP property it is possible to rewrite the application of the derivative # operator $D$ in the calculation of the volume integral into a subcell based finite volume type @@ -105,7 +103,6 @@ # flux $f=f_{sur}$ used for the numerical flux $f_{sur}^*$ and the already mentioned volume # flux $f_{vol}$ especially for this formulation. - # This formulation creates a more stable version of DGSEM, because it fulfils entropy stability. # Moreover it allows the construction of entropy conserving discretizations without relying on # exact integration. This is achieved when using a two-point entropy conserving flux function as @@ -113,8 +110,6 @@ # Then, the numerical surface flux can be used to control the dissipation of the discretization and to # guarantee decreasing entropy, i.e. entropy stability. - - # ## [Implementation in Trixi.jl](@id fluxDiffExample) # Now, we have a look at the implementation of DGSEM with flux differencing with [Trixi.jl](https://github.com/trixi-framework/Trixi.jl). using OrdinaryDiffEq, Trixi @@ -158,21 +153,21 @@ initial_condition = initial_condition_weak_blast_wave # We will confirm the entropy conservation property numerically. volume_flux = flux_ranocha # = f_vol -solver = DGSEM(polydeg=3, surface_flux=volume_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = volume_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Now, we implement Trixi.jl's `mesh`, `semi` and `ode` in a simple framework. For more information please # have a look at the documentation, the basic tutorial [introduction to DG methods](@ref scalar_linear_advection_1d) # or some basic elixirs. coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 5, + n_cells_max = 10_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_condition_periodic) + boundary_conditions = boundary_condition_periodic) ## ODE solvers tspan = (0.0, 0.4) @@ -180,11 +175,11 @@ ode = semidiscretize(semi, tspan); # To analyse the entropy conservation of the approximation, we will use the analysis calllback # implemented in Trixi. It provides some information about the approximation including the entropy change. -analysis_callback = AnalysisCallback(semi, interval=100); +analysis_callback = AnalysisCallback(semi, interval = 100); # We now run the simulation using `flux_ranocha` for both surface and volume flux. -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=analysis_callback); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = analysis_callback); # A look at the change in entropy $\sum \partial S/\partial U \cdot U_t$ in the analysis callback # confirms that the flux is entropy conserving since the change is about machine precision. @@ -202,34 +197,33 @@ equations = CompressibleEulerEquations2D(gamma) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha # = f_vol -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 5, + n_cells_max = 10_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_condition_periodic) + boundary_conditions = boundary_condition_periodic) ## ODE solvers tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan); -analysis_callback = AnalysisCallback(semi, interval=100); +analysis_callback = AnalysisCallback(semi, interval = 100); # We now run the simulation using the volume flux `flux_ranocha` and surface flux `flux_lax_friedrichs`. -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=analysis_callback); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = analysis_callback); # The change in entropy confirms the expected entropy stability. using Plots plot(sol) - # Of course, you can use more than these two fluxes in Trixi. Here, we will give a short list # of possible fluxes for the compressible Euler equations. # For the volume flux Trixi.jl provides for example [`flux_ranocha`](@ref), [`flux_shima_etal`](@ref), diff --git a/docs/literate/src/files/adaptive_mesh_refinement.jl b/docs/literate/src/files/adaptive_mesh_refinement.jl index d6150e887a8..c96040350e9 100644 --- a/docs/literate/src/files/adaptive_mesh_refinement.jl +++ b/docs/literate/src/files/adaptive_mesh_refinement.jl @@ -50,7 +50,6 @@ # amr_indicator = IndicatorMax(semi, variable=variable) # ```` - # ### Controllers # The spatial discretization into elements is tree-based for both AMR supporting mesh types `TreeMesh` # and `P4estMesh`. Thus, the higher the level in the tree the higher the level of refinement. @@ -87,7 +86,6 @@ # This controller is for instance used in # [`elixir_euler_astro_jet_amr.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl). - # ### Callback # The AMR indicator and controller are added to the simulation through the callback [`AMRCallback`](@ref). # It contains a semidiscretization `semi`, the controller `amr_controller` and the parameters `interval`, @@ -103,7 +101,6 @@ # adapt_initial_condition_only_refine=true) # ```` - # # Exemplary simulation # Here, we want to implement a simple AMR simulation of the 2D linear advection equation for a Gaussian pulse. @@ -114,17 +111,16 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan); @@ -132,29 +128,29 @@ ode = semidiscretize(semi, tspan); # `IndicatorMax`. As described before, it returns the maximal value of the specified variable # (here the only conserved variable). Therefore, regions with a high maximum are refined. # This is not really useful numerical application, but a nice demonstration example. -amr_indicator = IndicatorMax(semi, variable=first) +amr_indicator = IndicatorMax(semi, variable = first) # These values are transferred to a refinement level with the `ControllerThreeLevel`, such that # every element with maximal value greater than `0.1` is refined once and elements with maximum # above `0.6` are refined twice. amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(amr_callback, stepsize_callback); # Running 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); +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); # We plot the solution and add the refined mesh at the end of the simulation. using Plots @@ -162,7 +158,6 @@ pd = PlotData2D(sol) plot(pd) plot!(getmesh(pd)) - # # More examples # Trixi.jl provides many elixirs using AMR. We want to give some examples for different mesh types: # - `elixir_euler_blast_wave_amr.jl` for [`TreeMesh`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl) diff --git a/docs/literate/src/files/adding_new_parabolic_terms.jl b/docs/literate/src/files/adding_new_parabolic_terms.jl index 882f73f66ff..7da7ba78520 100644 --- a/docs/literate/src/files/adding_new_parabolic_terms.jl +++ b/docs/literate/src/files/adding_new_parabolic_terms.jl @@ -7,7 +7,6 @@ using OrdinaryDiffEq using Trixi - advection_velocity = (1.0, 1.0) equations_hyperbolic = LinearScalarAdvectionEquation2D(advection_velocity); @@ -20,12 +19,13 @@ equations_hyperbolic = LinearScalarAdvectionEquation2D(advection_velocity); # functions defined for hyperbolic equations (such as `varnames`). struct ConstantAnisotropicDiffusion2D{E, T} <: Trixi.AbstractEquationsParabolic{2, 1} - diffusivity::T - equations_hyperbolic::E + diffusivity::T + equations_hyperbolic::E end -varnames(variable_mapping, equations_parabolic::ConstantAnisotropicDiffusion2D) = - varnames(variable_mapping, equations_parabolic.equations_hyperbolic) +function varnames(variable_mapping, equations_parabolic::ConstantAnisotropicDiffusion2D) + varnames(variable_mapping, equations_parabolic.equations_hyperbolic) +end # Next, we define the viscous flux function. We assume that the mixed hyperbolic-parabolic system # is of the form @@ -39,14 +39,15 @@ varnames(variable_mapping, equations_parabolic::ConstantAnisotropicDiffusion2D) # # Here, we specialize the flux to our new parabolic equation type `ConstantAnisotropicDiffusion2D`. -function Trixi.flux(u, gradients, orientation::Integer, equations_parabolic::ConstantAnisotropicDiffusion2D) - @unpack diffusivity = equations_parabolic - dudx, dudy = gradients - if orientation == 1 - return SVector(diffusivity[1, 1] * dudx + diffusivity[1, 2] * dudy) - else # if orientation == 2 - return SVector(diffusivity[2, 1] * dudx + diffusivity[2, 2] * dudy) - end +function Trixi.flux(u, gradients, orientation::Integer, + equations_parabolic::ConstantAnisotropicDiffusion2D) + @unpack diffusivity = equations_parabolic + dudx, dudy = gradients + if orientation == 1 + return SVector(diffusivity[1, 1] * dudx + diffusivity[1, 2] * dudy) + else # if orientation == 2 + return SVector(diffusivity[2, 1] * dudx + diffusivity[2, 2] * dudy) + end end # ## Defining boundary conditions @@ -69,7 +70,7 @@ end # As an example, let us introduce a Dirichlet boundary condition with constant boundary data. struct BoundaryConditionConstantDirichlet{T <: Real} - boundary_value::T + boundary_value::T end # This boundary condition contains only the field `boundary_value`, which we assume to be some @@ -80,10 +81,13 @@ end # the `Gradient` and `Divergence`. Since the gradient is operating on the solution `u`, the boundary # data should be the value of `u`, and we can directly impose Dirichlet data. -@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, u_inner, normal::AbstractVector, - x, t, operator_type::Trixi.Gradient, +@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, + u_inner, + normal::AbstractVector, + x, t, + operator_type::Trixi.Gradient, equations_parabolic::ConstantAnisotropicDiffusion2D) - return boundary_condition.boundary_value + return boundary_condition.boundary_value end # While the gradient acts on the solution `u`, the divergence acts on the viscous flux ``\bm{\sigma}``. @@ -95,10 +99,13 @@ end # `flux_inner`, which is boundary data for ``\bm{\sigma}`` computed using the "inner" or interior solution. # This way, we supply boundary data for the divergence operation without imposing any additional conditions. -@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, u_inner, normal::AbstractVector, - x, t, operator_type::Trixi.Divergence, +@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, + u_inner, + normal::AbstractVector, + x, t, + operator_type::Trixi.Divergence, equations_parabolic::ConstantAnisotropicDiffusion2D) - return flux_inner + return flux_inner end # ### A note on the choice of gradient variables @@ -123,38 +130,38 @@ using Trixi: SMatrix diffusivity = 5.0e-2 * SMatrix{2, 2}([2 -1; -1 2]) equations_parabolic = ConstantAnisotropicDiffusion2D(diffusivity, equations_hyperbolic); -boundary_conditions_hyperbolic = (; x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1.0)), - y_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(2.0)), - y_pos = boundary_condition_do_nothing, - x_pos = boundary_condition_do_nothing) +boundary_conditions_hyperbolic = (; + x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1.0)), + y_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(2.0)), + y_pos = boundary_condition_do_nothing, + x_pos = boundary_condition_do_nothing) boundary_conditions_parabolic = (; x_neg = BoundaryConditionConstantDirichlet(1.0), - y_neg = BoundaryConditionConstantDirichlet(2.0), - y_pos = BoundaryConditionConstantDirichlet(0.0), - x_pos = BoundaryConditionConstantDirichlet(0.0)); + y_neg = BoundaryConditionConstantDirichlet(2.0), + y_pos = BoundaryConditionConstantDirichlet(0.0), + x_pos = BoundaryConditionConstantDirichlet(0.0)); -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=false, n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 4, + periodicity = false, n_cells_max = 30_000) # set maximum capacity of tree data structure initial_condition = (x, t, equations) -> SVector(0.0) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations_hyperbolic, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions_hyperbolic, - boundary_conditions_parabolic)) + boundary_conditions = (boundary_conditions_hyperbolic, + boundary_conditions_parabolic)) tspan = (0.0, 2.0) ode = semidiscretize(semi, tspan) callbacks = CallbackSet(SummaryCallback()) time_int_tol = 1.0e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks); using Plots plot(sol) - diff --git a/docs/literate/src/files/adding_new_scalar_equations.jl b/docs/literate/src/files/adding_new_scalar_equations.jl index fec7bcf667a..c66ad37f2ae 100644 --- a/docs/literate/src/files/adding_new_scalar_equations.jl +++ b/docs/literate/src/files/adding_new_scalar_equations.jl @@ -12,8 +12,8 @@ # ## Basic setup using Trixi -struct CubicEquation <: Trixi.AbstractEquations{1 #= number of spatial dimensions =#, - 1 #= number of primary variables, i.e. scalar =#}; +struct CubicEquation <: Trixi.AbstractEquations{1, #= number of spatial dimensions =# + 1} #= number of primary variables, i.e. scalar =# end # We create `CubicEquation` as an empty `struct` since we do not use any parameters @@ -23,7 +23,7 @@ end # Next, we define the physical flux `f(u) = u^3` using the calling structure # used in Trixi.jl. -Trixi.flux(u, orientation, equation::CubicEquation) = u.^3 +Trixi.flux(u, orientation, equation::CubicEquation) = u .^ 3 Trixi.varnames(_, ::CubicEquation) = ("scalar",) # In Trixi.jl, the conserved variables `u` are usually passed as `SVector`s of variables @@ -41,10 +41,10 @@ equation = CubicEquation() initial_condition_sine(x, t, equation::CubicEquation) = SVector(sinpi(x[1])) mesh = TreeMesh(-1.0, 1.0, # min/max coordinates - initial_refinement_level=4, - n_cells_max=10^4) + initial_refinement_level = 4, + n_cells_max = 10^4) -solver = DGSEM(3 #= polynomial degree =#, flux_central) +solver = DGSEM(3, flux_central) #= polynomial degree =# semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -67,7 +67,7 @@ callbacks = CallbackSet(summary_callback) ## OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks sol = solve(ode, SSPRK43(); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); # That's it, you ran your first simulation using your new equation with Trixi.jl! Now, we can plot # the solution at the final time using Plots.jl. @@ -79,20 +79,21 @@ plot(sol) # To avoid these issues, we need to use dissipative numerical fluxes (approximate # Riemann solvers) at interfaces. - # ## Advanced setup # Thus, we add a Godunov's flux for our cubic equation. That is easy for this equation # since the wave speed `f'(u) = 3u^2` is always non-negative. -@inline Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) = flux(u_ll, orientation, equation) +@inline function Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) + flux(u_ll, orientation, equation) +end # Let's run the example again but with a dissipative numerical flux at interfaces. # `remake` will recreate the semidiscretization we used before and only change # selected parameters, in this case the `solver`. ## A new setup with dissipation -semi = remake(semi, solver=DGSEM(3, flux_godunov)) +semi = remake(semi, solver = DGSEM(3, flux_godunov)) ode = semidiscretize(semi, tspan) sol = solve(ode, SSPRK43(); ode_default_options()...) plot!(sol) @@ -101,8 +102,9 @@ plot!(sol) # Now let's increase the final time (and also the spatial resolution). ## A larger final time: Nonclassical shocks develop (you can even increase the refinement to 12) -semi = remake(semi, mesh=TreeMesh(-1.0, 1.0, initial_refinement_level=8, n_cells_max=10^5)) -ode = semidiscretize(semi, (0.0, 0.5) #= tspan =#) +semi = remake(semi, + mesh = TreeMesh(-1.0, 1.0, initial_refinement_level = 8, n_cells_max = 10^5)) +ode = semidiscretize(semi, (0.0, 0.5)) #= tspan =# sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) @@ -112,14 +114,16 @@ plot(sol) # to define an entropy-conservative numerical flux @inline function Trixi.flux_ec(u_ll, u_rr, orientation, equation::CubicEquation) - return SVector(0.25 * (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) + return SVector(0.25 * + (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) end # and use a [`VolumeIntegralFluxDifferencing`](@ref) instead of the standard # [`VolumeIntegralWeakForm`](@ref) in the DGSEM. ## Let's use a provably entropy-dissipative semidiscretization -semi = remake(semi, solver=DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) +semi = remake(semi, + solver = DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) ode = semidiscretize(semi, (0.0, 0.5)) sol = solve(ode, SSPRK43(); ode_default_options()...); plot(sol) @@ -137,7 +141,6 @@ plot(sol) # the 2D scalar "KPP equation" from [Kurganov, Petrova, Popov (2007)](https://doi.org/10.1137/040614189) is # implemented. - # ## Summary of the code # To sum up, here is the complete code that we used (without the callbacks since these create a @@ -150,21 +153,23 @@ module CubicConservationLaw using Trixi -struct CubicEquation <: Trixi.AbstractEquations{1 #= number of spatial dimensions =#, - 1 #= number of primary variables, i.e. scalar =#} +struct CubicEquation <: Trixi.AbstractEquations{1, #= number of spatial dimensions =# + 1} #= number of primary variables, i.e. scalar =# end -@inline Trixi.flux(u, orientation, equation::CubicEquation) = u.^3 +@inline Trixi.flux(u, orientation, equation::CubicEquation) = u .^ 3 Trixi.varnames(_, ::CubicEquation) = ("scalar",) -@inline Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) = flux(u_ll, orientation, equation) +@inline function Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) + flux(u_ll, orientation, equation) +end @inline function Trixi.flux_ec(u_ll, u_rr, orientation, equation::CubicEquation) - return SVector(0.25 * (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) + return SVector(0.25 * + (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) end end # module - ## Create a simulation setup import .CubicConservationLaw using Trixi @@ -173,13 +178,15 @@ using Plots equation = CubicConservationLaw.CubicEquation() -initial_condition_sine(x, t, equation::CubicConservationLaw.CubicEquation) = SVector(sinpi(x[1])) +function initial_condition_sine(x, t, equation::CubicConservationLaw.CubicEquation) + SVector(sinpi(x[1])) +end mesh = TreeMesh(-1.0, 1.0, # min/max coordinates - initial_refinement_level=4, - n_cells_max=10^4) + initial_refinement_level = 4, + n_cells_max = 10^4) -solver = DGSEM(3 #= polynomial degree =#, flux_central) +solver = DGSEM(3, flux_central) #= polynomial degree =# semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -191,23 +198,22 @@ ode = semidiscretize(semi, tspan) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) - ## A new setup with dissipation -semi = remake(semi, solver=DGSEM(3, flux_godunov)) +semi = remake(semi, solver = DGSEM(3, flux_godunov)) ode = semidiscretize(semi, tspan) sol = solve(ode, SSPRK43(); ode_default_options()...) plot!(sol) - ## A larger final time: Nonclassical shocks develop (you can even increase the refinement to 12) -semi = remake(semi, mesh=TreeMesh(-1.0, 1.0, initial_refinement_level=8, n_cells_max=10^5)) +semi = remake(semi, + mesh = TreeMesh(-1.0, 1.0, initial_refinement_level = 8, n_cells_max = 10^5)) ode = semidiscretize(semi, (0.0, 0.5)) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) - ## Let's use a provably entropy-dissipative semidiscretization -semi = remake(semi, solver=DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) +semi = remake(semi, + solver = DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) ode = semidiscretize(semi, (0.0, 0.5)) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) diff --git a/docs/literate/src/files/adding_nonconservative_equation.jl b/docs/literate/src/files/adding_nonconservative_equation.jl index 110fa486070..ddd6d8d5207 100644 --- a/docs/literate/src/files/adding_nonconservative_equation.jl +++ b/docs/literate/src/files/adding_nonconservative_equation.jl @@ -40,27 +40,28 @@ import Trixi: varnames, default_analysis_integrals, flux, max_abs_speed_naive, ## Since there is no native support for variable coefficients, we use two ## variables: one for the basic unknown `u` and another one for the coefficient `a` -struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, - 2 #= two variables (u,a) =#} +struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# + 2} #= two variables (u,a) =# end -varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") +function varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) + ("scalar", "advection_velocity") +end default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () - ## The conservative part of the flux is zero flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) ## Calculate maximum wave speed for local Lax-Friedrichs-type dissipation -function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) +function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, + ::NonconservativeLinearAdvectionEquation) _, advection_velocity_ll = u_ll _, advection_velocity_rr = u_rr return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) end - ## We use nonconservative terms have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() @@ -73,7 +74,7 @@ have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.Tru function flux_nonconservative(u_mine, u_other, orientation, equations::NonconservativeLinearAdvectionEquation) _, advection_velocity = u_mine - scalar, _ = u_other + scalar, _ = u_other return SVector(advection_velocity * scalar, zero(scalar)) end @@ -105,15 +106,15 @@ end ## Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level=4, n_cells_max=10^4) + initial_refinement_level = 4, n_cells_max = 10^4) ## Create a DGSEM solver with polynomials of degree `polydeg` ## Remember to pass a tuple of the form `(conservative_flux, nonconservative_flux)` ## as `surface_flux` and `volume_flux` when working with nonconservative terms -volume_flux = (flux_central, flux_nonconservative) +volume_flux = (flux_central, flux_nonconservative) surface_flux = (flux_lax_friedrichs, flux_nonconservative) -solver = DGSEM(polydeg=3, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ## Setup the spatial semidiscretization containing all ingredients semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -125,13 +126,13 @@ ode = semidiscretize(semi, tspan) ## Set up some standard callbacks summarizing the simulation setup and computing ## errors of the numerical solution summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval=50) +analysis_callback = AnalysisCallback(semi, interval = 50) callbacks = CallbackSet(summary_callback, analysis_callback) ## OrdinaryDiffEq's `solve` method evolves the solution in time and executes ## the passed callbacks -sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, - save_everystep=false, callback=callbacks) +sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, + save_everystep = false, callback = callbacks) ## Print the timer summary summary_callback() @@ -152,7 +153,7 @@ error_1 = analysis_callback(sol).l2 |> first # simulation again. mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level=5, n_cells_max=10^4) + initial_refinement_level = 5, n_cells_max = 10^4) semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -160,24 +161,22 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval=50) +analysis_callback = AnalysisCallback(semi, interval = 50) callbacks = CallbackSet(summary_callback, analysis_callback); -sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, - save_everystep=false, callback=callbacks); +sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, + save_everystep = false, callback = callbacks); summary_callback() #nb #- error_2 = analysis_callback(sol).l2 |> first -@test isapprox(error_2, 1.860295931682964e-5, rtol=0.05) #src +@test isapprox(error_2, 1.860295931682964e-5, rtol = 0.05) #src #- error_1 / error_2 -@test isapprox(error_1 / error_2, 15.916970234784808, rtol=0.05) #src +@test isapprox(error_1 / error_2, 15.916970234784808, rtol = 0.05) #src # As expected, the new error is roughly reduced by a factor of 16, corresponding # to an experimental order of convergence of 4 (for polynomials of degree 3). - - # ## Summary of the code # Here is the complete code that we used (without the callbacks since these @@ -186,7 +185,6 @@ error_1 / error_2 # That ensures that we can re-create `struct`s defined therein without having to # restart Julia. - # Define new physics module NonconservativeLinearAdvection @@ -197,27 +195,28 @@ import Trixi: varnames, default_analysis_integrals, flux, max_abs_speed_naive, ## Since there is not yet native support for variable coefficients, we use two ## variables: one for the basic unknown `u` and another one for the coefficient `a` -struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, - 2 #= two variables (u,a) =#} +struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# + 2} #= two variables (u,a) =# end -varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") +function varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) + ("scalar", "advection_velocity") +end default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () - ## The conservative part of the flux is zero flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) ## Calculate maximum wave speed for local Lax-Friedrichs-type dissipation -function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) +function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, + ::NonconservativeLinearAdvectionEquation) _, advection_velocity_ll = u_ll _, advection_velocity_rr = u_rr return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) end - ## We use nonconservative terms have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() @@ -230,15 +229,13 @@ have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.Tru function flux_nonconservative(u_mine, u_other, orientation, equations::NonconservativeLinearAdvectionEquation) _, advection_velocity = u_mine - scalar, _ = u_other + scalar, _ = u_other return SVector(advection_velocity * scalar, zero(scalar)) end end # module - - ## Create a simulation setup import .NonconservativeLinearAdvection using Trixi @@ -248,7 +245,8 @@ equation = NonconservativeLinearAdvection.NonconservativeLinearAdvectionEquation ## You can derive the exact solution for this setup using the method of ## characteristics -function initial_condition_sine(x, t, equation::NonconservativeLinearAdvection.NonconservativeLinearAdvectionEquation) +function initial_condition_sine(x, t, + equation::NonconservativeLinearAdvection.NonconservativeLinearAdvectionEquation) x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) scalar = sin(x0) advection_velocity = 2 + cos(x[1]) @@ -257,15 +255,15 @@ end ## Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level=4, n_cells_max=10^4) + initial_refinement_level = 4, n_cells_max = 10^4) ## Create a DGSEM solver with polynomials of degree `polydeg` ## Remember to pass a tuple of the form `(conservative_flux, nonconservative_flux)` ## as `surface_flux` and `volume_flux` when working with nonconservative terms -volume_flux = (flux_central, NonconservativeLinearAdvection.flux_nonconservative) +volume_flux = (flux_central, NonconservativeLinearAdvection.flux_nonconservative) surface_flux = (flux_lax_friedrichs, NonconservativeLinearAdvection.flux_nonconservative) -solver = DGSEM(polydeg=3, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ## Setup the spatial semidiscretization containing all ingredients semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -277,13 +275,13 @@ ode = semidiscretize(semi, tspan); ## Set up some standard callbacks summarizing the simulation setup and computing ## errors of the numerical solution summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval=50) +analysis_callback = AnalysisCallback(semi, interval = 50) callbacks = CallbackSet(summary_callback, analysis_callback); ## OrdinaryDiffEq's `solve` method evolves the solution in time and executes ## the passed callbacks -sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, - save_everystep=false); +sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, + save_everystep = false); ## Plot the numerical solution at the final time using Plots: plot diff --git a/docs/literate/src/files/differentiable_programming.jl b/docs/literate/src/files/differentiable_programming.jl index ecc09d05dcf..5b6b21525bb 100644 --- a/docs/literate/src/files/differentiable_programming.jl +++ b/docs/literate/src/files/differentiable_programming.jl @@ -10,13 +10,11 @@ using Test: @test #src # In the following, we will walk through some examples demonstrating how to differentiate through # Trixi.jl. - # ## Forward mode automatic differentiation # Trixi.jl integrates well with [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) # for forward mode AD. - # ### Computing the Jacobian # The high-level interface to compute the Jacobian this way is [`jacobian_ad_forward`](@ref). # First, we load the required packages and compute the Jacobian of a semidiscretization @@ -27,7 +25,7 @@ using Trixi, LinearAlgebra, Plots equations = CompressibleEulerEquations2D(1.4) solver = DGSEM(3, flux_central) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_wave, solver) @@ -38,7 +36,7 @@ size(J) # Next, we compute the eigenvalues of the Jacobian. λ = eigvals(J) -scatter(real.(λ), imag.(λ), label="central flux") +scatter(real.(λ), imag.(λ), label = "central flux") # As you can see here, the maximal real part is close to zero. @@ -54,7 +52,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_w J = jacobian_ad_forward(semi) λ = eigvals(J) -scatter!(real.(λ), imag.(λ), label="Lax-Friedrichs flux") +scatter!(real.(λ), imag.(λ), label = "Lax-Friedrichs flux") # Although the maximal real part is still somewhat small, it's larger than for # the purely central discretization. @@ -74,7 +72,7 @@ condition_number = cond(V) equations = CompressibleEulerEquations1D(1.4) solver = DGSEM(3, flux_central) -mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=6, n_cells_max=10^5) +mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level = 6, n_cells_max = 10^5) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_wave, solver) @@ -82,7 +80,7 @@ J = jacobian_ad_forward(semi) λ = eigvals(J) -scatter(real.(λ), imag.(λ), label="central flux") +scatter(real.(λ), imag.(λ), label = "central flux") # Here, the maximal real part is basically zero to machine accuracy. @@ -103,7 +101,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_w J = jacobian_ad_forward(semi) λ = eigvals(J) -scatter!(real.(λ), imag.(λ), label="Lax-Friedrichs flux") +scatter!(real.(λ), imag.(λ), label = "Lax-Friedrichs flux") # As you can see from the plot generated above, the maximal real part is still # basically zero to machine precision. @@ -121,7 +119,6 @@ condition_number = cond(V) # Note that the condition number of the eigenvector matrix increases but is # still smaller than for the example in 2D. - # ### Computing other derivatives # It is also possible to compute derivatives of other dependencies using AD in Trixi.jl. For example, @@ -146,40 +143,41 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - inicenter = SVector(0.0, 0.0) # initial center of the vortex - iniamplitude = 5.0 # size and strength of the vortex + inicenter = SVector(0.0, 0.0) # initial center of the vortex + iniamplitude = 5.0 # size and strength of the vortex - rho = 1.0 # base flow - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 + rho = 1.0 # base flow + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 - cent = inicenter + vel*t_loc # shift advection of center to handle periodic BC, but only for v1 = v2 = 1.0 - cent = x - cent # distance to center point - cent = SVector(-cent[2], cent[1]) + cent = inicenter + vel * t_loc # shift advection of center to handle periodic BC, but only for v1 = v2 = 1.0 + cent = x - cent # distance to center point + cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) solver = DGSEM(3, flux_lax_friedrichs, VolumeIntegralFluxDifferencing(flux_ranocha)) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, + solver) u0_ode = Trixi.compute_coefficients(0.0, semi) size(u0_ode) @@ -188,13 +186,14 @@ size(u0_ode) # Next, we compute the Jacobian using `ForwardDiff.jacobian`. J = ForwardDiff.jacobian((du_ode, γ) -> begin - equations_inner = CompressibleEulerEquations2D(first(γ)) - semi_inner = Trixi.remake(semi, equations=equations_inner, uEltype=eltype(γ)) - Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) -end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` + equations_inner = CompressibleEulerEquations2D(first(γ)) + semi_inner = Trixi.remake(semi, equations = equations_inner, + uEltype = eltype(γ)) + Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) + end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` -round.(extrema(J), sigdigits=2) -@test round.(extrema(J), sigdigits=2) == (-220.0, 220.0) #src +round.(extrema(J), sigdigits = 2) +@test round.(extrema(J), sigdigits = 2) == (-220.0, 220.0) #src # Note that we create a semidiscretization `semi` at first to determine the state `u0_ode` around # which we want to perform the linearization. Next, we wrap the RHS evaluation inside a closure @@ -211,7 +210,6 @@ norm(J[1:4:end]) # Here, we used some knowledge about the internal memory layout of Trixi.jl, an array of structs # with the conserved variables as fastest-varying index in memory. - # ## Differentiating through a complete simulation # It is also possible to differentiate through a complete simulation. As an example, let's differentiate @@ -222,22 +220,23 @@ using Trixi, OrdinaryDiffEq, ForwardDiff, Plots function energy_at_final_time(k) # k is the wave number of the initial condition equations = LinearScalarAdvectionEquation2D(1.0, -0.3) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, + n_cells_max = 10^4) solver = DGSEM(3, flux_lax_friedrichs) initial_condition = (x, t, equation) -> begin - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) - return SVector(sinpi(k * sum(x_trans))) + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) + return SVector(sinpi(k * sum(x_trans))) end semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)) + uEltype = typeof(k)) ode = semidiscretize(semi, (0.0, 1.0)) - sol = solve(ode, BS3(), save_everystep=false) + sol = solve(ode, BS3(), save_everystep = false) Trixi.integrate(energy_total, sol.u[end], semi) end -k_values = range(0.9, 1.1, length=101) +k_values = range(0.9, 1.1, length = 101) -plot(k_values, energy_at_final_time.(k_values), label="Energy") +plot(k_values, energy_at_final_time.(k_values), label = "Energy") # You see a plot of a curve that resembles a parabola with local maximum around `k = 1.0`. # Why's that? Well, the domain is fixed but the wave number changes. Thus, if the wave number is @@ -249,44 +248,45 @@ plot(k_values, energy_at_final_time.(k_values), label="Energy") # We can compute the discrete derivative of the energy at the final time with respect to the wave # number `k` as follows. -round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits=2) -@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits=2) == 1.4e-5 #src +round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits = 2) +@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits = 2) == 1.4e-5 #src # This is rather small and we can treat it as zero in comparison to the value of this derivative at # other wave numbers `k`. dk_values = ForwardDiff.derivative.((energy_at_final_time,), k_values); -plot(k_values, dk_values, label="Derivative") +plot(k_values, dk_values, label = "Derivative") # If you remember basic calculus, a sufficient condition for a local maximum is that the first derivative # vanishes and the second derivative is negative. We can also check this discretely. -second_derivative = round(ForwardDiff.derivative( - k -> Trixi.ForwardDiff.derivative(energy_at_final_time, k), 1.0), - sigdigits=2) +second_derivative = round(ForwardDiff.derivative(k -> Trixi.ForwardDiff.derivative(energy_at_final_time, + k), 1.0), + sigdigits = 2) @test second_derivative ≈ -0.9 #src # Having seen this application, let's break down what happens step by step. function energy_at_final_time(k) # k is the wave number of the initial condition equations = LinearScalarAdvectionEquation2D(1.0, -0.3) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, + n_cells_max = 10^4) solver = DGSEM(3, flux_lax_friedrichs) initial_condition = (x, t, equation) -> begin x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) return SVector(sinpi(k * sum(x_trans))) end semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)) + uEltype = typeof(k)) ode = semidiscretize(semi, (0.0, 1.0)) - sol = solve(ode, BS3(), save_everystep=false) + sol = solve(ode, BS3(), save_everystep = false) Trixi.integrate(energy_total, sol.u[end], semi) end k = 1.0 -round(ForwardDiff.derivative(energy_at_final_time, k), sigdigits=2) -@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits=2) == 1.4e-5 #src +round(ForwardDiff.derivative(energy_at_final_time, k), sigdigits = 2) +@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits = 2) == 1.4e-5 #src # When calling `ForwardDiff.derivative(energy_at_final_time, k)` with `k=1.0`, ForwardDiff.jl # will basically use the chain rule and known derivatives of existing basic functions @@ -300,7 +300,7 @@ round(ForwardDiff.derivative(energy_at_final_time, k), sigdigits=2) # The first step in this example creates some basic ingredients of our simulation. equations = LinearScalarAdvectionEquation2D(1.0, -0.3) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, n_cells_max = 10^4) solver = DGSEM(3, flux_lax_friedrichs); # These do not have internal caches storing intermediate values of the numerical @@ -325,19 +325,18 @@ end; # need to tell Trixi.jl to allow `ForwardDiff.Dual` numbers in these caches. That's what # the keyword argument `uEltype=typeof(k)` in semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)); + uEltype = typeof(k)); # does. This is basically the only part where you need to modify your standard Trixi.jl # code to enable automatic differentiation. From there on, the remaining steps ode = semidiscretize(semi, (0.0, 1.0)) -sol = solve(ode, BS3(), save_everystep=false) -round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits=5) -@test round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits=5) == 0.24986 #src +sol = solve(ode, BS3(), save_everystep = false) +round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits = 5) +@test round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits = 5) == 0.24986 #src # do not need any modifications since they are sufficiently generic (and enough effort # has been spend to allow general types inside these calls). - # ## Propagating errors using Measurements.jl # [![Error bars by Randall Munroe](https://imgs.xkcd.com/comics/error_bars.png)](https://xkcd.com/2110/) @@ -354,16 +353,16 @@ using Trixi, OrdinaryDiffEq, Measurements, Plots, LaTeXStrings equations = LinearScalarAdvectionEquation1D(1.0 ± 0.1) -mesh = TreeMesh((-1.0,), (1.0,), n_cells_max=10^5, initial_refinement_level=5) +mesh = TreeMesh((-1.0,), (1.0,), n_cells_max = 10^5, initial_refinement_level = 5) solver = DGSEM(3) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver, uEltype=Measurement{Float64}) + solver, uEltype = Measurement{Float64}) ode = semidiscretize(semi, (0.0, 1.5)) -sol = solve(ode, BS3(), save_everystep=false); +sol = solve(ode, BS3(), save_everystep = false); plot(sol) @@ -378,7 +377,6 @@ plot(sol) # All this is possible due to allowing generic types and having good abstractions # in Julia that allow packages to work together seamlessly. - # ## Finite difference approximations # Trixi.jl provides the convenience function [`jacobian_fd`](@ref) to approximate the Jacobian @@ -390,7 +388,7 @@ equations = CompressibleEulerEquations2D(1.4) solver = DGSEM(3, flux_central) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_wave, solver) @@ -403,7 +401,6 @@ relative_difference = norm(J_fd - J_ad) / size(J_fd, 1) # This discrepancy is of the expected order of magnitude for central finite difference approximations. - # ## Linear systems # When a linear PDE is discretized using a linear scheme such as a standard DG method, @@ -426,9 +423,10 @@ equations = LinearScalarAdvectionEquation2D(1.0, -0.3) solver = DGSEM(3, flux_lax_friedrichs) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) A, b = linear_structure(semi) diff --git a/docs/literate/src/files/hohqmesh_tutorial.jl b/docs/literate/src/files/hohqmesh_tutorial.jl index 87076108d91..b0e6402aa74 100644 --- a/docs/literate/src/files/hohqmesh_tutorial.jl +++ b/docs/literate/src/files/hohqmesh_tutorial.jl @@ -35,8 +35,8 @@ # There is a default example for this mesh type that can be executed by using Trixi -redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md -trixi_include(default_example_unstructured()) +redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md + trixi_include(default_example_unstructured()) end #hide #md # This will compute a smooth, manufactured solution test case for the 2D compressible Euler equations @@ -52,8 +52,8 @@ end #hide #md # To convert the HDF5-formatted `.h5` output file(s) from Trixi.jl into VTK format execute the following using Trixi2Vtk -redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md -trixi2vtk("out/solution_000180.h5", output_directory="out") +redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md + trixi2vtk("out/solution_000180.h5", output_directory = "out") end #hide #md # Note this step takes about 15-30 seconds as the package `Trixi2Vtk` must be precompiled and executed for the first time @@ -62,8 +62,8 @@ end #hide #md # where the new files will be saved; it defaults to the current directory. (2) Specifying a higher number of # visualization nodes. For instance, if we want to use 12 uniformly spaced nodes for visualization we can execute -redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md -trixi2vtk("out/solution_000180.h5", output_directory="out", nvisnodes=12) +redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md + trixi2vtk("out/solution_000180.h5", output_directory = "out", nvisnodes = 12) end #hide #md # By default `trixi2vtk` sets `nvisnodes` to be the same as the number of nodes specified in @@ -71,8 +71,8 @@ end #hide #md # Finally, if you want to convert all the solution files to VTK execute -redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md -trixi2vtk("out/solution_000*.h5", output_directory="out", nvisnodes=12) +redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md + trixi2vtk("out/solution_000*.h5", output_directory = "out", nvisnodes = 12) end #hide #md # then it is possible to open the `.pvd` file with ParaView and create a video of the simulation. @@ -94,64 +94,64 @@ end #hide #md # The associated `ice_cream_straight_sides.control` file is created below. open("out/ice_cream_straight_sides.control", "w") do io - println(io, raw""" -\begin{CONTROL_INPUT} - \begin{RUN_PARAMETERS} - mesh file name = ice_cream_straight_sides.mesh - plot file name = ice_cream_straight_sides.tec - stats file name = none - mesh file format = ISM-v2 - polynomial order = 4 - plot file format = skeleton - \end{RUN_PARAMETERS} - - \begin{BACKGROUND_GRID} - x0 = [-8.0, -8.0, 0.0] - dx = [1.0, 1.0, 0.0] - N = [16,16,1] - \end{BACKGROUND_GRID} - - \begin{SPRING_SMOOTHER} - smoothing = ON - smoothing type = LinearAndCrossBarSpring - number of iterations = 25 - \end{SPRING_SMOOTHER} - -\end{CONTROL_INPUT} - -\begin{MODEL} - - \begin{INNER_BOUNDARIES} - - \begin{CHAIN} - name = IceCreamCone - \begin{END_POINTS_LINE} - name = LeftSlant - xStart = [-2.0, 1.0, 0.0] - xEnd = [ 0.0, -3.0, 0.0] - \end{END_POINTS_LINE} - - \begin{END_POINTS_LINE} - name = RightSlant - xStart = [ 0.0, -3.0, 0.0] - xEnd = [ 2.0, 1.0, 0.0] - \end{END_POINTS_LINE} - - \begin{CIRCULAR_ARC} - name = IceCream - units = degrees - center = [ 0.0, 1.0, 0.0] - radius = 2.0 - start angle = 0.0 - end angle = 180.0 - \end{CIRCULAR_ARC} - \end{CHAIN} - - \end{INNER_BOUNDARIES} - -\end{MODEL} -\end{FILE} -""") + println(io, raw""" + \begin{CONTROL_INPUT} + \begin{RUN_PARAMETERS} + mesh file name = ice_cream_straight_sides.mesh + plot file name = ice_cream_straight_sides.tec + stats file name = none + mesh file format = ISM-v2 + polynomial order = 4 + plot file format = skeleton + \end{RUN_PARAMETERS} + + \begin{BACKGROUND_GRID} + x0 = [-8.0, -8.0, 0.0] + dx = [1.0, 1.0, 0.0] + N = [16,16,1] + \end{BACKGROUND_GRID} + + \begin{SPRING_SMOOTHER} + smoothing = ON + smoothing type = LinearAndCrossBarSpring + number of iterations = 25 + \end{SPRING_SMOOTHER} + + \end{CONTROL_INPUT} + + \begin{MODEL} + + \begin{INNER_BOUNDARIES} + + \begin{CHAIN} + name = IceCreamCone + \begin{END_POINTS_LINE} + name = LeftSlant + xStart = [-2.0, 1.0, 0.0] + xEnd = [ 0.0, -3.0, 0.0] + \end{END_POINTS_LINE} + + \begin{END_POINTS_LINE} + name = RightSlant + xStart = [ 0.0, -3.0, 0.0] + xEnd = [ 2.0, 1.0, 0.0] + \end{END_POINTS_LINE} + + \begin{CIRCULAR_ARC} + name = IceCream + units = degrees + center = [ 0.0, 1.0, 0.0] + radius = 2.0 + start angle = 0.0 + end angle = 180.0 + \end{CIRCULAR_ARC} + \end{CHAIN} + + \end{INNER_BOUNDARIES} + + \end{MODEL} + \end{FILE} + """) end # The first three blocks of information are wrapped within a `CONTROL_INPUT` environment block as they define the @@ -304,18 +304,18 @@ equations = CompressibleEulerEquations2D(1.4) # set gas gamma = 1.4 ## freestream flow state with Ma_inf = 0.3 @inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D) - ## set the freestream flow parameters - rho_freestream = 1.0 - u_freestream = 0.3 - p_freestream = inv(equations.gamma) + ## set the freestream flow parameters + rho_freestream = 1.0 + u_freestream = 0.3 + p_freestream = inv(equations.gamma) - theta = 0.0 # zero angle of attack - si, co = sincos(theta) - v1 = u_freestream * co - v2 = u_freestream * si + theta = 0.0 # zero angle of attack + si, co = sincos(theta) + v1 = u_freestream * co + v2 = u_freestream * si - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end ## initial condition @@ -325,13 +325,13 @@ initial_condition = uniform_flow_state boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state) ## boundary condition dictionary -boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, - :Top => boundary_condition_uniform_flow, - :Right => boundary_condition_uniform_flow, - :Left => boundary_condition_uniform_flow, - :LeftSlant => boundary_condition_slip_wall, - :RightSlant => boundary_condition_slip_wall, - :IceCream => boundary_condition_slip_wall ); +boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow, + :Top => boundary_condition_uniform_flow, + :Right => boundary_condition_uniform_flow, + :Left => boundary_condition_uniform_flow, + :LeftSlant => boundary_condition_slip_wall, + :RightSlant => boundary_condition_slip_wall, + :IceCream => boundary_condition_slip_wall); ## DGSEM solver. ## 1) polydeg must be >= the polynomial order set in the HOHQMesh control file to guarantee @@ -339,8 +339,8 @@ boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, ## 2) VolumeIntegralFluxDifferencing with central volume flux is activated ## for dealiasing volume_flux = flux_ranocha -solver = DGSEM(polydeg=4, surface_flux=flux_hll, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = flux_hll, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ## create the unstructured mesh from your mesh file mesh_file = joinpath("out", "ice_cream_straight_sides.mesh") @@ -348,29 +348,28 @@ mesh = UnstructuredMesh2D(mesh_file) ## Create semidiscretization with all spatial discretization-related components semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ## Create ODE problem from semidiscretization with time span from 0.0 to 2.0 tspan = (0.0, 2.0) ode = semidiscretize(semi, tspan) - ## Create the callbacks to output solution files and adapt the time step summary_callback = SummaryCallback() -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl=1.0) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, save_solution, stepsize_callback) -redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md -## Evolve ODE problem in time using `solve` from OrdinaryDiffEq -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); -## print the timer summary -summary_callback() +redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md + ## Evolve ODE problem in time using `solve` from OrdinaryDiffEq + 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) + ## print the timer summary + summary_callback() end #hide #md # Visualization of the solution is carried out in a similar way as above. That is, one converts the `.h5` @@ -388,72 +387,72 @@ end #hide #md # We create the new control file `ice_cream_curved_sides.control` file below and will then highlight the # major differences compared to `ice_cream_straight_sides.control`. open("out/ice_cream_curved_sides.control", "w") do io - println(io, raw""" -\begin{CONTROL_INPUT} - \begin{RUN_PARAMETERS} - mesh file name = ice_cream_curved_sides.mesh - plot file name = ice_cream_curved_sides.tec - stats file name = none - mesh file format = ISM-v2 - polynomial order = 4 - plot file format = skeleton - \end{RUN_PARAMETERS} - - \begin{BACKGROUND_GRID} - background grid size = [1.0, 1.0, 0.0] - \end{BACKGROUND_GRID} - - \begin{SPRING_SMOOTHER} - smoothing = ON - smoothing type = LinearAndCrossBarSpring - number of iterations = 25 - \end{SPRING_SMOOTHER} - -\end{CONTROL_INPUT} - -\begin{MODEL} - - \begin{OUTER_BOUNDARY} - \begin{PARAMETRIC_EQUATION_CURVE} - name = OuterCircle - xEqn = x(t) = 8.0*sin(2.0*pi*t) - yEqn = y(t) = 8.0*cos(2.0*pi*t) - zEqn = z(t) = 0.0 - \end{PARAMETRIC_EQUATION_CURVE} - - \end{OUTER_BOUNDARY} - - \begin{INNER_BOUNDARIES} - - \begin{CHAIN} - name = IceCreamCone - \begin{END_POINTS_LINE} - name = LeftSlant - xStart = [-2.0, 1.0, 0.0] - xEnd = [ 0.0, -3.0, 0.0] - \end{END_POINTS_LINE} - - \begin{END_POINTS_LINE} - name = RightSlant - xStart = [ 0.0, -3.0, 0.0] - xEnd = [ 2.0, 1.0, 0.0] - \end{END_POINTS_LINE} - - \begin{CIRCULAR_ARC} - name = IceCream - units = degrees - center = [ 0.0, 1.0, 0.0] - radius = 2.0 - start angle = 0.0 - end angle = 180.0 - \end{CIRCULAR_ARC} - \end{CHAIN} - - \end{INNER_BOUNDARIES} - -\end{MODEL} -\end{FILE} -""") + println(io, raw""" + \begin{CONTROL_INPUT} + \begin{RUN_PARAMETERS} + mesh file name = ice_cream_curved_sides.mesh + plot file name = ice_cream_curved_sides.tec + stats file name = none + mesh file format = ISM-v2 + polynomial order = 4 + plot file format = skeleton + \end{RUN_PARAMETERS} + + \begin{BACKGROUND_GRID} + background grid size = [1.0, 1.0, 0.0] + \end{BACKGROUND_GRID} + + \begin{SPRING_SMOOTHER} + smoothing = ON + smoothing type = LinearAndCrossBarSpring + number of iterations = 25 + \end{SPRING_SMOOTHER} + + \end{CONTROL_INPUT} + + \begin{MODEL} + + \begin{OUTER_BOUNDARY} + \begin{PARAMETRIC_EQUATION_CURVE} + name = OuterCircle + xEqn = x(t) = 8.0*sin(2.0*pi*t) + yEqn = y(t) = 8.0*cos(2.0*pi*t) + zEqn = z(t) = 0.0 + \end{PARAMETRIC_EQUATION_CURVE} + + \end{OUTER_BOUNDARY} + + \begin{INNER_BOUNDARIES} + + \begin{CHAIN} + name = IceCreamCone + \begin{END_POINTS_LINE} + name = LeftSlant + xStart = [-2.0, 1.0, 0.0] + xEnd = [ 0.0, -3.0, 0.0] + \end{END_POINTS_LINE} + + \begin{END_POINTS_LINE} + name = RightSlant + xStart = [ 0.0, -3.0, 0.0] + xEnd = [ 2.0, 1.0, 0.0] + \end{END_POINTS_LINE} + + \begin{CIRCULAR_ARC} + name = IceCream + units = degrees + center = [ 0.0, 1.0, 0.0] + radius = 2.0 + start angle = 0.0 + end angle = 180.0 + \end{CIRCULAR_ARC} + \end{CHAIN} + + \end{INNER_BOUNDARIES} + + \end{MODEL} + \end{FILE} + """) end # The first alteration is that we have altered the second block of information @@ -500,10 +499,10 @@ output = generate_mesh(control_file); # dictionary because we now have a boundary named `OuterCircle` instead of four edges of a bounding box. ## boundary condition dictionary -boundary_conditions = Dict( :OuterCircle => boundary_condition_uniform_flow, - :LeftSlant => boundary_condition_slip_wall, - :RightSlant => boundary_condition_slip_wall, - :IceCream => boundary_condition_slip_wall ); +boundary_conditions = Dict(:OuterCircle => boundary_condition_uniform_flow, + :LeftSlant => boundary_condition_slip_wall, + :RightSlant => boundary_condition_slip_wall, + :IceCream => boundary_condition_slip_wall); # Also, we must update the construction of the mesh from our new mesh file `ice_cream_curved_sides.mesh` that # is located in the `out` folder. @@ -512,12 +511,10 @@ boundary_conditions = Dict( :OuterCircle => boundary_condition_uniform_flow, mesh_file = joinpath("out", "ice_cream_curved_sides.mesh") mesh = UnstructuredMesh2D(mesh_file); - # We can then post-process the solution file at the final time on the new mesh with `Trixi2Vtk` and visualize with ParaView. # ![simulation_curved_sides](https://user-images.githubusercontent.com/25242486/129733924-778795c1-9119-419a-8b89-bcbe13e33cd7.png) - # ## Setting up a simulation with AMR via `P4estMesh` # The above explained mesh file format of `ISM-V2` only works with `UnstructuredMesh2D` and so does # not support AMR. On the other hand, the mesh type [`P4estMesh`](@ref) allows AMR. The mesh diff --git a/docs/literate/src/files/non_periodic_boundaries.jl b/docs/literate/src/files/non_periodic_boundaries.jl index 54da88a64aa..5b92afa6a0d 100644 --- a/docs/literate/src/files/non_periodic_boundaries.jl +++ b/docs/literate/src/files/non_periodic_boundaries.jl @@ -25,7 +25,6 @@ # where `x` specifies the spatial coordinates, `t` is the current time, and `equations` is the # corresponding system of equations. - # We want to give a short example for a simulation with such a Dirichlet BC. # Consider the one-dimensional linear advection equation with domain $\Omega=[0, 2]$ and a constant @@ -39,7 +38,8 @@ initial_condition_zero(x, t, equation::LinearScalarAdvectionEquation1D) = SVecto initial_condition = initial_condition_zero using Plots -plot(x -> sum(initial_condition(x, 0.0, equations)), label="initial condition", ylim=(-1.5, 1.5)) +plot(x -> sum(initial_condition(x, 0.0, equations)), label = "initial condition", + ylim = (-1.5, 1.5)) # Using an advection velocity of `1.0` and the (local) Lax-Friedrichs/Rusanov flux # [`FluxLaxFriedrichs`](@ref) as a numerical surface flux, we are able to create an inflow boundary @@ -57,10 +57,10 @@ end boundary_condition = boundary_condition_sine_sector # We set the BC in negative and positive x-direction. -boundary_conditions = (x_neg=BoundaryConditionDirichlet(boundary_condition), - x_pos=BoundaryConditionDirichlet(boundary_condition)) +boundary_conditions = (x_neg = BoundaryConditionDirichlet(boundary_condition), + x_pos = BoundaryConditionDirichlet(boundary_condition)) #- -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (2.0,) @@ -68,41 +68,41 @@ coordinates_max = (2.0,) # For the mesh type `TreeMesh` the parameter `periodicity` must be set to `false` in the # corresponding direction. mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) tspan = (0.0, 6.0) ode = semidiscretize(semi, tspan) -analysis_callback = AnalysisCallback(semi, interval=100,) +analysis_callback = AnalysisCallback(semi, interval = 100) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(analysis_callback, stepsize_callback); # We define some equidistant nodes for the visualization -visnodes = range(tspan[1], tspan[2], length=300) +visnodes = range(tspan[1], tspan[2], length = 300) # and run the simulation. -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=1, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, saveat=visnodes, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep = false, saveat = visnodes, callback = callbacks); using Plots @gif for step in 1:length(sol.u) - plot(sol.u[step], semi, ylim=(-1.5, 1.5), legend=true, label="approximation", title="time t=$(round(sol.t[step], digits=5))") - scatter!([0.0], [sum(boundary_condition(SVector(0.0), sol.t[step], equations))], label="boundary condition") + plot(sol.u[step], semi, ylim = (-1.5, 1.5), legend = true, label = "approximation", + title = "time t=$(round(sol.t[step], digits=5))") + scatter!([0.0], [sum(boundary_condition(SVector(0.0), sol.t[step], equations))], + label = "boundary condition") end - # # Other available example elixirs with non-trivial BC # Moreover, there are other boundary conditions in Trixi.jl. For instance, you can use the slip wall # boundary condition [`boundary_condition_slip_wall`](@ref). diff --git a/docs/literate/src/files/parabolic_terms.jl b/docs/literate/src/files/parabolic_terms.jl index bac0098f8e9..8c7800a1f1f 100644 --- a/docs/literate/src/files/parabolic_terms.jl +++ b/docs/literate/src/files/parabolic_terms.jl @@ -34,27 +34,33 @@ equations_parabolic = LaplaceDiffusion2D(diffusivity, equations_hyperbolic); boundary_condition_zero_dirichlet = BoundaryConditionDirichlet((x, t, equations) -> SVector(0.0)) -boundary_conditions_hyperbolic = (; x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.5 * x[2])), - y_neg = boundary_condition_zero_dirichlet, - y_pos = boundary_condition_do_nothing, - x_pos = boundary_condition_do_nothing) - -boundary_conditions_parabolic = (; x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.5 * x[2])), - y_neg = boundary_condition_zero_dirichlet, - y_pos = boundary_condition_zero_dirichlet, - x_pos = boundary_condition_zero_dirichlet); +boundary_conditions_hyperbolic = (; + x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + + 0.5 * + x[2])), + y_neg = boundary_condition_zero_dirichlet, + y_pos = boundary_condition_do_nothing, + x_pos = boundary_condition_do_nothing) + +boundary_conditions_parabolic = (; + x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + + 0.5 * + x[2])), + y_neg = boundary_condition_zero_dirichlet, + y_pos = boundary_condition_zero_dirichlet, + x_pos = boundary_condition_zero_dirichlet); # ## Defining the solver and mesh # The process of creating the DG solver and mesh is the same as for a purely # hyperbolic system of equations. -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=false, n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 4, + periodicity = false, n_cells_max = 30_000) # set maximum capacity of tree data structure initial_condition = (x, t, equations) -> SVector(0.0); @@ -68,8 +74,8 @@ initial_condition = (x, t, equations) -> SVector(0.0); semi = SemidiscretizationHyperbolicParabolic(mesh, (equations_hyperbolic, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions_hyperbolic, - boundary_conditions_parabolic)) + boundary_conditions = (boundary_conditions_hyperbolic, + boundary_conditions_parabolic)) # The rest of the code is identical to the hyperbolic case. We create a system of ODEs through # `semidiscretize`, defining callbacks, and then passing the system to OrdinaryDiffEq.jl. @@ -78,11 +84,10 @@ tspan = (0.0, 1.5) ode = semidiscretize(semi, tspan) callbacks = CallbackSet(SummaryCallback()) time_int_tol = 1.0e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks); # We can now visualize the solution, which develops a boundary layer at the outflow boundaries. using Plots plot(sol) - diff --git a/docs/literate/src/files/scalar_linear_advection_1d.jl b/docs/literate/src/files/scalar_linear_advection_1d.jl index 42c831c98ba..1ad62484038 100644 --- a/docs/literate/src/files/scalar_linear_advection_1d.jl +++ b/docs/literate/src/files/scalar_linear_advection_1d.jl @@ -50,7 +50,6 @@ dx = (coordinates_max - coordinates_min) / n_elements # length of one element # ``` # Here, $u_t^{Q_l}$ and $u_\xi^{Q_l}$ denote the time and spatial derivatives of the solution on the element $Q_l$. - # ### ii. Polynomial approach # Now, we want to approximate the solution in each element $Q_l$ by a polynomial of degree $N$. Since we transformed # the equation, we can use the same polynomial approach for the reference coordinate $\xi\in[-1, 1]$ in every @@ -104,8 +103,7 @@ weights = basis.weights # \end{align*} # ``` # Let's use our nodes and weights for $N=3$ and plug in -integral = sum(nodes.^3 .* weights) - +integral = sum(nodes .^ 3 .* weights) # Using this polynomial approach leads to the equation # ```math @@ -119,10 +117,10 @@ integral = sum(nodes.^3 .* weights) # for every node. x = Matrix{Float64}(undef, length(nodes), n_elements) for element in 1:n_elements - x_l = coordinates_min + (element - 1) * dx + dx/2 + x_l = coordinates_min + (element - 1) * dx + dx / 2 for i in 1:length(nodes) ξ = nodes[i] # nodes in [-1, 1] - x[i, element] = x_l + dx/2 * ξ + x[i, element] = x_l + dx / 2 * ξ end end @@ -130,7 +128,7 @@ u0 = initial_condition_sine_wave.(x) # To have a look at the initial sinus curve, we plot it. using Plots -plot(vec(x), vec(u0), label="initial condition", legend=:topleft) +plot(vec(x), vec(u0), label = "initial condition", legend = :topleft) # ### iii. Variational formulation # After defining the equation and initial condition, we want to implement an algorithm to @@ -243,8 +241,9 @@ D = basis.derivative_matrix # ``` # for $k=0,...,N$ and therefore, $\underline{f}' = D \underline{f}$. basis_N8 = LobattoLegendreBasis(8) -plot(vec(x), x -> 3 * x^2, label="f'", lw=2) -scatter!(basis_N8.nodes, basis_N8.derivative_matrix * basis_N8.nodes.^3, label="Df", lw=3) +plot(vec(x), x -> 3 * x^2, label = "f'", lw = 2) +scatter!(basis_N8.nodes, basis_N8.derivative_matrix * basis_N8.nodes .^ 3, label = "Df", + lw = 3) # Combining the volume term for every $i=0,...,N$ results in # ```math @@ -302,13 +301,15 @@ function rhs!(du, u, x, t) ## Trixi.jl needs the equation we are dealing with and an additional `1`, that indicates the ## first coordinate direction. equations = LinearScalarAdvectionEquation1D(1.0) - for element in 2:n_elements-1 + for element in 2:(n_elements - 1) ## left interface - flux_numerical[1, element] = surface_flux(u[end, element-1], u[1, element], 1, equations) - flux_numerical[end, element-1] = flux_numerical[1, element] + flux_numerical[1, element] = surface_flux(u[end, element - 1], u[1, element], 1, + equations) + flux_numerical[end, element - 1] = flux_numerical[1, element] ## right interface - flux_numerical[end, element] = surface_flux(u[end, element], u[1, element+1], 1, equations) - flux_numerical[1, element+1] = flux_numerical[end, element] + flux_numerical[end, element] = surface_flux(u[end, element], u[1, element + 1], 1, + equations) + flux_numerical[1, element + 1] = flux_numerical[end, element] end ## boundary flux flux_numerical[1, 1] = surface_flux(u[end, end], u[1, 1], 1, equations) @@ -342,13 +343,12 @@ using OrdinaryDiffEq tspan = (0.0, 2.0) ode = ODEProblem(rhs!, u0, tspan, x) -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...) +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()...) @test maximum(abs.(u0 - sol.u[end])) < 5e-5 #src -plot(vec(x), vec(sol.u[end]), label="solution at t=$(tspan[2])", legend=:topleft, lw=3) - - - +plot(vec(x), vec(sol.u[end]), label = "solution at t=$(tspan[2])", legend = :topleft, + lw = 3) # ## Alternative Implementation based on Trixi.jl # Now, we implement the same example. But this time, we directly use the functionality that Trixi.jl @@ -362,7 +362,7 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) # Then, create a DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux. # The implementation of the basis and the numerical flux is now already done. -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # We will now create a mesh with 16 elements for the physical domain `[-1, 1]` with periodic boundaries. # We use Trixi.jl's standard mesh [`TreeMesh`](@ref). Since it's limited to hypercube domains, we @@ -371,29 +371,30 @@ solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate coordinates_max = 1.0 # maximum coordinate mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, # number of elements = 2^4 - n_cells_max=30_000) # set maximum capacity of tree data structure (only needed for AMR) + initial_refinement_level = 4, # number of elements = 2^4 + n_cells_max = 30_000) # set maximum capacity of tree data structure (only needed for AMR) # A semidiscretization collects data structures and functions for the spatial discretization. # In Trixi.jl, an initial condition has the following parameter structure and is of the type `SVector`. -initial_condition_sine_wave(x, t, equations) = SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) +function initial_condition_sine_wave(x, t, equations) + SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) +end semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_sine_wave, solver) # Again, combining all definitions and the function that calculates the right-hand side, we define the ODE and # solve it until `t=2` with OrdinaryDiffEq's `solve` function and the Runge-Kutta method `RDPK3SpFSAL49()`. tspan = (0.0, 2.0) -ode_trixi = semidiscretize(semi, tspan) +ode_trixi = semidiscretize(semi, tspan) -sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...); +sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()...); # We add a plot of the new approximated solution to the one calculated before. -plot!(sol_trixi, label="solution at t=$(tspan[2]) with Trixi.jl", legend=:topleft, linestyle=:dash, lw=2) +plot!(sol_trixi, label = "solution at t=$(tspan[2]) with Trixi.jl", legend = :topleft, + linestyle = :dash, lw = 2) @test maximum(abs.(vec(u0) - sol_trixi.u[end])) ≈ maximum(abs.(u0 - sol.u[end])) #src - - - # ## Summary of the code # To sum up, here is the complete code that we used. @@ -410,16 +411,16 @@ B = diagm([-1; zeros(polydeg - 1); 1]) ## mesh coordinates_min = -1.0 # minimum coordinate coordinates_max = 1.0 # maximum coordinate -n_elements = 16 # number of elements +n_elements = 16 # number of elements dx = (coordinates_max - coordinates_min) / n_elements # length of one element x = Matrix{Float64}(undef, length(nodes), n_elements) for element in 1:n_elements - x_l = -1 + (element - 1) * dx + dx/2 + x_l = -1 + (element - 1) * dx + dx / 2 for i in 1:length(nodes) # basis points in [-1, 1] ξ = nodes[i] - x[i, element] = x_l + dx/2 * ξ + x[i, element] = x_l + dx / 2 * ξ end end @@ -427,7 +428,7 @@ end initial_condition_sine_wave(x) = 1.0 + 0.5 * sin(pi * x) u0 = initial_condition_sine_wave.(x) -plot(vec(x), vec(u0), label="initial condition", legend=:topleft) +plot(vec(x), vec(u0), label = "initial condition", legend = :topleft) ## flux Lax-Friedrichs surface_flux = flux_lax_friedrichs @@ -440,13 +441,15 @@ function rhs!(du, u, x, t) ## calculate interface and boundary fluxes equations = LinearScalarAdvectionEquation1D(1.0) - for element in 2:n_elements-1 + for element in 2:(n_elements - 1) ## left interface - flux_numerical[1, element] = surface_flux(u[end, element-1], u[1, element], 1, equations) - flux_numerical[end, element-1] = flux_numerical[1, element] + flux_numerical[1, element] = surface_flux(u[end, element - 1], u[1, element], 1, + equations) + flux_numerical[end, element - 1] = flux_numerical[1, element] ## right interface - flux_numerical[end, element] = surface_flux(u[end, element], u[1, element+1], 1, equations) - flux_numerical[1, element+1] = flux_numerical[end, element] + flux_numerical[end, element] = surface_flux(u[end, element], u[1, element + 1], 1, + equations) + flux_numerical[1, element + 1] = flux_numerical[end, element] end ## boundary flux flux_numerical[1, 1] = surface_flux(u[end, end], u[1, 1], 1, equations) @@ -476,11 +479,12 @@ tspan = (0.0, 2.0) ode = ODEProblem(rhs!, u0, tspan, x) ## solve -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...) +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()...) @test maximum(abs.(vec(u0) - sol_trixi.u[end])) ≈ maximum(abs.(u0 - sol.u[end])) #src -plot(vec(x), vec(sol.u[end]), label="solution at t=$(tspan[2])", legend=:topleft, lw=3) - +plot(vec(x), vec(sol.u[end]), label = "solution at t=$(tspan[2])", legend = :topleft, + lw = 3) # ### Alternative Implementation based on Trixi.jl using Trixi, OrdinaryDiffEq, Plots @@ -490,24 +494,28 @@ advection_velocity = 1.0 equations = LinearScalarAdvectionEquation1D(advection_velocity) ## create DG solver with flux lax friedrichs and LGL basis -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) ## distretize domain with `TreeMesh` coordinates_min = -1.0 # minimum coordinate coordinates_max = 1.0 # maximum coordinate mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, # number of elements = 2^4 - n_cells_max=30_000) + initial_refinement_level = 4, # number of elements = 2^4 + n_cells_max = 30_000) ## create initial condition and semidiscretization -initial_condition_sine_wave(x, t, equations) = SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) +function initial_condition_sine_wave(x, t, equations) + SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) +end semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_sine_wave, solver) ## solve tspan = (0.0, 2.0) -ode_trixi = semidiscretize(semi, tspan) -sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...); +ode_trixi = semidiscretize(semi, tspan) +sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()...); -plot!(sol_trixi, label="solution at t=$(tspan[2]) with Trixi.jl", legend=:topleft, linestyle=:dash, lw=2) +plot!(sol_trixi, label = "solution at t=$(tspan[2]) with Trixi.jl", legend = :topleft, + linestyle = :dash, lw = 2) @test maximum(abs.(vec(u0) - sol_trixi.u[end])) ≈ maximum(abs.(u0 - sol.u[end])) #src diff --git a/docs/literate/src/files/shock_capturing.jl b/docs/literate/src/files/shock_capturing.jl index b165f7ec8bd..73fd06983bb 100644 --- a/docs/literate/src/files/shock_capturing.jl +++ b/docs/literate/src/files/shock_capturing.jl @@ -4,7 +4,6 @@ # and its implementation in [Trixi.jl](https://github.com/trixi-framework/Trixi.jl). # In the second part, an implementation of a positivity preserving limiter is added to the simulation. - # # Shock capturing with flux differencing # The following rough explanation is on a very basic level. More information about an entropy stable @@ -36,7 +35,6 @@ # volume_flux_fv=volume_flux_fv) # ```` - # We now focus on a choice of the shock capturing indicator `indicator_sc`. # A possible indicator is $\alpha_{HG}$ presented by Hennemann et al. (p.10), which depends on the # current approximation with modal coefficients $\{m_j\}_{j=0}^N$ of a given `variable`. @@ -84,8 +82,6 @@ # variable=variable) # ```` - - # # Positivity preserving limiter # Some numerical solutions are physically meaningless, for instance negative values of pressure @@ -132,7 +128,6 @@ # SSPRK43(stage_limiter!). # ```` - # # Simulation with shock capturing and positivity preserving # Now, we can run a simulation using the described methods of shock capturing and positivity @@ -143,26 +138,26 @@ equations = CompressibleEulerEquations2D(1.4) # As our initial condition we use the Sedov blast wave setup. 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) - - 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) + ## 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) + + 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 #- @@ -171,7 +166,7 @@ basis = LobattoLegendreBasis(3) # We set the numerical fluxes and divide between the surface flux and the two volume fluxes for the DG # and FV method. Here, we are using [`flux_lax_friedrichs`](@ref) and [`flux_ranocha`](@ref). surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha # Now, we specify the shock capturing indicator $\alpha$. @@ -180,26 +175,26 @@ volume_flux = flux_ranocha # Since density and pressure are the critical variables in this example, we use # `density_pressure = density * pressure = rho * p` as indicator variable. indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) # Now, we can use the defined fluxes and the indicator to implement the volume integral using shock # capturing. volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) # We finalize the discretization by implementing Trixi.jl's `solver`, `mesh`, `semi` and `ode`, # while `solver` now has the extra parameter `volume_integral`. solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -207,20 +202,20 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan); # We add some callbacks to get an solution analysis and use a CFL-based time step size calculation. -analysis_callback = AnalysisCallback(semi, interval=100) +analysis_callback = AnalysisCallback(semi, interval = 100) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(analysis_callback, stepsize_callback); # We now run the simulation using the positivity preserving limiter of Zhang and Shu for the variables # density and pressure. -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); using Plots plot(sol) diff --git a/docs/literate/src/files/structured_mesh_mapping.jl b/docs/literate/src/files/structured_mesh_mapping.jl index 0ae9cf723f8..6cf9588f594 100644 --- a/docs/literate/src/files/structured_mesh_mapping.jl +++ b/docs/literate/src/files/structured_mesh_mapping.jl @@ -18,15 +18,16 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) # We start with a pressure perturbation at `(xs, 0.0)` as initial condition. -function initial_condition_pressure_perturbation(x, t, equations::CompressibleEulerEquations2D) - xs = 1.5 # location of the initial disturbance on the x axis - w = 1/8 # half width - p = exp(-log(2) * ((x[1]-xs)^2 + x[2]^2)/w^2) + 1.0 - v1 = 0.0 - v2 = 0.0 - rho = 1.0 - - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_pressure_perturbation(x, t, + equations::CompressibleEulerEquations2D) + xs = 1.5 # location of the initial disturbance on the x axis + w = 1 / 8 # half width + p = exp(-log(2) * ((x[1] - xs)^2 + x[2]^2) / w^2) + 1.0 + v1 = 0.0 + v2 = 0.0 + rho = 1.0 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_pressure_perturbation @@ -35,8 +36,8 @@ boundary_conditions = boundary_condition_slip_wall # The approximation setup is an entropy-stable split-form DG method with `polydeg=4`. We are using # the two fluxes [`flux_ranocha`](@ref) and [`flux_lax_friedrichs`](@ref). -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha)) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) # We want to define a circular cylinder as physical domain. It contains an inner semicircle with # radius `r0` and an outer semicircle of radius `r1`. @@ -68,7 +69,6 @@ solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, #src # \end{tikzpicture} #src # \end{document} - # The domain boundary curves with curve parameter in $[-1,1]$ are sorted as shown in the sketch. # They always are orientated from negative to positive coordinate, such that the corners have to # fit like this $f_1(+1) = f_4(-1)$, $f_3(+1) = f_2(-1)$, etc. @@ -76,37 +76,37 @@ solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, # In our case we can define the domain boundary curves as follows: r0 = 0.5 # inner radius r1 = 5.0 # outer radius -f1(xi) = SVector( r0 + 0.5 * (r1 - r0) * (xi + 1), 0.0) # right line -f2(xi) = SVector(-r0 - 0.5 * (r1 - r0) * (xi + 1), 0.0) # left line +f1(xi) = SVector(r0 + 0.5 * (r1 - r0) * (xi + 1), 0.0) # right line +f2(xi) = SVector(-r0 - 0.5 * (r1 - r0) * (xi + 1), 0.0) # left line f3(eta) = SVector(r0 * cos(0.5 * pi * (eta + 1)), r0 * sin(0.5 * pi * (eta + 1))) # inner circle f4(eta) = SVector(r1 * cos(0.5 * pi * (eta + 1)), r1 * sin(0.5 * pi * (eta + 1))) # outer circle # We create a curved mesh with 16 x 16 elements. The defined domain boundary curves are passed as a tuple. cells_per_dimension = (16, 16) -mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4), periodicity=false) +mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4), periodicity = false) # Then, we define the simulation with endtime `T=3` with `semi`, `ode` and `callbacks`. semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) tspan = (0.0, 3.0) ode = semidiscretize(semi, tspan) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(analysis_callback, alive_callback, stepsize_callback); # Running 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); +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); using Plots plot(sol) @@ -115,7 +115,6 @@ pd = PlotData2D(sol) plot(pd["p"]) plot!(getmesh(pd)) - # ## Mesh directly defined by the transformation mapping # As mentioned before, you can also define the domain for a `StructuredMesh` by directly setting up # a transformation mapping. Here, we want to present a nice mapping, which is often used to test @@ -132,22 +131,22 @@ equations = CompressibleEulerEquations2D(1.4) # initial condition. initial_condition = initial_condition_constant -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # We define the transformation mapping with variables in $[-1, 1]$ as described in # Rueda-Ramírez et al. (2021), p.18 (reduced to 2D): function mapping(xi_, eta_) - ## Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + ## Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end # Instead of a tuple of boundary functions, the `mesh` now has the mapping as its parameter. @@ -159,28 +158,28 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) -analysis_callback = AnalysisCallback(semi, interval=250) +analysis_callback = AnalysisCallback(semi, interval = 250) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(analysis_callback, stepsize_callback) -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); +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); # Now, we want to verify the free-stream preservation property and plot the mesh. For the verification, # we calculate the absolute difference of the first conservation variable density `u[1]` and `1.0`. # To plot this error and the mesh, we are using the visualization feature `ScalarPlotData2D`, # explained in [visualization](@ref visualization). error_density = let u = Trixi.wrap_array(sol.u[end], semi) - abs.(u[1, :, :, :] .- 1.0) # density, x, y, elements + abs.(u[1, :, :, :] .- 1.0) # density, x, y, elements end pd = ScalarPlotData2D(error_density, semi) using Plots -plot(pd, title="Error in density") +plot(pd, title = "Error in density") plot!(getmesh(pd)) # We observe that the errors in the variable `density` are at the level of machine accuracy. diff --git a/docs/literate/src/files/upwind_fdsbp.jl b/docs/literate/src/files/upwind_fdsbp.jl index 36ca1b57404..b15259cebd3 100644 --- a/docs/literate/src/files/upwind_fdsbp.jl +++ b/docs/literate/src/files/upwind_fdsbp.jl @@ -9,8 +9,8 @@ # operator can be created as follows. using Trixi D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=11) + derivative_order = 1, accuracy_order = 2, + xmin = 0.0, xmax = 1.0, N = 11) # Instead of prefixing the source of coefficients `MattssonNordström2004()`, # you can also load the package SummationByPartsOperators.jl. Either way, # this yields an object representing the operator efficiently. If you want to @@ -21,8 +21,8 @@ Matrix(D_SBP) # Upwind SBP operators are a concept introduced in 2017 by Ken Mattsson. You can # create them as follows. D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=11) + derivative_order = 1, accuracy_order = 2, + xmin = 0.0, xmax = 1.0, N = 11) # Upwind operators are derivative operators biased towards one direction. # The "minus" variants has a bias towards the left side, i.e., it uses values # from more nodes to the left than from the right to compute the discrete diff --git a/docs/make.jl b/docs/make.jl index 5069e4dc49a..2b3c3df4219 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,7 +2,8 @@ using Documenter import Pkg # Fix for https://github.com/trixi-framework/Trixi.jl/issues/668 -if (get(ENV, "CI", nothing) != "true") && (get(ENV, "TRIXI_DOC_DEFAULT_ENVIRONMENT", nothing) != "true") +if (get(ENV, "CI", nothing) != "true") && + (get(ENV, "TRIXI_DOC_DEFAULT_ENVIRONMENT", nothing) != "true") push!(LOAD_PATH, dirname(@__DIR__)) end @@ -16,30 +17,31 @@ include(joinpath(trixi_root_dir, "docs", "literate", "make.jl")) # Copy list of authors to not need to synchronize it manually authors_text = read(joinpath(trixi_root_dir, "AUTHORS.md"), String) -authors_text = replace(authors_text, "in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)") +authors_text = replace(authors_text, + "in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)") write(joinpath(@__DIR__, "src", "authors.md"), authors_text) # Define module-wide setups such that the respective modules are available in doctests -DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive=true) -DocMeta.setdocmeta!(Trixi2Vtk, :DocTestSetup, :(using Trixi2Vtk); recursive=true) +DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive = true) +DocMeta.setdocmeta!(Trixi2Vtk, :DocTestSetup, :(using Trixi2Vtk); recursive = true) # Copy some files from the repository root directory to the docs and modify them # as necessary # Based on: https://github.com/ranocha/SummationByPartsOperators.jl/blob/0206a74140d5c6eb9921ca5021cb7bf2da1a306d/docs/make.jl#L27-L41 open(joinpath(@__DIR__, "src", "code_of_conduct.md"), "w") do io - # Point to source license file - println(io, """ - ```@meta - EditURL = "https://github.com/trixi-framework/Trixi.jl/blob/main/CODE_OF_CONDUCT.md" - ``` - """) - # Write the modified contents - println(io, "# [Code of Conduct](@id code-of-conduct)") - println(io, "") - for line in eachline(joinpath(dirname(@__DIR__), "CODE_OF_CONDUCT.md")) - line = replace(line, "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)") - println(io, "> ", line) - end + # Point to source license file + println(io, """ + ```@meta + EditURL = "https://github.com/trixi-framework/Trixi.jl/blob/main/CODE_OF_CONDUCT.md" + ``` + """) + # Write the modified contents + println(io, "# [Code of Conduct](@id code-of-conduct)") + println(io, "") + for line in eachline(joinpath(dirname(@__DIR__), "CODE_OF_CONDUCT.md")) + line = replace(line, "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)") + println(io, "> ", line) + end end # Create tutorials for the following files: @@ -68,67 +70,63 @@ files = [ # Topic: other stuff "Explicit time stepping" => "time_stepping.jl", "Differentiable programming" => "differentiable_programming.jl", - ] +] tutorials = create_tutorials(files) # Make documentation makedocs( - # Specify modules for which docstrings should be shown - modules = [Trixi, Trixi2Vtk], - # Set sitename to Trixi.jl - sitename="Trixi.jl", - # Provide additional formatting options - format = Documenter.HTML( - # Disable pretty URLs during manual testing - prettyurls = get(ENV, "CI", nothing) == "true", - # Explicitly add favicon as asset - assets = ["assets/favicon.ico"], - # Set canonical URL to GitHub pages URL - canonical = "https://trixi-framework.github.io/Trixi.jl/stable" - ), - # Explicitly specify documentation structure - pages = [ - "Home" => "index.md", - "Getting started" => [ - "Overview" => "overview.md", - "Visualization" => "visualization.md", - ], - "Tutorials" => tutorials, - "Basic building blocks" => [ - "Meshes" => [ - "Tree mesh" => joinpath("meshes", "tree_mesh.md"), - "Structured mesh" => joinpath("meshes", "structured_mesh.md"), - "Unstructured mesh" => joinpath("meshes", "unstructured_quad_mesh.md"), - "P4est-based mesh" => joinpath("meshes", "p4est_mesh.md"), - "DGMulti mesh" => joinpath("meshes", "dgmulti_mesh.md"), - ], - "Time integration" => "time_integration.md", - "Callbacks" => "callbacks.md", - ], - "Advanced topics & developers" => [ - "Conventions" =>"conventions.md", - "Development" => "development.md", - "GitHub & Git" => "github-git.md", - "Style guide" => "styleguide.md", - "Testing" => "testing.md", - "Performance" => "performance.md", - "Parallelization" => "parallelization.md", - ], - "Troubleshooting and FAQ" => "troubleshooting.md", - "Reference" => [ - "Trixi.jl" => "reference-trixi.md", - "Trixi2Vtk.jl" => "reference-trixi2vtk.md" - ], - "Authors" => "authors.md", - "Contributing" => "contributing.md", - "Code of Conduct" => "code_of_conduct.md", - "License" => "license.md" - ], - strict = true # to make the GitHub action fail when doctests fail, see https://github.com/neuropsychology/Psycho.jl/issues/34 -) + # Specify modules for which docstrings should be shown + modules = [Trixi, Trixi2Vtk], + # Set sitename to Trixi.jl + sitename = "Trixi.jl", + # Provide additional formatting options + format = Documenter.HTML( + # Disable pretty URLs during manual testing + prettyurls = get(ENV, "CI", nothing) == "true", + # Explicitly add favicon as asset + assets = ["assets/favicon.ico"], + # Set canonical URL to GitHub pages URL + canonical = "https://trixi-framework.github.io/Trixi.jl/stable"), + # Explicitly specify documentation structure + pages = [ + "Home" => "index.md", + "Getting started" => [ + "Overview" => "overview.md", + "Visualization" => "visualization.md", + ], + "Tutorials" => tutorials, + "Basic building blocks" => [ + "Meshes" => [ + "Tree mesh" => joinpath("meshes", "tree_mesh.md"), + "Structured mesh" => joinpath("meshes", "structured_mesh.md"), + "Unstructured mesh" => joinpath("meshes", "unstructured_quad_mesh.md"), + "P4est-based mesh" => joinpath("meshes", "p4est_mesh.md"), + "DGMulti mesh" => joinpath("meshes", "dgmulti_mesh.md"), + ], + "Time integration" => "time_integration.md", + "Callbacks" => "callbacks.md", + ], + "Advanced topics & developers" => [ + "Conventions" => "conventions.md", + "Development" => "development.md", + "GitHub & Git" => "github-git.md", + "Style guide" => "styleguide.md", + "Testing" => "testing.md", + "Performance" => "performance.md", + "Parallelization" => "parallelization.md", + ], + "Troubleshooting and FAQ" => "troubleshooting.md", + "Reference" => [ + "Trixi.jl" => "reference-trixi.md", + "Trixi2Vtk.jl" => "reference-trixi2vtk.md", + ], + "Authors" => "authors.md", + "Contributing" => "contributing.md", + "Code of Conduct" => "code_of_conduct.md", + "License" => "license.md", + ], + strict = true) -deploydocs( - repo = "github.com/trixi-framework/Trixi.jl", - devbranch = "main", - push_preview = true -) +deploydocs(repo = "github.com/trixi-framework/Trixi.jl", + devbranch = "main", + push_preview = true) diff --git a/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl b/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl index d06ed05a621..09d66fe8aea 100644 --- a/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl +++ b/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl @@ -23,8 +23,8 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (8,) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(-1.0,), coordinates_max=(1.0,), - periodicity=true) + coordinates_min = (-1.0,), coordinates_max = (1.0,), + periodicity = true) ############################################################################### # setup the test problem (no source term needed for linear advection) @@ -49,10 +49,10 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) # handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=0.75) +stepsize_callback = StepsizeCallback(cfl = 0.75) # collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback) @@ -60,9 +60,8 @@ callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=1.0, save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1.0, save_everystep = false, callback = callbacks); # Print the timer summary summary_callback() - diff --git a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl index f5c2a07bd24..d31c0dbdba5 100644 --- a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl @@ -2,8 +2,10 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Line(), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), + approximation_type = periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 50), surface_flux = FluxHLL(min_max_speed_naive), volume_integral = VolumeIntegralWeakForm()) @@ -11,8 +13,8 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test -mesh = DGMultiMesh(dg, coordinates_min=(-1.0,), - coordinates_max=( 1.0,)) +mesh = DGMultiMesh(dg, coordinates_min = (-1.0,), + coordinates_max = (1.0,)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -21,15 +23,16 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -stepsize_callback = StepsizeCallback(cfl=1.0) -callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, analysis_callback) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +stepsize_callback = StepsizeCallback(cfl = 1.0) +callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, + analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_1d/elixir_euler_flux_diff.jl b/examples/dgmulti_1d/elixir_euler_flux_diff.jl index 489b23e37b2..56a24d25d07 100644 --- a/examples/dgmulti_1d/elixir_euler_flux_diff.jl +++ b/examples/dgmulti_1d/elixir_euler_flux_diff.jl @@ -13,17 +13,17 @@ source_terms = source_terms_convergence_test cells_per_dimension = (8,) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(-1.0,), coordinates_max=(1.0,), periodicity=true) + coordinates_min = (-1.0,), coordinates_max = (1.0,), periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; - source_terms=source_terms) + source_terms = source_terms) tspan = (0.0, 1.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) @@ -31,7 +31,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_advection_diffusion.jl b/examples/dgmulti_2d/elixir_advection_diffusion.jl index 8a79e9700ac..ce7b0e745a4 100644 --- a/examples/dgmulti_2d/elixir_advection_diffusion.jl +++ b/examples/dgmulti_2d/elixir_advection_diffusion.jl @@ -11,48 +11,52 @@ initial_condition_zero(x, t, equations::LinearScalarAdvectionEquation2D) = SVect initial_condition = initial_condition_zero # tag different boundary segments -left(x, tol=50*eps()) = abs(x[1] + 1) < tol -right(x, tol=50*eps()) = abs(x[1] - 1) < tol -bottom(x, tol=50*eps()) = abs(x[2] + 1) < tol -top(x, tol=50*eps()) = abs(x[2] - 1) < tol +left(x, tol = 50 * eps()) = abs(x[1] + 1) < tol +right(x, tol = 50 * eps()) = abs(x[1] - 1) < tol +bottom(x, tol = 50 * eps()) = abs(x[2] + 1) < tol +top(x, tol = 50 * eps()) = abs(x[2] - 1) < tol is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary) # BC types -boundary_condition_left = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.1 * x[2])) +boundary_condition_left = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + + 0.1 * + x[2])) boundary_condition_zero = BoundaryConditionDirichlet((x, t, equations) -> SVector(0.0)) boundary_condition_neumann_zero = BoundaryConditionNeumann((x, t, equations) -> SVector(0.0)) # define inviscid boundary conditions boundary_conditions = (; :left => boundary_condition_left, - :bottom => boundary_condition_zero, - :top => boundary_condition_do_nothing, - :right => boundary_condition_do_nothing) + :bottom => boundary_condition_zero, + :top => boundary_condition_do_nothing, + :right => boundary_condition_do_nothing) # define viscous boundary conditions boundary_conditions_parabolic = (; :left => boundary_condition_left, - :bottom => boundary_condition_zero, - :top => boundary_condition_zero, - :right => boundary_condition_neumann_zero) + :bottom => boundary_condition_zero, + :top => boundary_condition_zero, + :right => boundary_condition_neumann_zero) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) tspan = (0.0, 1.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl b/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl index 7e87d9f097d..d2f11f18507 100644 --- a/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl +++ b/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl @@ -16,61 +16,63 @@ equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) # to numerical partial differential equations. # [DOI](https://doi.org/10.1007/978-3-319-41640-3_6). function initial_condition_erikkson_johnson(x, t, equations) - l = 4 - epsilon = diffusivity() # Note: this requires epsilon < 0.6 due to the sqrt - lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + - cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) - return SVector{1}(u) + l = 4 + epsilon = diffusivity() # Note: this requires epsilon < 0.6 due to the sqrt + lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + + cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) + return SVector{1}(u) end initial_condition = initial_condition_erikkson_johnson # tag different boundary segments -left(x, tol=50*eps()) = abs(x[1] + 1) < tol -right(x, tol=50*eps()) = abs(x[1]) < tol -bottom(x, tol=50*eps()) = abs(x[2] + 0.5) < tol -top(x, tol=50*eps()) = abs(x[2] - 0.5) < tol -entire_boundary(x, tol=50*eps()) = true +left(x, tol = 50 * eps()) = abs(x[1] + 1) < tol +right(x, tol = 50 * eps()) = abs(x[1]) < tol +bottom(x, tol = 50 * eps()) = abs(x[2] + 0.5) < tol +top(x, tol = 50 * eps()) = abs(x[2] - 0.5) < tol +entire_boundary(x, tol = 50 * eps()) = true is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom, :entire_boundary => entire_boundary) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension; - coordinates_min=(-1.0, -0.5), - coordinates_max=(0.0, 0.5), + coordinates_min = (-1.0, -0.5), + coordinates_max = (0.0, 0.5), is_on_boundary) # BC types boundary_condition = BoundaryConditionDirichlet(initial_condition) # define inviscid boundary conditions, enforce "do nothing" boundary condition at the outflow -boundary_conditions = (; :left => boundary_condition, - :top => boundary_condition, - :bottom => boundary_condition, - :right => boundary_condition_do_nothing) +boundary_conditions = (; :left => boundary_condition, + :top => boundary_condition, + :bottom => boundary_condition, + :right => boundary_condition_do_nothing) # define viscous boundary conditions boundary_conditions_parabolic = (; :entire_boundary => boundary_condition) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) tspan = (0.0, 1.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl b/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl index 76512f1e39f..c498e5468d3 100644 --- a/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl +++ b/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl @@ -8,12 +8,12 @@ equations = LinearScalarAdvectionEquation2D(0.0, 0.0) equations_parabolic = LaplaceDiffusion2D(5.0e-1, equations) function initial_condition_sharp_gaussian(x, t, equations::LinearScalarAdvectionEquation2D) - return SVector(exp(-100 * (x[1]^2 + x[2]^2))) + return SVector(exp(-100 * (x[1]^2 + x[2]^2))) end initial_condition = initial_condition_sharp_gaussian cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg) @@ -21,16 +21,16 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - dt = time_int_tol, ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + dt = time_int_tol, ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_bilinear.jl b/examples/dgmulti_2d/elixir_euler_bilinear.jl index e9f02863c9b..b0e575e5200 100644 --- a/examples/dgmulti_2d/elixir_euler_bilinear.jl +++ b/examples/dgmulti_2d/elixir_euler_bilinear.jl @@ -10,27 +10,28 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol=50*eps()) = abs(x[2]-1) top_boundary, :rest => rest_of_boundary) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) -vertex_coordinates, EToV = StartUpDG.uniform_mesh(dg.basis.element_type, cells_per_dimension...) +vertex_coordinates, EToV = StartUpDG.uniform_mesh(dg.basis.element_type, + cells_per_dimension...) for i in eachindex(vertex_coordinates[1]) - vx, vy = getindex.(vertex_coordinates, i) - setindex!.(vertex_coordinates, mapping(vx, vy), i) + vx, vy = getindex.(vertex_coordinates, i) + setindex!.(vertex_coordinates, mapping(vx, vy), i) end -mesh = DGMultiMesh(dg, vertex_coordinates, EToV, is_on_boundary=is_on_boundary) +mesh = DGMultiMesh(dg, vertex_coordinates, EToV, is_on_boundary = is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -40,15 +41,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl b/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl index 4bb05c0b062..e7830c4736b 100644 --- a/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl +++ b/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl @@ -1,6 +1,6 @@ using Trixi, OrdinaryDiffEq -dg = DGMulti(polydeg=4, element_type = Quad(), approximation_type = Polynomial(), +dg = DGMulti(polydeg = 4, element_type = Quad(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(FluxLaxFriedrichs()), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) @@ -16,38 +16,38 @@ incompressible version. [DOI: 10.1006/jcph.1995.1205](https://doi.org/10.1006/jcph.1995.1205) """ function initial_condition_BM_vortex(x, t, equations::CompressibleEulerEquations2D) - pbar = 9.0 / equations.gamma - delta = 0.05 - epsilon = 30 - H = (x[2] < 0) ? tanh(epsilon * (x[2] + 0.25)) : tanh(epsilon * (0.25 - x[2])) - rho = 1.0 - v1 = H - v2 = delta * cos(2.0 * pi * x[1]) - p = pbar - return prim2cons(SVector(rho, v1, v2, p), equations) + pbar = 9.0 / equations.gamma + delta = 0.05 + epsilon = 30 + H = (x[2] < 0) ? tanh(epsilon * (x[2] + 0.25)) : tanh(epsilon * (0.25 - x[2])) + rho = 1.0 + v1 = H + v2 = delta * cos(2.0 * pi * x[1]) + p = pbar + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_BM_vortex cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(-0.5, -0.5), coordinates_max=(0.5, 0.5), - periodicity=true) + coordinates_min = (-0.5, -0.5), coordinates_max = (0.5, 0.5), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) ############################################################################### # run the simulation tol = 1.0e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=tol, reltol=tol, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = tol, reltol = tol, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_curved.jl b/examples/dgmulti_2d/elixir_euler_curved.jl index 9e773ff7399..a48252e9ee0 100644 --- a/examples/dgmulti_2d/elixir_euler_curved.jl +++ b/examples/dgmulti_2d/elixir_euler_curved.jl @@ -10,21 +10,21 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol=50*eps()) = abs(x[2]-1) top_boundary, :rest => rest_of_boundary) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary=is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary = is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -34,15 +34,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl index 81cd9224d18..2959bd98657 100644 --- a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl @@ -2,8 +2,10 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Quad(), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), + approximation_type = periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 50), surface_flux = FluxHLL(min_max_speed_naive), volume_integral = VolumeIntegralWeakForm()) @@ -11,8 +13,8 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test -mesh = DGMultiMesh(dg, coordinates_min=(-1.0, -1.0), - coordinates_max=( 1.0, 1.0)) +mesh = DGMultiMesh(dg, coordinates_min = (-1.0, -1.0), + coordinates_max = (1.0, 1.0)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -21,15 +23,16 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -stepsize_callback = StepsizeCallback(cfl=1.0) -callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, analysis_callback) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +stepsize_callback = StepsizeCallback(cfl = 1.0) +callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, + analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_hohqmesh.jl b/examples/dgmulti_2d/elixir_euler_hohqmesh.jl index b9a24dc2450..f534b5bc8ad 100644 --- a/examples/dgmulti_2d/elixir_euler_hohqmesh.jl +++ b/examples/dgmulti_2d/elixir_euler_hohqmesh.jl @@ -15,11 +15,11 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (; :Slant => boundary_condition_convergence_test, - :Bezier => boundary_condition_convergence_test, - :Right => boundary_condition_convergence_test, - :Bottom => boundary_condition_convergence_test, - :Top => boundary_condition_convergence_test ) +boundary_conditions = (; :Slant => boundary_condition_convergence_test, + :Bezier => boundary_condition_convergence_test, + :Right => boundary_condition_convergence_test, + :Bottom => boundary_condition_convergence_test, + :Top => boundary_condition_convergence_test) ############################################################################### # Get the DG approximation space @@ -32,8 +32,9 @@ dg = DGMulti(polydeg = 8, element_type = Quad(), approximation_type = SBP(), # Get the curved quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_trixi_unstructured_mesh_docs.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = DGMultiMesh(dg, mesh_file) @@ -42,8 +43,8 @@ mesh = DGMultiMesh(dg, mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - source_terms=source_terms, - boundary_conditions=boundary_conditions) + source_terms = source_terms, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -54,9 +55,9 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -66,7 +67,7 @@ callbacks = CallbackSet(summary_callback, # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - dt = time_int_tol, ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + dt = time_int_tol, ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl b/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl index 39e98d1a2c5..14de0bf0e8b 100644 --- a/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl +++ b/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl @@ -15,23 +15,24 @@ A version of the classical Kelvin-Helmholtz instability based on of the Euler Equations [arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) """ -function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability cells_per_dimension = (32, 32) -mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=true) +mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) @@ -39,9 +40,9 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) @@ -49,7 +50,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl index e3ced751af4..efcb3451388 100644 --- a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl @@ -29,34 +29,34 @@ defined below. """ @inline function initial_condition_rayleigh_taylor_instability(x, t, equations::CompressibleEulerEquations2D, - slope=1000) - tol = 1e2*eps() - - if x[2] < 0.5 - p = 2*x[2] + 1 - else - p = x[2] + 3/2 - end - - # smooth the discontinuity to avoid ambiguity at element interfaces - smoothed_heaviside(x, left, right) = left + 0.5*(1 + tanh(slope * x)) * (right-left) - rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) - - c = sqrt(equations.gamma * p / rho) - # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the - # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. - v = -0.025 * c * cos(8*pi*x[1]) * sin(pi*x[2])^6 - u = 0.0 - - return prim2cons(SVector(rho, u, v, p), equations) + slope = 1000) + tol = 1e2 * eps() + + if x[2] < 0.5 + p = 2 * x[2] + 1 + else + p = x[2] + 3 / 2 + end + + # smooth the discontinuity to avoid ambiguity at element interfaces + smoothed_heaviside(x, left, right) = left + 0.5 * (1 + tanh(slope * x)) * (right - left) + rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) + + c = sqrt(equations.gamma * p / rho) + # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the + # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. + v = -0.025 * c * cos(8 * pi * x[1]) * sin(pi * x[2])^6 + u = 0.0 + + return prim2cons(SVector(rho, u, v, p), equations) end @inline function source_terms_rayleigh_taylor_instability(u, x, t, equations::CompressibleEulerEquations2D) - g = 1.0 - rho, rho_v1, rho_v2, rho_e = u + g = 1.0 + rho, rho_v1, rho_v2, rho_e = u - return SVector(0.0, 0.0, g*rho, g*rho_v2) + return SVector(0.0, 0.0, g * rho, g * rho_v2) end # numerical parameters @@ -67,8 +67,8 @@ dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial num_elements = 16 cells_per_dimension = (num_elements, 4 * num_elements) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(0.0, 0.0), coordinates_max=(0.25, 1.0), - periodicity=(true, false)) + coordinates_min = (0.0, 0.0), coordinates_max = (0.25, 1.0), + periodicity = (true, false)) initial_condition = initial_condition_rayleigh_taylor_instability boundary_conditions = (; :entire_boundary => boundary_condition_slip_wall) @@ -86,9 +86,9 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -97,7 +97,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_shockcapturing.jl b/examples/dgmulti_2d/elixir_euler_shockcapturing.jl index 4b2a408c757..36494b268d6 100644 --- a/examples/dgmulti_2d/elixir_euler_shockcapturing.jl +++ b/examples/dgmulti_2d/elixir_euler_shockcapturing.jl @@ -10,25 +10,25 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 -basis = DGMultiBasis(Quad(), polydeg, approximation_type=GaussSBP()) +basis = DGMultiBasis(Quad(), polydeg, approximation_type = GaussSBP()) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) dg = DGMulti(basis, surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = volume_integral) cells_per_dimension = (8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) @@ -36,16 +36,15 @@ tspan = (0.0, 0.15) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary - diff --git a/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl b/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl index dad898b99b6..5e8d9e6c8e4 100644 --- a/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl +++ b/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl @@ -10,27 +10,27 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 -basis = DGMultiBasis(Quad(), polydeg, approximation_type=GaussSBP()) +basis = DGMultiBasis(Quad(), polydeg, approximation_type = GaussSBP()) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) dg = DGMulti(basis, surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = volume_integral) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension, mapping) @@ -41,16 +41,15 @@ tspan = (0.0, 0.15) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary - diff --git a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl index 150fb769138..cc150a319f0 100644 --- a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl +++ b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl @@ -13,11 +13,11 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole()) # the pre-defined Triangulate geometry in StartUpDG has integer boundary tags. this routine # assigns boundary faces based on these integer boundary tags. -mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary=>1, :inner_boundary=>2)) +mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary => 1, :inner_boundary => 2)) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test, - :inner_boundary => boundary_condition_convergence_test) + :inner_boundary => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -27,14 +27,14 @@ tspan = (0.0, 0.2) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_weakform.jl b/examples/dgmulti_2d/elixir_euler_weakform.jl index a43790a4d5f..cf08866e178 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform.jl @@ -10,16 +10,16 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol=50*eps()) = abs(x[2]-1) top_boundary, :rest => rest_of_boundary) cells_per_dimension = (8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary=is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary = is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -29,15 +29,16 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -stepsize_callback = StepsizeCallback(cfl=1.5) -callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, analysis_callback) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +stepsize_callback = StepsizeCallback(cfl = 1.5) +callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, + analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl index 0bb011bf540..6fe578c1527 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl @@ -10,7 +10,7 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test cells_per_dimension = (4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -18,14 +18,14 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl b/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl index a1351cf8244..2b8d36fb94f 100644 --- a/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl +++ b/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl @@ -8,70 +8,73 @@ using LinearAlgebra: norm, dot # for use in the MHD boundary condition equations = IdealGlmMhdEquations2D(1.4) function initial_condition_perturbation(x, t, equations::IdealGlmMhdEquations2D) - # pressure perturbation in a vertically magnetized field on the domain [-1, 1]^2 + # pressure perturbation in a vertically magnetized field on the domain [-1, 1]^2 - r2 = (x[1] + 0.25)^2 + (x[2] + 0.25)^2 + r2 = (x[1] + 0.25)^2 + (x[2] + 0.25)^2 - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = 1 + 0.5 * exp(-100 * r2) + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = 1 + 0.5 * exp(-100 * r2) - # the pressure and magnetic field are chosen to be strongly - # magnetized, such that p / ||B||^2 ≈ 0.01. - B1 = 0.0 - B2 = 40.0 / sqrt(4.0 * pi) - B3 = 0.0 + # the pressure and magnetic field are chosen to be strongly + # magnetized, such that p / ||B||^2 ≈ 0.01. + B1 = 0.0 + B2 = 40.0 / sqrt(4.0 * pi) + B3 = 0.0 - psi = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) + psi = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) end initial_condition = initial_condition_perturbation surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGMulti(polydeg=3, element_type = Quad(), approximation_type = GaussSBP(), +solver = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = GaussSBP(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) -x_neg(x, tol=50*eps()) = abs(x[1] + 1) < tol -x_pos(x, tol=50*eps()) = abs(x[1] - 1) < tol -y_neg(x, tol=50*eps()) = abs(x[2] + 1) < tol -y_pos(x, tol=50*eps()) = abs(x[2] - 1) < tol +x_neg(x, tol = 50 * eps()) = abs(x[1] + 1) < tol +x_pos(x, tol = 50 * eps()) = abs(x[1] - 1) < tol +y_neg(x, tol = 50 * eps()) = abs(x[2] + 1) < tol +y_pos(x, tol = 50 * eps()) = abs(x[2] - 1) < tol is_on_boundary = Dict(:x_neg => x_neg, :x_pos => x_pos, :y_neg => y_neg, :y_pos => y_pos) cells_per_dimension = (16, 16) -mesh = DGMultiMesh(solver, cells_per_dimension; periodicity=(false, false), is_on_boundary) +mesh = DGMultiMesh(solver, cells_per_dimension; periodicity = (false, false), + is_on_boundary) # Create a "reflective-like" boundary condition by mirroring the velocity but leaving the magnetic field alone. # Note that this boundary condition is probably not entropy stable. -function boundary_condition_velocity_slip_wall(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, equations::IdealGlmMhdEquations2D) +function boundary_condition_velocity_slip_wall(u_inner, normal_direction::AbstractVector, x, + t, + surface_flux_function, + equations::IdealGlmMhdEquations2D) - # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later - norm_ = norm(normal_direction) - normal = normal_direction / norm_ + # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later + norm_ = norm(normal_direction) + normal = normal_direction / norm_ - # compute the primitive variables - rho, v1, v2, v3, p, B1, B2, B3, psi = cons2prim(u_inner, equations) + # compute the primitive variables + rho, v1, v2, v3, p, B1, B2, B3, psi = cons2prim(u_inner, equations) - v_normal = dot(normal, SVector(v1, v2)) - u_mirror = prim2cons(SVector(rho, v1 - 2 * v_normal * normal[1], - v2 - 2 * v_normal * normal[2], - v3, p, B1, B2, B3, psi), equations) + v_normal = dot(normal, SVector(v1, v2)) + u_mirror = prim2cons(SVector(rho, v1 - 2 * v_normal * normal[1], + v2 - 2 * v_normal * normal[2], + v3, p, B1, B2, B3, psi), equations) - return surface_flux_function(u_inner, u_mirror, normal, equations) * norm_ + return surface_flux_function(u_inner, u_mirror, normal, equations) * norm_ end -boundary_conditions = (; x_neg=boundary_condition_velocity_slip_wall, - x_pos=boundary_condition_velocity_slip_wall, - y_neg=boundary_condition_do_nothing, - y_pos=BoundaryConditionDirichlet(initial_condition)) +boundary_conditions = (; x_neg = boundary_condition_velocity_slip_wall, + x_pos = boundary_condition_velocity_slip_wall, + y_neg = boundary_condition_do_nothing, + y_pos = BoundaryConditionDirichlet(initial_condition)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -82,12 +85,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(solver)) -alive_callback = AliveCallback(alive_interval=10) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + uEltype = real(solver)) +alive_callback = AliveCallback(alive_interval = 10) cfl = 0.5 -stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -98,8 +102,8 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=1e-5, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1e-5, # 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 diff --git a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl index bf5045ce8b0..663301e189f 100644 --- a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl +++ b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl @@ -11,14 +11,14 @@ initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = Polynomial(), +dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(-2.0, -2.0), coordinates_max=(2.0, 2.0), - periodicity=true) + coordinates_min = (-2.0, -2.0), coordinates_max = (2.0, 2.0), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) ############################################################################### @@ -30,13 +30,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +alive_callback = AliveCallback(analysis_interval = analysis_interval) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -47,8 +47,8 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl index 9c8dfcb3801..3dc070a7296 100644 --- a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl +++ b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl @@ -15,13 +15,13 @@ initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = SBP(), +dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(-2.0, -2.0), coordinates_max=(2.0, 2.0), - periodicity=true) + coordinates_min = (-2.0, -2.0), coordinates_max = (2.0, 2.0), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) ############################################################################### @@ -33,8 +33,8 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # See comment above and https://github.com/trixi-framework/Trixi.jl/issues/881 # DGMulti uses a conservative timestep estimate, so we can use a large CFL here. @@ -46,8 +46,7 @@ alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, #stepsize_callback, - alive_callback, - #=glm_speed_callback=#) + alive_callback) #=glm_speed_callback=# ############################################################################### # run the simulation @@ -56,7 +55,7 @@ callbacks = CallbackSet(summary_callback, # 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); -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_navierstokes_convergence.jl b/examples/dgmulti_2d/elixir_navierstokes_convergence.jl index 23c9c2e8ed4..cd3c015b5fa 100644 --- a/examples/dgmulti_2d/elixir_navierstokes_convergence.jl +++ b/examples/dgmulti_2d/elixir_navierstokes_convergence.jl @@ -10,169 +10,214 @@ mu() = 0.01 equations = CompressibleEulerEquations2D(1.4) # Note: If you change the Navier-Stokes parameters here, also change them in the initial condition # I really do not like this structure but it should work for now -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), Prandtl=prandtl_number(), - gradient_variables=GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=(true, false), is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = (true, false), is_on_boundary) # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion2D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion2D`) # and by the initial condition (which passes in `CompressibleEulerEquations2D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Amplitude and shift - A = 0.5 - c = 2.0 + # Amplitude and shift + A = 0.5 + c = 2.0 - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0)) ) * cos(pi_t) - v2 = v1 - p = rho^2 + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0))) * cos(pi_t) + v2 = v1 + p = rho^2 - return prim2cons(SVector(rho, v1, v2, p), equations) + return prim2cons(SVector(rho, v1, v2, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - y = x[2] - - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Same settings as in `initial_condition` - # Amplitude and shift - A = 0.5 - c = 2.0 - - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t - - # compute the manufactured solution and all necessary derivatives - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) - rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) - rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) - rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - - v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) - v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_y = sin(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_xy = pi * cos(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_yy = (sin(pi_x) * ( 2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) - - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) - - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_xx = v1_xx - v2_xy = v1_xy - v2_yy = v1_yy - - p = rho * rho - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x - p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y - - # Note this simplifies slightly because the ansatz assumes that v1 = v2 - E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) - E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y - - # Some convenience constants - T_const = equations.gamma * inv_gamma_minus_one / Pr - inv_rho_cubed = 1.0 / (rho^3) - - # compute the source terms - # density equation - du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y - - # x-momentum equation - du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - # stress tensor from x-direction - - 4.0 / 3.0 * v1_xx * mu_ - + 2.0 / 3.0 * v2_xy * mu_ - - v1_yy * mu_ - - v2_xy * mu_ ) - # y-momentum equation - du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - # stress tensor from y-direction - - v1_xy * mu_ - - v2_xx * mu_ - - 4.0 / 3.0 * v2_yy * mu_ - + 2.0 / 3.0 * v1_xy * mu_ ) - # total energy equation - du4 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - # stress tensor and temperature gradient terms from x-direction - - 4.0 / 3.0 * v1_xx * v1 * mu_ - + 2.0 / 3.0 * v2_xy * v1 * mu_ - - 4.0 / 3.0 * v1_x * v1_x * mu_ - + 2.0 / 3.0 * v2_y * v1_x * mu_ - - v1_xy * v2 * mu_ - - v2_xx * v2 * mu_ - - v1_y * v2_x * mu_ - - v2_x * v2_x * mu_ - - T_const * inv_rho_cubed * ( p_xx * rho * rho - - 2.0 * p_x * rho * rho_x - + 2.0 * p * rho_x * rho_x - - p * rho * rho_xx ) * mu_ - # stress tensor and temperature gradient terms from y-direction - - v1_yy * v1 * mu_ - - v2_xy * v1 * mu_ - - v1_y * v1_y * mu_ - - v2_x * v1_y * mu_ - - 4.0 / 3.0 * v2_yy * v2 * mu_ - + 2.0 / 3.0 * v1_xy * v2 * mu_ - - 4.0 / 3.0 * v2_y * v2_y * mu_ - + 2.0 / 3.0 * v1_x * v2_y * mu_ - - T_const * inv_rho_cubed * ( p_yy * rho * rho - - 2.0 * p_y * rho * rho_y - + 2.0 * p * rho_y * rho_y - - p * rho * rho_yy ) * mu_ ) - - return SVector(du1, du2, du3, du4) + y = x[2] + + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Same settings as in `initial_condition` + # Amplitude and shift + A = 0.5 + c = 2.0 + + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t + + # compute the manufactured solution and all necessary derivatives + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) + rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) + rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) + rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + + v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) + v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_y = sin(pi_x) * + (A * log(y + 2.0) * exp(-A * (y - 1.0)) + + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_xy = pi * cos(pi_x) * + (A * log(y + 2.0) * exp(-A * (y - 1.0)) + + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_yy = (sin(pi_x) * + (2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) + - + A * A * log(y + 2.0) * exp(-A * (y - 1.0)) + - + (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_xx = v1_xx + v2_xy = v1_xy + v2_yy = v1_yy + + p = rho * rho + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x + p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y + + # Note this simplifies slightly because the ansatz assumes that v1 = v2 + E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) + E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y + + # Some convenience constants + T_const = equations.gamma * inv_gamma_minus_one / Pr + inv_rho_cubed = 1.0 / (rho^3) + + # compute the source terms + # density equation + du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y + + # x-momentum equation + du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + # stress tensor from x-direction + - + 4.0 / 3.0 * v1_xx * mu_ + + + 2.0 / 3.0 * v2_xy * mu_ + - + v1_yy * mu_ + - + v2_xy * mu_) + # y-momentum equation + du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + # stress tensor from y-direction + - + v1_xy * mu_ + - + v2_xx * mu_ + - + 4.0 / 3.0 * v2_yy * mu_ + + + 2.0 / 3.0 * v1_xy * mu_) + # total energy equation + du4 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + # stress tensor and temperature gradient terms from x-direction + - + 4.0 / 3.0 * v1_xx * v1 * mu_ + + + 2.0 / 3.0 * v2_xy * v1 * mu_ + - + 4.0 / 3.0 * v1_x * v1_x * mu_ + + + 2.0 / 3.0 * v2_y * v1_x * mu_ + - + v1_xy * v2 * mu_ + - + v2_xx * v2 * mu_ + - + v1_y * v2_x * mu_ + - + v2_x * v2_x * mu_ + - + T_const * inv_rho_cubed * + (p_xx * rho * rho + - + 2.0 * p_x * rho * rho_x + + + 2.0 * p * rho_x * rho_x + - + p * rho * rho_xx) * mu_ + # stress tensor and temperature gradient terms from y-direction + - + v1_yy * v1 * mu_ + - + v2_xy * v1 * mu_ + - + v1_y * v1_y * mu_ + - + v2_x * v1_y * mu_ + - + 4.0 / 3.0 * v2_yy * v2 * mu_ + + + 2.0 / 3.0 * v1_xy * v2 * mu_ + - + 4.0 / 3.0 * v2_y * v2_y * mu_ + + + 2.0 / 3.0 * v1_x * v2_y * mu_ + - + T_const * inv_rho_cubed * + (p_yy * rho * rho + - + 2.0 * p_y * rho * rho_y + + + 2.0 * p * rho_y * rho_y + - + p * rho * rho_yy) * mu_) + + return SVector(du1, du2, du3, du4) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, + t, + equations)[2:3]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, + heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -180,10 +225,11 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) - +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -193,15 +239,15 @@ tspan = (0.0, 0.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl b/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl index 86b5ae64348..996446d1db7 100644 --- a/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl +++ b/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl @@ -10,24 +10,26 @@ mu() = 0.01 equations = CompressibleEulerEquations2D(1.4) # Note: If you change the Navier-Stokes parameters here, also change them in the initial condition # I really do not like this structure but it should work for now -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), Prandtl=prandtl_number(), - gradient_variables=GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity=(true, false), is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity = (true, false), + is_on_boundary) # This initial condition is taken from `examples/dgmulti_2d/elixir_navierstokes_convergence.jl` @@ -36,150 +38,194 @@ mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity=(true, false), # and by the initial condition (which passes in `CompressibleEulerEquations2D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Amplitude and shift - A = 0.5 - c = 2.0 + # Amplitude and shift + A = 0.5 + c = 2.0 - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0)) ) * cos(pi_t) - v2 = v1 - p = rho^2 + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0))) * cos(pi_t) + v2 = v1 + p = rho^2 - return prim2cons(SVector(rho, v1, v2, p), equations) + return prim2cons(SVector(rho, v1, v2, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - y = x[2] - - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Same settings as in `initial_condition` - # Amplitude and shift - A = 0.5 - c = 2.0 - - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t - - # compute the manufactured solution and all necessary derivatives - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) - rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) - rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) - rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - - v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) - v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_y = sin(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_xy = pi * cos(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_yy = (sin(pi_x) * ( 2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) - - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) - - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_xx = v1_xx - v2_xy = v1_xy - v2_yy = v1_yy - - p = rho * rho - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x - p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y - - # Note this simplifies slightly because the ansatz assumes that v1 = v2 - E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) - E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y - - # Some convenience constants - T_const = equations.gamma * inv_gamma_minus_one / Pr - inv_rho_cubed = 1.0 / (rho^3) - - # compute the source terms - # density equation - du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y - - # x-momentum equation - du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - # stress tensor from x-direction - - 4.0 / 3.0 * v1_xx * mu_ - + 2.0 / 3.0 * v2_xy * mu_ - - v1_yy * mu_ - - v2_xy * mu_ ) - # y-momentum equation - du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - # stress tensor from y-direction - - v1_xy * mu_ - - v2_xx * mu_ - - 4.0 / 3.0 * v2_yy * mu_ - + 2.0 / 3.0 * v1_xy * mu_ ) - # total energy equation - du4 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - # stress tensor and temperature gradient terms from x-direction - - 4.0 / 3.0 * v1_xx * v1 * mu_ - + 2.0 / 3.0 * v2_xy * v1 * mu_ - - 4.0 / 3.0 * v1_x * v1_x * mu_ - + 2.0 / 3.0 * v2_y * v1_x * mu_ - - v1_xy * v2 * mu_ - - v2_xx * v2 * mu_ - - v1_y * v2_x * mu_ - - v2_x * v2_x * mu_ - - T_const * inv_rho_cubed * ( p_xx * rho * rho - - 2.0 * p_x * rho * rho_x - + 2.0 * p * rho_x * rho_x - - p * rho * rho_xx ) * mu_ - # stress tensor and temperature gradient terms from y-direction - - v1_yy * v1 * mu_ - - v2_xy * v1 * mu_ - - v1_y * v1_y * mu_ - - v2_x * v1_y * mu_ - - 4.0 / 3.0 * v2_yy * v2 * mu_ - + 2.0 / 3.0 * v1_xy * v2 * mu_ - - 4.0 / 3.0 * v2_y * v2_y * mu_ - + 2.0 / 3.0 * v1_x * v2_y * mu_ - - T_const * inv_rho_cubed * ( p_yy * rho * rho - - 2.0 * p_y * rho * rho_y - + 2.0 * p * rho_y * rho_y - - p * rho * rho_yy ) * mu_ ) - - return SVector(du1, du2, du3, du4) + y = x[2] + + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Same settings as in `initial_condition` + # Amplitude and shift + A = 0.5 + c = 2.0 + + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t + + # compute the manufactured solution and all necessary derivatives + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) + rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) + rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) + rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + + v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) + v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_y = sin(pi_x) * + (A * log(y + 2.0) * exp(-A * (y - 1.0)) + + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_xy = pi * cos(pi_x) * + (A * log(y + 2.0) * exp(-A * (y - 1.0)) + + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_yy = (sin(pi_x) * + (2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) + - + A * A * log(y + 2.0) * exp(-A * (y - 1.0)) + - + (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_xx = v1_xx + v2_xy = v1_xy + v2_yy = v1_yy + + p = rho * rho + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x + p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y + + # Note this simplifies slightly because the ansatz assumes that v1 = v2 + E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) + E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y + + # Some convenience constants + T_const = equations.gamma * inv_gamma_minus_one / Pr + inv_rho_cubed = 1.0 / (rho^3) + + # compute the source terms + # density equation + du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y + + # x-momentum equation + du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + # stress tensor from x-direction + - + 4.0 / 3.0 * v1_xx * mu_ + + + 2.0 / 3.0 * v2_xy * mu_ + - + v1_yy * mu_ + - + v2_xy * mu_) + # y-momentum equation + du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + # stress tensor from y-direction + - + v1_xy * mu_ + - + v2_xx * mu_ + - + 4.0 / 3.0 * v2_yy * mu_ + + + 2.0 / 3.0 * v1_xy * mu_) + # total energy equation + du4 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + # stress tensor and temperature gradient terms from x-direction + - + 4.0 / 3.0 * v1_xx * v1 * mu_ + + + 2.0 / 3.0 * v2_xy * v1 * mu_ + - + 4.0 / 3.0 * v1_x * v1_x * mu_ + + + 2.0 / 3.0 * v2_y * v1_x * mu_ + - + v1_xy * v2 * mu_ + - + v2_xx * v2 * mu_ + - + v1_y * v2_x * mu_ + - + v2_x * v2_x * mu_ + - + T_const * inv_rho_cubed * + (p_xx * rho * rho + - + 2.0 * p_x * rho * rho_x + + + 2.0 * p * rho_x * rho_x + - + p * rho * rho_xx) * mu_ + # stress tensor and temperature gradient terms from y-direction + - + v1_yy * v1 * mu_ + - + v2_xy * v1 * mu_ + - + v1_y * v1_y * mu_ + - + v2_x * v1_y * mu_ + - + 4.0 / 3.0 * v2_yy * v2 * mu_ + + + 2.0 / 3.0 * v1_xy * v2 * mu_ + - + 4.0 / 3.0 * v2_y * v2_y * mu_ + + + 2.0 / 3.0 * v1_x * v2_y * mu_ + - + T_const * inv_rho_cubed * + (p_yy * rho * rho + - + 2.0 * p_y * rho * rho_y + + + 2.0 * p * rho_y * rho_y + - + p * rho * rho_yy) * mu_) + + return SVector(du1, du2, du3, du4) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, + t, + equations)[2:3]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, + heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -187,10 +233,11 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) - +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -200,15 +247,15 @@ tspan = (0.0, 0.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl b/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl index 97b779ebaf9..7c55cbf0ccf 100644 --- a/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl +++ b/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl @@ -9,28 +9,27 @@ prandtl_number() = 0.72 mu() = 0.001 equations = CompressibleEulerEquations2D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), - Prandtl=prandtl_number()) - +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), + Prandtl = prandtl_number()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = GaussSBP(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) -top(x, tol=50*eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol=50*eps()) = !top(x, tol) +top(x, tol = 50 * eps()) = abs(x[2] - 1) < tol +rest_of_boundary(x, tol = 50 * eps()) = !top(x, tol) is_on_boundary = Dict(:top => top, :rest_of_boundary => rest_of_boundary) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary) function initial_condition_cavity(x, t, equations::CompressibleEulerEquations2D) - Ma = 0.1 - rho = 1.0 - u, v = 0.0, 0.0 - p = 1.0 / (Ma^2 * equations.gamma) - return prim2cons(SVector(rho, u, v, p), equations) + Ma = 0.1 + rho = 1.0 + u, v = 0.0, 0.0 + p = 1.0 / (Ma^2 * equations.gamma) + return prim2cons(SVector(rho, u, v, p), equations) end initial_condition = initial_condition_cavity @@ -43,15 +42,16 @@ boundary_condition_cavity = BoundaryConditionNavierStokesWall(velocity_bc_cavity # define inviscid boundary conditions boundary_conditions = (; :top => boundary_condition_slip_wall, - :rest_of_boundary => boundary_condition_slip_wall) + :rest_of_boundary => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top => boundary_condition_lid, - :rest_of_boundary => boundary_condition_cavity) - -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) + :rest_of_boundary => boundary_condition_cavity) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -61,15 +61,15 @@ tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl b/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl index 3551c863ff2..f7120d8091b 100644 --- a/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl +++ b/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl @@ -4,24 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal) -dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = SBP(), +dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) cells_per_dimension = (8, 8) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min=(0.0, 0.0), coordinates_max=(sqrt(2), sqrt(2)), - periodicity=true) - + coordinates_min = (0.0, 0.0), coordinates_max = (sqrt(2), sqrt(2)), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -32,8 +31,8 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -42,7 +41,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-7, reltol=1.0e-7, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl b/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl index 4f43f2571a3..e877e602547 100644 --- a/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl +++ b/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl @@ -16,17 +16,15 @@ dg = DGMulti(element_type = Wedge(), surface_flux = flux_lax_friedrichs, polydeg = tensor_polydeg) - cells_per_dimension = (8, 8, 8) -mesh = DGMultiMesh(dg, +mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-1.0, -1.0, -1.0), + coordinates_min = (-1.0, -1.0, -1.0), coordinates_max = (1.0, 1.0, 1.0), periodicity = true) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions=boundary_condition_periodic) + boundary_conditions = boundary_condition_periodic) ############################################################################### # ODE solvers, callbacks etc. @@ -37,20 +35,20 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.0) - -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback) +stepsize_callback = StepsizeCallback(cfl = 1.0) +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, + stepsize_callback) ############################################################################### # run the simulation sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), dt = 1.0, - save_everystep=false, callback=callbacks); + save_everystep = false, callback = callbacks); -summary_callback() # print the timer summary \ No newline at end of file +summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_euler_curved.jl b/examples/dgmulti_3d/elixir_euler_curved.jl index 56d870f6bf6..5f2a03f780b 100644 --- a/examples/dgmulti_3d/elixir_euler_curved.jl +++ b/examples/dgmulti_3d/elixir_euler_curved.jl @@ -1,7 +1,7 @@ using Trixi, OrdinaryDiffEq -dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type=SBP(), +dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = SBP(), surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) @@ -10,22 +10,22 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol=50*eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol=50*eps()) = !top_boundary(x, tol) +top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol +rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary) function mapping(xi, eta, zeta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y, z) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary=is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary = is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -35,14 +35,14 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl index 35f7aee8795..0eb38674689 100644 --- a/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl @@ -10,19 +10,20 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test -volume_flux = flux_ranocha +volume_flux = flux_ranocha solver = DGMulti(element_type = Hex(), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=20), + approximation_type = periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 20), surface_flux = flux_lax_friedrichs, volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) -mesh = DGMultiMesh(solver, coordinates_min=(-1.0, -1.0, -1.0), - coordinates_max=( 1.0, 1.0, 1.0)) +mesh = DGMultiMesh(solver, coordinates_min = (-1.0, -1.0, -1.0), + coordinates_max = (1.0, 1.0, 1.0)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; - source_terms=source_terms) - + source_terms = source_terms) ############################################################################### # ODE solvers, callbacks etc. @@ -33,14 +34,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(solver)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + uEltype = real(solver)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation diff --git a/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl b/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl index 253d2486468..fea43ad4d26 100644 --- a/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl +++ b/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl @@ -12,35 +12,38 @@ equations = CompressibleEulerEquations3D(1.4) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, + equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + + 1.0 / 16.0 * A^2 * rho * + (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + + cos(2 * x[2]) * cos(2 * x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex -volume_flux = flux_ranocha +volume_flux = flux_ranocha surface_flux = flux_lax_friedrichs solver = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(), - surface_integral= SurfaceIntegralWeakForm(surface_flux), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + surface_integral = SurfaceIntegralWeakForm(surface_flux), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) cells_per_dimension = (8, 8, 8) mesh = DGMultiMesh(solver, cells_per_dimension, - coordinates_min=(-pi, -pi, -pi), coordinates_max=(pi, pi, pi), - periodicity=true) + coordinates_min = (-pi, -pi, -pi), coordinates_max = (pi, pi, pi), + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -50,14 +53,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(solver)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + uEltype = real(solver)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation diff --git a/examples/dgmulti_3d/elixir_euler_weakform.jl b/examples/dgmulti_3d/elixir_euler_weakform.jl index 2a44a7b6c7b..5e54f016579 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform.jl @@ -10,16 +10,16 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol=50*eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol=50*eps()) = !top_boundary(x, tol) +top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol +rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary) cells_per_dimension = (4, 4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary=is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary = is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -29,14 +29,14 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl index fd4a83a386f..8ffbf54bd18 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl @@ -10,7 +10,7 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test cells_per_dimension = (4, 4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -19,14 +19,14 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_navierstokes_convergence.jl b/examples/dgmulti_3d/elixir_navierstokes_convergence.jl index 9a237b2d2fc..b5e6c6f80a8 100644 --- a/examples/dgmulti_3d/elixir_navierstokes_convergence.jl +++ b/examples/dgmulti_3d/elixir_navierstokes_convergence.jl @@ -8,219 +8,234 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), Prandtl=prandtl_number(), - gradient_variables=GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) cells_per_dimension = (8, 8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=(true, false, true), is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = (true, false, true), + is_on_boundary) # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion3D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion3D`) # and by the initial condition (which passes in `CompressibleEulerEquations3D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * cos(pi_t) - v2 = v1 - v3 = v1 - p = rho^2 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * + cos(pi_t) + v2 = v1 + v3 = v1 + p = rho^2 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - # Define auxiliary functions for the strange function of the y variable - # to make expressions easier to read - g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) - g_y = ( A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) - + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0) ) - g_yy = ( 2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) - - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) - - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) ) - - # Density and its derivatives - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) - rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) - rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) - rho_xx = -pi^2 * (rho - c) - rho_yy = -pi^2 * (rho - c) - rho_zz = -pi^2 * (rho - c) - - # Velocities and their derivatives - # v1 terms - v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) - v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_xx = -pi^2 * v1 - v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) - v1_zz = -pi^2 * v1 - v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) - # v2 terms (simplifies from ansatz) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_z = v1_z - v2_xx = v1_xx - v2_yy = v1_yy - v2_zz = v1_zz - v2_xy = v1_xy - v2_yz = v1_yz - # v3 terms (simplifies from ansatz) - v3 = v1 - v3_t = v1_t - v3_x = v1_x - v3_y = v1_y - v3_z = v1_z - v3_xx = v1_xx - v3_yy = v1_yy - v3_zz = v1_zz - v3_xz = v1_xz - v3_yz = v1_yz - - # Pressure and its derivatives - p = rho^2 - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_z = 2.0 * rho * rho_z - - # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 - E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 - E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y - E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z - - # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho - kappa = equations.gamma * inv_gamma_minus_one / Pr - q_xx = kappa * rho_xx # kappa T_xx - q_yy = kappa * rho_yy # kappa T_yy - q_zz = kappa * rho_zz # kappa T_zz - - # Stress tensor and its derivatives (exploit symmetry) - tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) - tau12 = v1_y + v2_x - tau13 = v1_z + v3_x - tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) - tau23 = v2_z + v3_y - tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) - - tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) - tau12_x = v1_xy + v2_xx - tau13_x = v1_xz + v3_xx - - tau12_y = v1_yy + v2_xy - tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) - tau23_y = v2_yz + v3_yy - - tau13_z = v1_zz + v3_xz - tau23_z = v2_zz + v3_yz - tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) - - # Compute the source terms - # Density equation - du1 = ( rho_t + rho_x * v1 + rho * v1_x - + rho_y * v2 + rho * v2_y - + rho_z * v3 + rho * v3_z ) - # x-momentum equation - du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - + rho_z * v1 * v3 - + rho * v1_z * v3 - + rho * v1 * v3_z - - mu_ * (tau11_x + tau12_y + tau13_z) ) - # y-momentum equation - du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - + rho_z * v2 * v3 - + rho * v2_z * v3 - + rho * v2 * v3_z - - mu_ * (tau12_x + tau22_y + tau23_z) ) - # z-momentum equation - du4 = ( rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 - + rho * v1_x * v3 - + rho * v1 * v3_x - + rho_y * v2 * v3 - + rho * v2_y * v3 - + rho * v2 * v3_y - + rho_z * v3^2 - + 2.0 * rho * v3 * v3_z - - mu_ * (tau13_x + tau23_y + tau33_z) ) - # Total energy equation - du5 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - + v3_z * (E + p) + v3 * (E_z + p_z) - # stress tensor and temperature gradient from x-direction - - mu_ * ( q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 - + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) - # stress tensor and temperature gradient terms from y-direction - - mu_ * ( q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 - + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) - # stress tensor and temperature gradient terms from z-direction - - mu_ * ( q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 - + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z) ) - - return SVector(du1, du2, du3, du4, du5) + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + # Define auxiliary functions for the strange function of the y variable + # to make expressions easier to read + g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) + g_y = (A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) + + + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0)) + g_yy = (2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) + - + (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) + - + A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0))) + + # Density and its derivatives + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) + rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) + rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) + rho_xx = -pi^2 * (rho - c) + rho_yy = -pi^2 * (rho - c) + rho_zz = -pi^2 * (rho - c) + + # Velocities and their derivatives + # v1 terms + v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) + v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_xx = -pi^2 * v1 + v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) + v1_zz = -pi^2 * v1 + v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) + # v2 terms (simplifies from ansatz) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_z = v1_z + v2_xx = v1_xx + v2_yy = v1_yy + v2_zz = v1_zz + v2_xy = v1_xy + v2_yz = v1_yz + # v3 terms (simplifies from ansatz) + v3 = v1 + v3_t = v1_t + v3_x = v1_x + v3_y = v1_y + v3_z = v1_z + v3_xx = v1_xx + v3_yy = v1_yy + v3_zz = v1_zz + v3_xz = v1_xz + v3_yz = v1_yz + + # Pressure and its derivatives + p = rho^2 + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_z = 2.0 * rho * rho_z + + # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 + E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 + E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y + E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z + + # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho + kappa = equations.gamma * inv_gamma_minus_one / Pr + q_xx = kappa * rho_xx # kappa T_xx + q_yy = kappa * rho_yy # kappa T_yy + q_zz = kappa * rho_zz # kappa T_zz + + # Stress tensor and its derivatives (exploit symmetry) + tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) + tau12 = v1_y + v2_x + tau13 = v1_z + v3_x + tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) + tau23 = v2_z + v3_y + tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) + + tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) + tau12_x = v1_xy + v2_xx + tau13_x = v1_xz + v3_xx + + tau12_y = v1_yy + v2_xy + tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) + tau23_y = v2_yz + v3_yy + + tau13_z = v1_zz + v3_xz + tau23_z = v2_zz + v3_yz + tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) + + # Compute the source terms + # Density equation + du1 = (rho_t + rho_x * v1 + rho * v1_x + + rho_y * v2 + rho * v2_y + + rho_z * v3 + rho * v3_z) + # x-momentum equation + du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + + rho_z * v1 * v3 + + rho * v1_z * v3 + + rho * v1 * v3_z + - + mu_ * (tau11_x + tau12_y + tau13_z)) + # y-momentum equation + du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + + rho_z * v2 * v3 + + rho * v2_z * v3 + + rho * v2 * v3_z + - + mu_ * (tau12_x + tau22_y + tau23_z)) + # z-momentum equation + du4 = (rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 + + rho * v1_x * v3 + + rho * v1 * v3_x + + rho_y * v2 * v3 + + rho * v2_y * v3 + + rho * v2 * v3_y + + rho_z * v3^2 + + 2.0 * rho * v3 * v3_z + - + mu_ * (tau13_x + tau23_y + tau33_z)) + # Total energy equation + du5 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + + v3_z * (E + p) + v3 * (E_z + p_z) + # stress tensor and temperature gradient from x-direction + - + mu_ * (q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 + + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) + # stress tensor and temperature gradient terms from y-direction + - + mu_ * (q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 + + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) + # stress tensor and temperature gradient terms from z-direction + - + mu_ * (q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 + + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z)) + + return SVector(du1, du2, du3, du4, du5) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, + t, + equations)[2:4]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, + heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -228,10 +243,11 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) - +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -241,15 +257,15 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl b/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl index c14d6620803..87c19dbd509 100644 --- a/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl +++ b/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl @@ -8,25 +8,27 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), Prandtl=prandtl_number(), - gradient_variables=GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) function mapping(xi, eta, zeta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y, z) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity=(true, false, true), is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity = (true, false, true), + is_on_boundary) # This initial condition is taken from `examples/dgmulti_3d/elixir_navierstokes_convergence.jl` @@ -35,200 +37,213 @@ mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity=(true, false, t # and by the initial condition (which passes in `CompressibleEulerEquations3D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * cos(pi_t) - v2 = v1 - v3 = v1 - p = rho^2 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * + cos(pi_t) + v2 = v1 + v3 = v1 + p = rho^2 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - # Define auxiliary functions for the strange function of the y variable - # to make expressions easier to read - g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) - g_y = ( A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) - + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0) ) - g_yy = ( 2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) - - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) - - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) ) - - # Density and its derivatives - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) - rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) - rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) - rho_xx = -pi^2 * (rho - c) - rho_yy = -pi^2 * (rho - c) - rho_zz = -pi^2 * (rho - c) - - # Velocities and their derivatives - # v1 terms - v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) - v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_xx = -pi^2 * v1 - v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) - v1_zz = -pi^2 * v1 - v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) - # v2 terms (simplifies from ansatz) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_z = v1_z - v2_xx = v1_xx - v2_yy = v1_yy - v2_zz = v1_zz - v2_xy = v1_xy - v2_yz = v1_yz - # v3 terms (simplifies from ansatz) - v3 = v1 - v3_t = v1_t - v3_x = v1_x - v3_y = v1_y - v3_z = v1_z - v3_xx = v1_xx - v3_yy = v1_yy - v3_zz = v1_zz - v3_xz = v1_xz - v3_yz = v1_yz - - # Pressure and its derivatives - p = rho^2 - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_z = 2.0 * rho * rho_z - - # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 - E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 - E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y - E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z - - # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho - kappa = equations.gamma * inv_gamma_minus_one / Pr - q_xx = kappa * rho_xx # kappa T_xx - q_yy = kappa * rho_yy # kappa T_yy - q_zz = kappa * rho_zz # kappa T_zz - - # Stress tensor and its derivatives (exploit symmetry) - tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) - tau12 = v1_y + v2_x - tau13 = v1_z + v3_x - tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) - tau23 = v2_z + v3_y - tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) - - tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) - tau12_x = v1_xy + v2_xx - tau13_x = v1_xz + v3_xx - - tau12_y = v1_yy + v2_xy - tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) - tau23_y = v2_yz + v3_yy - - tau13_z = v1_zz + v3_xz - tau23_z = v2_zz + v3_yz - tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) - - # Compute the source terms - # Density equation - du1 = ( rho_t + rho_x * v1 + rho * v1_x - + rho_y * v2 + rho * v2_y - + rho_z * v3 + rho * v3_z ) - # x-momentum equation - du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - + rho_z * v1 * v3 - + rho * v1_z * v3 - + rho * v1 * v3_z - - mu_ * (tau11_x + tau12_y + tau13_z) ) - # y-momentum equation - du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - + rho_z * v2 * v3 - + rho * v2_z * v3 - + rho * v2 * v3_z - - mu_ * (tau12_x + tau22_y + tau23_z) ) - # z-momentum equation - du4 = ( rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 - + rho * v1_x * v3 - + rho * v1 * v3_x - + rho_y * v2 * v3 - + rho * v2_y * v3 - + rho * v2 * v3_y - + rho_z * v3^2 - + 2.0 * rho * v3 * v3_z - - mu_ * (tau13_x + tau23_y + tau33_z) ) - # Total energy equation - du5 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - + v3_z * (E + p) + v3 * (E_z + p_z) - # stress tensor and temperature gradient from x-direction - - mu_ * ( q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 - + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) - # stress tensor and temperature gradient terms from y-direction - - mu_ * ( q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 - + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) - # stress tensor and temperature gradient terms from z-direction - - mu_ * ( q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 - + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z) ) - - return SVector(du1, du2, du3, du4, du5) + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + # Define auxiliary functions for the strange function of the y variable + # to make expressions easier to read + g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) + g_y = (A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) + + + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0)) + g_yy = (2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) + - + (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) + - + A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0))) + + # Density and its derivatives + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) + rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) + rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) + rho_xx = -pi^2 * (rho - c) + rho_yy = -pi^2 * (rho - c) + rho_zz = -pi^2 * (rho - c) + + # Velocities and their derivatives + # v1 terms + v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) + v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_xx = -pi^2 * v1 + v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) + v1_zz = -pi^2 * v1 + v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) + # v2 terms (simplifies from ansatz) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_z = v1_z + v2_xx = v1_xx + v2_yy = v1_yy + v2_zz = v1_zz + v2_xy = v1_xy + v2_yz = v1_yz + # v3 terms (simplifies from ansatz) + v3 = v1 + v3_t = v1_t + v3_x = v1_x + v3_y = v1_y + v3_z = v1_z + v3_xx = v1_xx + v3_yy = v1_yy + v3_zz = v1_zz + v3_xz = v1_xz + v3_yz = v1_yz + + # Pressure and its derivatives + p = rho^2 + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_z = 2.0 * rho * rho_z + + # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 + E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 + E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y + E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z + + # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho + kappa = equations.gamma * inv_gamma_minus_one / Pr + q_xx = kappa * rho_xx # kappa T_xx + q_yy = kappa * rho_yy # kappa T_yy + q_zz = kappa * rho_zz # kappa T_zz + + # Stress tensor and its derivatives (exploit symmetry) + tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) + tau12 = v1_y + v2_x + tau13 = v1_z + v3_x + tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) + tau23 = v2_z + v3_y + tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) + + tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) + tau12_x = v1_xy + v2_xx + tau13_x = v1_xz + v3_xx + + tau12_y = v1_yy + v2_xy + tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) + tau23_y = v2_yz + v3_yy + + tau13_z = v1_zz + v3_xz + tau23_z = v2_zz + v3_yz + tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) + + # Compute the source terms + # Density equation + du1 = (rho_t + rho_x * v1 + rho * v1_x + + rho_y * v2 + rho * v2_y + + rho_z * v3 + rho * v3_z) + # x-momentum equation + du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + + rho_z * v1 * v3 + + rho * v1_z * v3 + + rho * v1 * v3_z + - + mu_ * (tau11_x + tau12_y + tau13_z)) + # y-momentum equation + du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + + rho_z * v2 * v3 + + rho * v2_z * v3 + + rho * v2 * v3_z + - + mu_ * (tau12_x + tau22_y + tau23_z)) + # z-momentum equation + du4 = (rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 + + rho * v1_x * v3 + + rho * v1 * v3_x + + rho_y * v2 * v3 + + rho * v2_y * v3 + + rho * v2 * v3_y + + rho_z * v3^2 + + 2.0 * rho * v3 * v3_z + - + mu_ * (tau13_x + tau23_y + tau33_z)) + # Total energy equation + du5 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + + v3_z * (E + p) + v3 * (E_z + p_z) + # stress tensor and temperature gradient from x-direction + - + mu_ * (q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 + + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) + # stress tensor and temperature gradient terms from y-direction + - + mu_ * (q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 + + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) + # stress tensor and temperature gradient terms from z-direction + - + mu_ * (q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 + + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z)) + + return SVector(du1, du2, du3, du4, du5) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, + t, + equations)[2:4]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, + heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -236,10 +251,11 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) - +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, dg; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -249,15 +265,15 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl b/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl index 7953838afeb..dedd8267a3b 100644 --- a/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl +++ b/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl @@ -10,26 +10,30 @@ prandtl_number() = 0.72 mu() = 6.25e-4 # equivalent to Re = 1600 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), - Prandtl=prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), + Prandtl = prandtl_number()) """ initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, + equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + + 1.0 / 16.0 * A^2 * rho * + (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + + cos(2 * x[2]) * cos(2 * x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex @@ -39,11 +43,11 @@ dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = GaussSBP(), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = ( 1.0, 1.0, 1.0) .* pi +coordinates_max = (1.0, 1.0, 1.0) .* pi cells_per_dimension = (8, 8, 8) mesh = DGMultiMesh(dg, cells_per_dimension; coordinates_min, coordinates_max, - periodicity=(true, true, true)) + periodicity = (true, true, true)) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg) @@ -55,18 +59,18 @@ tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg), - extra_analysis_integrals=(energy_kinetic, - energy_internal, - enstrophy)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg), + extra_analysis_integrals = (energy_kinetic, + energy_internal, + enstrophy)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl b/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl index 841a080947e..5a2537be4e6 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl @@ -7,74 +7,73 @@ module TrixiExtension using Trixi -struct IndicatorSolutionIndependent{Cache<:NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorSolutionIndependent{Cache <: NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorSolutionIndependent(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) - return IndicatorSolutionIndependent{typeof(cache)}(cache) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) + return IndicatorSolutionIndependent{typeof(cache)}(cache) end -function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any,4}, +function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any, 4}, mesh, equations, dg, cache; t, kwargs...) - - mesh = indicator.cache.mesh - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) - - #Predict the theoretical center. - advection_velocity = (0.2, -0.7) - center = t.*advection_velocity - - inner_distance = 1 - outer_distance = 1.85 - - #Iterate over all elements - for element in 1:length(alpha) - # Calculate periodic distance between cell and center. - # This requires an uncurved mesh! - coordinates = SVector(0.5 * (cache.elements.node_coordinates[1, 1, 1, element] + - cache.elements.node_coordinates[1, end, 1, element]), - 0.5 * (cache.elements.node_coordinates[2, 1, 1, element] + - cache.elements.node_coordinates[2, 1, end, element])) - - #The geometric shape of the amr should be preserved when the base_level is increased. - #This is done by looking at the original coordinates of each cell. - cell_coordinates = original_coordinates(coordinates, 5/8) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) - if cell_distance < (inner_distance+outer_distance)/2 - cell_coordinates = original_coordinates(coordinates, 5/16) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + mesh = indicator.cache.mesh + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) + + #Predict the theoretical center. + advection_velocity = (0.2, -0.7) + center = t .* advection_velocity + + inner_distance = 1 + outer_distance = 1.85 + + #Iterate over all elements + for element in 1:length(alpha) + # Calculate periodic distance between cell and center. + # This requires an uncurved mesh! + coordinates = SVector(0.5 * (cache.elements.node_coordinates[1, 1, 1, element] + + cache.elements.node_coordinates[1, end, 1, element]), + 0.5 * (cache.elements.node_coordinates[2, 1, 1, element] + + cache.elements.node_coordinates[2, 1, end, element])) + + #The geometric shape of the amr should be preserved when the base_level is increased. + #This is done by looking at the original coordinates of each cell. + cell_coordinates = original_coordinates(coordinates, 5 / 8) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + if cell_distance < (inner_distance + outer_distance) / 2 + cell_coordinates = original_coordinates(coordinates, 5 / 16) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + end + + #Set alpha according to cells position inside the circles. + target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) + alpha[element] = target_level / 2 end - - #Set alpha according to cells position inside the circles. - target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) - alpha[element] = target_level/2 - end - return alpha + return alpha end # For periodic domains, distance between two points must take into account # periodic extensions of the domain function periodic_distance_2d(coordinates, center, domain_length) - dx = coordinates .- center - dx_shifted = abs.(dx .% domain_length) - dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) - return sqrt(sum(dx_periodic.^2)) + dx = coordinates .- center + dx_shifted = abs.(dx .% domain_length) + dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) + return sqrt(sum(dx_periodic .^ 2)) end #This takes a cells coordinates and transforms them into the coordinates of a parent-cell it originally refined from. #It does it so that the parent-cell has given cell_length. function original_coordinates(coordinates, cell_length) - offset = coordinates .% cell_length - offset_sign = sign.(offset) - border = coordinates - offset - center = border + (offset_sign .* cell_length/2) - return center + offset = coordinates .% cell_length + offset_sign = sign.(offset) + border = coordinates - offset + center = border + (offset_sign .* cell_length / 2) + return center end end # module TrixiExtension @@ -88,21 +87,19 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) trees_per_dimension = (1, 1) -mesh = P4estMesh(trees_per_dimension, polydeg=3, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=4) - +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 4) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -112,38 +109,38 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_controller = ControllerThreeLevel(semi, TrixiExtension.IndicatorSolutionIndependent(semi), - base_level=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, + TrixiExtension.IndicatorSolutionIndependent(semi), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl b/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl index 7e6d99c83b1..0a50b3644f0 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl @@ -12,18 +12,16 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :all => boundary_condition -) +boundary_conditions = Dict(:all => boundary_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-5.0, 5 * s - 5.0) -f2(s) = SVector( 5.0, 5 * s + 5.0) +f2(s) = SVector(5.0, 5 * s + 5.0) f3(s) = SVector(5 * s, -5.0 + 5 * sin(0.5 * pi * s)) -f4(s) = SVector(5 * s, 5.0 + 5 * sin(0.5 * pi * s)) +f4(s) = SVector(5 * s, 5.0 + 5 * sin(0.5 * pi * s)) faces = (f1, f2, f3, f4) # This creates a mapping that transforms [-1, 1]^2 to the domain with the faces defined above. @@ -34,17 +32,16 @@ mapping_flag = Trixi.transfinite_mapping(faces) # Unstructured mesh with 24 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) - -mesh = P4estMesh{2}(mesh_file, polydeg=3, - mapping=mapping_flag, - initial_refinement_level=1) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) +mesh = P4estMesh{2}(mesh_file, polydeg = 3, + mapping = mapping_flag, + initial_refinement_level = 1) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -55,41 +52,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +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=1, - med_level=2, med_threshold=0.1, - max_level=3, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 1, + med_level = 2, med_threshold = 0.1, + max_level = 3, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.7) +stepsize_callback = StepsizeCallback(cfl = 0.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, amr_callback, stepsize_callback); - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=1, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1, # 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 diff --git a/examples/p4est_2d_dgsem/elixir_advection_basic.jl b/examples/p4est_2d_dgsem/elixir_advection_basic.jl index 0b2de85da48..ed235bf839c 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_basic.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_basic.jl @@ -11,21 +11,21 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) trees_per_dimension = (8, 8) # Create P4estMesh with 8 x 8 trees and 16 x 16 elements -mesh = P4estMesh(trees_per_dimension, polydeg=3, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=1) +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 1) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -38,26 +38,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl index 1cd075e84ea..0b5129e3c0f 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl @@ -9,19 +9,21 @@ advection_velocity = (1.0, 0.0) equations = LinearScalarAdvectionEquation2D(advection_velocity) equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) -function x_trans_periodic(x, domain_length=SVector(2 * pi), center=SVector(0.0)) +function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0)) x_normalized = x .- center x_shifted = x_normalized .% domain_length - x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* domain_length + x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* + domain_length return center + x_shifted + x_offset end # Define initial condition (copied from "examples/tree_1d_dgsem/elixir_advection_diffusion.jl") -function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation2D) +function initial_condition_diffusive_convergence_test(x, t, + equation::LinearScalarAdvectionEquation2D) # Store translated coordinate for easy use of exact solution # Assumes that advection_velocity[2] = 0 (effectively that we are solving a 1D equation) x_trans = x_trans_periodic(x[1] - equation.advection_velocity[1] * t) - + nu = diffusivity() c = 0.0 A = 1.0 @@ -32,23 +34,22 @@ end initial_condition = initial_condition_diffusive_convergence_test # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-pi, -pi) # minimum coordinates (min(x), min(y)) -coordinates_max = ( pi, pi) # maximum coordinates (max(x), max(y)) +coordinates_max = (pi, pi) # maximum coordinates (max(x), max(y)) trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg=3, initial_refinement_level=2, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=true) + polydeg = 3, initial_refinement_level = 2, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -62,22 +63,21 @@ 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) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl index b438fb8a29c..130def37997 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl @@ -9,19 +9,21 @@ advection_velocity = (1.0, 0.0) equations = LinearScalarAdvectionEquation2D(advection_velocity) equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) -function x_trans_periodic(x, domain_length=SVector(2 * pi), center=SVector(0.0)) +function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0)) x_normalized = x .- center x_shifted = x_normalized .% domain_length - x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* domain_length + x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* + domain_length return center + x_shifted + x_offset end # Define initial condition (copied from "examples/tree_1d_dgsem/elixir_advection_diffusion.jl") -function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation2D) +function initial_condition_diffusive_convergence_test(x, t, + equation::LinearScalarAdvectionEquation2D) # Store translated coordinate for easy use of exact solution # Assumes that advection_velocity[2] = 0 (effectively that we are solving a 1D equation) x_trans = x_trans_periodic(x[1] - equation.advection_velocity[1] * t) - + nu = diffusivity() c = 0.0 A = 1.0 @@ -32,28 +34,27 @@ end initial_condition = initial_condition_diffusive_convergence_test # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # This maps the domain [-1, 1]^2 to [-pi, pi]^2 while also # introducing a curved warping to interior nodes. function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return pi * SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return pi * SVector(x, y) end trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg=3, initial_refinement_level=2, - mapping=mapping, - periodicity=true) + polydeg = 3, initial_refinement_level = 2, + mapping = mapping, + periodicity = true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -67,22 +68,21 @@ 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) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_extended.jl b/examples/p4est_2d_dgsem/elixir_advection_extended.jl index 6d8e7030ac0..66a5b7e0f5b 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_extended.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_extended.jl @@ -12,31 +12,28 @@ initial_condition = initial_condition_convergence_test # BCs must be passed as Dict boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :x_neg => boundary_condition, - :x_pos => boundary_condition, - :y_neg => boundary_condition, - :y_pos => boundary_condition -) +boundary_conditions = Dict(:x_neg => boundary_condition, + :x_pos => boundary_condition, + :y_neg => boundary_condition, + :y_pos => boundary_condition) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # The initial condition is 2-periodic coordinates_min = (-1.5, 1.3) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 0.5, 5.3) # maximum coordinates (max(x), max(y)) +coordinates_max = (0.5, 5.3) # maximum coordinates (max(x), max(y)) trees_per_dimension = (19, 37) # Create curved mesh with 19 x 37 elements -mesh = P4estMesh(trees_per_dimension, polydeg=3, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=false) +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = false) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -51,24 +48,24 @@ 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, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.6) +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, @@ -76,14 +73,13 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl b/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl index 0e6e314ebd7..b47b0d61192 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the linear advection equation @@ -10,42 +9,44 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) # Create DG solver with polynomial degree = 4 and (local) Lax-Friedrichs/Rusanov flux as surface flux -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector( 1.0, s + 1.0) +f2(s) = SVector(1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) # Create P4estMesh with 3 x 2 trees and 6 x 4 elements, # approximate the geometry with a smaller polydeg for testing. trees_per_dimension = (3, 2) -mesh = P4estMesh(trees_per_dimension, polydeg=3, - faces=(f1, f2, f3, f4), - initial_refinement_level=1) +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + faces = (f1, f2, f3, f4), + initial_refinement_level = 1) # Refine bottom left quadrant of each tree to level 4 function refine_fn(p4est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 4 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 4 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 4 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p4est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -58,26 +59,26 @@ ode = semidiscretize(semi, (0.0, 0.2)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_restart.jl b/examples/p4est_2d_dgsem/elixir_advection_restart.jl index 1906fb2896e..46eabb4cf38 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_restart.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_restart.jl @@ -10,7 +10,6 @@ restart_file = "restart_000021.h5" trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file)) - ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -21,16 +20,15 @@ restart_filename = joinpath("out", restart_file) mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl b/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl index 9f5b813639f..37fcc547f60 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl @@ -3,7 +3,6 @@ using Downloads: download using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the linear advection equation @@ -13,19 +12,17 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :all => boundary_condition -) +boundary_conditions = Dict(:all => boundary_condition) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector( 1.0, s + 1.0) +f2(s) = SVector(1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) faces = (f1, f2, f3, f4) Trixi.validate_faces(faces) @@ -33,16 +30,17 @@ mapping_flag = Trixi.transfinite_mapping(faces) # Unstructured mesh with 24 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{2}(mesh_file, polydeg=3, - mapping=mapping_flag, - initial_refinement_level=2) +mesh = P4estMesh{2}(mesh_file, polydeg = 3, + mapping = mapping_flag, + initial_refinement_level = 2) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -56,26 +54,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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.4) +stepsize_callback = StepsizeCallback(cfl = 1.4) # 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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl index e3f33fb0d28..0ca4fdc2eb7 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl @@ -17,49 +17,48 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) # Unstructured mesh with 48 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_1.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", + mesh_file) -mesh = P4estMesh{2}(mesh_file, polydeg=3, initial_refinement_level=1) +mesh = P4estMesh{2}(mesh_file, polydeg = 3, initial_refinement_level = 1) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=Dict( - :all => BoundaryConditionDirichlet(initial_condition) - )) + boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition))) ############################################################################### # ODE solvers, callbacks etc. @@ -70,40 +69,39 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=1, - max_level =3, max_threshold=0.01) + base_level = 1, + max_level = 3, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl index 6d00aa91ba3..37de44fd40d 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl @@ -21,64 +21,66 @@ See Section IV c on the paper below for details. The Numerical Simulation of Two-Dimensional Fluid Flows with Strong Shocks. [DOI: 10.1016/0021-9991(84)90142-6](https://doi.org/10.1016/0021-9991(84)90142-6) """ -@inline function initial_condition_double_mach_reflection(x, t, equations::CompressibleEulerEquations2D) - - if x[1] < 1 / 6 + (x[2] + 20 * t) / sqrt(3) - phi = pi / 6 - sin_phi, cos_phi = sincos(phi) - - rho = 8 - v1 = 8.25 * cos_phi - v2 = -8.25 * sin_phi - p = 116.5 - else - rho = 1.4 - v1 = 0 - v2 = 0 - p = 1 - end - - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) +@inline function initial_condition_double_mach_reflection(x, t, + equations::CompressibleEulerEquations2D) + if x[1] < 1 / 6 + (x[2] + 20 * t) / sqrt(3) + phi = pi / 6 + sin_phi, cos_phi = sincos(phi) + + rho = 8 + v1 = 8.25 * cos_phi + v2 = -8.25 * sin_phi + p = 116.5 + else + rho = 1.4 + v1 = 0 + v2 = 0 + p = 1 + end + + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_double_mach_reflection - boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition_double_mach_reflection) # Supersonic outflow boundary condition. Solution is taken entirely from the internal state. # See `examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl` for complete documentation. @inline function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, equations::CompressibleEulerEquations2D) - # NOTE: Only for the supersonic outflow is this strategy valid - # Calculate the boundary flux entirely from the internal solution state - return flux(u_inner, normal_direction, equations) + surface_flux_function, + equations::CompressibleEulerEquations2D) + # NOTE: Only for the supersonic outflow is this strategy valid + # Calculate the boundary flux entirely from the internal solution state + return flux(u_inner, normal_direction, equations) end # Special mixed boundary condition type for the :Bottom of the domain. # It is Dirichlet when x < 1/6 and a slip wall when x >= 1/6 -@inline function boundary_condition_mixed_dirichlet_wall(u_inner, normal_direction::AbstractVector, +@inline function boundary_condition_mixed_dirichlet_wall(u_inner, + normal_direction::AbstractVector, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) - if x[1] < 1 / 6 - # From the BoundaryConditionDirichlet - # get the external value of the solution - u_boundary = initial_condition_double_mach_reflection(x, t, equations) - # Calculate boundary flux - flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations) - else # x[1] >= 1 / 6 - # Use the free slip wall BC otherwise - flux = boundary_condition_slip_wall(u_inner, normal_direction, x, t, surface_flux_function, equations) - end - - return flux + if x[1] < 1 / 6 + # From the BoundaryConditionDirichlet + # get the external value of the solution + u_boundary = initial_condition_double_mach_reflection(x, t, equations) + # Calculate boundary flux + flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations) + else # x[1] >= 1 / 6 + # Use the free slip wall BC otherwise + flux = boundary_condition_slip_wall(u_inner, normal_direction, x, t, + surface_flux_function, equations) + end + + return flux end -boundary_conditions = Dict( :Bottom => boundary_condition_mixed_dirichlet_wall, - :Top => boundary_condition_inflow, - :Right => boundary_condition_outflow, - :Left => boundary_condition_inflow ) +boundary_conditions = Dict(:Bottom => boundary_condition_mixed_dirichlet_wall, + :Top => boundary_condition_inflow, + :Right => boundary_condition_outflow, + :Left => boundary_condition_inflow) volume_flux = flux_ranocha surface_flux = flux_lax_friedrichs @@ -86,25 +88,27 @@ surface_flux = flux_lax_friedrichs polydeg = 4 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_double_mach.inp") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/a0806ef0d03cf5ea221af523167b6e32/raw/61ed0eb017eb432d996ed119a52fb041fe363e8c/abaqus_double_mach.inp", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/a0806ef0d03cf5ea221af523167b6e32/raw/61ed0eb017eb432d996ed119a52fb041fe363e8c/abaqus_double_mach.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -115,27 +119,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_indicator = IndicatorLöhner(semi, variable=Trixi.density) +amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=0, - med_level=3, med_threshold=0.05, - max_level=6, max_threshold=0.1) + base_level = 0, + med_level = 3, med_threshold = 0.05, + max_level = 6, max_threshold = 0.1) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -143,11 +147,11 @@ callbacks = CallbackSet(summary_callback, amr_callback) # positivity limiter necessary for this example with strong shocks -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl index 667834ea108..0ec9fc222f2 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl @@ -20,19 +20,18 @@ See Section IV b on the paper below for details. [DOI: 10.1016/0021-9991(84)90142-6](https://doi.org/10.1016/0021-9991(84)90142-6) """ @inline function initial_condition_mach3_flow(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.4 - v1 = 3.0 - v2 = 0.0 - p_freestream = 1.0 - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.4 + v1 = 3.0 + v2 = 0.0 + p_freestream = 1.0 + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = initial_condition_mach3_flow - boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition_mach3_flow) # Outflow boundary condition. @@ -46,46 +45,47 @@ boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition_mach3_f # Inflow/Outflow Boundary Conditions with Application to FUN3D. # [NASA TM 20110022658](https://ntrs.nasa.gov/citations/20110022658) @inline function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, equations::CompressibleEulerEquations2D) - # # This would be for the general case where we need to check the magnitude of the local Mach number - # norm_ = norm(normal_direction) - # # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later - # normal = normal_direction / norm_ - - # # Rotate the internal solution state - # u_local = Trixi.rotate_to_x(u_inner, normal, equations) - - # # Compute the primitive variables - # rho_local, v_normal, v_tangent, p_local = cons2prim(u_local, equations) - - # # Compute local Mach number - # a_local = sqrt( equations.gamma * p_local / rho_local ) - # Mach_local = abs( v_normal / a_local ) - # if Mach_local <= 1.0 - # p_local = # Set to the external reference pressure value (somehow? maybe stored in `equations`) - # end - - # # Create the `u_surface` solution state where the local pressure is possibly set from an external value - # prim = SVector(rho_local, v_normal, v_tangent, p_local) - # u_boundary = prim2cons(prim, equations) - # u_surface = Trixi.rotate_from_x(u_boundary, normal, equations) - - # Compute the flux using the appropriate mixture of internal / external solution states - # flux = Trixi.flux(u_surface, normal_direction, equations) - - # NOTE: Only for the supersonic outflow is this strategy valid - # Calculate the boundary flux entirely from the internal solution state - flux = Trixi.flux(u_inner, normal_direction, equations) - - return flux + surface_flux_function, + equations::CompressibleEulerEquations2D) + # # This would be for the general case where we need to check the magnitude of the local Mach number + # norm_ = norm(normal_direction) + # # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later + # normal = normal_direction / norm_ + + # # Rotate the internal solution state + # u_local = Trixi.rotate_to_x(u_inner, normal, equations) + + # # Compute the primitive variables + # rho_local, v_normal, v_tangent, p_local = cons2prim(u_local, equations) + + # # Compute local Mach number + # a_local = sqrt( equations.gamma * p_local / rho_local ) + # Mach_local = abs( v_normal / a_local ) + # if Mach_local <= 1.0 + # p_local = # Set to the external reference pressure value (somehow? maybe stored in `equations`) + # end + + # # Create the `u_surface` solution state where the local pressure is possibly set from an external value + # prim = SVector(rho_local, v_normal, v_tangent, p_local) + # u_boundary = prim2cons(prim, equations) + # u_surface = Trixi.rotate_from_x(u_boundary, normal, equations) + + # Compute the flux using the appropriate mixture of internal / external solution states + # flux = Trixi.flux(u_surface, normal_direction, equations) + + # NOTE: Only for the supersonic outflow is this strategy valid + # Calculate the boundary flux entirely from the internal solution state + flux = Trixi.flux(u_inner, normal_direction, equations) + + return flux end -boundary_conditions = Dict( :Bottom => boundary_condition_slip_wall, - :Step_Front => boundary_condition_slip_wall, - :Step_Top => boundary_condition_slip_wall, - :Top => boundary_condition_slip_wall, - :Right => boundary_condition_outflow, - :Left => boundary_condition_inflow ) +boundary_conditions = Dict(:Bottom => boundary_condition_slip_wall, + :Step_Front => boundary_condition_slip_wall, + :Step_Top => boundary_condition_slip_wall, + :Top => boundary_condition_slip_wall, + :Right => boundary_condition_outflow, + :Left => boundary_condition_inflow) volume_flux = flux_ranocha surface_flux = flux_lax_friedrichs @@ -93,25 +93,27 @@ surface_flux = flux_lax_friedrichs polydeg = 4 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_forward_step.inp") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/b346ee6aa5446687f128eab8b37d52a7/raw/cd1e1d43bebd8d2631a07caec45585ec8456ca4c/abaqus_forward_step.inp", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/b346ee6aa5446687f128eab8b37d52a7/raw/cd1e1d43bebd8d2631a07caec45585ec8456ca4c/abaqus_forward_step.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -122,27 +124,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=2000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 2000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_indicator = IndicatorLöhner(semi, variable=Trixi.density) +amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=0, - med_level=2, med_threshold=0.05, - max_level=5, max_threshold=0.1) + base_level = 0, + med_level = 2, med_threshold = 0.05, + max_level = 5, max_threshold = 0.1) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -150,12 +152,12 @@ callbacks = CallbackSet(summary_callback, amr_callback) # positivity limiter necessary for this example with strong shocks -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation sol = solve(ode, SSPRK43(stage_limiter!); - maxiters=999999, ode_default_options()..., - callback=callbacks); + maxiters = 999999, ode_default_options()..., + callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl b/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl index e88baa2223d..38307a7d781 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl @@ -10,21 +10,21 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_constant -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040 but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end ############################################################################### @@ -32,34 +32,34 @@ end # Unstructured mesh with 48 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_1.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", + mesh_file) # Map the unstructured mesh with the mapping above -mesh = P4estMesh{2}(mesh_file, polydeg=3, mapping=mapping, initial_refinement_level=1) +mesh = P4estMesh{2}(mesh_file, polydeg = 3, mapping = mapping, initial_refinement_level = 1) # Refine bottom left quadrant of each tree to level 2 function refine_fn(p4est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 3 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 3 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 2. # The mesh will be rebalanced before the simulation starts. -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p4est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=Dict( - :all => BoundaryConditionDirichlet(initial_condition) - )) - + boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition))) ############################################################################### # ODE solvers, callbacks etc. @@ -70,16 +70,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=2.0) +stepsize_callback = StepsizeCallback(cfl = 2.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -89,7 +89,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_sedov.jl b/examples/p4est_2d_dgsem/elixir_euler_sedov.jl index 9f5247e8c4d..1b78a152d4e 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_sedov.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_sedov.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) - p0_outer = 1.0e-5 # = true Sedov 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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) + p0_outer = 1.0e-5 # = true Sedov 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 @@ -43,26 +43,27 @@ volume_flux = flux_ranocha polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 1.0, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) ############################################################################### coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg=4, initial_refinement_level=2, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=true) + polydeg = 4, initial_refinement_level = 2, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -75,15 +76,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=300, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 300, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -94,7 +95,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl b/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl index 6ef551c486f..0cb18526f8d 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl @@ -14,30 +14,30 @@ volume_flux = flux_ranocha polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 1.0, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) ############################################################################### coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg=4, initial_refinement_level=2, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=true) + polydeg = 4, initial_refinement_level = 2, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -47,16 +47,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -66,7 +66,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl b/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl index d9a322b065a..09d018309a6 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl @@ -14,18 +14,16 @@ source_terms = source_terms_convergence_test # BCs must be passed as Dict boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :all => boundary_condition -) +boundary_conditions = Dict(:all => boundary_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector( 1.0, s + 1.0) +f2(s) = SVector(1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) faces = (f1, f2, f3, f4) Trixi.validate_faces(faces) @@ -34,34 +32,36 @@ mapping_flag = Trixi.transfinite_mapping(faces) # Get the uncurved mesh from a file (downloads the file if not available locally) # Unstructured mesh with 24 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{2}(mesh_file, polydeg=3, - mapping=mapping_flag, - initial_refinement_level=1) +mesh = P4estMesh{2}(mesh_file, polydeg = 3, + mapping = mapping_flag, + initial_refinement_level = 1) # Refine bottom left quadrant of each tree to level 2 function refine_fn(p4est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 2 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p4est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms, - boundary_conditions=boundary_conditions) - + source_terms = source_terms, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -72,19 +72,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -93,7 +93,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl b/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl index 366be700f9f..aae0b109392 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl @@ -23,14 +23,14 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) @inline function initial_condition_mach3_flow(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.4 - v1 = 3.0 - v2 = 0.0 - p_freestream = 1.0 - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.4 + v1 = 3.0 + v2 = 0.0 + p_freestream = 1.0 + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = initial_condition_mach3_flow @@ -38,30 +38,33 @@ initial_condition = initial_condition_mach3_flow # Supersonic inflow boundary condition. # Calculate the boundary flux entirely from the external solution state, i.e., set # external solution state values for everything entering the domain. -@inline function boundary_condition_supersonic_inflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, equations::CompressibleEulerEquations2D) - u_boundary = initial_condition_mach3_flow(x, t, equations) - flux = Trixi.flux(u_boundary, normal_direction, equations) - - return flux +@inline function boundary_condition_supersonic_inflow(u_inner, + normal_direction::AbstractVector, x, + t, + surface_flux_function, + equations::CompressibleEulerEquations2D) + u_boundary = initial_condition_mach3_flow(x, t, equations) + flux = Trixi.flux(u_boundary, normal_direction, equations) + + return flux end - # Supersonic outflow boundary condition. # Calculate the boundary flux entirely from the internal solution state. Analogous to supersonic inflow # except all the solution state values are set from the internal solution as everything leaves the domain @inline function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, equations::CompressibleEulerEquations2D) - flux = Trixi.flux(u_inner, normal_direction, equations) + surface_flux_function, + equations::CompressibleEulerEquations2D) + flux = Trixi.flux(u_inner, normal_direction, equations) - return flux + return flux end -boundary_conditions = Dict( :Bottom => boundary_condition_slip_wall, - :Circle => boundary_condition_slip_wall, - :Top => boundary_condition_slip_wall, - :Right => boundary_condition_outflow, - :Left => boundary_condition_supersonic_inflow ) +boundary_conditions = Dict(:Bottom => boundary_condition_slip_wall, + :Circle => boundary_condition_slip_wall, + :Top => boundary_condition_slip_wall, + :Right => boundary_condition_outflow, + :Left => boundary_condition_supersonic_inflow) volume_flux = flux_ranocha_turbo surface_flux = flux_lax_friedrichs @@ -69,25 +72,27 @@ surface_flux = flux_lax_friedrichs polydeg = 3 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_cylinder_in_channel.inp") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/a08f78f6b185b63c3baeff911a63f628/raw/addac716ea0541f588b9d2bd3f92f643eb27b88f/abaqus_cylinder_in_channel.inp", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/a08f78f6b185b63c3baeff911a63f628/raw/addac716ea0541f588b9d2bd3f92f643eb27b88f/abaqus_cylinder_in_channel.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers @@ -100,26 +105,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_indicator = IndicatorLöhner(semi, variable=Trixi.density) +amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=0, - med_level=3, med_threshold=0.05, - max_level=5, max_threshold=0.1) + base_level = 0, + med_level = 3, med_threshold = 0.05, + max_level = 5, max_threshold = 0.1) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -128,11 +133,11 @@ callbacks = CallbackSet(summary_callback, # positivity limiter necessary for this example with strong shocks. Very sensitive # to the order of the limiter variables, pressure must come first. -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-7, 1.0e-6), - variables=(pressure, Trixi.density)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-7, 1.0e-6), + variables = (pressure, Trixi.density)) ############################################################################### # run the simulation sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl index 7c7896ce372..8b8d05bade8 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl @@ -9,45 +9,46 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) @inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.0 - u_freestream = 0.3 - p_freestream = inv(equations.gamma) - - theta = pi / 90.0 # analogous with a two degree angle of attack - si, co = sincos(theta) - v1 = u_freestream * co - v2 = u_freestream * si - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.0 + u_freestream = 0.3 + p_freestream = inv(equations.gamma) + + theta = pi / 90.0 # analogous with a two degree angle of attack + si, co = sincos(theta) + v1 = u_freestream * co + v2 = u_freestream * si + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = uniform_flow_state boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state) -boundary_conditions = Dict( :Body => boundary_condition_uniform_flow, - :Button1 => boundary_condition_slip_wall, - :Button2 => boundary_condition_slip_wall, - :Eye1 => boundary_condition_slip_wall, - :Eye2 => boundary_condition_slip_wall, - :Smile => boundary_condition_slip_wall, - :Bowtie => boundary_condition_slip_wall ) +boundary_conditions = Dict(:Body => boundary_condition_uniform_flow, + :Button1 => boundary_condition_slip_wall, + :Button2 => boundary_condition_slip_wall, + :Eye1 => boundary_condition_slip_wall, + :Eye2 => boundary_condition_slip_wall, + :Smile => boundary_condition_slip_wall, + :Bowtie => boundary_condition_slip_wall) volume_flux = flux_ranocha -solver = DGSEM(polydeg=5, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_gingerbread_man.inp") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/0e9e990a04b5105d1d2e3096a6e41272/raw/0d924b1d7e7d3cc1070a6cc22fe1d501687aa6dd/abaqus_gingerbread_man.inp", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/0e9e990a04b5105d1d2e3096a6e41272/raw/0d924b1d7e7d3cc1070a6cc22fe1d501687aa6dd/abaqus_gingerbread_man.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -58,36 +59,35 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_indicator = IndicatorLöhner(semi, variable=density) +amr_indicator = IndicatorLöhner(semi, variable = density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=0, - med_level=1, med_threshold=0.05, - max_level=3, max_threshold=0.1) + base_level = 0, + med_level = 1, med_threshold = 0.05, + max_level = 3, max_threshold = 0.1) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback) - ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-7, reltol=1.0e-7, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl index a99f9110aa8..974466e3b3b 100644 --- a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl @@ -2,10 +2,8 @@ using OrdinaryDiffEq using Trixi - initial_condition = initial_condition_eoc_test_coupled_euler_gravity - ############################################################################### # semidiscretization of the compressible Euler equations gamma = 2.0 @@ -18,13 +16,13 @@ coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) trees_per_dimension = (1, 1) -mesh = P4estMesh(trees_per_dimension, polydeg=1, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=2) - -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, - source_terms=source_terms_eoc_test_coupled_euler_gravity) +mesh = P4estMesh(trees_per_dimension, polydeg = 1, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 2) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, + solver_euler, + source_terms = source_terms_eoc_test_coupled_euler_gravity) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -32,24 +30,23 @@ equations_gravity = HyperbolicDiffusionEquations2D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, - source_terms=source_terms_harmonic) - +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, + solver_gravity, + source_terms = source_terms_harmonic) ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 +parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 # rho0 is (ab)used to add a "+8π" term to the source terms # for the manufactured solution - gravitational_constant=1.0, # aka G - cfl=1.1, - resid_tol=1.0e-10, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!) + gravitational_constant = 1.0, # aka G + cfl = 1.1, + resid_tol = 1.0e-10, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -57,31 +54,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, - save_analysis=true) +analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, + save_analysis = true) callbacks = CallbackSet(summary_callback, stepsize_callback, save_restart, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl index 8b4aee5eec6..58b02b3b94c 100644 --- a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -2,28 +2,29 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, + surface_flux = (FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) -coordinates_min = (0.0 , 0.0 ) +coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) trees_per_dimension = (8, 8) mesh = P4estMesh(trees_per_dimension, - polydeg=3, initial_refinement_level=0, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=true) + polydeg = 3, initial_refinement_level = 0, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -36,14 +37,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) cfl = 0.9 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -54,7 +55,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl b/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl index 58915a8f6a7..380db487356 100644 --- a/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl +++ b/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl @@ -16,74 +16,74 @@ The classical MHD rotor test case. Here, the setup is taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ function initial_condition_rotor(x, t, equations::IdealGlmMhdEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 1.4 - dx = x[1] - 0.5 - dy = x[2] - 0.5 - r = sqrt(dx^2 + dy^2) - f = (0.115 - r)/0.015 - if r <= 0.1 - rho = 10.0 - v1 = -20.0*dy - v2 = 20.0*dx - elseif r >= 0.115 - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - else - rho = 1.0 + 9.0*f - v1 = -20.0*f*dy - v2 = 20.0*f*dx - end - v3 = 0.0 - p = 1.0 - B1 = 5.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) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 1.4 + dx = x[1] - 0.5 + dy = x[2] - 0.5 + r = sqrt(dx^2 + dy^2) + f = (0.115 - r) / 0.015 + if r <= 0.1 + rho = 10.0 + v1 = -20.0 * dy + v2 = 20.0 * dx + elseif r >= 0.115 + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + else + rho = 1.0 + 9.0 * f + v1 = -20.0 * f * dy + v2 = 20.0 * f * dx + end + v3 = 0.0 + p = 1.0 + B1 = 5.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_rotor surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) # Affine type mapping to take the [-1,1]^2 domain from the mesh file # and put it onto the rotor domain [0,1]^2 and then warp it with a mapping # as described in https://arxiv.org/abs/2012.12040 function mapping_twist(xi, eta) - y = 0.5 * (eta + 1.0) + 0.05 * cos(1.5 * pi * (2.0 * xi - 1.0)) * cos(0.5 * pi * (2.0 * eta - 1.0)) - x = 0.5 * (xi + 1.0) + 0.05 * cos(0.5 * pi * (2.0 * xi - 1.0)) * cos(2.0 * pi * y) - return SVector(x, y) + y = 0.5 * (eta + 1.0) + + 0.05 * cos(1.5 * pi * (2.0 * xi - 1.0)) * cos(0.5 * pi * (2.0 * eta - 1.0)) + x = 0.5 * (xi + 1.0) + 0.05 * cos(0.5 * pi * (2.0 * xi - 1.0)) * cos(2.0 * pi * y) + return SVector(x, y) end - mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) mesh = P4estMesh{2}(mesh_file, - polydeg=4, - mapping=mapping_twist, - initial_refinement_level=1) + polydeg = 4, + mapping = mapping_twist, + initial_refinement_level = 1) boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( :all => boundary_condition ) +boundary_conditions = Dict(:all => boundary_condition) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -94,31 +94,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorLöhner(semi, - variable=density_pressure) + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=1, - med_level =3, med_threshold=0.05, - max_level =5, max_threshold=0.1) + base_level = 1, + med_level = 3, med_threshold = 0.05, + max_level = 5, max_threshold = 0.1) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) cfl = 0.5 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -131,7 +131,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl index b185a8ce39d..c7922fd3b75 100644 --- a/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,17 +5,17 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test # MMS EOC test - ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the P4estMesh and setup a periodic mesh @@ -25,14 +25,13 @@ coordinates_max = (sqrt(2.0), sqrt(2.0)) # maximum coordinates (max(x), max(y)) # Create P4estMesh with 8 x 8 trees and 16 x 16 elements trees_per_dimension = (8, 8) -mesh = P4estMesh(trees_per_dimension, polydeg=3, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=1) +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 1) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -44,13 +43,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -58,6 +57,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_advection_amr.jl b/examples/p4est_3d_dgsem/elixir_advection_amr.jl index 0473fd2b23a..d56ecc233ff 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_amr.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_amr.jl @@ -11,23 +11,21 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0, -5.0) -coordinates_max = ( 5.0, 5.0, 5.0) +coordinates_max = (5.0, 5.0, 5.0) trees_per_dimension = (1, 1, 1) # Note that it is not necessary to use mesh polydeg lower than the solver polydeg # on a Cartesian mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -mesh = P4estMesh(trees_per_dimension, polydeg=1, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=4) - +mesh = P4estMesh(trees_per_dimension, polydeg = 1, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 4) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -37,26 +35,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +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=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -68,7 +66,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl b/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl index fb87c361c18..cd280cf5bf6 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl @@ -12,54 +12,55 @@ equations = LinearScalarAdvectionEquation3D(advection_velocity) # Solver with polydeg=4 to ensure free stream preservation (FSP) on non-conforming meshes. # The polydeg of the solver must be at least twice as big as the polydeg of the mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) initial_condition = initial_condition_gauss boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :all => boundary_condition -) +boundary_conditions = Dict(:all => boundary_condition) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. The original mapping applied to this unstructured mesh # causes some Jacobians to be negative, which makes the mesh invalid. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + 1/4 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 1/4 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 1/4 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - # Transform the weird deformed cube to be approximately the size of [-5,5]^3 to match IC - return SVector(5 * x, 5 * y, 5 * z) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 1 / 4 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 1 / 4 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 1 / 4 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + # Transform the weird deformed cube to be approximately the size of [-5,5]^3 to match IC + return SVector(5 * x, 5 * y, 5 * z) end # Unstructured mesh with 48 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", + mesh_file) # Mesh polydeg of 2 (half the solver polydeg) to ensure FSP (see above). -mesh = P4estMesh{3}(mesh_file, polydeg=2, - mapping=mapping, - initial_refinement_level=1) - - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) +mesh = P4estMesh{3}(mesh_file, polydeg = 2, + mapping = mapping, + initial_refinement_level = 1) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -70,29 +71,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +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=1, - med_level=2, med_threshold=0.1, - max_level=3, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 1, + med_level = 2, med_threshold = 0.1, + max_level = 3, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -105,7 +106,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_advection_basic.jl b/examples/p4est_3d_dgsem/elixir_advection_basic.jl index a165d1ff132..02ffa5c7aff 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_basic.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_basic.jl @@ -11,19 +11,20 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create P4estMesh with 8 x 8 x 8 elements (note `refinement_level=1`) trees_per_dimension = (4, 4, 4) -mesh = P4estMesh(trees_per_dimension, polydeg=3, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=1) +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 1) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -37,30 +38,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +analysis_callback = AnalysisCallback(semi, interval = 100) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - solution_variables=cons2prim) +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.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution, stepsize_callback) - +callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl b/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl index 07a8b36bb4c..cd641ca4af7 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl @@ -9,21 +9,20 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :inside => boundary_condition, - :outside => boundary_condition, -) +boundary_conditions = Dict(:inside => boundary_condition, + :outside => boundary_condition) mesh = Trixi.P4estMeshCubedSphere(5, 3, 0.5, 0.5, - polydeg=3, initial_refinement_level=0) + polydeg = 3, initial_refinement_level = 0) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -37,26 +36,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) # 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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl index 93ff17c7842..34b0e95834d 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the linear advection equation @@ -10,39 +9,42 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) trees_per_dimension = (1, 1, 1) # Note that it is not necessary to use mesh polydeg lower than the solver polydeg # on a Cartesian mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -mesh = P4estMesh(trees_per_dimension, polydeg=3, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - initial_refinement_level=2) +mesh = P4estMesh(trees_per_dimension, polydeg = 3, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + initial_refinement_level = 2) # Refine bottom left quadrant of each tree to level 3 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 3 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && + quadrant_obj.level < 3 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 3 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -56,26 +58,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_advection_restart.jl b/examples/p4est_3d_dgsem/elixir_advection_restart.jl index 71b37e9f39b..95aa1dd983f 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_restart.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_restart.jl @@ -6,8 +6,7 @@ using Trixi # create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), - trees_per_dimension=(2, 2, 2)) - + trees_per_dimension = (2, 2, 2)) ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -18,16 +17,16 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), restart_filename = joinpath("out", "restart_000010.h5") mesh = load_mesh(restart_filename) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl b/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl index 85fd0b9a2cf..6df9ac0b16a 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl @@ -10,51 +10,54 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :all => boundary_condition -) +boundary_conditions = Dict(:all => boundary_condition) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. The original mapping applied to this unstructured mesh # causes some Jacobians to be negative, which makes the mesh invalid. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end # Unstructured mesh with 68 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_1.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", + mesh_file) -mesh = P4estMesh{3}(mesh_file, polydeg=3, - mapping=mapping, - initial_refinement_level=2) +mesh = P4estMesh{3}(mesh_file, polydeg = 3, + mapping = mapping, + initial_refinement_level = 2) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -68,32 +71,32 @@ 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) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - solution_variables=cons2prim) +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.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, stepsize_callback) - +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, + 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl b/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl index 27c8ceb130c..0274a89aec7 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl @@ -22,190 +22,194 @@ equations = CompressibleEulerEquations3D(gamma) # Initial condition for an idealized baroclinic instability test # https://doi.org/10.1002/qj.2241, Section 3.2 and Appendix A -function initial_condition_baroclinic_instability(x, t, equations::CompressibleEulerEquations3D) - lon, lat, r = cartesian_to_sphere(x) - radius_earth = 6.371229e6 - # Make sure that the r is not smaller than radius_earth - z = max(r - radius_earth, 0.0) +function initial_condition_baroclinic_instability(x, t, + equations::CompressibleEulerEquations3D) + lon, lat, r = cartesian_to_sphere(x) + radius_earth = 6.371229e6 + # Make sure that the r is not smaller than radius_earth + z = max(r - radius_earth, 0.0) - # Unperturbed basic state - rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) + # Unperturbed basic state + rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) - # Stream function type perturbation - u_perturbation, v_perturbation = perturbation_stream_function(lon, lat, z) + # Stream function type perturbation + u_perturbation, v_perturbation = perturbation_stream_function(lon, lat, z) - u += u_perturbation - v = v_perturbation + u += u_perturbation + v = v_perturbation - # Convert spherical velocity to Cartesian - v1 = -sin(lon) * u - sin(lat) * cos(lon) * v - v2 = cos(lon) * u - sin(lat) * sin(lon) * v - v3 = cos(lat) * v + # Convert spherical velocity to Cartesian + v1 = -sin(lon) * u - sin(lat) * cos(lon) * v + v2 = cos(lon) * u - sin(lat) * sin(lon) * v + v3 = cos(lat) * v - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end # Steady state for RHS correction below function steady_state_baroclinic_instability(x, t, equations::CompressibleEulerEquations3D) - lon, lat, r = cartesian_to_sphere(x) - radius_earth = 6.371229e6 - # Make sure that the r is not smaller than radius_earth - z = max(r - radius_earth, 0.0) + lon, lat, r = cartesian_to_sphere(x) + radius_earth = 6.371229e6 + # Make sure that the r is not smaller than radius_earth + z = max(r - radius_earth, 0.0) - # Unperturbed basic state - rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) + # Unperturbed basic state + rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) - # Convert spherical velocity to Cartesian - v1 = -sin(lon) * u - v2 = cos(lon) * u - v3 = 0.0 + # Convert spherical velocity to Cartesian + v1 = -sin(lon) * u + v2 = cos(lon) * u + v3 = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end function cartesian_to_sphere(x) - r = norm(x) - lambda = atan(x[2], x[1]) - if lambda < 0 - lambda += 2 * pi - end - phi = asin(x[3] / r) - - return lambda, phi, r + r = norm(x) + lambda = atan(x[2], x[1]) + if lambda < 0 + lambda += 2 * pi + end + phi = asin(x[3] / r) + + return lambda, phi, r end # Unperturbed balanced steady-state. # Returns primitive variables with only the velocity in longitudinal direction (rho, u, p). # The other velocity components are zero. function basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) - # Parameters from Table 1 in the paper - # Corresponding names in the paper are commented - radius_earth = 6.371229e6 # a - half_width_parameter = 2 # b - gravitational_acceleration = 9.80616 # g - k = 3 # k - surface_pressure = 1e5 # p₀ - gas_constant = 287 # R - surface_equatorial_temperature = 310.0 # T₀ᴱ - surface_polar_temperature = 240.0 # T₀ᴾ - lapse_rate = 0.005 # Γ - angular_velocity = 7.29212e-5 # Ω - - # Distance to the center of the Earth - r = z + radius_earth - - # In the paper: T₀ - temperature0 = 0.5 * (surface_equatorial_temperature + surface_polar_temperature) - # In the paper: A, B, C, H - const_a = 1 / lapse_rate - const_b = (temperature0 - surface_polar_temperature) / - (temperature0 * surface_polar_temperature) - const_c = 0.5 * (k + 2) * (surface_equatorial_temperature - surface_polar_temperature) / - (surface_equatorial_temperature * surface_polar_temperature) - const_h = gas_constant * temperature0 / gravitational_acceleration - - # In the paper: (r - a) / bH - scaled_z = z / (half_width_parameter * const_h) - - # Temporary variables - temp1 = exp(lapse_rate/temperature0 * z) - temp2 = exp(-scaled_z^2) - - # In the paper: ̃τ₁, ̃τ₂ - tau1 = const_a * lapse_rate / temperature0 * temp1 + const_b * (1 - 2 * scaled_z^2) * temp2 - tau2 = const_c * (1 - 2 * scaled_z^2) * temp2 - - # In the paper: ∫τ₁(r') dr', ∫τ₂(r') dr' - inttau1 = const_a * (temp1 - 1) + const_b * z * temp2 - inttau2 = const_c * z * temp2 - - # Temporary variables - temp3 = r/radius_earth * cos(lat) - temp4 = temp3^k - k/(k + 2) * temp3^(k+2) - - # In the paper: T - temperature = 1 / ((r/radius_earth)^2 * (tau1 - tau2 * temp4)) - - # In the paper: U, u (zonal wind, first component of spherical velocity) - big_u = gravitational_acceleration/radius_earth * k * temperature * inttau2 * (temp3^(k-1) - temp3^(k+1)) - temp5 = radius_earth * cos(lat) - u = -angular_velocity * temp5 + sqrt(angular_velocity^2 * temp5^2 + temp5 * big_u) - - # Hydrostatic pressure - p = surface_pressure * exp(-gravitational_acceleration/gas_constant * (inttau1 - inttau2 * temp4)) - - # Density (via ideal gas law) - rho = p / (gas_constant * temperature) - - return rho, u, p + # Parameters from Table 1 in the paper + # Corresponding names in the paper are commented + radius_earth = 6.371229e6 # a + half_width_parameter = 2 # b + gravitational_acceleration = 9.80616 # g + k = 3 # k + surface_pressure = 1e5 # p₀ + gas_constant = 287 # R + surface_equatorial_temperature = 310.0 # T₀ᴱ + surface_polar_temperature = 240.0 # T₀ᴾ + lapse_rate = 0.005 # Γ + angular_velocity = 7.29212e-5 # Ω + + # Distance to the center of the Earth + r = z + radius_earth + + # In the paper: T₀ + temperature0 = 0.5 * (surface_equatorial_temperature + surface_polar_temperature) + # In the paper: A, B, C, H + const_a = 1 / lapse_rate + const_b = (temperature0 - surface_polar_temperature) / + (temperature0 * surface_polar_temperature) + const_c = 0.5 * (k + 2) * (surface_equatorial_temperature - surface_polar_temperature) / + (surface_equatorial_temperature * surface_polar_temperature) + const_h = gas_constant * temperature0 / gravitational_acceleration + + # In the paper: (r - a) / bH + scaled_z = z / (half_width_parameter * const_h) + + # Temporary variables + temp1 = exp(lapse_rate / temperature0 * z) + temp2 = exp(-scaled_z^2) + + # In the paper: ̃τ₁, ̃τ₂ + tau1 = const_a * lapse_rate / temperature0 * temp1 + + const_b * (1 - 2 * scaled_z^2) * temp2 + tau2 = const_c * (1 - 2 * scaled_z^2) * temp2 + + # In the paper: ∫τ₁(r') dr', ∫τ₂(r') dr' + inttau1 = const_a * (temp1 - 1) + const_b * z * temp2 + inttau2 = const_c * z * temp2 + + # Temporary variables + temp3 = r / radius_earth * cos(lat) + temp4 = temp3^k - k / (k + 2) * temp3^(k + 2) + + # In the paper: T + temperature = 1 / ((r / radius_earth)^2 * (tau1 - tau2 * temp4)) + + # In the paper: U, u (zonal wind, first component of spherical velocity) + big_u = gravitational_acceleration / radius_earth * k * temperature * inttau2 * + (temp3^(k - 1) - temp3^(k + 1)) + temp5 = radius_earth * cos(lat) + u = -angular_velocity * temp5 + sqrt(angular_velocity^2 * temp5^2 + temp5 * big_u) + + # Hydrostatic pressure + p = surface_pressure * + exp(-gravitational_acceleration / gas_constant * (inttau1 - inttau2 * temp4)) + + # Density (via ideal gas law) + rho = p / (gas_constant * temperature) + + return rho, u, p end # Perturbation as in Equations 25 and 26 of the paper (analytical derivative) function perturbation_stream_function(lon, lat, z) - # Parameters from Table 1 in the paper - # Corresponding names in the paper are commented - perturbation_radius = 1/6 # d₀ / a - perturbed_wind_amplitude = 1.0 # Vₚ - perturbation_lon = pi/9 # Longitude of perturbation location - perturbation_lat = 2 * pi/9 # Latitude of perturbation location - pertz = 15000 # Perturbation height cap - - # Great circle distance (d in the paper) divided by a (radius of the Earth) - # because we never actually need d without dividing by a - great_circle_distance_by_a = acos(sin(perturbation_lat) * sin(lat) + - cos(perturbation_lat) * cos(lat) * - cos(lon - perturbation_lon)) - - # In the first case, the vertical taper function is per definition zero. - # In the second case, the stream function is per definition zero. - if z > pertz || great_circle_distance_by_a > perturbation_radius - return 0.0, 0.0 - end - - # Vertical tapering of stream function - perttaper = 1.0 - 3 * z^2 / pertz^2 + 2 * z^3 / pertz^3 - - # sin/cos(pi * d / (2 * d_0)) in the paper - sin_, cos_ = sincos(0.5 * pi * great_circle_distance_by_a / perturbation_radius) - - # Common factor for both u and v - factor = 16 / (3 * sqrt(3)) * perturbed_wind_amplitude * perttaper * cos_^3 * sin_ - - u_perturbation = -factor * (-sin(perturbation_lat) * cos(lat) + - cos(perturbation_lat) * sin(lat) * cos(lon - perturbation_lon) - ) / sin(great_circle_distance_by_a) - - v_perturbation = factor * cos(perturbation_lat) * sin(lon - perturbation_lon) / - sin(great_circle_distance_by_a) - - return u_perturbation, v_perturbation -end + # Parameters from Table 1 in the paper + # Corresponding names in the paper are commented + perturbation_radius = 1 / 6 # d₀ / a + perturbed_wind_amplitude = 1.0 # Vₚ + perturbation_lon = pi / 9 # Longitude of perturbation location + perturbation_lat = 2 * pi / 9 # Latitude of perturbation location + pertz = 15000 # Perturbation height cap + + # Great circle distance (d in the paper) divided by a (radius of the Earth) + # because we never actually need d without dividing by a + great_circle_distance_by_a = acos(sin(perturbation_lat) * sin(lat) + + cos(perturbation_lat) * cos(lat) * + cos(lon - perturbation_lon)) + + # In the first case, the vertical taper function is per definition zero. + # In the second case, the stream function is per definition zero. + if z > pertz || great_circle_distance_by_a > perturbation_radius + return 0.0, 0.0 + end + + # Vertical tapering of stream function + perttaper = 1.0 - 3 * z^2 / pertz^2 + 2 * z^3 / pertz^3 + + # sin/cos(pi * d / (2 * d_0)) in the paper + sin_, cos_ = sincos(0.5 * pi * great_circle_distance_by_a / perturbation_radius) + # Common factor for both u and v + factor = 16 / (3 * sqrt(3)) * perturbed_wind_amplitude * perttaper * cos_^3 * sin_ -@inline function source_terms_baroclinic_instability(u, x, t, equations::CompressibleEulerEquations3D) - radius_earth = 6.371229e6 # a - gravitational_acceleration = 9.80616 # g - angular_velocity = 7.29212e-5 # Ω + u_perturbation = -factor * (-sin(perturbation_lat) * cos(lat) + + cos(perturbation_lat) * sin(lat) * cos(lon - perturbation_lon)) / + sin(great_circle_distance_by_a) - r = norm(x) - # Make sure that r is not smaller than radius_earth - z = max(r - radius_earth, 0.0) - r = z + radius_earth + v_perturbation = factor * cos(perturbation_lat) * sin(lon - perturbation_lon) / + sin(great_circle_distance_by_a) - du1 = zero(eltype(u)) + return u_perturbation, v_perturbation +end + +@inline function source_terms_baroclinic_instability(u, x, t, + equations::CompressibleEulerEquations3D) + radius_earth = 6.371229e6 # a + gravitational_acceleration = 9.80616 # g + angular_velocity = 7.29212e-5 # Ω + + r = norm(x) + # Make sure that r is not smaller than radius_earth + z = max(r - radius_earth, 0.0) + r = z + radius_earth - # Gravity term - temp = -gravitational_acceleration * radius_earth^2 / r^3 - du2 = temp * u[1] * x[1] - du3 = temp * u[1] * x[2] - du4 = temp * u[1] * x[3] - du5 = temp * (u[2] * x[1] + u[3] * x[2] + u[4] * x[3]) + du1 = zero(eltype(u)) - # Coriolis term, -2Ω × ρv = -2 * angular_velocity * (0, 0, 1) × u[2:4] - du2 -= -2 * angular_velocity * u[3] - du3 -= 2 * angular_velocity * u[2] + # Gravity term + temp = -gravitational_acceleration * radius_earth^2 / r^3 + du2 = temp * u[1] * x[1] + du3 = temp * u[1] * x[2] + du4 = temp * u[1] * x[3] + du5 = temp * (u[2] * x[1] + u[3] * x[2] + u[4] * x[3]) - return SVector(du1, du2, du3, du4, du5) + # Coriolis term, -2Ω × ρv = -2 * angular_velocity * (0, 0, 1) × u[2:4] + du2 -= -2 * angular_velocity * u[3] + du3 -= 2 * angular_velocity * u[2] + + return SVector(du1, du2, du3, du4, du5) end ############################################################################### @@ -213,26 +217,24 @@ end initial_condition = initial_condition_baroclinic_instability -boundary_conditions = Dict( - :inside => boundary_condition_slip_wall, - :outside => boundary_condition_slip_wall, -) +boundary_conditions = Dict(:inside => boundary_condition_slip_wall, + :outside => boundary_condition_slip_wall) # This is a good estimate for the speed of sound in this example. # Other values between 300 and 400 should work as well. surface_flux = FluxLMARS(340) -volume_flux = flux_kennedy_gruber -solver = DGSEM(polydeg=5, surface_flux=surface_flux, volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +volume_flux = flux_kennedy_gruber +solver = DGSEM(polydeg = 5, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # For optimal results, use (16, 8) here trees_per_cube_face = (8, 4) mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0, - polydeg=5, initial_refinement_level=0) + polydeg = 5, initial_refinement_level = 0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_baroclinic_instability, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_baroclinic_instability, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -250,20 +252,20 @@ tspan = (0.0, 10 * 24 * 60 * 60.0) # time in seconds for 10 days u_steady_state = compute_coefficients(steady_state_baroclinic_instability, tspan[1], semi) # Use a `let` block for performance (otherwise du_steady_state will be a global variable) let du_steady_state = similar(u_steady_state) - # Save RHS of the steady state - Trixi.rhs!(du_steady_state, u_steady_state, semi, tspan[1]) - - global function corrected_rhs!(du, u, semi, t) - # Normal RHS evaluation - Trixi.rhs!(du, u, semi, t) - # Correct by subtracting the steady-state RHS - Trixi.@trixi_timeit Trixi.timer() "rhs correction" begin - # Use Trixi.@threaded for threaded performance - Trixi.@threaded for i in eachindex(du) - du[i] -= du_steady_state[i] - end + # Save RHS of the steady state + Trixi.rhs!(du_steady_state, u_steady_state, semi, tspan[1]) + + global function corrected_rhs!(du, u, semi, t) + # Normal RHS evaluation + Trixi.rhs!(du, u, semi, t) + # Correct by subtracting the steady-state RHS + Trixi.@trixi_timeit Trixi.timer() "rhs correction" begin + # Use Trixi.@threaded for threaded performance + Trixi.@threaded for i in eachindex(du) + du[i] -= du_steady_state[i] + end + end end - end end u0 = compute_coefficients(tspan[1], semi) ode = ODEProblem(corrected_rhs!, u0, tspan, semi) @@ -271,27 +273,27 @@ ode = ODEProblem(corrected_rhs!, u0, tspan, semi) summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=5000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 5000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) - ############################################################################### # run the simulation # Use a Runge-Kutta method with automatic (error based) time step size control # Enable threading of the RK method for better performance on multiple threads -sol = solve(ode, RDPK3SpFSAL49(thread=OrdinaryDiffEq.True()); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()); abstol = 1.0e-6, + reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl index 63e937620f0..34a43a5b534 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl @@ -14,78 +14,77 @@ using LinearAlgebra gamma = 1.4 equations = CompressibleEulerEquations3D(gamma) - function initial_condition_circular_wind(x, t, equations::CompressibleEulerEquations3D) - radius_earth = 6.371229e6 - p = 1e5 - rho = 1.0 - v1 = -10 * x[2] / radius_earth - v2 = 10 * x[1] / radius_earth - v3 = 0.0 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + radius_earth = 6.371229e6 + p = 1e5 + rho = 1.0 + v1 = -10 * x[2] / radius_earth + v2 = 10 * x[1] / radius_earth + v3 = 0.0 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end -@inline function source_terms_circular_wind(u, x, t, equations::CompressibleEulerEquations3D) - radius_earth = 6.371229e6 - rho = 1.0 +@inline function source_terms_circular_wind(u, x, t, + equations::CompressibleEulerEquations3D) + radius_earth = 6.371229e6 + rho = 1.0 - du1 = 0.0 - du2 = -rho * (10 / radius_earth) * (10 * x[1] / radius_earth) - du3 = -rho * (10 / radius_earth) * (10 * x[2] / radius_earth) - du4 = 0.0 - du5 = 0.0 + du1 = 0.0 + du2 = -rho * (10 / radius_earth) * (10 * x[1] / radius_earth) + du3 = -rho * (10 / radius_earth) * (10 * x[2] / radius_earth) + du4 = 0.0 + du5 = 0.0 - return SVector(du1, du2, du3, du4, du5) + return SVector(du1, du2, du3, du4, du5) end - -function indicator_test(u::AbstractArray{<:Any,5}, +function indicator_test(u::AbstractArray{<:Any, 5}, mesh, equations, dg::DGSEM, cache; kwargs...) - alpha = zeros(Int, nelements(dg, cache)) - - for element in eachelement(dg, cache) - for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) - x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, k, element) - lambda, phi, r = cart_to_sphere(x) - if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 - alpha[element] = 1 - end + alpha = zeros(Int, nelements(dg, cache)) + + for element in eachelement(dg, cache) + for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) + x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, + k, element) + lambda, phi, r = cart_to_sphere(x) + if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 + alpha[element] = 1 + end + end end - end - return alpha + return alpha end function cart_to_sphere(x) - r = norm(x) - lambda = atan(x[2], x[1]) - if lambda < 0 - lambda += 2 * pi - end - phi = asin(x[3] / r) - - return lambda, phi, r + r = norm(x) + lambda = atan(x[2], x[1]) + if lambda < 0 + lambda += 2 * pi + end + phi = asin(x[3] / r) + + return lambda, phi, r end -function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), ::AMRCallback) - return nothing +function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), + ::AMRCallback) + return nothing end initial_condition = initial_condition_circular_wind -boundary_conditions = Dict( - :inside => boundary_condition_slip_wall, - :outside => boundary_condition_slip_wall -) +boundary_conditions = Dict(:inside => boundary_condition_slip_wall, + :outside => boundary_condition_slip_wall) # The speed of sound in this example is 374 m/s. surface_flux = FluxLMARS(374) # Note that a free stream is not preserved if N < 2 * N_geo, where N is the # polydeg of the solver and N_geo is the polydeg of the mesh. # However, the FSP error is negligible in this example. -solver = DGSEM(polydeg=4, surface_flux=surface_flux) +solver = DGSEM(polydeg = 4, surface_flux = surface_flux) # Other mesh configurations to run this simulation on. # The cylinder allows to use a structured mesh, the face of the cubed sphere @@ -113,12 +112,11 @@ solver = DGSEM(polydeg=4, surface_flux=surface_flux) trees_per_cube_face = (6, 2) mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0, - polydeg=4, initial_refinement_level=0) + polydeg = 4, initial_refinement_level = 0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_circular_wind, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_circular_wind, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -129,22 +127,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=5000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 5000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_controller = ControllerThreeLevel(semi, indicator_test, - base_level=0, - max_level=1, max_threshold=0.6) + base_level = 0, + max_level = 1, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=0, # Only initial refinement - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 0, # Only initial refinement + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -152,13 +150,13 @@ callbacks = CallbackSet(summary_callback, save_solution, amr_callback) - ############################################################################### # run the simulation # Use a Runge-Kutta method with automatic (error based) time step size control # Enable threading of the RK method for better performance on multiple threads -sol = solve(ode, RDPK3SpFSAL49(thread=OrdinaryDiffEq.True()); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()); abstol = 1.0e-6, + reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_euler_ec.jl b/examples/p4est_3d_dgsem/elixir_euler_ec.jl index 463a26fca53..d9d774a7ffc 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_ec.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_ec.jl @@ -6,56 +6,59 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerEquations3D(5/3) +equations = CompressibleEulerEquations3D(5 / 3) initial_condition = initial_condition_weak_blast_wave -boundary_conditions = Dict( - :all => boundary_condition_slip_wall -) +boundary_conditions = Dict(:all => boundary_condition_slip_wall) # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg=5, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 5, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Get the curved quad mesh from a file # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end # Unstructured mesh with 48 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{3}(mesh_file, polydeg=5, - mapping=mapping, - initial_refinement_level=0) +mesh = P4estMesh{3}(mesh_file, polydeg = 5, + mapping = mapping, + initial_refinement_level = 0) # create the semidiscretization object -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -66,15 +69,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -85,7 +88,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl b/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl index 3450adfe861..24a781ca59e 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl @@ -10,70 +10,75 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_constant -boundary_conditions = Dict( - :all => BoundaryConditionDirichlet(initial_condition) -) +boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition)) # Solver with polydeg=4 to ensure free stream preservation (FSP) on non-conforming meshes. # The polydeg of the solver must be at least twice as big as the polydeg of the mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. This can yield problematic geometries if the unrefined mesh # is not fine enough. function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end # Unstructured mesh with 68 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_1.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", + mesh_file) # Mesh polydeg of 2 (half the solver polydeg) to ensure FSP (see above). -mesh = P4estMesh{3}(mesh_file, polydeg=2, - mapping=mapping, - initial_refinement_level=0) +mesh = P4estMesh{3}(mesh_file, polydeg = 2, + mapping = mapping, + initial_refinement_level = 0) # Refine bottom left quadrant of each second tree to level 2 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if iseven(convert(Int, which_tree)) && quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if iseven(convert(Int, which_tree)) && quadrant_obj.x == 0 && quadrant_obj.y == 0 && + quadrant_obj.z == 0 && quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of every second tree has level 2. # The mesh will be rebalanced before the simulation starts. -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -84,27 +89,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl b/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl index 630a269b4a1..f56fe3a429d 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl @@ -10,12 +10,10 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_constant -boundary_conditions = Dict( - :all => BoundaryConditionDirichlet(initial_condition) -) +boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition)) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but reduced to 2D. # This particular mesh is unstructured in the yz-plane, but extruded in x-direction. @@ -23,47 +21,52 @@ solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, # in x-direction to ensure free stream preservation on a non-conforming mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. function mapping(xi, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 - z = zeta + 1/6 * (cos(1.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) + z = zeta + + 1 / 6 * (cos(1.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) - y = eta + 1/6 * (cos(0.5 * pi * (2 * eta - 3)/3) * - cos(2 * pi * (2 * z - 3)/3)) + y = eta + 1 / 6 * (cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(2 * pi * (2 * z - 3) / 3)) - return SVector(xi, y, z) + return SVector(xi, y, z) end # Unstructured mesh with 48 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_2.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{3}(mesh_file, polydeg=3, - mapping=mapping, - initial_refinement_level=0) +mesh = P4estMesh{3}(mesh_file, polydeg = 3, + mapping = mapping, + initial_refinement_level = 0) # Refine quadrants in y-direction of each tree at one edge to level 2 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if convert(Int, which_tree) < 4 && quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if convert(Int, which_tree) < 4 && quadrant_obj.x == 0 && quadrant_obj.y == 0 && + quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each desired quadrant has level 2. # The mesh will be rebalanced before the simulation starts. -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -74,30 +77,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, stepsize_callback) - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), #maxiters=1, - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), #maxiters=1, + 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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_sedov.jl b/examples/p4est_3d_dgsem/elixir_euler_sedov.jl index 00da4132851..fe0ee77818e 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_sedov.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_sedov.jl @@ -14,28 +14,29 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 with smaller strength of the initial discontinuity. """ -function initial_condition_medium_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D) - # Set up polar coordinates - inicenter = SVector(0.0, 0.0, 0.0) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - z_norm = x[3] - inicenter[3] - r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) - p0_outer = 1.0e-3 - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_medium_sedov_blast_wave(x, t, + equations::CompressibleEulerEquations3D) + # Set up polar coordinates + inicenter = SVector(0.0, 0.0, 0.0) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + z_norm = x[3] - inicenter[3] + r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) + p0_outer = 1.0e-3 + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_medium_sedov_blast_wave @@ -45,24 +46,25 @@ volume_flux = flux_ranocha polydeg = 5 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 1.0, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = ( 1.0, 1.0, 1.0) +coordinates_max = (1.0, 1.0, 1.0) trees_per_dimension = (4, 4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg=4, initial_refinement_level=0, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=true) + polydeg = 4, initial_refinement_level = 0, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -76,15 +78,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -95,7 +97,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl index fc5c7da5234..28cdec12da5 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl @@ -11,68 +11,68 @@ using LinearAlgebra gamma = 1.4 equations = CompressibleEulerEquations3D(gamma) +function initial_condition_convergence_test_sphere(x, t, + equations::CompressibleEulerEquations3D) + x_scaled = x / 6.371229e6 + t_scaled = t / 6.371229e6 -function initial_condition_convergence_test_sphere(x, t, equations::CompressibleEulerEquations3D) - x_scaled = x / 6.371229e6 - t_scaled = t / 6.371229e6 - - return initial_condition_convergence_test(x_scaled, t_scaled, equations) + return initial_condition_convergence_test(x_scaled, t_scaled, equations) end -@inline function source_terms_convergence_test_sphere(u, x, t, equations::CompressibleEulerEquations3D) - x_scaled = x / 6.371229e6 - t_scaled = t / 6.371229e6 +@inline function source_terms_convergence_test_sphere(u, x, t, + equations::CompressibleEulerEquations3D) + x_scaled = x / 6.371229e6 + t_scaled = t / 6.371229e6 - return source_terms_convergence_test(u, x_scaled, t_scaled, equations) / 6.371229e6 + return source_terms_convergence_test(u, x_scaled, t_scaled, equations) / 6.371229e6 end - -function indicator_test(u::AbstractArray{<:Any,5}, +function indicator_test(u::AbstractArray{<:Any, 5}, mesh, equations, dg::DGSEM, cache; kwargs...) - alpha = zeros(Int, nelements(dg, cache)) - - for element in eachelement(dg, cache) - for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) - x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, k, element) - lambda, phi, r = cart_to_sphere(x) - if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 - alpha[element] = 1 - end + alpha = zeros(Int, nelements(dg, cache)) + + for element in eachelement(dg, cache) + for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) + x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, + k, element) + lambda, phi, r = cart_to_sphere(x) + if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 + alpha[element] = 1 + end + end end - end - return alpha + return alpha end function cart_to_sphere(x) - r = norm(x) - lambda = atan(x[2], x[1]) - if lambda < 0 - lambda += 2 * pi - end - phi = asin(x[3] / r) - - return lambda, phi, r + r = norm(x) + lambda = atan(x[2], x[1]) + if lambda < 0 + lambda += 2 * pi + end + phi = asin(x[3] / r) + + return lambda, phi, r end -function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), ::AMRCallback) - return nothing +function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), + ::AMRCallback) + return nothing end initial_condition = initial_condition_convergence_test_sphere boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :inside => boundary_condition, - :outside => boundary_condition -) +boundary_conditions = Dict(:inside => boundary_condition, + :outside => boundary_condition) surface_flux = FluxHLL(min_max_speed_naive) # Note that a free stream is not preserved if N < 2 * N_geo, where N is the # polydeg of the solver and N_geo is the polydeg of the mesh. # However, the FSP error is negligible in this example. -solver = DGSEM(polydeg=4, surface_flux=surface_flux) +solver = DGSEM(polydeg = 4, surface_flux = surface_flux) # For performance reasons, only one face of the cubed sphere can be used: @@ -87,12 +87,11 @@ solver = DGSEM(polydeg=4, surface_flux=surface_flux) trees_per_cube_face = (6, 2) mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0, - polydeg=4, initial_refinement_level=0) + polydeg = 4, initial_refinement_level = 0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test_sphere, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test_sphere, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -103,22 +102,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_controller = ControllerThreeLevel(semi, indicator_test, - base_level=0, - max_level=1, max_threshold=0.6) + base_level = 0, + max_level = 1, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=0, # Only initial refinement - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 0, # Only initial refinement + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -126,12 +125,11 @@ callbacks = CallbackSet(summary_callback, save_solution, amr_callback) - ############################################################################### # run the simulation # Use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl index dd394091758..0de22eaea40 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl @@ -11,73 +11,77 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :all => boundary_condition -) +boundary_conditions = Dict(:all => boundary_condition) # Solver with polydeg=4 to ensure free stream preservation (FSP) on non-conforming meshes. # The polydeg of the solver must be at least twice as big as the polydeg of the mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. The original mapping applied to this unstructured mesh # causes some Jacobians to be negative, which makes the mesh invalid. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - # Transform the weird deformed cube to be approximately the cube [0,2]^3 - return SVector(x + 1, y + 1, z + 1) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + # Transform the weird deformed cube to be approximately the cube [0,2]^3 + return SVector(x + 1, y + 1, z + 1) end # Unstructured mesh with 68 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_1.inp") -isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || + download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", + mesh_file) # Mesh polydeg of 2 (half the solver polydeg) to ensure FSP (see above). -mesh = P4estMesh{3}(mesh_file, polydeg=2, - mapping=mapping, - initial_refinement_level=0) +mesh = P4estMesh{3}(mesh_file, polydeg = 2, + mapping = mapping, + initial_refinement_level = 0) # Refine bottom left quadrant of each tree to level 2 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && + quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 2 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -88,27 +92,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl index cd796c33e47..fc5e4da3ceb 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -10,31 +10,28 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( - :x_neg => boundary_condition, - :x_pos => boundary_condition, - :y_neg => boundary_condition, - :y_pos => boundary_condition, - :z_neg => boundary_condition, - :z_pos => boundary_condition -) - -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +boundary_conditions = Dict(:x_neg => boundary_condition, + :x_pos => boundary_condition, + :y_neg => boundary_condition, + :y_pos => boundary_condition, + :z_neg => boundary_condition, + :z_pos => boundary_condition) + +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) trees_per_dimension = (2, 2, 2) -mesh = P4estMesh(trees_per_dimension, polydeg=1, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=false, initial_refinement_level=1) +mesh = P4estMesh(trees_per_dimension, polydeg = 1, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = false, initial_refinement_level = 1) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -45,27 +42,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl index ff101bea8aa..0fa3a28fe8b 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl @@ -11,25 +11,25 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( :Bottom => boundary_condition, - :Top => boundary_condition, - :Circle => boundary_condition, - :Cut => boundary_condition ) +boundary_conditions = Dict(:Bottom => boundary_condition, + :Top => boundary_condition, + :Circle => boundary_condition, + :Cut => boundary_condition) -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) # Unstructured 3D half circle mesh from HOHQMesh default_mesh_file = joinpath(@__DIR__, "abaqus_half_circle_3d.inp") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/11461efbfb02c42e06aca338b3d0b645/raw/81deeb1ebc4945952c30af5bb75fe222a18d975c/abaqus_half_circle_3d.inp", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/11461efbfb02c42e06aca338b3d0b645/raw/81deeb1ebc4945952c30af5bb75fe222a18d975c/abaqus_half_circle_3d.inp", + default_mesh_file) mesh_file = default_mesh_file -mesh = P4estMesh{3}(mesh_file, initial_refinement_level=0) +mesh = P4estMesh{3}(mesh_file, initial_refinement_level = 0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -40,17 +40,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=50, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 50, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -58,12 +58,11 @@ callbacks = CallbackSet(summary_callback, save_solution, stepsize_callback); - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=1, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 1, # 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 diff --git a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl index 988e9e09ea3..9cacfc2e8ac 100644 --- a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl @@ -5,40 +5,45 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5/3) +equations = IdealGlmMhdEquations3D(5 / 3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = ( 1.0, 1.0, 1.0) +coordinates_max = (1.0, 1.0, 1.0) # Create P4estMesh with 2 x 2 x 2 trees trees_per_dimension = (2, 2, 2) mesh = P4estMesh(trees_per_dimension, - polydeg=3, initial_refinement_level=2, - coordinates_min=coordinates_min, coordinates_max=coordinates_max, - periodicity=true) + polydeg = 3, initial_refinement_level = 2, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = true) # OBS! Workaround to add a refinement patch after mesh is constructed # Refine bottom left quadrant of each tree to level 4 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 4 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && + quadrant_obj.level < 4 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 4 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, + (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -52,18 +57,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -71,11 +76,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl b/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl index fc95d427abb..3941a40b2e4 100644 --- a/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl +++ b/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl @@ -17,71 +17,74 @@ Weak magnetic blast wave setup taken from Section 6.1 of the paper: [doi: 10.1016/j.jcp.2021.110580](https://doi.org/10.1016/j.jcp.2021.110580) """ function initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations3D) - # Center of the blast wave is selected for the domain [0, 3]^3 - inicenter = (1.5, 1.5, 1.5) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - z_norm = x[3] - inicenter[3] - r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) - - delta_0 = 0.1 - r_0 = 0.3 - lambda = exp(5.0 / delta_0 * (r - r_0)) - - prim_inner = SVector(1.2, 0.1, 0.0, 0.1, 0.9, 1.0, 1.0, 1.0, 0.0) - prim_outer = SVector(1.2, 0.2, -0.4, 0.2, 0.3, 1.0, 1.0, 1.0, 0.0) - prim_vars = (prim_inner + lambda * prim_outer) / (1.0 + lambda) - - return prim2cons(prim_vars, equations) + # Center of the blast wave is selected for the domain [0, 3]^3 + inicenter = (1.5, 1.5, 1.5) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + z_norm = x[3] - inicenter[3] + r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) + + delta_0 = 0.1 + r_0 = 0.3 + lambda = exp(5.0 / delta_0 * (r - r_0)) + + prim_inner = SVector(1.2, 0.1, 0.0, 0.1, 0.9, 1.0, 1.0, 1.0, 0.0) + prim_outer = SVector(1.2, 0.2, -0.4, 0.2, 0.3, 1.0, 1.0, 1.0, 0.0) + prim_vars = (prim_inner + lambda * prim_outer) / (1.0 + lambda) + + return prim2cons(prim_vars, equations) end initial_condition = initial_condition_blast_wave surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Mapping as described in https://arxiv.org/abs/2012.12040 but with slightly less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/11 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/11 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/11 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 11 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 11 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 11 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end trees_per_dimension = (2, 2, 2) mesh = P4estMesh(trees_per_dimension, - polydeg=3, - mapping=mapping, - initial_refinement_level=2, - periodicity=true) + polydeg = 3, + mapping = mapping, + initial_refinement_level = 2, + periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -95,24 +98,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) amr_indicator = IndicatorLöhner(semi, - variable=density_pressure) + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=2, - max_level =4, max_threshold=0.15) + base_level = 2, + max_level = 4, max_threshold = 0.15) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -121,11 +124,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl index f76ca4f2cdf..4f44d7b12ac 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl @@ -8,18 +8,16 @@ equations = CompressibleEulerEquations2D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg = 3, surface_flux = FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_eoc_test_euler) - + source_terms = source_terms_eoc_test_euler) ############################################################################### # ODE solvers, callbacks etc. @@ -29,26 +27,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval=analysis_interval) -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) callbacks = CallbackSet(summary_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl index 8277577f5b9..49b98803577 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl @@ -2,10 +2,8 @@ using OrdinaryDiffEq using Trixi - initial_condition = initial_condition_eoc_test_coupled_euler_gravity - ############################################################################### # semidiscretization of the compressible Euler equations gamma = 2.0 @@ -17,12 +15,12 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, - source_terms=source_terms_eoc_test_coupled_euler_gravity) + initial_refinement_level = 2, + n_cells_max = 10_000) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, + solver_euler, + source_terms = source_terms_eoc_test_coupled_euler_gravity) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -30,24 +28,23 @@ equations_gravity = HyperbolicDiffusionEquations2D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, - source_terms=source_terms_harmonic) - +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, + solver_gravity, + source_terms = source_terms_harmonic) ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 +parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 # rho0 is (ab)used to add a "+8π" term to the source terms # for the manufactured solution - gravitational_constant=1.0, # aka G - cfl=1.1, - resid_tol=1.0e-10, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!) + gravitational_constant = 1.0, # aka G + cfl = 1.1, + resid_tol = 1.0e-10, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -55,28 +52,27 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, - save_analysis=true) +analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, + save_analysis = true) callbacks = CallbackSet(summary_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl index a23915745df..2f2cefe198c 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - """ initial_condition_jeans_instability(x, t, equations::Union{CompressibleEulerEquations2D, @@ -19,52 +18,51 @@ The classical Jeans instability taken from in CGS (centimeter, gram, second) units. """ function initial_condition_jeans_instability(x, t, - equations::CompressibleEulerEquations2D) - # Jeans gravitational instability test case - # see Derigs et al. https://arxiv.org/abs/1605.03572; Sec. 4.6 - # OBS! this uses cgs (centimeter, gram, second) units - # periodic boundaries - # domain size [0,L]^2 depends on the wave number chosen for the perturbation - # OBS! Be very careful here L must be chosen such that problem is periodic - # typical final time is T = 5 - # gamma = 5/3 - dens0 = 1.5e7 # g/cm^3 - pres0 = 1.5e7 # dyn/cm^2 - delta0 = 1e-3 - # set wave vector values for perturbation (units 1/cm) - # see FLASH manual: https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf - kx = 2.0*pi/0.5 # 2π/λ_x, λ_x = 0.5 - ky = 0.0 # 2π/λ_y, λ_y = 1e10 - k_dot_x = kx*x[1] + ky*x[2] - # perturb density and pressure away from reference states ρ_0 and p_0 - dens = dens0*(1.0 + delta0*cos(k_dot_x)) # g/cm^3 - pres = pres0*(1.0 + equations.gamma*delta0*cos(k_dot_x)) # dyn/cm^2 - # flow starts as stationary - velx = 0.0 # cm/s - vely = 0.0 # cm/s - return prim2cons((dens, velx, vely, pres), equations) + equations::CompressibleEulerEquations2D) + # Jeans gravitational instability test case + # see Derigs et al. https://arxiv.org/abs/1605.03572; Sec. 4.6 + # OBS! this uses cgs (centimeter, gram, second) units + # periodic boundaries + # domain size [0,L]^2 depends on the wave number chosen for the perturbation + # OBS! Be very careful here L must be chosen such that problem is periodic + # typical final time is T = 5 + # gamma = 5/3 + dens0 = 1.5e7 # g/cm^3 + pres0 = 1.5e7 # dyn/cm^2 + delta0 = 1e-3 + # set wave vector values for perturbation (units 1/cm) + # see FLASH manual: https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf + kx = 2.0 * pi / 0.5 # 2π/λ_x, λ_x = 0.5 + ky = 0.0 # 2π/λ_y, λ_y = 1e10 + k_dot_x = kx * x[1] + ky * x[2] + # perturb density and pressure away from reference states ρ_0 and p_0 + dens = dens0 * (1.0 + delta0 * cos(k_dot_x)) # g/cm^3 + pres = pres0 * (1.0 + equations.gamma * delta0 * cos(k_dot_x)) # dyn/cm^2 + # flow starts as stationary + velx = 0.0 # cm/s + vely = 0.0 # cm/s + return prim2cons((dens, velx, vely, pres), equations) end function initial_condition_jeans_instability(x, t, equations::HyperbolicDiffusionEquations2D) - # gravity equation: -Δϕ = -4πGρ - # Constants taken from the FLASH manual - # https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf - rho0 = 1.5e7 - delta0 = 1e-3 - - phi = rho0*delta0 # constant background perturbation magnitude - q1 = 0.0 - q2 = 0.0 - return (phi, q1, q2) + # gravity equation: -Δϕ = -4πGρ + # Constants taken from the FLASH manual + # https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf + rho0 = 1.5e7 + delta0 = 1e-3 + + phi = rho0 * delta0 # constant background perturbation magnitude + q1 = 0.0 + q2 = 0.0 + return (phi, q1, q2) end initial_condition = initial_condition_jeans_instability - ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5/3 +gamma = 5 / 3 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 @@ -73,11 +71,11 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler) + initial_refinement_level = 4, + n_cells_max = 10_000) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, + solver_euler) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -85,22 +83,21 @@ equations_gravity = HyperbolicDiffusionEquations2D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, - source_terms=source_terms_harmonic) - +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, + solver_gravity, + source_terms = source_terms_harmonic) ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density=1.5e7, # aka rho0 - gravitational_constant=6.674e-8, # aka G - cfl=1.6, - resid_tol=1.0e-4, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_carpenter_kennedy_erk54_2N!) +parameters = ParametersEulerGravity(background_density = 1.5e7, # aka rho0 + gravitational_constant = 6.674e-8, # aka G + cfl = 1.6, + resid_tol = 1.0e-4, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_carpenter_kennedy_erk54_2N!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 5.0) @@ -108,51 +105,58 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) Trixi.pretty_form_utf(::Val{:energy_potential}) = "∑e_potential" Trixi.pretty_form_ascii(::Val{:energy_potential}) = "e_potential" -function Trixi.analyze(::Val{:energy_potential}, du, u_euler, t, semi::SemidiscretizationEulerGravity) - - u_gravity = Trixi.wrap_array(semi.cache.u_ode, semi.semi_gravity) - - mesh, equations_euler, dg, cache = Trixi.mesh_equations_solver_cache(semi.semi_euler) - _, equations_gravity, _, _ = Trixi.mesh_equations_solver_cache(semi.semi_gravity) - - e_potential = Trixi.integrate_via_indices(u_euler, mesh, equations_euler, dg, cache, equations_gravity, u_gravity) do u, i, j, element, equations_euler, dg, equations_gravity, u_gravity - u_euler_local = Trixi.get_node_vars(u_euler, equations_euler, dg, i, j, element) - u_gravity_local = Trixi.get_node_vars(u_gravity, equations_gravity, dg, i, j, element) - # OBS! subtraction is specific to Jeans instability test where rho0 = 1.5e7 - return (u_euler_local[1] - 1.5e7) * u_gravity_local[1] - end - return e_potential +function Trixi.analyze(::Val{:energy_potential}, du, u_euler, t, + semi::SemidiscretizationEulerGravity) + u_gravity = Trixi.wrap_array(semi.cache.u_ode, semi.semi_gravity) + + mesh, equations_euler, dg, cache = Trixi.mesh_equations_solver_cache(semi.semi_euler) + _, equations_gravity, _, _ = Trixi.mesh_equations_solver_cache(semi.semi_gravity) + + e_potential = Trixi.integrate_via_indices(u_euler, mesh, equations_euler, dg, cache, + equations_gravity, + u_gravity) do u, i, j, element, + equations_euler, dg, + equations_gravity, u_gravity + u_euler_local = Trixi.get_node_vars(u_euler, equations_euler, dg, i, j, element) + u_gravity_local = Trixi.get_node_vars(u_gravity, equations_gravity, dg, i, j, + element) + # OBS! subtraction is specific to Jeans instability test where rho0 = 1.5e7 + return (u_euler_local[1] - 1.5e7) * u_gravity_local[1] + end + return e_potential end -analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal, Val(:energy_potential))) +analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (energy_total, + energy_kinetic, + energy_internal, + Val(:energy_potential))) callbacks = CallbackSet(summary_callback, stepsize_callback, save_restart, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl index de8baf2ecdb..ba92f77bbaf 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl @@ -19,33 +19,33 @@ based on Should be used together with [`boundary_condition_sedov_self_gravity`](@ref). """ function initial_condition_sedov_self_gravity(x, t, equations::CompressibleEulerEquations2D) - # Set up polar coordinates - r = sqrt(x[1]^2 + x[2]^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 - r0 = 0.125 # = 4.0 * smallest dx (for domain length=8 and max-ref=8) - E = 1.0 - p_inner = (equations.gamma - 1) * E / (pi * r0^2) - p_ambient = 1e-5 # = true Sedov setup - - # Calculate primitive variables - # use a logistic function to transfer density value smoothly - L = 1.0 # maximum of function - x0 = 1.0 # center point of function - k = -150.0 # sharpness of transfer - logistic_function_rho = L/(1.0 + exp(-k*(r - x0))) - rho_ambient = 1e-5 - rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny - - # velocities are zero - v1 = 0.0 - v2 = 0.0 - - # use a logistic function to transfer pressure value smoothly - logistic_function_p = p_inner/(1.0 + exp(-k*(r - r0))) - p = max(logistic_function_p, p_ambient) - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Set up polar coordinates + r = sqrt(x[1]^2 + x[2]^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 + r0 = 0.125 # = 4.0 * smallest dx (for domain length=8 and max-ref=8) + E = 1.0 + p_inner = (equations.gamma - 1) * E / (pi * r0^2) + p_ambient = 1e-5 # = true Sedov setup + + # Calculate primitive variables + # use a logistic function to transfer density value smoothly + L = 1.0 # maximum of function + x0 = 1.0 # center point of function + k = -150.0 # sharpness of transfer + logistic_function_rho = L / (1.0 + exp(-k * (r - x0))) + rho_ambient = 1e-5 + rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny + + # velocities are zero + v1 = 0.0 + v2 = 0.0 + + # use a logistic function to transfer pressure value smoothly + logistic_function_p = p_inner / (1.0 + exp(-k * (r - r0))) + p = max(logistic_function_p, p_ambient) + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_sedov_self_gravity @@ -65,50 +65,50 @@ Should be used together with [`initial_condition_sedov_self_gravity`](@ref). function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) - # velocities are zero, density/pressure are ambient values according to - # initial_condition_sedov_self_gravity - rho = 1e-5 - v1 = 0.0 - v2 = 0.0 - p = 1e-5 - - u_boundary = prim2cons(SVector(rho, v1, v2, p), equations) - - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end - - return flux + # velocities are zero, density/pressure are ambient values according to + # initial_condition_sedov_self_gravity + rho = 1e-5 + v1 = 0.0 + v2 = 0.0 + p = 1e-5 + + u_boundary = prim2cons(SVector(rho, v1, v2, p), equations) + + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end + + return flux end boundary_conditions = boundary_condition_sedov_self_gravity surface_flux = FluxHLL(min_max_speed_naive) -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations_euler, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver_euler = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-4, -4) -coordinates_max = ( 4, 4) +coordinates_max = (4, 4) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=100_000, - periodicity=false) - -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, - boundary_conditions=boundary_conditions) + initial_refinement_level = 2, + n_cells_max = 100_000, + periodicity = false) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, + solver_euler, + boundary_conditions = boundary_conditions) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -125,12 +125,13 @@ based on - http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 Should be used together with [`boundary_condition_sedov_self_gravity`](@ref). """ -function initial_condition_sedov_self_gravity(x, t, equations::HyperbolicDiffusionEquations2D) - # for now just use constant initial condition for sedov blast wave (can likely be improved) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - return SVector(phi, q1, q2) +function initial_condition_sedov_self_gravity(x, t, + equations::HyperbolicDiffusionEquations2D) + # for now just use constant initial condition for sedov blast wave (can likely be improved) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + return SVector(phi, q1, q2) end """ @@ -147,39 +148,38 @@ based on Should be used together with [`initial_condition_sedov_self_gravity`](@ref). """ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, x, t, - surface_flux_function, - equations::HyperbolicDiffusionEquations2D) - u_boundary = initial_condition_sedov_self_gravity(x, t, equations) - - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end - - return flux + surface_flux_function, + equations::HyperbolicDiffusionEquations2D) + u_boundary = initial_condition_sedov_self_gravity(x, t, equations) + + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end + + return flux end solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, - boundary_conditions=boundary_conditions, - source_terms=source_terms_harmonic) - +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, + solver_gravity, + boundary_conditions = boundary_conditions, + source_terms = source_terms_harmonic) ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density=0.0, # aka rho0 - gravitational_constant=6.674e-8, # aka G - cfl=2.4, - resid_tol=1.0e-4, - n_iterations_max=100, - timestep_gravity=timestep_gravity_erk52_3Sstar!) +parameters = ParametersEulerGravity(background_density = 0.0, # aka rho0 + gravitational_constant = 6.674e-8, # aka G + cfl = 2.4, + resid_tol = 1.0e-4, + n_iterations_max = 100, + timestep_gravity = timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 1.0) @@ -188,41 +188,42 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0, - alpha_smooth=false, - variable=density_pressure) + alpha_max = 1.0, + alpha_min = 0.0, + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=2, - max_level =8, max_threshold=0.0003) + base_level = 2, + max_level = 8, max_threshold = 0.0003) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (energy_total, + energy_kinetic, + energy_internal)) callbacks = CallbackSet(summary_callback, amr_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl index 029c19380cf..df6e4e6349f 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl @@ -9,10 +9,10 @@ equations = HyperbolicDiffusionEquations2D() initial_condition = initial_condition_poisson_nonperiodic # 1 => -x, 2 => +x, 3 => -y, 4 => +y as usual for orientations -boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, - x_pos=boundary_condition_poisson_nonperiodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic) +boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, + x_pos = boundary_condition_poisson_nonperiodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) polydeg = 3 surface_flux = flux_lax_friedrichs @@ -21,15 +21,13 @@ solver = DGSEM(polydeg, surface_flux) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000, - periodicity=(false, true)) - + initial_refinement_level = 2, + n_cells_max = 30_000, + periodicity = (false, true)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_poisson_nonperiodic, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_poisson_nonperiodic, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -40,29 +38,28 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 1.0e-10 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) analysis_interval = 500 -alive_callback = AliveCallback(analysis_interval=analysis_interval) -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) callbacks = CallbackSet(summary_callback, steady_state_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 diff --git a/examples/special_elixirs/elixir_euler_ad.jl b/examples/special_elixirs/elixir_euler_ad.jl index 48fd37cc9d4..3aa44f9a773 100644 --- a/examples/special_elixirs/elixir_euler_ad.jl +++ b/examples/special_elixirs/elixir_euler_ad.jl @@ -6,10 +6,10 @@ using Trixi, LinearAlgebra, ForwardDiff equations = CompressibleEulerEquations2D(1.4) mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), - initial_refinement_level=2, n_cells_max=10^5) + initial_refinement_level = 2, n_cells_max = 10^5) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) """ initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) @@ -21,43 +21,45 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, + solver) u0_ode = compute_coefficients(0.0, semi) J = ForwardDiff.jacobian((du_ode, γ) -> begin - equations_inner = CompressibleEulerEquations2D(first(γ)) - semi_inner = Trixi.remake(semi, equations=equations_inner, uEltype=eltype(γ)) - Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) - end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` + equations_inner = CompressibleEulerEquations2D(first(γ)) + semi_inner = Trixi.remake(semi, equations = equations_inner, + uEltype = eltype(γ)) + Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) + end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` diff --git a/examples/structured_1d_dgsem/elixir_advection_basic.jl b/examples/structured_1d_dgsem/elixir_advection_basic.jl index 82464f23964..cdabeb4c61a 100644 --- a/examples/structured_1d_dgsem/elixir_advection_basic.jl +++ b/examples/structured_1d_dgsem/elixir_advection_basic.jl @@ -11,7 +11,7 @@ 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0,) # minimum coordinate coordinates_max = (1.0,) # maximum coordinate @@ -21,8 +21,8 @@ cells_per_dimension = (16,) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -35,26 +35,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl b/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl index e87e0b36b0a..1e0c579ffcf 100644 --- a/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl +++ b/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl @@ -11,18 +11,16 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) initial_condition = initial_condition_gauss boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (5.0,) -mesh = StructuredMesh((16,), coordinates_min, coordinates_max, periodicity=false) - +mesh = StructuredMesh((16,), coordinates_min, coordinates_max, periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -33,31 +31,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, stepsize_callback); - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl b/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl index 313812fe08d..96566bc2373 100644 --- a/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl +++ b/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl @@ -17,30 +17,30 @@ Slight simplification from [DOI: 10.1006/jcph.1996.0130](https://doi.org/10.1006/jcph.1996.0130) """ function initial_condition_composite(x, t, equations::LinearScalarAdvectionEquation1D) - xmin, xmax = -1.0, 1.0 # Only works if the domain is [-1.0,1.0] - x_trans = x[1] - t - L = xmax - xmin - if x_trans > xmax - x_ = x_trans - L * floor((x_trans + xmin) / L) - elseif x_trans < xmin - x_ = x_trans + L * floor((xmax - x_trans) / L) - else - x_ = x_trans - end - - if x_ > -0.8 && x_ < -0.6 - value = exp(-log(2.0) * (x_ + 0.7)^2 / 0.0009) - elseif x_ > -0.4 && x_ < -0.2 - value = 1.0 - elseif x_ > 0.0 && x_ < 0.2 - value = 1.0 - abs(10.0 * (x_ - 0.1)) - elseif x_ > 0.4 && x_ < 0.6 - value = sqrt(1.0 - 100.0 * (x_ - 0.5)^2) - else - value = 0.0 - end - - return SVector(value) + xmin, xmax = -1.0, 1.0 # Only works if the domain is [-1.0,1.0] + x_trans = x[1] - t + L = xmax - xmin + if x_trans > xmax + x_ = x_trans - L * floor((x_trans + xmin) / L) + elseif x_trans < xmin + x_ = x_trans + L * floor((xmax - x_trans) / L) + else + x_ = x_trans + end + + if x_ > -0.8 && x_ < -0.6 + value = exp(-log(2.0) * (x_ + 0.7)^2 / 0.0009) + elseif x_ > -0.4 && x_ < -0.2 + value = 1.0 + elseif x_ > 0.0 && x_ < 0.2 + value = 1.0 - abs(10.0 * (x_ - 0.1)) + elseif x_ > 0.4 && x_ < 0.6 + value = sqrt(1.0 - 100.0 * (x_ - 0.5)^2) + else + value = 0.0 + end + + return SVector(value) end initial_condition = initial_condition_composite @@ -52,13 +52,13 @@ volume_flux = flux_central polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=Trixi.first) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = Trixi.first) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) # Create curved mesh @@ -66,12 +66,11 @@ cells_per_dimension = (120,) coordinates_min = (-1.0,) # minimum coordinate coordinates_max = (1.0,) # maximum coordinate mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, - periodicity=true) + periodicity = true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -84,23 +83,23 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) # 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) - +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, # 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 \ No newline at end of file +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 diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov.jl b/examples/structured_1d_dgsem/elixir_euler_sedov.jl index ee950b3aaaa..9293a864058 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov.jl @@ -14,50 +14,50 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - p0_outer = 1.0e-5 # = true Sedov setup - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + p0_outer = 1.0e-5 # = true Sedov setup + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=shock_indicator_variable) + alpha_max = 1.0, + alpha_min = 0.001, + alpha_smooth = true, + variable = shock_indicator_variable) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) cells_per_dimension = (64,) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) -mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, periodicity=true) +coordinates_max = (2.0,) +mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -67,28 +67,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) -callbacks = CallbackSet(summary_callback, - analysis_callback, +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, save_solution, stepsize_callback) - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl index 230ba92d6b6..270da192fe1 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl @@ -14,49 +14,49 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - p0_outer = 1.0e-5 # = true Sedov setup - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + p0_outer = 1.0e-5 # = true Sedov setup + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_hll -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=shock_indicator_variable) + alpha_max = 1.0, + alpha_min = 0.001, + alpha_smooth = true, + variable = shock_indicator_variable) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) cells_per_dimension = (64,) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) -mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, periodicity=true) +coordinates_max = (2.0,) +mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -66,28 +66,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) -callbacks = CallbackSet(summary_callback, - analysis_callback, +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, save_solution, stepsize_callback) - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # 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 \ No newline at end of file +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl index 05bf07f59c0..6cf42df9416 100644 --- a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl @@ -13,7 +13,7 @@ initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. # Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (2.0,) @@ -21,10 +21,8 @@ cells_per_dimension = (16,) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -35,29 +33,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl index 9aa5b7f4979..d5063838136 100644 --- a/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -15,20 +15,18 @@ source_terms = source_terms_convergence_test # 1*ndims == 2 directions or you can pass a tuple containing BCs for # each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg=boundary_condition, - x_pos=boundary_condition) +boundary_conditions = (x_neg = boundary_condition, + x_pos = boundary_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) f1() = SVector(0.0) f2() = SVector(2.0) -mesh = StructuredMesh((16,), (f1, f2), periodicity=false) - +mesh = StructuredMesh((16,), (f1, f2), periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms, - boundary_conditions=boundary_conditions) - + source_terms = source_terms, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -39,30 +37,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/structured_2d_dgsem/elixir_advection_basic.jl b/examples/structured_2d_dgsem/elixir_advection_basic.jl index 7d2e1f49276..1d7235fc214 100644 --- a/examples/structured_2d_dgsem/elixir_advection_basic.jl +++ b/examples/structured_2d_dgsem/elixir_advection_basic.jl @@ -11,10 +11,10 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) cells_per_dimension = (16, 16) @@ -22,8 +22,8 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -36,26 +36,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_coupled.jl b/examples/structured_2d_dgsem/elixir_advection_coupled.jl index 1e54e411db6..2a56d23f4c0 100644 --- a/examples/structured_2d_dgsem/elixir_advection_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_advection_coupled.jl @@ -1,7 +1,6 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # Coupled semidiscretization of two linear advection systems, which are connected periodically # @@ -35,11 +34,11 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # First mesh is the left half of a [-1,1]^2 square coordinates_min1 = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max1 = ( 0.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y)) # Define identical resolution as a variable such that it is easier to change from `trixi_include` cells_per_dimension = (8, 16) @@ -49,32 +48,45 @@ cells_per_dimension1 = cells_per_dimension mesh1 = StructuredMesh(cells_per_dimension1, coordinates_min1, coordinates_max1) # A semidiscretization collects data structures and functions for the spatial discretization -semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_convergence_test, solver, - boundary_conditions=( - # Connect left boundary with right boundary of right mesh - x_neg=BoundaryConditionCoupled(2, (:end, :i_forward), Float64), - # Connect right boundary with left boundary of right mesh - x_pos=BoundaryConditionCoupled(2, (:begin, :i_forward), Float64), - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic)) - +semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_convergence_test, + solver, + boundary_conditions = ( + # Connect left boundary with right boundary of right mesh + x_neg = BoundaryConditionCoupled(2, + (:end, + :i_forward), + Float64), + # Connect right boundary with left boundary of right mesh + x_pos = BoundaryConditionCoupled(2, + (:begin, + :i_forward), + Float64), + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic)) # Second mesh is the right half of a [-1,1]^2 square coordinates_min2 = (0.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max2 = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max2 = (1.0, 1.0) # maximum coordinates (max(x), max(y)) cells_per_dimension2 = cells_per_dimension mesh2 = StructuredMesh(cells_per_dimension2, coordinates_min2, coordinates_max2) -semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_convergence_test, solver, - boundary_conditions=( - # Connect left boundary with right boundary of left mesh - x_neg=BoundaryConditionCoupled(1, (:end, :i_forward), Float64), - # Connect right boundary with left boundary of left mesh - x_pos=BoundaryConditionCoupled(1, (:begin, :i_forward), Float64), - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic)) +semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_convergence_test, + solver, + boundary_conditions = ( + # Connect left boundary with right boundary of left mesh + x_neg = BoundaryConditionCoupled(1, + (:end, + :i_forward), + Float64), + # Connect right boundary with left boundary of left mesh + x_pos = BoundaryConditionCoupled(1, + (:begin, + :i_forward), + Float64), + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic)) # Create a semidiscretization that bundles semi1 and semi2 semi = SemidiscretizationCoupled(semi1, semi2) @@ -90,28 +102,28 @@ ode = semidiscretize(semi, (0.0, 2.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback1 = AnalysisCallback(semi1, interval=100) -analysis_callback2 = AnalysisCallback(semi2, interval=100) +analysis_callback1 = AnalysisCallback(semi1, interval = 100) +analysis_callback2 = AnalysisCallback(semi2, interval = 100) analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - solution_variables=cons2prim) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_extended.jl b/examples/structured_2d_dgsem/elixir_advection_extended.jl index fbaa7783d99..df7e1f375a9 100644 --- a/examples/structured_2d_dgsem/elixir_advection_extended.jl +++ b/examples/structured_2d_dgsem/elixir_advection_extended.jl @@ -18,11 +18,11 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # The initial condition is 2-periodic coordinates_min = (-1.5, 1.3) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 0.5, 5.3) # maximum coordinates (max(x), max(y)) +coordinates_max = (0.5, 5.3) # maximum coordinates (max(x), max(y)) cells_per_dimension = (19, 37) @@ -31,8 +31,7 @@ mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -47,24 +46,24 @@ 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, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.6) +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, @@ -72,14 +71,13 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_free_stream.jl b/examples/structured_2d_dgsem/elixir_advection_free_stream.jl index 155a2d19fc9..7785b4f9e18 100644 --- a/examples/structured_2d_dgsem/elixir_advection_free_stream.jl +++ b/examples/structured_2d_dgsem/elixir_advection_free_stream.jl @@ -11,21 +11,21 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_constant # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (16, 16) @@ -36,7 +36,6 @@ mesh = StructuredMesh(cells_per_dimension, mapping) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -48,30 +47,30 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +save_solution = SaveSolutionCallback(interval = 100, + solution_variables = cons2prim) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=2.0) +stepsize_callback = StepsizeCallback(cfl = 2.0) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution, stepsize_callback) - +callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl index 2aad3a01566..e2e113b168d 100644 --- a/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl @@ -13,16 +13,14 @@ initial_condition = initial_condition_gauss # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) -mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity=false) - +coordinates_max = (5.0, 5.0) +mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -33,17 +31,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -52,7 +50,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl b/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl index b9a6d3f91ae..b70deb12318 100644 --- a/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl +++ b/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl @@ -7,24 +7,23 @@ using OrdinaryDiffEq using Trixi - # initial_condition_convergence_test transformed to the parallelogram function initial_condition_parallelogram(x, t, equation::LinearScalarAdvectionEquation2D) - # Transform back to unit square - x_transformed = SVector(x[1] - x[2], x[2]) - a = equation.advection_velocity - a_transformed = SVector(a[1] - a[2], a[2]) - - # Store translated coordinate for easy use of exact solution - x_translated = x_transformed - a_transformed * t - - c = 1.0 - A = 0.5 - L = 2 - f = 1/L - omega = 2 * pi * f - scalar = c + A * sin(omega * sum(x_translated)) - return SVector(scalar) + # Transform back to unit square + x_transformed = SVector(x[1] - x[2], x[2]) + a = equation.advection_velocity + a_transformed = SVector(a[1] - a[2], a[2]) + + # Store translated coordinate for easy use of exact solution + x_translated = x_transformed - a_transformed * t + + c = 1.0 + A = 0.5 + L = 2 + f = 1 / L + omega = 2 * pi * f + scalar = c + A * sin(omega * sum(x_translated)) + return SVector(scalar) end ############################################################################### @@ -35,7 +34,7 @@ advection_velocity = (-0.5, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Define faces for a parallelogram that looks like this # @@ -49,11 +48,11 @@ mapping(xi, eta) = SVector(xi + eta, eta) cells_per_dimension = (16, 16) # Create curved mesh with 16 x 16 elements, periodic in both dimensions -mesh = StructuredMesh(cells_per_dimension, mapping; periodicity=(true, true)) +mesh = StructuredMesh(cells_per_dimension, mapping; periodicity = (true, true)) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_parallelogram, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_parallelogram, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -66,26 +65,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_restart.jl b/examples/structured_2d_dgsem/elixir_advection_restart.jl index 2c2a0ef8f51..b4ae56543f8 100644 --- a/examples/structured_2d_dgsem/elixir_advection_restart.jl +++ b/examples/structured_2d_dgsem/elixir_advection_restart.jl @@ -10,7 +10,6 @@ restart_file = "restart_000021.h5" trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file)) - ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -25,11 +24,10 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 diff --git a/examples/structured_2d_dgsem/elixir_advection_rotated.jl b/examples/structured_2d_dgsem/elixir_advection_rotated.jl index 7dfee23a067..826c7ebaacb 100644 --- a/examples/structured_2d_dgsem/elixir_advection_rotated.jl +++ b/examples/structured_2d_dgsem/elixir_advection_rotated.jl @@ -7,7 +7,6 @@ using OrdinaryDiffEq using Trixi - # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -17,40 +16,41 @@ using Trixi # initial_condition_convergence_test transformed to the rotated rectangle struct InitialConditionConvergenceTestRotated - sin_alpha::Float64 - cos_alpha::Float64 + sin_alpha::Float64 + cos_alpha::Float64 end function InitialConditionConvergenceTestRotated(alpha) - sin_alpha, cos_alpha = sincos(alpha) + sin_alpha, cos_alpha = sincos(alpha) - InitialConditionConvergenceTestRotated(sin_alpha, cos_alpha) + InitialConditionConvergenceTestRotated(sin_alpha, cos_alpha) end -function (initial_condition::InitialConditionConvergenceTestRotated)(x, t, equation::LinearScalarAdvectionEquation2D) - sin_ = initial_condition.sin_alpha - cos_ = initial_condition.cos_alpha +function (initial_condition::InitialConditionConvergenceTestRotated)(x, t, + equation::LinearScalarAdvectionEquation2D) + sin_ = initial_condition.sin_alpha + cos_ = initial_condition.cos_alpha - # Rotate back to unit square + # Rotate back to unit square - # Clockwise rotation by α and translation by 1 - # Multiply with [ cos(α) sin(α); - # -sin(α) cos(α)] - x_rot = SVector(cos_ * x[1] + sin_ * x[2], -sin_ * x[1] + cos_ * x[2]) - a = equation.advection_velocity - a_rot = SVector(cos_ * a[1] + sin_ * a[2], -sin_ * a[1] + cos_ * a[2]) + # Clockwise rotation by α and translation by 1 + # Multiply with [ cos(α) sin(α); + # -sin(α) cos(α)] + x_rot = SVector(cos_ * x[1] + sin_ * x[2], -sin_ * x[1] + cos_ * x[2]) + a = equation.advection_velocity + a_rot = SVector(cos_ * a[1] + sin_ * a[2], -sin_ * a[1] + cos_ * a[2]) - # Store translated coordinate for easy use of exact solution - x_trans = x_rot - a_rot * t + # Store translated coordinate for easy use of exact solution + x_trans = x_rot - a_rot * t - c = 1.0 - A = 0.5 - L = 2 - f = 1/L - omega = 2 * pi * f - scalar = c + A * sin(omega * sum(x_trans)) + c = 1.0 + A = 0.5 + L = 2 + f = 1 / L + omega = 2 * pi * f + scalar = c + A * sin(omega * sum(x_trans)) - return SVector(scalar) + return SVector(scalar) end end # module TrixiExtensionAdvectionRotated @@ -70,7 +70,7 @@ advection_velocity = Tuple(T * [0.2, -0.7]) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) mapping(xi, eta) = T * SVector(xi, eta) @@ -82,7 +82,6 @@ mesh = StructuredMesh(cells_per_dimension, mapping) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -94,26 +93,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl b/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl index d0db19ea635..50393d50a19 100644 --- a/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl +++ b/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl @@ -11,14 +11,14 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector( 1.0, s + 1.0) +f2(s) = SVector(1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) cells_per_dimension = (16, 16) @@ -28,7 +28,6 @@ mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4)) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -40,30 +39,30 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +analysis_callback = AnalysisCallback(semi, interval = 100) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - solution_variables=cons2prim) +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.4) +stepsize_callback = StepsizeCallback(cfl = 1.4) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution, stepsize_callback) - +callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_euler_ec.jl b/examples/structured_2d_dgsem/elixir_euler_ec.jl index 2c91349ff98..29686bd3cb7 100644 --- a/examples/structured_2d_dgsem/elixir_euler_ec.jl +++ b/examples/structured_2d_dgsem/elixir_euler_ec.jl @@ -13,25 +13,25 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg=4, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the curved quad mesh from a mapping function # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (16, 16) @@ -53,15 +53,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -72,7 +72,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_free_stream.jl b/examples/structured_2d_dgsem/elixir_euler_free_stream.jl index c4ddb887e5f..3aab4be979e 100644 --- a/examples/structured_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/structured_2d_dgsem/elixir_euler_free_stream.jl @@ -9,21 +9,21 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_constant -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (16, 16) @@ -32,7 +32,6 @@ mesh = StructuredMesh(cells_per_dimension, mapping) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -42,16 +41,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=2.0) +stepsize_callback = StepsizeCallback(cfl = 2.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -61,7 +60,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl index 499aea21d9b..744c40213a3 100644 --- a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl @@ -29,40 +29,40 @@ defined below. """ @inline function initial_condition_rayleigh_taylor_instability(x, t, equations::CompressibleEulerEquations2D, - slope=1000) - tol = 1e2*eps() - - if x[2] < 0.5 - p = 2*x[2] + 1 - else - p = x[2] + 3/2 - end - - # smooth the discontinuity to avoid ambiguity at element interfaces - smoothed_heaviside(x, left, right) = left + 0.5*(1 + tanh(slope * x)) * (right-left) - rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) - - c = sqrt(equations.gamma * p / rho) - # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the - # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. - v = -0.025 * c * cos(8*pi*x[1]) * sin(pi*x[2])^6 - u = 0.0 - - return prim2cons(SVector(rho, u, v, p), equations) + slope = 1000) + tol = 1e2 * eps() + + if x[2] < 0.5 + p = 2 * x[2] + 1 + else + p = x[2] + 3 / 2 + end + + # smooth the discontinuity to avoid ambiguity at element interfaces + smoothed_heaviside(x, left, right) = left + 0.5 * (1 + tanh(slope * x)) * (right - left) + rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) + + c = sqrt(equations.gamma * p / rho) + # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the + # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. + v = -0.025 * c * cos(8 * pi * x[1]) * sin(pi * x[2])^6 + u = 0.0 + + return prim2cons(SVector(rho, u, v, p), equations) end @inline function source_terms_rayleigh_taylor_instability(u, x, t, equations::CompressibleEulerEquations2D) - g = 1.0 - rho, rho_v1, rho_v2, rho_e = u + g = 1.0 + rho, rho_v1, rho_v2, rho_e = u - return SVector(0.0, 0.0, g*rho, g*rho_v2) + return SVector(0.0, 0.0, g * rho, g * rho_v2) end # numerical parameters volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = FluxHLL(min_max_speed_naive), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # The domain is [0, 0.25] x [0, 1] mapping(xi, eta) = SVector(0.25 * 0.5 * (1.0 + xi), 0.5 * (1.0 + eta)) @@ -72,12 +72,10 @@ cells_per_dimension = (num_elements_per_dimension, num_elements_per_dimension * mesh = StructuredMesh(cells_per_dimension, mapping) initial_condition = initial_condition_rayleigh_taylor_instability -boundary_conditions = ( - x_neg=boundary_condition_slip_wall, - x_pos=boundary_condition_slip_wall, - y_neg=boundary_condition_slip_wall, - y_pos=boundary_condition_slip_wall, - ) +boundary_conditions = (x_neg = boundary_condition_slip_wall, + x_pos = boundary_condition_slip_wall, + y_neg = boundary_condition_slip_wall, + y_pos = boundary_condition_slip_wall) # # Alternative setup: left/right periodic BCs and Dirichlet BCs on the top/bottom. # boundary_conditions = ( @@ -88,8 +86,8 @@ boundary_conditions = ( # ) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; - source_terms=source_terms_rayleigh_taylor_instability, - boundary_conditions=boundary_conditions) + source_terms = source_terms_rayleigh_taylor_instability, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -100,9 +98,9 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -111,7 +109,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/structured_2d_dgsem/elixir_euler_sedov.jl b/examples/structured_2d_dgsem/elixir_euler_sedov.jl index ed1bfab3be2..2f91e6db7a5 100644 --- a/examples/structured_2d_dgsem/elixir_euler_sedov.jl +++ b/examples/structured_2d_dgsem/elixir_euler_sedov.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) - p0_outer = 1.0e-5 # = true Sedov 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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) + p0_outer = 1.0e-5 # = true Sedov 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 @@ -43,29 +43,30 @@ volume_flux = flux_ranocha polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 1.0, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = 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)) + 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) + 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=true) + +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true) # create the semidiscretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -79,15 +80,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=300, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 300, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -98,7 +99,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms.jl index 70d3e060dd0..6827848e185 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms.jl @@ -11,7 +11,7 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) @@ -20,10 +20,8 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -34,16 +32,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -53,7 +51,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl index 94537ecef0d..f42d223611a 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -12,21 +12,20 @@ initial_condition = initial_condition_convergence_test # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg=boundary_condition, - x_pos=boundary_condition, - y_neg=boundary_condition, - y_pos=boundary_condition,) +boundary_conditions = (x_neg = boundary_condition, + x_pos = boundary_condition, + y_neg = boundary_condition, + y_pos = boundary_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) -mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity=false) +mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -37,19 +36,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -58,7 +57,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl index a9c08049f41..5d6b0908389 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl @@ -9,7 +9,7 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Define faces for a parallelogram that looks like this # @@ -24,10 +24,8 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, mapping) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -38,16 +36,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -57,7 +55,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl index fdd189ffb55..f2e3c448893 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -12,68 +11,69 @@ using Trixi # initial_condition_convergence_test transformed to the rotated rectangle struct InitialConditionSourceTermsRotated - sin_alpha::Float64 - cos_alpha::Float64 + sin_alpha::Float64 + cos_alpha::Float64 end function InitialConditionSourceTermsRotated(alpha) - sin_alpha, cos_alpha = sincos(alpha) + sin_alpha, cos_alpha = sincos(alpha) - InitialConditionSourceTermsRotated(sin_alpha, cos_alpha) + InitialConditionSourceTermsRotated(sin_alpha, cos_alpha) end -function (initial_condition::InitialConditionSourceTermsRotated)(x, t, equations::CompressibleEulerEquations2D) - sin_ = initial_condition.sin_alpha - cos_ = initial_condition.cos_alpha +function (initial_condition::InitialConditionSourceTermsRotated)(x, t, + equations::CompressibleEulerEquations2D) + sin_ = initial_condition.sin_alpha + cos_ = initial_condition.cos_alpha - # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 + # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 - # Clockwise rotation by α and translation by 1 - # Multiply with [ cos(α) sin(α); - # -sin(α) cos(α)] - x1 = cos_ * x[1] + sin_ * x[2] + 1 - x2 = -sin_ * x[1] + cos_ * x[2] + 1 + # Clockwise rotation by α and translation by 1 + # Multiply with [ cos(α) sin(α); + # -sin(α) cos(α)] + x1 = cos_ * x[1] + sin_ * x[2] + 1 + x2 = -sin_ * x[1] + cos_ * x[2] + 1 - rho, rho_v1, rho_v2, rho_e = initial_condition_convergence_test(SVector(x1, x2), t, equations) + rho, rho_v1, rho_v2, rho_e = initial_condition_convergence_test(SVector(x1, x2), t, + equations) - # Rotate velocity vector counterclockwise - # Multiply with [ cos(α) -sin(α); - # sin(α) cos(α)] - rho_v1_rot = cos_ * rho_v1 - sin_ * rho_v2 - rho_v2_rot = sin_ * rho_v1 + cos_ * rho_v2 + # Rotate velocity vector counterclockwise + # Multiply with [ cos(α) -sin(α); + # sin(α) cos(α)] + rho_v1_rot = cos_ * rho_v1 - sin_ * rho_v2 + rho_v2_rot = sin_ * rho_v1 + cos_ * rho_v2 - return SVector(rho, rho_v1_rot, rho_v2_rot, rho_e) + return SVector(rho, rho_v1_rot, rho_v2_rot, rho_e) end +@inline function (source_terms::InitialConditionSourceTermsRotated)(u, x, t, + equations::CompressibleEulerEquations2D) + sin_ = source_terms.sin_alpha + cos_ = source_terms.cos_alpha -@inline function (source_terms::InitialConditionSourceTermsRotated)(u, x, t, equations::CompressibleEulerEquations2D) - sin_ = source_terms.sin_alpha - cos_ = source_terms.cos_alpha - - # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 + # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 - # Clockwise rotation by α and translation by 1 - # Multiply with [ cos(α) sin(α); - # -sin(α) cos(α)] - x1 = cos_ * x[1] + sin_ * x[2] + 1 - x2 = -sin_ * x[1] + cos_ * x[2] + 1 + # Clockwise rotation by α and translation by 1 + # Multiply with [ cos(α) sin(α); + # -sin(α) cos(α)] + x1 = cos_ * x[1] + sin_ * x[2] + 1 + x2 = -sin_ * x[1] + cos_ * x[2] + 1 - du1, du2, du3, du4 = source_terms_convergence_test(u, SVector(x1, x2), t, equations) + du1, du2, du3, du4 = source_terms_convergence_test(u, SVector(x1, x2), t, equations) - # Rotate velocity vector counterclockwise - # Multiply with [ cos(α) -sin(α); - # sin(α) cos(α)] - du2_rotated = cos_ * du2 - sin_ * du3 - du3_rotated = sin_ * du2 + cos_ * du3 + # Rotate velocity vector counterclockwise + # Multiply with [ cos(α) -sin(α); + # sin(α) cos(α)] + du2_rotated = cos_ * du2 - sin_ * du3 + du3_rotated = sin_ * du2 + cos_ * du3 - return SVector(du1, du2_rotated, du3_rotated, du4) + return SVector(du1, du2_rotated, du3_rotated, du4) end end # module TrixiExtensionEulerRotated import .TrixiExtensionEulerRotated - ############################################################################### # semidiscretization of the compressible Euler equations @@ -85,8 +85,7 @@ sin_ = initial_condition_source_terms.sin_alpha cos_ = initial_condition_source_terms.cos_alpha T = [cos_ -sin_; sin_ cos_] - -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) mapping(xi, eta) = T * SVector(xi, eta) @@ -94,10 +93,8 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, mapping) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_source_terms, solver, - source_terms=initial_condition_source_terms) - + source_terms = initial_condition_source_terms) ############################################################################### # ODE solvers, callbacks etc. @@ -108,16 +105,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -127,7 +124,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl index 505e28ecd8d..4a78b65ae0b 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl @@ -9,23 +9,21 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector( 1.0, s + 1.0) +f2(s) = SVector(1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4)) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -36,16 +34,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -55,7 +53,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl index 6730b1c4beb..ccb74fa4b68 100644 --- a/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl @@ -7,43 +7,42 @@ using Trixi equations = HyperbolicDiffusionEquations2D() -@inline function initial_condition_harmonic_nonperiodic(x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω - if t == 0.0 - phi = 1.0 - q1 = 1.0 - q2 = 1.0 - else - C = inv(sinh(pi)) - sinpi_x1, cospi_x1 = sincos(pi*x[1]) - sinpi_x2, cospi_x2 = sincos(pi*x[2]) - sinh_pix1 = sinh(pi*x[1]) - cosh_pix1 = cosh(pi*x[1]) - sinh_pix2 = sinh(pi*x[2]) - cosh_pix2 = cosh(pi*x[2]) - phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) - q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) - q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) - end - return SVector(phi, q1, q2) +@inline function initial_condition_harmonic_nonperiodic(x, t, + equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω + if t == 0.0 + phi = 1.0 + q1 = 1.0 + q2 = 1.0 + else + C = inv(sinh(pi)) + sinpi_x1, cospi_x1 = sincos(pi * x[1]) + sinpi_x2, cospi_x2 = sincos(pi * x[2]) + sinh_pix1 = sinh(pi * x[1]) + cosh_pix1 = cosh(pi * x[1]) + sinh_pix2 = sinh(pi * x[2]) + cosh_pix2 = cosh(pi * x[2]) + phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) + q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) + q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_harmonic_nonperiodic boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=4, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 4, surface_flux = flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) cells_per_dimension = (8, 8) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, - periodicity=false) - + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions, - source_terms=source_terms_harmonic) - + boundary_conditions = boundary_conditions, + source_terms = source_terms_harmonic) ############################################################################### # ODE solvers, callbacks etc. @@ -54,30 +53,29 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl index ba77dca9a99..681b3bd781b 100644 --- a/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -9,40 +9,38 @@ equations = HyperbolicDiffusionEquations2D() initial_condition = initial_condition_poisson_nonperiodic -solver = DGSEM(polydeg=6, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 6, surface_flux = flux_lax_friedrichs) -boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, - x_pos=boundary_condition_poisson_nonperiodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic) +boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, + x_pos = boundary_condition_poisson_nonperiodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) ############################################################################### # Get the curved quad mesh from a mapping function # # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end # Create curved mesh with 8 x 8 elements cells_per_dimension = (8, 8) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=(false, true)) - +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = (false, true)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_poisson_nonperiodic, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_poisson_nonperiodic, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -53,31 +51,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 4000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=4000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 4000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.9) +stepsize_callback = StepsizeCallback(cfl = 1.9) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) - ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=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 diff --git a/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl index 259875050c6..e8f2b2ecc3a 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,31 +5,34 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Get the curved quad mesh from a mapping function # Mapping as described in https://arxiv.org/abs/1809.01178 function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0, sqrt(2)] - # Note, we use the domain [0, sqrt(2)]^2 for the Alfvén wave convergence test case - xi = 0.5 * sqrt(2) * xi_ + 0.5 * sqrt(2) - eta = 0.5 * sqrt(2) * eta_ + 0.5 * sqrt(2) + # Transform input variables between -1 and 1 onto [0, sqrt(2)] + # Note, we use the domain [0, sqrt(2)]^2 for the Alfvén wave convergence test case + xi = 0.5 * sqrt(2) * xi_ + 0.5 * sqrt(2) + eta = 0.5 * sqrt(2) * eta_ + 0.5 * sqrt(2) - y = eta + sqrt(2)/12 * (cos(1.5 * pi * (2 * xi - sqrt(2))/sqrt(2)) * - cos(0.5 * pi * (2 * eta - sqrt(2))/sqrt(2))) + y = eta + + sqrt(2) / 12 * (cos(1.5 * pi * (2 * xi - sqrt(2)) / sqrt(2)) * + cos(0.5 * pi * (2 * eta - sqrt(2)) / sqrt(2))) - x = xi + sqrt(2)/12 * (cos(0.5 * pi * (2 * xi - sqrt(2))/sqrt(2)) * - cos(2 * pi * (2 * y - sqrt(2))/sqrt(2))) + x = xi + + sqrt(2) / 12 * (cos(0.5 * pi * (2 * xi - sqrt(2)) / sqrt(2)) * + cos(2 * pi * (2 * y - sqrt(2)) / sqrt(2))) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (4, 4) @@ -47,21 +50,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) - -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 2.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -73,7 +79,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_mhd_ec.jl b/examples/structured_2d_dgsem/elixir_mhd_ec.jl index 634738e5c8b..a6c31744ca5 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_ec.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_ec.jl @@ -8,45 +8,46 @@ using Trixi equations = IdealGlmMhdEquations2D(1.4) function initial_condition_shifted_weak_blast_wave(x, t, equations::IdealGlmMhdEquations2D) - # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) - # Same discontinuity in the velocities but with magnetic fields - # Set up polar coordinates - inicenter = (1.5, 1.5) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) - v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) - p = r > 0.5 ? 1.0 : 1.245 - - return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) + # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) + # Same discontinuity in the velocities but with magnetic fields + # Set up polar coordinates + inicenter = (1.5, 1.5) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) + v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) + p = r > 0.5 ? 1.0 : 1.245 + + return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) end initial_condition = initial_condition_shifted_weak_blast_wave # Get the DG approximation space volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=5, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 5, + surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Get the curved quad mesh from a mapping function # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3)) + y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3)) - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3)) + x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3)) - return SVector(x, y) + return SVector(x, y) end # Create curved mesh with 8 x 8 elements @@ -65,21 +66,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) - -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -91,7 +95,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl b/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl index 084aeca90b9..6668014a0b6 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations equations = IdealGlmMhdEquations2D(1.4) @@ -10,17 +9,17 @@ equations = IdealGlmMhdEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + 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 @@ -31,16 +30,14 @@ function mapping(xi, eta) x = 2.0 * xi + 1.0 / 6.0 * (cos(0.5 * pi * xi) * cos(2 * pi * y)) return SVector(x, y) - end +end cells_per_dimension = (16, 16) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=true) - +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -50,14 +47,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -68,7 +65,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl index 18f48080850..48fe37b9996 100644 --- a/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,13 +5,14 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) @@ -20,10 +21,8 @@ cells_per_dimension = (8, 8) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -34,16 +33,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=2.0) +stepsize_callback = StepsizeCallback(cfl = 2.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -53,7 +52,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl index 17836fa6b8f..c7c14da2ab4 100644 --- a/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl @@ -7,21 +7,22 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.0) +equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) - + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -30,16 +31,17 @@ initial_condition = initial_condition_well_balancedness # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), +surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, + hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal) -solver = DGSEM(polydeg=4, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup a structured periodic mesh coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) cells_per_dimension = (4, 4) @@ -64,30 +66,33 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), + element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -96,16 +101,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -113,7 +118,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_advection_basic.jl b/examples/structured_3d_dgsem/elixir_advection_basic.jl index 47ae6352485..5b0bb371fe8 100644 --- a/examples/structured_3d_dgsem/elixir_advection_basic.jl +++ b/examples/structured_3d_dgsem/elixir_advection_basic.jl @@ -11,18 +11,18 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) cells_per_dimension = (8, 8, 8) # Create curved mesh with 8 x 8 x 8 elements mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -35,30 +35,30 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +save_solution = SaveSolutionCallback(interval = 100, + solution_variables = cons2prim) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) # 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, save_restart, stepsize_callback) - +callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, save_restart, + 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_3d_dgsem/elixir_advection_free_stream.jl b/examples/structured_3d_dgsem/elixir_advection_free_stream.jl index 749233b8c68..12d52f15160 100644 --- a/examples/structured_3d_dgsem/elixir_advection_free_stream.jl +++ b/examples/structured_3d_dgsem/elixir_advection_free_stream.jl @@ -13,24 +13,27 @@ solver = DGSEM(3, flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) @@ -41,7 +44,6 @@ mesh = StructuredMesh(cells_per_dimension, mapping) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_constant, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -53,26 +55,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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=2.0) +stepsize_callback = StepsizeCallback(cfl = 2.0) # 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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl b/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl index fa8ae756566..1a20a9c8533 100644 --- a/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl +++ b/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl @@ -11,36 +11,38 @@ equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_convergence_test boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=false) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -51,20 +53,20 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -76,7 +78,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_advection_restart.jl b/examples/structured_3d_dgsem/elixir_advection_restart.jl index 39e1a675167..a4b72ef34c2 100644 --- a/examples/structured_3d_dgsem/elixir_advection_restart.jl +++ b/examples/structured_3d_dgsem/elixir_advection_restart.jl @@ -6,8 +6,7 @@ using Trixi # create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), - cells_per_dimension=(4, 4, 4)) - + cells_per_dimension = (4, 4, 4)) ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -18,16 +17,16 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), restart_filename = joinpath("out", "restart_000010.h5") mesh = load_mesh(restart_filename) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_ec.jl b/examples/structured_3d_dgsem/elixir_euler_ec.jl index 0009eb31180..1330006760e 100644 --- a/examples/structured_3d_dgsem/elixir_euler_ec.jl +++ b/examples/structured_3d_dgsem/elixir_euler_ec.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerEquations3D(5/3) +equations = CompressibleEulerEquations3D(5 / 3) initial_condition = initial_condition_weak_blast_wave @@ -13,32 +13,35 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg=5, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 5, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the curved quad mesh from a file # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -59,15 +62,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -78,7 +81,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_free_stream.jl b/examples/structured_3d_dgsem/elixir_euler_free_stream.jl index b0e71435767..1b01287100e 100644 --- a/examples/structured_3d_dgsem/elixir_euler_free_stream.jl +++ b/examples/structured_3d_dgsem/elixir_euler_free_stream.jl @@ -9,29 +9,32 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_constant -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -40,7 +43,6 @@ mesh = StructuredMesh(cells_per_dimension, mapping) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -50,30 +52,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.3) +stepsize_callback = StepsizeCallback(cfl = 1.3) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_sedov.jl b/examples/structured_3d_dgsem/elixir_euler_sedov.jl index 8f428495b4f..99e2fd72f96 100644 --- a/examples/structured_3d_dgsem/elixir_euler_sedov.jl +++ b/examples/structured_3d_dgsem/elixir_euler_sedov.jl @@ -14,28 +14,29 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 with smaller strength of the initial discontinuity. """ -function initial_condition_medium_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D) - # Set up polar coordinates - inicenter = SVector(0.0, 0.0, 0.0) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - z_norm = x[3] - inicenter[3] - r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) - p0_outer = 1.0e-3 - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_medium_sedov_blast_wave(x, t, + equations::CompressibleEulerEquations3D) + # Set up polar coordinates + inicenter = SVector(0.0, 0.0, 0.0) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + z_norm = x[3] - inicenter[3] + r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) + p0_outer = 1.0e-3 + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_medium_sedov_blast_wave @@ -45,30 +46,31 @@ volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 1.0, + 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(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) + +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi, eta, zeta) - y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) + y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) - x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) + x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) - z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) + z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) - return SVector(x, y, z) + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=true) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -82,15 +84,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -101,7 +103,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_source_terms.jl b/examples/structured_3d_dgsem/elixir_euler_source_terms.jl index d8c6ea4bb83..ebf1336c12c 100644 --- a/examples/structured_3d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_3d_dgsem/elixir_euler_source_terms.jl @@ -11,8 +11,8 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) # coordinates_min = (0.0, 0.0, 0.0) # coordinates_max = (2.0, 2.0, 2.0) @@ -28,8 +28,7 @@ cells_per_dimension = (4, 4, 4) mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4, f5, f6)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,27 +39,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl b/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl index 8ddfd426553..eb358fa5da1 100644 --- a/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl +++ b/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl @@ -12,46 +12,48 @@ initial_condition = initial_condition_convergence_test # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg=boundary_condition, - x_pos=boundary_condition, - y_neg=boundary_condition, - y_pos=boundary_condition, - z_neg=boundary_condition, - z_pos=boundary_condition,) +boundary_conditions = (x_neg = boundary_condition, + x_pos = boundary_condition, + y_neg = boundary_condition, + y_pos = boundary_condition, + z_neg = boundary_condition, + z_pos = boundary_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - # Transform the weird deformed cube to be approximately the cube [0,2]^3 - return SVector(x + 1, y + 1, z + 1) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + # Transform the weird deformed cube to be approximately the cube [0,2]^3 + return SVector(x + 1, y + 1, z + 1) end cells_per_dimension = (4, 4, 4) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=false) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -62,27 +64,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl index 8d651a2fcf4..52f52c5b490 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,13 +5,15 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5/3) +equations = IdealGlmMhdEquations3D(5 / 3) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=5, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 5, + surface_flux = (FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Create the mesh # Note, we use the domain [-1, 1]^3 for the Alfvén wave convergence test case so the @@ -19,13 +21,13 @@ solver = DGSEM(polydeg=5, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_no # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi, eta, zeta) - y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) + y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) - x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) + x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) - z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) + z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) - return SVector(x, y, z) + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -43,18 +45,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.2 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -62,11 +64,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_mhd_ec.jl b/examples/structured_3d_dgsem/elixir_mhd_ec.jl index a8c2288e811..5b3cd6f3718 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_ec.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_ec.jl @@ -10,31 +10,35 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Create a heavily warped curved mesh # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -52,19 +56,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -72,11 +76,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl b/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl index d669c2350a5..084e2ee962a 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl @@ -10,42 +10,46 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Create a heavily warped curved mesh # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * - cos(0.5 * pi * (2 * eta - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * - cos(2 * pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * - cos(pi * (2 * y - 3)/3) * - cos(0.5 * pi * (2 * zeta - 3)/3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * + cos(0.5 * pi * (2 * eta - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + x = xi + + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * + cos(2 * pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + z = zeta + + 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * + cos(pi * (2 * y - 3) / 3) * + cos(0.5 * pi * (2 * zeta - 3) / 3)) + + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) @@ -63,25 +67,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_advection_amr.jl b/examples/tree_1d_dgsem/elixir_advection_amr.jl index dc371233bc8..1071c98ab7e 100644 --- a/examples/tree_1d_dgsem/elixir_advection_amr.jl +++ b/examples/tree_1d_dgsem/elixir_advection_amr.jl @@ -10,18 +10,16 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0,) -coordinates_max = ( 5.0,) +coordinates_max = (5.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -31,37 +29,36 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +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=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl index 098deedb9d6..ff62e905429 100644 --- a/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl @@ -11,21 +11,19 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) initial_condition = initial_condition_gauss boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (5.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -36,40 +34,39 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +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=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, amr_callback, stepsize_callback); - ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_advection_basic.jl b/examples/tree_1d_dgsem/elixir_advection_basic.jl index d61062c772e..cba522f6366 100644 --- a/examples/tree_1d_dgsem/elixir_advection_basic.jl +++ b/examples/tree_1d_dgsem/elixir_advection_basic.jl @@ -9,19 +9,19 @@ 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate -coordinates_max = 1.0 # maximum 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 + 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) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -34,26 +34,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_1d_dgsem/elixir_advection_diffusion.jl b/examples/tree_1d_dgsem/elixir_advection_diffusion.jl index 0472bd25a71..72b8b3f1933 100644 --- a/examples/tree_1d_dgsem/elixir_advection_diffusion.jl +++ b/examples/tree_1d_dgsem/elixir_advection_diffusion.jl @@ -11,49 +11,52 @@ diffusivity() = 0.1 equations_parabolic = LaplaceDiffusion1D(diffusivity(), equations) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = -pi # minimum coordinate -coordinates_max = pi # maximum coordinate +coordinates_max = pi # 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 - periodicity=true) - -function x_trans_periodic(x, domain_length = SVector(2*pi), center = SVector(0.0)) - x_normalized = x .- center - x_shifted = x_normalized .% domain_length - x_offset = ((x_shifted .< -0.5*domain_length) - (x_shifted .> 0.5*domain_length)) .* domain_length - return center + x_shifted + x_offset + initial_refinement_level = 4, + n_cells_max = 30_000, # set maximum capacity of tree data structure + periodicity = true) + +function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0)) + x_normalized = x .- center + x_shifted = x_normalized .% domain_length + x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* + domain_length + return center + x_shifted + x_offset end # Define initial condition -function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation1D) - # Store translated coordinate for easy use of exact solution - x_trans = x_trans_periodic(x - equation.advection_velocity * t) - - nu = diffusivity() - c = 0.0 - A = 1.0 - L = 2 - f = 1/L - omega = 1.0 - scalar = c + A * sin(omega * sum(x_trans)) * exp(-nu * omega^2 * t) - return SVector(scalar) +function initial_condition_diffusive_convergence_test(x, t, + equation::LinearScalarAdvectionEquation1D) + # Store translated coordinate for easy use of exact solution + x_trans = x_trans_periodic(x - equation.advection_velocity * t) + + nu = diffusivity() + c = 0.0 + A = 1.0 + L = 2 + f = 1 / L + omega = 1.0 + scalar = c + A * sin(omega * sum(x_trans)) * exp(-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_diffusive_convergence_test, solver; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) - +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition_diffusive_convergence_test, + solver; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -67,23 +70,22 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +analysis_callback = AnalysisCallback(semi, interval = 100) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=100) +alive_callback = AliveCallback(analysis_interval = 100) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-10 time_abs_tol = 1.0e-10 -sol = solve(ode, KenCarp4(autodiff=false), abstol=time_abs_tol, reltol=time_int_tol, - save_everystep=false, callback=callbacks) +sol = solve(ode, KenCarp4(autodiff = false), abstol = time_abs_tol, reltol = time_int_tol, + save_everystep = false, callback = callbacks) # Print the timer summary summary_callback() diff --git a/examples/tree_1d_dgsem/elixir_advection_extended.jl b/examples/tree_1d_dgsem/elixir_advection_extended.jl index 5c87ac7ef5c..df185834701 100644 --- a/examples/tree_1d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_1d_dgsem/elixir_advection_extended.jl @@ -18,21 +18,20 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate -coordinates_max = 1.0 # maximum 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 - periodicity=true) + initial_refinement_level = 4, + n_cells_max = 30_000, # set maximum capacity of tree data structure + periodicity = true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -47,24 +46,24 @@ 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, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.6) +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, @@ -72,14 +71,13 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl b/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl index 28518e7276a..62701f3ecf5 100644 --- a/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl +++ b/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl @@ -10,19 +10,19 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) # Create DG solver with polynomial degree = 0, i.e., a first order finite volume solver, # with (local) Lax-Friedrichs/Rusanov flux as surface flux -solver = DGSEM(polydeg=0, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 0, surface_flux = flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate -coordinates_max = 1.0 # maximum coordinate +coordinates_max = 1.0 # maximum coordinate # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 5, + 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) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -35,22 +35,21 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +analysis_callback = AnalysisCallback(semi, interval = 100) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback) - ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks sol = solve(ode, Euler(), - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); + 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() diff --git a/examples/tree_1d_dgsem/elixir_burgers_basic.jl b/examples/tree_1d_dgsem/elixir_burgers_basic.jl index cebd9b11201..f57b8e730fe 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_basic.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_basic.jl @@ -9,18 +9,16 @@ equations = InviscidBurgersEquation1D() initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -31,29 +29,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl b/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl index 6a25f94ca05..ae2039edde6 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl @@ -8,23 +8,22 @@ using Trixi equations = InviscidBurgersEquation1D() function initial_condition_linear_stability(x, t, equation::InviscidBurgersEquation1D) - k = 1 - 2 + sinpi(k * (x[1] - 0.7)) |> SVector + k = 1 + 2 + sinpi(k * (x[1] - 0.7)) |> SVector end volume_flux = flux_ec -solver = DGSEM(polydeg=3, surface_flux=flux_ec, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ec, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = -1.0 -coordinates_max = 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_linear_stability, solver) + initial_refinement_level = 4, + n_cells_max = 10_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_linear_stability, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -35,23 +34,22 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl b/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl index 28ab7b7c768..d32b9d6f1f4 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl @@ -10,18 +10,18 @@ equations = InviscidBurgersEquation1D() basis = LobattoLegendreBasis(3) # Use shock capturing techniques to suppress oscillations at discontinuities indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=first) + alpha_max = 1.0, + alpha_min = 0.001, + alpha_smooth = true, + variable = first) -volume_flux = flux_ec +volume_flux = flux_ec surface_flux = flux_lax_friedrichs volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) - + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) + solver = DGSEM(basis, surface_flux, volume_integral) coordinate_min = 0.0 @@ -29,42 +29,41 @@ coordinate_max = 1.0 # Make sure to turn periodicity explicitly off as special boundary conditions are specified mesh = TreeMesh(coordinate_min, coordinate_max, - initial_refinement_level=6, - n_cells_max=10_000, - periodicity=false) + initial_refinement_level = 6, + n_cells_max = 10_000, + periodicity = false) # Discontinuous initial condition (Riemann Problem) leading to a rarefaction fan. function initial_condition_rarefaction(x, t, equation::InviscidBurgersEquation1D) - scalar = x[1] < 0.5 ? 0.5 : 1.5 + scalar = x[1] < 0.5 ? 0.5 : 1.5 - return SVector(scalar) -end + return SVector(scalar) +end ############################################################################### # Specify non-periodic boundary conditions function inflow(x, t, equations::InviscidBurgersEquation1D) - return initial_condition_rarefaction(coordinate_min, t, equations) + return initial_condition_rarefaction(coordinate_min, t, equations) end boundary_condition_inflow = BoundaryConditionDirichlet(inflow) function boundary_condition_outflow(u_inner, orientation, normal_direction, x, t, - surface_flux_function, equations::InviscidBurgersEquation1D) - # Calculate the boundary flux entirely from the internal solution state - flux = Trixi.flux(u_inner, normal_direction, equations) + surface_flux_function, + equations::InviscidBurgersEquation1D) + # Calculate the boundary flux entirely from the internal solution state + flux = Trixi.flux(u_inner, normal_direction, equations) - return flux + return flux end +boundary_conditions = (x_neg = boundary_condition_inflow, + x_pos = boundary_condition_outflow) -boundary_conditions = (x_neg=boundary_condition_inflow, - x_pos=boundary_condition_outflow) - initial_condition = initial_condition_rarefaction semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -75,12 +74,11 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -stepsize_callback = StepsizeCallback(cfl=0.9) +alive_callback = AliveCallback(analysis_interval = analysis_interval) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -89,9 +87,8 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation - -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=42, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 42, # 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 diff --git a/examples/tree_1d_dgsem/elixir_burgers_shock.jl b/examples/tree_1d_dgsem/elixir_burgers_shock.jl index 00b5314e19f..1f0b0e7e042 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_shock.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_shock.jl @@ -10,17 +10,17 @@ equations = InviscidBurgersEquation1D() basis = LobattoLegendreBasis(3) # Use shock capturing techniques to suppress oscillations at discontinuities indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=first) + alpha_max = 1.0, + alpha_min = 0.001, + alpha_smooth = true, + variable = first) -volume_flux = flux_ec +volume_flux = flux_ec surface_flux = flux_lax_friedrichs volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=surface_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = surface_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) @@ -29,42 +29,41 @@ coordinate_max = 1.0 # Make sure to turn periodicity explicitly off as special boundary conditions are specified mesh = TreeMesh(coordinate_min, coordinate_max, - initial_refinement_level=6, - n_cells_max=10_000, - periodicity=false) + initial_refinement_level = 6, + n_cells_max = 10_000, + periodicity = false) # Discontinuous initial condition (Riemann Problem) leading to a shock to test e.g. correct shock speed. function initial_condition_shock(x, t, equation::InviscidBurgersEquation1D) - scalar = x[1] < 0.5 ? 1.5 : 0.5 + scalar = x[1] < 0.5 ? 1.5 : 0.5 - return SVector(scalar) + return SVector(scalar) end ############################################################################### # Specify non-periodic boundary conditions function inflow(x, t, equations::InviscidBurgersEquation1D) - return initial_condition_shock(coordinate_min, t, equations) + return initial_condition_shock(coordinate_min, t, equations) end boundary_condition_inflow = BoundaryConditionDirichlet(inflow) function boundary_condition_outflow(u_inner, orientation, normal_direction, x, t, - surface_flux_function, equations::InviscidBurgersEquation1D) - # Calculate the boundary flux entirely from the internal solution state - flux = Trixi.flux(u_inner, normal_direction, equations) + surface_flux_function, + equations::InviscidBurgersEquation1D) + # Calculate the boundary flux entirely from the internal solution state + flux = Trixi.flux(u_inner, normal_direction, equations) - return flux + return flux end - -boundary_conditions = (x_neg=boundary_condition_inflow, - x_pos=boundary_condition_outflow) +boundary_conditions = (x_neg = boundary_condition_inflow, + x_pos = boundary_condition_outflow) initial_condition = initial_condition_shock semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -75,12 +74,11 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -stepsize_callback = StepsizeCallback(cfl=0.85) +alive_callback = AliveCallback(analysis_interval = analysis_interval) +stepsize_callback = StepsizeCallback(cfl = 0.85) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -89,9 +87,8 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation - -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=42, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 42, # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl b/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl index 2318063c2be..9cba4936d22 100644 --- a/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl +++ b/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl @@ -16,49 +16,47 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - # The following code is equivalent to - # phi = atan(0.0, x_norm) - # cos_phi = cos(phi) - # in 1D but faster - cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + # The following code is equivalent to + # phi = atan(0.0, x_norm) + # cos_phi = cos(phi) + # in 1D but faster + cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -69,27 +67,26 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl index d35dec6bc73..05f392624fd 100644 --- a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl +++ b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl @@ -2,7 +2,8 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.97-0.0001.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.97-0.0001.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.97-0.0001.bson", + network) model1d = load(network, @__MODULE__)[:model1d] using OrdinaryDiffEq @@ -14,7 +15,6 @@ using Trixi # University of Cologne, advisors: Gregor Gassner, Michael Schlottke-Lakemper # This motivates the particular choice of fluxes, mesh resolution etc. - ############################################################################### # semidiscretization of the compressible Euler equations @@ -29,53 +29,51 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - # The following code is equivalent to - # phi = atan(0.0, x_norm) - # cos_phi = cos(phi) - # in 1D but faster - cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + # The following code is equivalent to + # phi = atan(0.0, x_norm) + # cos_phi = cos(phi) + # in 1D but faster + cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkPerssonPeraire(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=false, - alpha_amr=false, - variable=density_pressure, - network=model1d) + indicator_type = NeuralNetworkPerssonPeraire(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = false, + alpha_amr = false, + variable = density_pressure, + network = model1d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -86,27 +84,26 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl index fb36f8540f8..de2f5134a49 100644 --- a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl +++ b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl @@ -2,7 +2,8 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnrh-0.95-0.009.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrh-0.95-0.009.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrh-0.95-0.009.bson", + network) model1d = load(network, @__MODULE__)[:model1d] using OrdinaryDiffEq @@ -14,7 +15,6 @@ using Trixi # University of Cologne, advisors: Gregor Gassner, Michael Schlottke-Lakemper # This motivates the particular choice of fluxes, mesh resolution etc. - ############################################################################### # semidiscretization of the compressible Euler equations @@ -29,53 +29,51 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - # The following code is equivalent to - # phi = atan(0.0, x_norm) - # cos_phi = cos(phi) - # in 1D but faster - cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + # The following code is equivalent to + # phi = atan(0.0, x_norm) + # cos_phi = cos(phi) + # in 1D but faster + cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkRayHesthaven(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=false, - alpha_amr=false, - variable=density_pressure, - network=model1d) + indicator_type = NeuralNetworkRayHesthaven(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = false, + alpha_amr = false, + variable = density_pressure, + network = model1d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -86,27 +84,26 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl b/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl index fe221ea5bd7..1fa07d4edda 100644 --- a/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl +++ b/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl @@ -9,19 +9,17 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_hllc, - volume_integral=VolumeIntegralPureLGLFiniteVolume(flux_hllc)) +solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, + volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc)) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -32,29 +30,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_density_wave.jl b/examples/tree_1d_dgsem/elixir_euler_density_wave.jl index 746989dfe56..01ccbb2b517 100644 --- a/examples/tree_1d_dgsem/elixir_euler_density_wave.jl +++ b/examples/tree_1d_dgsem/elixir_euler_density_wave.jl @@ -8,18 +8,16 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_density_wave -solver = DGSEM(polydeg=5, surface_flux=flux_central) +solver = DGSEM(polydeg = 5, surface_flux = flux_central) coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000) - + initial_refinement_level = 2, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -29,16 +27,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 2000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -48,7 +46,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_ec.jl b/examples/tree_1d_dgsem/elixir_euler_ec.jl index f20bd4fd69e..0be9c8fbf4c 100644 --- a/examples/tree_1d_dgsem/elixir_euler_ec.jl +++ b/examples/tree_1d_dgsem/elixir_euler_ec.jl @@ -9,19 +9,17 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -31,27 +29,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_positivity.jl b/examples/tree_1d_dgsem/elixir_euler_positivity.jl index 7942937151a..1a6017eb529 100644 --- a/examples/tree_1d_dgsem/elixir_euler_positivity.jl +++ b/examples/tree_1d_dgsem/elixir_euler_positivity.jl @@ -14,97 +14,92 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - 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 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + 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 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 4.0) ode = semidiscretize(semi, tspan) - summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorLöhner(semi, - variable=density_pressure) + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - med_level =0, med_threshold=0.1, # med_level = current level - max_level =6, max_threshold=0.3) + base_level = 4, + med_level = 0, med_threshold = 0.1, # med_level = current level + max_level = 6, max_threshold = 0.3) amr_callback = AMRCallback(semi, amr_controller, - interval=2, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 2, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) - -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) - +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl index 746a7cf1bac..f4b817c3a8c 100644 --- a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -14,96 +14,92 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - 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 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + 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 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=shock_indicator_variable) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = shock_indicator_variable) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 12.5) ode = semidiscretize(semi, tspan) - summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level=6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) 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=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl index 00b80dbae92..96f68470c85 100644 --- a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl +++ b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - 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 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + 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 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave @@ -42,59 +42,55 @@ volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=7, - n_cells_max=10_000) - + initial_refinement_level = 7, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 12.5) ode = semidiscretize(semi, tspan) - summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level=7, max_threshold=0.01) + base_level = 4, + max_level = 7, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.25) +stepsize_callback = StepsizeCallback(cfl = 0.25) 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=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl b/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl index 90547f8ddc1..08367505377 100644 --- a/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl +++ b/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl @@ -10,28 +10,26 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_shima_etal +volume_flux = flux_shima_etal basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -2.0 -coordinates_max = 2.0 +coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -41,27 +39,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl index 193c6cedc5b..442b61f8158 100644 --- a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl @@ -11,18 +11,16 @@ initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. # Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -33,29 +31,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl index 3794e0c8d54..922ac3dd97d 100644 --- a/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -13,23 +13,21 @@ initial_condition = initial_condition_convergence_test # 1*ndims == 2 directions or you can pass a tuple containing BCs for # each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg=boundary_condition, - x_pos=boundary_condition) +boundary_conditions = (x_neg = boundary_condition, + x_pos = boundary_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -40,30 +38,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl index 762ab1c90ca..6d54c6b86c9 100644 --- a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl @@ -15,11 +15,11 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler) + initial_refinement_level = 2, + n_cells_max = 10_000) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, + solver_euler) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -27,22 +27,21 @@ equations_gravity = HyperbolicDiffusionEquations1D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, - source_terms=source_terms_harmonic) - +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, + solver_gravity, + source_terms = source_terms_harmonic) ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 - gravitational_constant=1.0, # aka G - cfl=1.5, - resid_tol=1.0e-10, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!) +parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 + gravitational_constant = 1.0, # aka G + cfl = 1.5, + resid_tol = 1.0e-10, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -51,20 +50,20 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, - save_analysis=true) +analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, + save_analysis = true) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -73,11 +72,10 @@ callbacks = CallbackSet(summary_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl index 2444fe8611d..6d6316898b7 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0,) -coordinates_max = ( 1.0,) +coordinates_max = (1.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -33,27 +31,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl index 86f4a4bad04..1b37a8a2279 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4, 1.4), gas_constants = (0.4, 0.4, 0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0,) -coordinates_max = ( 1.0,) +coordinates_max = (1.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -33,27 +31,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl b/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl index 04d937a9a8f..73f8de15d82 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl @@ -4,26 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), gas_constants = (0.4, 0.4, 0.4)) - initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -34,28 +31,27 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(Trixi.density,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (Trixi.density,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_es.jl b/examples/tree_1d_dgsem/elixir_eulermulti_es.jl index 7abb3b0d021..7fbec0c0055 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_es.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_es.jl @@ -4,26 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) - initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0,) -coordinates_max = ( 2.0,) +coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -34,31 +31,30 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(Trixi.density,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (Trixi.density,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl b/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl index 81966194180..20aeaf9fb48 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl @@ -5,8 +5,8 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), - gas_constants = (0.4, 0.4, 0.4)) +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), + gas_constants = (0.4, 0.4, 0.4)) """ initial_condition_two_interacting_blast_waves(x, t, equations::CompressibleEulerMulticomponentEquations1D) @@ -16,69 +16,68 @@ A multicomponent two interacting blast wave test taken from The consistent multi-fluid advection method [arXiv: 9807241](https://arxiv.org/pdf/astro-ph/9807241.pdf) """ -function initial_condition_two_interacting_blast_waves(x, t, equations::CompressibleEulerMulticomponentEquations1D) +function initial_condition_two_interacting_blast_waves(x, t, + equations::CompressibleEulerMulticomponentEquations1D) + rho1 = 0.5 * x[1]^2 + rho2 = 0.5 * (sin(20 * x[1]))^2 + rho3 = 1 - rho1 - rho2 - rho1 = 0.5 * x[1]^2 - rho2 = 0.5 * (sin(20 * x[1]))^2 - rho3 = 1 - rho1 - rho2 + prim_rho = SVector{3, real(equations)}(rho1, rho2, rho3) - prim_rho = SVector{3, real(equations)}(rho1, rho2, rho3) + v1 = 0.0 - v1 = 0.0 + if x[1] <= 0.1 + p = 1000 + elseif x[1] < 0.9 + p = 0.01 + else + p = 100 + end - if x[1] <= 0.1 - p = 1000 - elseif x[1] < 0.9 - p = 0.01 - else - p = 100 - end + prim_other = SVector{2, real(equations)}(v1, p) - prim_other = SVector{2, real(equations)}(v1, p) - - return prim2cons(vcat(prim_other, prim_rho), equations) + return prim2cons(vcat(prim_other, prim_rho), equations) end initial_condition = initial_condition_two_interacting_blast_waves -function boundary_condition_two_interacting_blast_waves(u_inner, orientation, direction, x, t, +function boundary_condition_two_interacting_blast_waves(u_inner, orientation, direction, x, + t, surface_flux_function, equations::CompressibleEulerMulticomponentEquations1D) - - u_inner_reflect = SVector(-u_inner[1], u_inner[2], u_inner[3], u_inner[4], u_inner[5]) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_inner_reflect, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_inner_reflect, u_inner, orientation, equations) - end - - return flux + u_inner_reflect = SVector(-u_inner[1], u_inner[2], u_inner[3], u_inner[4], u_inner[5]) + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_inner_reflect, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_inner_reflect, u_inner, orientation, equations) + end + + return flux end boundary_conditions = boundary_condition_two_interacting_blast_waves surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, alpha_max = 0.8, alpha_min = 0.0, alpha_smooth = true, - variable=pressure) + variable = pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0,) coordinates_max = (1.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=9, - n_cells_max=10_000, - periodicity=false) - - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + initial_refinement_level = 9, + n_cells_max = 10_000, + periodicity = false) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -90,16 +89,16 @@ summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.1) +stepsize_callback = StepsizeCallback(cfl = 0.1) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -109,7 +108,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl index 9a19807ae29..b9173ec9f49 100644 --- a/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the hyperbolic diffusion equations -equations = HyperbolicDiffusionEquations1D(nu=1.25) +equations = HyperbolicDiffusionEquations1D(nu = 1.25) """ initial_condition_poisson_nonperiodic(x, t, equations::HyperbolicDiffusionEquations1D) @@ -16,36 +16,36 @@ A non-priodic harmonic function used in combination with !!! note The only harmonic functions in 1D have the form phi(x) = A + Bx """ -function initial_condition_harmonic_nonperiodic(x, t, equations::HyperbolicDiffusionEquations1D) - # elliptic equation: -νΔϕ = f - if t == 0.0 - phi = 5.0 - q1 = 0.0 - else - A = 3 - B = exp(1) - phi = A + B * x[1] - q1 = B - end - return SVector(phi, q1) +function initial_condition_harmonic_nonperiodic(x, t, + equations::HyperbolicDiffusionEquations1D) + # elliptic equation: -νΔϕ = f + if t == 0.0 + phi = 5.0 + q1 = 0.0 + else + A = 3 + B = exp(1) + phi = A + B * x[1] + q1 = B + end + return SVector(phi, q1) end initial_condition = initial_condition_harmonic_nonperiodic boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = -1.0 -coordinates_max = 2.0 +coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000, - periodicity=false) + initial_refinement_level = 2, + n_cells_max = 30_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions, - source_terms=source_terms_harmonic) - + boundary_conditions = boundary_conditions, + source_terms = source_terms_harmonic) ############################################################################### # ODE solvers, callbacks etc. @@ -56,30 +56,29 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.75) +stepsize_callback = StepsizeCallback(cfl = 1.75) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) - ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=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 diff --git a/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl index 827d8d25ce7..4da3b33a466 100644 --- a/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -11,19 +11,18 @@ initial_condition = initial_condition_poisson_nonperiodic boundary_conditions = boundary_condition_poisson_nonperiodic -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000, - periodicity=false) + initial_refinement_level = 3, + n_cells_max = 30_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions, - source_terms=source_terms_poisson_nonperiodic) - + boundary_conditions = boundary_conditions, + source_terms = source_terms_poisson_nonperiodic) ############################################################################### # ODE solvers, callbacks etc. @@ -34,31 +33,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl b/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl index 82bca93c707..1a66ac60b9b 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations1D(gamma) initial_condition = initial_condition_convergence_test volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,32 +30,33 @@ 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), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl index 0e25ac6ac6c..7be8492cad1 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl @@ -17,46 +17,44 @@ MHD extension of the Sod shock tube. Taken from Section V of the article [DOI: 10.1016/0021-9991(88)90120-9](https://doi.org/10.1016/0021-9991(88)90120-9) """ function initial_condition_briowu_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [0, 1], γ = 2, final time = 0.12 - rho = x[1] < 0.5 ? 1.0 : 0.125 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = x[1] < 0.5 ? 1.0 : 0.1 - B1 = 0.75 - B2 = x[1] < 0.5 ? 1.0 : -1.0 - B3 = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [0, 1], γ = 2, final time = 0.12 + rho = x[1] < 0.5 ? 1.0 : 0.125 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = x[1] < 0.5 ? 1.0 : 0.1 + B1 = 0.75 + B2 = x[1] < 0.5 ? 1.0 : -1.0 + B3 = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_briowu_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = FluxHLL(min_max_speed_einfeldt) -volume_flux = flux_derigs_etal +volume_flux = flux_derigs_etal basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -67,45 +65,44 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level=6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.65) +stepsize_callback = StepsizeCallback(cfl = 0.65) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_ec.jl b/examples/tree_1d_dgsem/elixir_mhd_ec.jl index 1f2e77006b1..e5da808f696 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_ec.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_ec.jl @@ -10,19 +10,17 @@ equations = IdealGlmMhdEquations1D(gamma) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg=3, surface_flux=flux_hindenlang_gassner, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_hindenlang_gassner, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,29 +30,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl index 0dbb21ad686..262c90b7dac 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations1D(gamma) """ @@ -22,48 +22,46 @@ present in the one dimensional MHD equations. It is the second test from Section This paper has a typo in the initial conditions. Their variable `E` should be `p`. """ function initial_condition_ryujones_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [0, 1], γ = 5/3, final time = 0.2 - rho = x[1] <= 0.5 ? 1.08 : 1.0 - v1 = x[1] <= 0.5 ? 1.2 : 0.0 - v2 = x[1] <= 0.5 ? 0.01 : 0.0 - v3 = x[1] <= 0.5 ? 0.5 : 0.0 - p = x[1] <= 0.5 ? 0.95 : 1.0 - inv_sqrt4pi = 1.0 / sqrt(4 * pi) - B1 = 2 * inv_sqrt4pi - B2 = x[1] <= 0.5 ? 3.6 * inv_sqrt4pi : 4.0 * inv_sqrt4pi - B3 = B1 - - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [0, 1], γ = 5/3, final time = 0.2 + rho = x[1] <= 0.5 ? 1.08 : 1.0 + v1 = x[1] <= 0.5 ? 1.2 : 0.0 + v2 = x[1] <= 0.5 ? 0.01 : 0.0 + v3 = x[1] <= 0.5 ? 0.5 : 0.0 + p = x[1] <= 0.5 ? 0.95 : 1.0 + inv_sqrt4pi = 1.0 / sqrt(4 * pi) + B1 = 2 * inv_sqrt4pi + B2 = x[1] <= 0.5 ? 3.6 * inv_sqrt4pi : 4.0 * inv_sqrt4pi + B3 = B1 + + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_ryujones_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = FluxHLL(min_max_speed_einfeldt) -volume_flux = flux_hindenlang_gassner +volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=Trixi.density) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = Trixi.density) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=7, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 7, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -74,27 +72,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl index 860698d7880..9a9ace4710f 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations1D(gamma) """ @@ -17,19 +17,19 @@ Taken from Section 4.1 of [DOI: 10.1016/j.jcp.2016.04.048](https://doi.org/10.1016/j.jcp.2016.04.048) """ function initial_condition_shu_osher_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 - # initial shock location is taken to be at x = -4 - x_0 = -4.0 - rho = x[1] <= x_0 ? 3.5 : 1.0 + 0.2 * sin(5.0 * x[1]) - v1 = x[1] <= x_0 ? 5.8846 : 0.0 - v2 = x[1] <= x_0 ? 1.1198 : 0.0 - v3 = 0.0 - p = x[1] <= x_0 ? 42.0267 : 1.0 - B1 = 1.0 - B2 = x[1] <= x_0 ? 3.6359 : 1.0 - B3 = 0.0 - - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 + # initial shock location is taken to be at x = -4 + x_0 = -4.0 + rho = x[1] <= x_0 ? 3.5 : 1.0 + 0.2 * sin(5.0 * x[1]) + v1 = x[1] <= x_0 ? 5.8846 : 0.0 + v2 = x[1] <= x_0 ? 1.1198 : 0.0 + v3 = 0.0 + p = x[1] <= x_0 ? 42.0267 : 1.0 + B1 = 1.0 + B2 = x[1] <= x_0 ? 3.6359 : 1.0 + B3 = 0.0 + + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end """ @@ -41,50 +41,49 @@ but shock propagates from right to left. !!! note This is useful to exercise some of the components of the HLL flux. """ -function initial_condition_shu_osher_shock_tube_flipped(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 - # initial shock location is taken to be at x = 4 - x_0 = 4.0 - rho = x[1] <= x_0 ? 1.0 + 0.2 * sin(5.0 * x[1]) : 3.5 - v1 = x[1] <= x_0 ? 0.0 : -5.8846 - v2 = x[1] <= x_0 ? 0.0 : -1.1198 - v3 = 0.0 - p = x[1] <= x_0 ? 1.0 : 42.0267 - B1 = 1.0 - B2 = x[1] <= x_0 ? 1.0 : 3.6359 - B3 = 0.0 - - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) +function initial_condition_shu_osher_shock_tube_flipped(x, t, + equations::IdealGlmMhdEquations1D) + # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 + # initial shock location is taken to be at x = 4 + x_0 = 4.0 + rho = x[1] <= x_0 ? 1.0 + 0.2 * sin(5.0 * x[1]) : 3.5 + v1 = x[1] <= x_0 ? 0.0 : -5.8846 + v2 = x[1] <= x_0 ? 0.0 : -1.1198 + v3 = 0.0 + p = x[1] <= x_0 ? 1.0 : 42.0267 + B1 = 1.0 + B2 = x[1] <= x_0 ? 1.0 : 3.6359 + B3 = 0.0 + + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_shu_osher_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = FluxHLL(min_max_speed_einfeldt) -volume_flux = flux_hindenlang_gassner +volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -5.0 -coordinates_max = 5.0 +coordinates_max = 5.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -95,42 +94,43 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level=7, max_threshold=0.01) + base_level = 4, + max_level = 7, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl index 68556764293..3b366c35e0f 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations1D(gamma) """ @@ -16,46 +16,44 @@ Torrilhon's shock tube test case for one dimensional ideal MHD equations. [DOI: 10.1017/S0022377803002186](https://doi.org/10.1017/S0022377803002186) """ function initial_condition_torrilhon_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [-1, 1.5], γ = 5/3, final time = 0.4 - rho = x[1] <= 0 ? 3.0 : 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = x[1] <= 0 ? 3.0 : 1.0 - B1 = 1.5 - B2 = x[1] <= 0 ? 1.0 : cos(1.5) - B3 = x[1] <= 0 ? 0.0 : sin(1.5) - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [-1, 1.5], γ = 5/3, final time = 0.4 + rho = x[1] <= 0 ? 3.0 : 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = x[1] <= 0 ? 3.0 : 1.0 + B1 = 1.5 + B2 = x[1] <= 0 ? 1.0 : cos(1.5) + B3 = x[1] <= 0 ? 0.0 : sin(1.5) + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_torrilhon_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = flux_lax_friedrichs -volume_flux = flux_central +volume_flux = flux_central basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -1.0 -coordinates_max = 1.5 +coordinates_max = 1.5 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=7, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 7, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -66,29 +64,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl index 376f11d52a2..831fa7afedb 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl @@ -4,8 +4,8 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0), - gas_constants = (2.0, 2.0)) +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0), + gas_constants = (2.0, 2.0)) """ initial_condition_briowu_shock_tube(x, t, equations::IdealGlmMhdMulticomponentEquations1D) @@ -16,55 +16,62 @@ MHD extension of the Sod shock tube. Taken from Section V of the article An Upwind Differencing Scheme for the Equations of Ideal Magnetohydrodynamics [DOI: 10.1016/0021-9991(88)90120-9](https://doi.org/10.1016/0021-9991(88)90120-9) """ -function initial_condition_briowu_shock_tube(x, t, equations::IdealGlmMhdMulticomponentEquations1D) - # domain must be set to [0, 1], γ = 2, final time = 0.12 - if x[1] < 0.5 - rho = 1.0 - prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i-1) * (1-2)/(1-2^ncomponents(equations)) * rho for i in eachcomponent(equations)) - else - rho = 0.125 - prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i-1) * (1-2)/(1-2^ncomponents(equations)) * rho for i in eachcomponent(equations)) - end - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = x[1] < 0.5 ? 1.0 : 0.1 - B1 = 0.75 - B2 = x[1] < 0.5 ? 1.0 : -1.0 - B3 = 0.0 - - prim_other = SVector(v1, v2, v3, p, B1, B2, B3) - return prim2cons(vcat(prim_other, prim_rho), equations) +function initial_condition_briowu_shock_tube(x, t, + equations::IdealGlmMhdMulticomponentEquations1D) + # domain must be set to [0, 1], γ = 2, final time = 0.12 + if x[1] < 0.5 + rho = 1.0 + prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i - 1) * (1 - 2) / + (1 - + 2^ncomponents(equations)) * + rho + for i in eachcomponent(equations)) + else + rho = 0.125 + prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i - 1) * (1 - 2) / + (1 - + 2^ncomponents(equations)) * + rho + for i in eachcomponent(equations)) + end + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = x[1] < 0.5 ? 1.0 : 0.1 + B1 = 0.75 + B2 = x[1] < 0.5 ? 1.0 : -1.0 + B3 = 0.0 + + prim_other = SVector(v1, v2, v3, p, B1, B2, B3) + return prim2cons(vcat(prim_other, prim_rho), equations) end initial_condition = initial_condition_briowu_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = flux_lax_friedrichs -volume_flux = flux_hindenlang_gassner +volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.8, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.8, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -75,45 +82,44 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level=6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl index 573bf6bc3e9..a1636c08478 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl @@ -5,25 +5,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (5/3, 5/3, 5/3), - gas_constants = (2.08, 2.08, 2.08)) +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (5 / 3, 5 / 3, 5 / 3), + gas_constants = (2.08, 2.08, 2.08)) initial_condition = initial_condition_convergence_test volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -33,17 +31,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 0.5 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -51,11 +50,10 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl index 69ea0551bed..71466f3138a 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), gas_constants = (2.0, 2.0, 2.0)) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg=3, surface_flux=flux_hindenlang_gassner, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_hindenlang_gassner, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,26 +30,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl index 93cf3e0fdb2..37623e048ed 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), gas_constants = (2.0, 2.0, 2.0)) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,29 +30,28 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl b/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl index 1469afec1ca..a3df37fb966 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl @@ -6,7 +6,7 @@ using Trixi # Semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations1D(gravity_constant=9.81) +equations = ShallowWaterEquations1D(gravity_constant = 9.81) # Initial condition with a truly discontinuous water height, velocity, and bottom # topography function as an academic testcase for entropy conservation. @@ -16,23 +16,23 @@ equations = ShallowWaterEquations1D(gravity_constant=9.81) # 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_discontinuous_bottom(x, t, equations::ShallowWaterEquations1D) - # Set the background values - H = 4.25 - v = 0.0 - b = sin(x[1]) # arbitrary continuous function - - # Setup the discontinuous water height and velocity - if x[1] >= 0.125 && x[1] <= 0.25 - H = 5.0 - v = 0.1882 - end - - # Setup a discontinuous bottom topography - if x[1] >= -0.25 && x[1] <= -0.125 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) - end - - return prim2cons(SVector(H, v, b), equations) + # Set the background values + H = 4.25 + v = 0.0 + b = sin(x[1]) # arbitrary continuous function + + # Setup the discontinuous water height and velocity + if x[1] >= 0.125 && x[1] <= 0.25 + H = 5.0 + v = 0.1882 + end + + # Setup a discontinuous bottom topography + if x[1] >= -0.25 && x[1] <= -0.125 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + end + + return prim2cons(SVector(H, v, b), equations) end initial_condition = initial_condition_ec_discontinuous_bottom @@ -41,8 +41,9 @@ initial_condition = initial_condition_ec_discontinuous_bottom # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -50,8 +51,8 @@ solver = DGSEM(polydeg=4, surface_flux=(flux_fjordholm_etal, flux_nonconservativ coordinates_min = -1.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) + initial_refinement_level = 4, + n_cells_max = 10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -68,15 +69,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -84,7 +85,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl b/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl index 62346d7b5ab..6ef697b0b89 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl @@ -5,36 +5,38 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant=9.812, H0=1.75) +equations = ShallowWaterEquations1D(gravity_constant = 9.812, H0 = 1.75) # Initial condition with a truly discontinuous velocity and bottom topography. # Works as intended for TreeMesh1D with `initial_refinement_level=3`. 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_stone_throw_discontinuous_bottom(x, t, equations::ShallowWaterEquations1D) +function initial_condition_stone_throw_discontinuous_bottom(x, t, + equations::ShallowWaterEquations1D) - # Calculate primitive variables + # Calculate primitive variables - # flat lake - H = equations.H0 + # flat lake + H = equations.H0 - # Discontinuous velocity - v = 0.0 - if x[1] >= -0.75 && x[1] <= 0.0 - v = -1.0 - elseif x[1] >= 0.0 && x[1] <= 0.75 - v = 1.0 - end + # Discontinuous velocity + v = 0.0 + if x[1] >= -0.75 && x[1] <= 0.0 + v = -1.0 + elseif x[1] >= 0.0 && x[1] <= 0.75 + v = 1.0 + end - b = ( 1.5 / exp( 0.5 * ((x[1] - 1.0)^2 ) ) - + 0.75 / exp( 0.5 * ((x[1] + 1.0)^2 ) ) ) + b = (1.5 / exp(0.5 * ((x[1] - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) - # Force a discontinuous bottom topography - if x[1] >= -1.5 && x[1] <= 0.0 - b = 0.5 - end + # Force a discontinuous bottom topography + if x[1] >= -1.5 && x[1] <= 0.0 + b = 0.5 + end - return prim2cons(SVector(H, v, b), equations) + return prim2cons(SVector(H, v, b), equations) end initial_condition = initial_condition_stone_throw_discontinuous_bottom @@ -45,18 +47,19 @@ boundary_condition = boundary_condition_slip_wall # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), +surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, + hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal) basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=waterheight_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = waterheight_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) @@ -66,9 +69,9 @@ solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -3.0 coordinates_max = 3.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=false) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, @@ -86,28 +89,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(energy_kinetic, - energy_internal, - lake_at_rest_error)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (energy_kinetic, + energy_internal, + lake_at_rest_error)) # Enable in-situ visualization with a new plot generated every 50 time steps # and we explicitly pass that the plot data will be one-dimensional # visualization = VisualizationCallback(interval=50, plot_data_creator=PlotData1D) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)#, - # visualization) +# visualization) ############################################################################### # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-7, reltol=1.0e-7, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl index 2f9f93f4335..af596a377f8 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,17 +5,17 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant=9.81) +equations = ShallowWaterEquations1D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test - ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -23,13 +23,13 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservativ coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,13 +40,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -54,6 +54,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl index c8ef1c1b70b..cbc98a30f9f 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant=9.81) +equations = ShallowWaterEquations1D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test @@ -16,8 +16,8 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=3, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -25,14 +25,14 @@ solver = DGSEM(polydeg=3, surface_flux=surface_flux, coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=false) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions = boundary_condition, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -43,13 +43,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -57,6 +57,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl index e9f444aed27..fc76b4f034b 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl @@ -5,18 +5,18 @@ using Trixi ############################################################################### # Semidiscretization of the two-layer shallow water equations -equations = ShallowWaterTwoLayerEquations1D(gravity_constant=10.0, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations1D(gravity_constant = 10.0, rho_upper = 0.9, + rho_lower = 1.0) initial_condition = initial_condition_convergence_test - ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) - +solver = DGSEM(polydeg = 3, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -24,13 +24,13 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservativ coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -41,13 +41,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=500, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 500, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -55,6 +55,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control - sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, - save_everystep=false, callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-8, reltol = 1.0e-8, + save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl index 60770d158fa..b2e6a81401b 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl @@ -6,28 +6,29 @@ using Trixi # Semidiscretization of the two-layer shallow water equations for a dam break # test with a discontinuous bottom topography function to test entropy conservation -equations = ShallowWaterTwoLayerEquations1D(gravity_constant=9.81, H0=2.0, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations1D(gravity_constant = 9.81, H0 = 2.0, + rho_upper = 0.9, rho_lower = 1.0) # Initial condition of a dam break with a discontinuous water heights and bottom topography. # Works as intended for TreeMesh1D with `initial_refinement_level=5`. 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_dam_break(x, t, equations::ShallowWaterTwoLayerEquations1D) - v1_upper = 0.0 - v1_lower = 0.0 - - # Set the discontinuity - if x[1] <= 10.0 - H_lower = 2.0 - H_upper = 4.0 - b = 0.0 - else - H_lower = 1.5 - H_upper = 3.0 - b = 0.5 - end - - return prim2cons(SVector(H_upper, v1_upper, H_lower, v1_lower, b), equations) + v1_upper = 0.0 + v1_lower = 0.0 + + # Set the discontinuity + if x[1] <= 10.0 + H_lower = 2.0 + H_upper = 4.0 + b = 0.0 + else + H_lower = 1.5 + H_upper = 3.0 + b = 0.5 + end + + return prim2cons(SVector(H_upper, v1_upper, H_lower, v1_lower, b), equations) end initial_condition = initial_condition_dam_break @@ -36,8 +37,9 @@ initial_condition = initial_condition_dam_break # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a non-periodic mesh @@ -45,20 +47,20 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservativ coordinates_min = 0.0 coordinates_max = 20.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10000, - periodicity=false) + initial_refinement_level = 5, + n_cells_max = 10000, + periodicity = false) boundary_condition = boundary_condition_slip_wall # create the semidiscretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_condition) + boundary_conditions = boundary_condition) ############################################################################### # ODE solvers -tspan = (0.0,0.4) +tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) ############################################################################### @@ -67,16 +69,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (energy_total, + energy_kinetic, + energy_internal)) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=500, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 500, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -84,6 +89,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, - save_everystep=false, callback=callbacks); -summary_callback() # print the timer summary \ No newline at end of file +sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-8, reltol = 1.0e-8, + save_everystep = false, callback = callbacks); +summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl index bec0b8ab69c..7236f1697d0 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl @@ -5,7 +5,8 @@ using Trixi ############################################################################### # Semidiscretization of the two-layer shallow water equations to test well-balancedness -equations = ShallowWaterTwoLayerEquations1D(gravity_constant=1.0, H0=0.6, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations1D(gravity_constant = 1.0, H0 = 0.6, + rho_upper = 0.9, rho_lower = 1.0) """ initial_condition_fjordholm_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations1D) @@ -15,7 +16,8 @@ Initial condition to test well balanced with a bottom topography from Fjordholm Energy conservative and stable schemes for the two-layer shallow water equations. [DOI: 10.1142/9789814417099_0039](https://doi.org/10.1142/9789814417099_0039) """ -function initial_condition_fjordholm_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations1D) +function initial_condition_fjordholm_well_balanced(x, t, + equations::ShallowWaterTwoLayerEquations1D) inicenter = 0.5 x_norm = x[1] - inicenter r = abs(x_norm) @@ -24,9 +26,9 @@ function initial_condition_fjordholm_well_balanced(x, t, equations::ShallowWater H_upper = 0.6 v1_upper = 0.0 v1_lower = 0.0 - b = r <= 0.1 ? 0.2 * (cos(10 * pi * (x[1] - 0.5)) + 1) : 0.0 + b = r <= 0.1 ? 0.2 * (cos(10 * pi * (x[1] - 0.5)) + 1) : 0.0 return prim2cons(SVector(H_upper, v1_upper, H_lower, v1_lower, b), equations) - end +end initial_condition = initial_condition_fjordholm_well_balanced @@ -34,8 +36,9 @@ initial_condition = initial_condition_fjordholm_well_balanced # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -43,9 +46,9 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_es_fjordholm_etal, flux_nonconserva coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -59,16 +62,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (lake_at_rest_error,)) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -76,7 +80,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl index e07bc04d76a..649e5023f6d 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations1D(gravity_constant=9.81, H0=3.25) +equations = ShallowWaterEquations1D(gravity_constant = 9.81, H0 = 3.25) # Setup a truly discontinuous bottom topography function for this academic # testcase of well-balancedness. The errors from the analysis callback are @@ -15,18 +15,19 @@ equations = ShallowWaterEquations1D(gravity_constant=9.81, H0=3.25) # Works as intended for TreeMesh1D with `initial_refinement_level=3`. 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_discontinuous_well_balancedness(x, t, equations::ShallowWaterEquations1D) - # Set the background values - H = equations.H0 - v = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography - if x[1] >= 0.5 && x[1] <= 0.75 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) - end - - return prim2cons(SVector(H, v, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, + equations::ShallowWaterEquations1D) + # Set the background values + H = equations.H0 + v = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography + if x[1] >= 0.5 && x[1] <= 0.75 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + end + + return prim2cons(SVector(H, v, b), equations) end initial_condition = initial_condition_discontinuous_well_balancedness @@ -36,17 +37,17 @@ initial_condition = initial_condition_discontinuous_well_balancedness volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=4, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000) + initial_refinement_level = 3, + n_cells_max = 10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -63,16 +64,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -80,7 +81,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl index 4dff087390d..78bdc57e548 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl @@ -5,19 +5,19 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant=1.0, H0=3.0) +equations = ShallowWaterEquations1D(gravity_constant = 1.0, H0 = 3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations1D) - # Set the background values - H = equations.H0 - v = 0.0 + # Set the background values + H = equations.H0 + v = 0.0 - b = (1.5 / exp( 0.5 * ((x[1] - 1.0)^2))+ 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) + b = (1.5 / exp(0.5 * ((x[1] - 1.0)^2)) + 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) - return prim2cons(SVector(H, v, b), equations) + return prim2cons(SVector(H, v, b), equations) end - + initial_condition = initial_condition_well_balancedness boundary_condition = BoundaryConditionDirichlet(initial_condition) @@ -26,8 +26,10 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, + surface_flux = (FluxHLL(min_max_speed_naive), + flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -35,9 +37,9 @@ solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonco coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=false) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, @@ -52,25 +54,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, +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); +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 diff --git a/examples/tree_1d_fdsbp/elixir_burgers_basic.jl b/examples/tree_1d_fdsbp/elixir_burgers_basic.jl index c7b0176dfdc..c58fc497e14 100644 --- a/examples/tree_1d_fdsbp/elixir_burgers_basic.jl +++ b/examples/tree_1d_fdsbp/elixir_burgers_basic.jl @@ -12,24 +12,23 @@ equations = InviscidBurgersEquation1D() initial_condition = initial_condition_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=32) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 32) flux_splitting = splitting_lax_friedrichs solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000) + initial_refinement_level = 3, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,25 +39,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_errors=(:l2_error_primitive, - :linf_error_primitive)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-9, reltol=1.0e-9, - ode_default_options()..., callback=callbacks); +sol = solve(ode, SSPRK43(); abstol = 1.0e-9, reltol = 1.0e-9, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl b/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl index 20508feba22..eeaae7a7843 100644 --- a/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl +++ b/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl @@ -10,28 +10,28 @@ using Trixi equations = InviscidBurgersEquation1D() function initial_condition_linear_stability(x, t, equation::InviscidBurgersEquation1D) - k = 1 - 2 + sinpi(k * (x[1] - 0.7)) |> SVector + k = 1 + 2 + sinpi(k * (x[1] - 0.7)) |> SVector end D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_lax_friedrichs solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = -1.0 -coordinates_max = 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_linear_stability, solver) + initial_refinement_level = 4, + n_cells_max = 10_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_linear_stability, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -42,19 +42,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_errors=(:l2_error_primitive, - :linf_error_primitive)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_fdsbp/elixir_euler_convergence.jl b/examples/tree_1d_fdsbp/elixir_euler_convergence.jl index f9f9297f7c8..7b6bfee946e 100644 --- a/examples/tree_1d_fdsbp/elixir_euler_convergence.jl +++ b/examples/tree_1d_fdsbp/elixir_euler_convergence.jl @@ -12,24 +12,23 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=32) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 32) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=1, - n_cells_max=10_000) + initial_refinement_level = 1, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,25 +39,24 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_errors = (:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl b/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl index 5c5192a3fbe..a28cd01120b 100644 --- a/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl +++ b/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl @@ -11,24 +11,23 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_density_wave D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_coirier_vanleer solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000) + initial_refinement_level = 2, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -38,23 +37,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 10000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl b/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl index d34399a5576..615da951871 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl @@ -4,26 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global=(0.5, 0.3), c_mean_global=2.0, - rho_mean_global=0.9) +equations = AcousticPerturbationEquations2D(v_mean_global = (0.5, 0.3), c_mean_global = 2.0, + rho_mean_global = 0.9) initial_condition = initial_condition_convergence_test # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max = (2.0, 2.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 3, + 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, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -37,26 +36,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) # 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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl b/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl index fa608e78693..b3fe55dccea 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl @@ -10,20 +10,19 @@ rho_mean_global = 1.0 equations = AcousticPerturbationEquations2D(v_mean_global, c_mean_global, rho_mean_global) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # 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 + 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_gauss, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -36,26 +35,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) # 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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl b/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl index 78102eaf874..918c0831fcd 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl @@ -4,20 +4,20 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global=(0.5, 0.0), c_mean_global=1.0, - rho_mean_global=1.0) +equations = AcousticPerturbationEquations2D(v_mean_global = (0.5, 0.0), c_mean_global = 1.0, + rho_mean_global = 1.0) # Create DG solver with polynomial degree = 5 and (local) Lax-Friedrichs/Rusanov flux as surface flux -solver = DGSEM(polydeg=5, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs) coordinates_min = (-100.0, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max = (100.0, 200.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=100_000, - periodicity=false) + initial_refinement_level = 4, + n_cells_max = 100_000, + periodicity = false) """ initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D) @@ -26,20 +26,19 @@ A Gaussian pulse, used in the `gauss_wall` example elixir in combination with [`boundary_condition_wall`](@ref). Uses the global mean values from `equations`. """ function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D) - v1_prime = 0.0 - v2_prime = 0.0 - p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) + v1_prime = 0.0 + v2_prime = 0.0 + p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) - prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) + prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) - return prim2cons(prim, equations) + return prim2cons(prim, equations) end initial_condition = initial_condition_gauss_wall # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_condition_wall) - + boundary_conditions = boundary_condition_wall) ############################################################################### # ODE solvers, callbacks etc. @@ -53,24 +52,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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=cons2state) +save_solution = SaveSolutionCallback(interval = 100, solution_variables = cons2state) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=0.7) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks) +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) # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl b/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl index 0a0e2520581..71d4f1a9f68 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl @@ -3,45 +3,45 @@ using Trixi # Oscillating Gaussian-shaped source terms function source_terms_gauss(u, x, t, equations::AcousticPerturbationEquations2D) - r = 0.1 - A = 1.0 - f = 2.0 + r = 0.1 + A = 1.0 + f = 2.0 - # Velocity sources - s1 = 0.0 - s2 = 0.0 - # Pressure source - s3 = exp(-(x[1]^2 + x[2]^2) / (2 * r^2)) * A * sin(2 * pi * f * t) + # Velocity sources + s1 = 0.0 + s2 = 0.0 + # Pressure source + s3 = exp(-(x[1]^2 + x[2]^2) / (2 * r^2)) * A * sin(2 * pi * f * t) - # Mean sources - s4 = s5 = s6 = s7 = 0.0 + # Mean sources + s4 = s5 = s6 = s7 = 0.0 - return SVector(s1, s2, s3, s4, s5, s6, s7) + return SVector(s1, s2, s3, s4, s5, s6, s7) end ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global=(-0.5, 0.25), c_mean_global=1.0, - rho_mean_global=1.0) +equations = AcousticPerturbationEquations2D(v_mean_global = (-0.5, 0.25), + c_mean_global = 1.0, + rho_mean_global = 1.0) initial_condition = initial_condition_constant # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-3.0, -3.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 3.0, 3.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (3.0, 3.0) # maximum coordinates (max(x), max(y)) # 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 + 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, solver, - source_terms=source_terms_gauss) - + source_terms = source_terms_gauss) ############################################################################### # ODE solvers, callbacks etc. @@ -55,30 +55,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +save_solution = SaveSolutionCallback(interval = 100, + solution_variables = cons2prim) # The TimeSeriesCallback records the solution at the given points over time time_series = TimeSeriesCallback(semi, [(0.0, 0.0), (-1.0, 0.5)]) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) # 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, time_series, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl b/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl index 0fdcbd22c44..d7265775114 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl @@ -4,11 +4,11 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global=(0.0, 0.0), c_mean_global=0.0, - rho_mean_global=0.0) +equations = AcousticPerturbationEquations2D(v_mean_global = (0.0, 0.0), c_mean_global = 0.0, + rho_mean_global = 0.0) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-20.6, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max = (30.6, 51.2) # maximum coordinates (max(x), max(y)) @@ -20,20 +20,20 @@ Initial condition for the monopole in a boundary layer setup, used in combinatio [`boundary_condition_monopole`](@ref). """ function initial_condition_monopole(x, t, equations::AcousticPerturbationEquations2D) - m = 0.3 # Mach number + m = 0.3 # Mach number - v1_prime = 0.0 - v2_prime = 0.0 - p_prime = 0.0 + v1_prime = 0.0 + v2_prime = 0.0 + p_prime = 0.0 - v1_mean = x[2] > 1 ? m : m * (2*x[2] - 2*x[2]^2 + x[2]^4) - v2_mean = 0.0 - c_mean = 1.0 - rho_mean = 1.0 + v1_mean = x[2] > 1 ? m : m * (2 * x[2] - 2 * x[2]^2 + x[2]^4) + v2_mean = 0.0 + c_mean = 1.0 + rho_mean = 1.0 - prim = SVector(v1_prime, v2_prime, p_prime, v1_mean, v2_mean, c_mean, rho_mean) + prim = SVector(v1_prime, v2_prime, p_prime, v1_mean, v2_mean, c_mean, rho_mean) - return prim2cons(prim, equations) + return prim2cons(prim, equations) end initial_condition = initial_condition_monopole # does not use the global mean values given above @@ -45,32 +45,35 @@ Boundary condition for a monopole in a boundary layer at the -y boundary, i.e. ` This will return an error for any other direction. This boundary condition is used in combination with [`initial_condition_monopole`](@ref). """ -function boundary_condition_monopole(u_inner, orientation, direction, x, t, surface_flux_function, +function boundary_condition_monopole(u_inner, orientation, direction, x, t, + surface_flux_function, equations::AcousticPerturbationEquations2D) - if direction != 3 - error("expected direction = 3, got $direction instead") - end - - # Wall at the boundary in -y direction with a monopole at -0.05 <= x <= 0.05. In the monopole area - # we use a sinusoidal boundary state for the perturbed variables. For the rest of the -y boundary - # we set the boundary state to the inner state and multiply the perturbed velocity in the - # y-direction by -1. - if -0.05 <= x[1] <= 0.05 # Monopole - v1_prime = 0.0 - v2_prime = p_prime = sin(2 * pi * t) - - prim_boundary = SVector(v1_prime, v2_prime, p_prime, u_inner[4], u_inner[5], u_inner[6], u_inner[7]) - - u_boundary = prim2cons(prim_boundary, equations) - else # Wall - u_boundary = SVector(u_inner[1], -u_inner[2], u_inner[3], u_inner[4], u_inner[5], u_inner[6], - u_inner[7]) - end - - # Calculate boundary flux - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + if direction != 3 + error("expected direction = 3, got $direction instead") + end + + # Wall at the boundary in -y direction with a monopole at -0.05 <= x <= 0.05. In the monopole area + # we use a sinusoidal boundary state for the perturbed variables. For the rest of the -y boundary + # we set the boundary state to the inner state and multiply the perturbed velocity in the + # y-direction by -1. + if -0.05 <= x[1] <= 0.05 # Monopole + v1_prime = 0.0 + v2_prime = p_prime = sin(2 * pi * t) + + prim_boundary = SVector(v1_prime, v2_prime, p_prime, u_inner[4], u_inner[5], + u_inner[6], u_inner[7]) + + u_boundary = prim2cons(prim_boundary, equations) + else # Wall + u_boundary = SVector(u_inner[1], -u_inner[2], u_inner[3], u_inner[4], u_inner[5], + u_inner[6], + u_inner[7]) + end + + # Calculate boundary flux + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - return flux + return flux end """ @@ -80,42 +83,42 @@ end Boundary condition that uses a boundary state where the state variables are zero and the mean variables are the same as in `u_inner`. """ -function boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function, +function boundary_condition_zero(u_inner, orientation, direction, x, t, + surface_flux_function, equations::AcousticPerturbationEquations2D) - value = zero(eltype(u_inner)) - u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) + value = zero(eltype(u_inner)) + u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end - return flux + return flux end -boundary_conditions = (x_neg=boundary_condition_zero, - x_pos=boundary_condition_zero, - y_neg=boundary_condition_monopole, - y_pos=boundary_condition_zero) +boundary_conditions = (x_neg = boundary_condition_zero, + x_pos = boundary_condition_zero, + y_neg = boundary_condition_monopole, + y_pos = boundary_condition_zero) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=100_000, - periodicity=false) + initial_refinement_level = 6, + n_cells_max = 100_000, + periodicity = false) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. # Create ODE problem with time span from 0.0 to 24.0 -tspan = (0.0, 24.0) +tspan = (0.0, 24.0) ode = semidiscretize(semi, tspan) # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup @@ -123,24 +126,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks) +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) # Print the timer summary -summary_callback() \ No newline at end of file +summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_amr.jl b/examples/tree_2d_dgsem/elixir_advection_amr.jl index 84841877448..c3f971d2ffc 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr.jl @@ -9,18 +9,16 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -30,37 +28,36 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +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=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl b/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl index 897d3569e10..aa042e7500e 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl @@ -3,7 +3,6 @@ using OrdinaryDiffEq using Trixi - # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -11,27 +10,27 @@ module TrixiExtensionCoarsen using Trixi -struct IndicatorAlwaysCoarsen{Cache<:NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorAlwaysCoarsen{Cache <: NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorAlwaysCoarsen(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) - return IndicatorAlwaysCoarsen{typeof(cache)}(cache) + return IndicatorAlwaysCoarsen{typeof(cache)}(cache) end -function (indicator::IndicatorAlwaysCoarsen)(u::AbstractArray{<:Any,4}, +function (indicator::IndicatorAlwaysCoarsen)(u::AbstractArray{<:Any, 4}, mesh, equations, dg, cache; t, kwargs...) - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) - alpha .= -1.0 + alpha .= -1.0 - return alpha + return alpha end end # module TrixiExtensionCoarsen @@ -46,18 +45,16 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -67,37 +64,37 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_controller = ControllerThreeLevel(semi, TrixiExtensionCoarsen.IndicatorAlwaysCoarsen(semi), - base_level=2, max_level=2, - med_threshold=0.1, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, + TrixiExtensionCoarsen.IndicatorAlwaysCoarsen(semi), + base_level = 2, max_level = 2, + med_threshold = 0.1, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl index 42aee985889..abb8a5035be 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl @@ -14,19 +14,17 @@ initial_condition = initial_condition_gauss # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 30_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -37,26 +35,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +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=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -65,7 +63,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = stepsize_callback(ode), # 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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl b/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl index e69cab29bb6..7b441775204 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl @@ -3,7 +3,6 @@ using OrdinaryDiffEq using Trixi - # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -11,27 +10,27 @@ module TrixiExtensionRefine using Trixi -struct IndicatorAlwaysRefine{Cache<:NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorAlwaysRefine{Cache <: NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorAlwaysRefine(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) - return IndicatorAlwaysRefine{typeof(cache)}(cache) + return IndicatorAlwaysRefine{typeof(cache)}(cache) end -function (indicator::IndicatorAlwaysRefine)(u::AbstractArray{<:Any,4}, +function (indicator::IndicatorAlwaysRefine)(u::AbstractArray{<:Any, 4}, mesh, equations, dg, cache; t, kwargs...) - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) - alpha .= 1.0 + alpha .= 1.0 - return alpha + return alpha end end # module TrixiExtensionRefine @@ -46,18 +45,16 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000) - + initial_refinement_level = 2, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -67,37 +64,37 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_controller = ControllerThreeLevel(semi, TrixiExtensionRefine.IndicatorAlwaysRefine(semi), - base_level=4, max_level=4, - med_threshold=0.1, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, + TrixiExtensionRefine.IndicatorAlwaysRefine(semi), + base_level = 4, max_level = 4, + med_threshold = 0.1, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl b/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl index efd282dab1f..03a213689ec 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl @@ -7,69 +7,68 @@ module TrixiExtension using Trixi -struct IndicatorSolutionIndependent{Cache<:NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorSolutionIndependent{Cache <: NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorSolutionIndependent(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) - return IndicatorSolutionIndependent{typeof(cache)}(cache) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) + return IndicatorSolutionIndependent{typeof(cache)}(cache) end -function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any,4}, +function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any, 4}, mesh, equations, dg, cache; t, kwargs...) - - mesh = indicator.cache.mesh - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) - - #Predict the theoretical center. - advection_velocity = (0.2, -0.7) - center = t.*advection_velocity - - inner_distance = 1 - outer_distance = 1.85 - - #Iterate over all elements - for element in 1:length(alpha) - #Calculate periodic distance between cell and center. - cell_id = cache.elements.cell_ids[element] - coordinates = mesh.tree.coordinates[1:2, cell_id] - - #The geometric shape of the amr should be preserved when the base_level is increased. - #This is done by looking at the original coordinates of each cell. - cell_coordinates = original_coordinates(coordinates, 5/8) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) - if cell_distance < (inner_distance+outer_distance)/2 - cell_coordinates = original_coordinates(coordinates, 5/16) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + mesh = indicator.cache.mesh + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) + + #Predict the theoretical center. + advection_velocity = (0.2, -0.7) + center = t .* advection_velocity + + inner_distance = 1 + outer_distance = 1.85 + + #Iterate over all elements + for element in 1:length(alpha) + #Calculate periodic distance between cell and center. + cell_id = cache.elements.cell_ids[element] + coordinates = mesh.tree.coordinates[1:2, cell_id] + + #The geometric shape of the amr should be preserved when the base_level is increased. + #This is done by looking at the original coordinates of each cell. + cell_coordinates = original_coordinates(coordinates, 5 / 8) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + if cell_distance < (inner_distance + outer_distance) / 2 + cell_coordinates = original_coordinates(coordinates, 5 / 16) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + end + + #Set alpha according to cells position inside the circles. + target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) + alpha[element] = target_level / 2 end - - #Set alpha according to cells position inside the circles. - target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) - alpha[element] = target_level/2 - end - return alpha + return alpha end # For periodic domains, distance between two points must take into account # periodic extensions of the domain function periodic_distance_2d(coordinates, center, domain_length) - dx = coordinates .- center - dx_shifted = abs.(dx .% domain_length) - dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) - return sqrt(sum(dx_periodic.^2)) + dx = coordinates .- center + dx_shifted = abs.(dx .% domain_length) + dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) + return sqrt(sum(dx_periodic .^ 2)) end #This takes a cells coordinates and transforms them into the coordinates of a parent-cell it originally refined from. #It does it so that the parent-cell has given cell_length. function original_coordinates(coordinates, cell_length) - offset = coordinates .% cell_length - offset_sign = sign.(offset) - border = coordinates - offset - center = border + (offset_sign .* cell_length/2) - return center + offset = coordinates .% cell_length + offset_sign = sign.(offset) + border = coordinates - offset + center = border + (offset_sign .* cell_length / 2) + return center end end # module TrixiExtension @@ -83,18 +82,16 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -104,38 +101,38 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_controller = ControllerThreeLevel(semi, TrixiExtension.IndicatorSolutionIndependent(semi), - base_level=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, + TrixiExtension.IndicatorSolutionIndependent(semi), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl b/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl index f517b4eb1cf..7b67b811177 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl @@ -9,27 +9,26 @@ using Plots advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) -function initial_condition_gauss_largedomain(x, t, equation::LinearScalarAdvectionEquation2D) - # Store translated coordinate for easy use of exact solution - domain_length = SVector(10, 10) - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t, domain_length) +function initial_condition_gauss_largedomain(x, t, + equation::LinearScalarAdvectionEquation2D) + # Store translated coordinate for easy use of exact solution + domain_length = SVector(10, 10) + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t, domain_length) - return SVector(exp(-(x_trans[1]^2 + x_trans[2]^2))) + return SVector(exp(-(x_trans[1]^2 + x_trans[2]^2))) end initial_condition = initial_condition_gauss_largedomain -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -39,41 +38,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # Enable in-situ visualization with a new plot generated every 20 time steps # and additional plotting options passed as keyword arguments -visualization = VisualizationCallback(interval=20, clims=(0,1)) +visualization = VisualizationCallback(interval = 20, clims = (0, 1)) -amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), - base_level=3, - med_level=4, med_threshold=0.1, - max_level=5, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 3, + med_level = 4, med_threshold = 0.1, + max_level = 5, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, visualization, 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_basic.jl b/examples/tree_2d_dgsem/elixir_advection_basic.jl index 269ab8cdd04..0ec0bc3629a 100644 --- a/examples/tree_2d_dgsem/elixir_advection_basic.jl +++ b/examples/tree_2d_dgsem/elixir_advection_basic.jl @@ -9,19 +9,19 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # 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 + 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) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -34,26 +34,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_callbacks.jl b/examples/tree_2d_dgsem/elixir_advection_callbacks.jl index 2ddd3e92ed2..708cd0aa3a3 100644 --- a/examples/tree_2d_dgsem/elixir_advection_callbacks.jl +++ b/examples/tree_2d_dgsem/elixir_advection_callbacks.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - # define new structs inside a module to allow re-evaluating the file module TrixiExtensionExample @@ -14,83 +13,81 @@ using OrdinaryDiffEq: DiscreteCallback, u_modified! # each time it is called. Its sole purpose here is to showcase how to implement # a stage callback for Trixi.jl. struct ExampleStageCallback - times::Vector{Float64} - min_values::Vector{Float64} - max_values::Vector{Float64} - - # You can optionally define an inner constructor like the one below to set up - # some required stuff. You can also create outer constructors (not demonstrated - # here) for further customization options. - function ExampleStageCallback() - new(Float64[], Float64[], Float64[]) - end + times::Vector{Float64} + min_values::Vector{Float64} + max_values::Vector{Float64} + + # You can optionally define an inner constructor like the one below to set up + # some required stuff. You can also create outer constructors (not demonstrated + # here) for further customization options. + function ExampleStageCallback() + new(Float64[], Float64[], Float64[]) + end end # This method is called when the `ExampleStageCallback` is used as `stage_limiter!` # which gets called after every RK stage. There is no specific initialization # method for such `stage_limiter!`s in OrdinaryDiffEq.jl. function (example_stage_callback::ExampleStageCallback)(u_ode, _, semi, t) + min_val, max_val = extrema(u_ode) + push!(example_stage_callback.times, t) + push!(example_stage_callback.min_values, min_val) + push!(example_stage_callback.max_values, max_val) - min_val, max_val = extrema(u_ode) - push!(example_stage_callback.times, t) - push!(example_stage_callback.min_values, min_val) - push!(example_stage_callback.max_values, max_val) - - return nothing + return nothing end - # This is an example implementation for a simple step callback (i.e., a callable # that is potentially executed after each Runge-Kutta *step*), which records # some values each time it is called. Its sole purpose here is to showcase # how to implement a step callback for Trixi.jl. struct ExampleStepCallback - message::String - times::Vector{Float64} - min_values::Vector{Float64} - max_values::Vector{Float64} - - # You can optionally define an inner constructor like the one below to set up - # some required stuff. You can also create outer constructors (not demonstrated - # here) for further customization options. - function ExampleStepCallback(message::String) - new(message, Float64[], Float64[], Float64[]) - end + message::String + times::Vector{Float64} + min_values::Vector{Float64} + max_values::Vector{Float64} + + # You can optionally define an inner constructor like the one below to set up + # some required stuff. You can also create outer constructors (not demonstrated + # here) for further customization options. + function ExampleStepCallback(message::String) + new(message, Float64[], Float64[], Float64[]) + end end # This method is called when the `ExampleStepCallback` is used as callback # which gets called after RK steps. function (example_callback::ExampleStepCallback)(integrator) - u_ode = integrator.u - t = integrator.t - # You can also access semi = integrator.p - - min_val, max_val = extrema(u_ode) - push!(example_callback.times, t) - push!(example_callback.min_values, min_val) - push!(example_callback.max_values, max_val) - - # avoid re-evaluating possible FSAL stages - u_modified!(integrator, false) - return nothing + u_ode = integrator.u + t = integrator.t + # You can also access semi = integrator.p + + min_val, max_val = extrema(u_ode) + push!(example_callback.times, t) + push!(example_callback.min_values, min_val) + push!(example_callback.max_values, max_val) + + # avoid re-evaluating possible FSAL stages + u_modified!(integrator, false) + return nothing end # This method is used to wrap an `ExampleStepCallback` inside a `DiscreteCallback` # which gets called after every RK step. You can pass an additional initialization # method and a separate condition specifying whether the callback shall be called. function ExampleStepCallback(; message::String) - # Call the `ExampleStepCallback` after every RK step. - condition = (u_ode, t, integrator) -> true + # Call the `ExampleStepCallback` after every RK step. + condition = (u_ode, t, integrator) -> true - # You can optionally pass an initialization method. There, you can access the - # `ExampleStepCallback` as `cb.affect!`. - initialize = (cb, u_ode, t, integrator) -> println(cb.affect!.message) + # You can optionally pass an initialization method. There, you can access the + # `ExampleStepCallback` as `cb.affect!`. + initialize = (cb, u_ode, t, integrator) -> println(cb.affect!.message) - example_callback = ExampleStepCallback(message) + example_callback = ExampleStepCallback(message) - DiscreteCallback(condition, example_callback, - save_positions=(false,false), - initialize=initialize) + DiscreteCallback(condition, example_callback, + save_positions = (false, false), + initialize = initialize) end end # module TrixiExtensionExample @@ -104,18 +101,16 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -125,19 +120,19 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) -alive_callback = AliveCallback(analysis_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=cons2cons) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2cons) -example_callback = TrixiExtensionExample.ExampleStepCallback(message="안녕하세요?") +example_callback = TrixiExtensionExample.ExampleStepCallback(message = "안녕하세요?") -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -158,9 +153,10 @@ example_stage_callback! = TrixiExtensionExample.ExampleStageCallback() ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(example_stage_callback!, 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); +sol = solve(ode, + CarpenterKennedy2N54(example_stage_callback!, 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 # Check whether we recorded the same values. diff --git a/examples/tree_2d_dgsem/elixir_advection_diffusion.jl b/examples/tree_2d_dgsem/elixir_advection_diffusion.jl index e96e1b5a171..dc85775bec4 100644 --- a/examples/tree_2d_dgsem/elixir_advection_diffusion.jl +++ b/examples/tree_2d_dgsem/elixir_advection_diffusion.jl @@ -10,30 +10,31 @@ diffusivity() = 5.0e-2 equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=true, - n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 4, + periodicity = true, + n_cells_max = 30_000) # set maximum capacity of tree data structure # Define initial condition -function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation2D) - # 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) +function initial_condition_diffusive_convergence_test(x, t, + equation::LinearScalarAdvectionEquation2D) + # 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 @@ -45,9 +46,8 @@ boundary_conditions_parabolic = boundary_condition_periodic semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions, - boundary_conditions_parabolic)) - + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -62,22 +62,21 @@ 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) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl index c3cd2ebeb20..8da542b0b5d 100644 --- a/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl @@ -10,16 +10,16 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -0.5) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 0.0, 0.5) # maximum coordinates (max(x), max(y)) +coordinates_max = (0.0, 0.5) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=false, - n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 4, + periodicity = false, + n_cells_max = 30_000) # set maximum capacity of tree data structure # Example setup taken from # - Truman Ellis, Jesse Chan, and Leszek Demkowicz (2016). @@ -28,22 +28,22 @@ mesh = TreeMesh(coordinates_min, coordinates_max, # to numerical partial differential equations. # [DOI](https://doi.org/10.1007/978-3-319-41640-3_6). function initial_condition_eriksson_johnson(x, t, equations) - l = 4 - epsilon = diffusivity() # TODO: this requires epsilon < .6 due to sqrt - lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + - cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) - return SVector{1}(u) + l = 4 + epsilon = diffusivity() # TODO: this requires epsilon < .6 due to sqrt + lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + + cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) + return SVector{1}(u) end initial_condition = initial_condition_eriksson_johnson boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition), - y_neg = BoundaryConditionDirichlet(initial_condition), - y_pos = BoundaryConditionDirichlet(initial_condition), - x_pos = boundary_condition_do_nothing) + y_neg = BoundaryConditionDirichlet(initial_condition), + y_pos = BoundaryConditionDirichlet(initial_condition), + x_pos = boundary_condition_do_nothing) boundary_conditions_parabolic = BoundaryConditionDirichlet(initial_condition) @@ -51,9 +51,8 @@ boundary_conditions_parabolic = BoundaryConditionDirichlet(initial_condition) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions, - boundary_conditions_parabolic)) - + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -68,22 +67,21 @@ 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) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_extended.jl b/examples/tree_2d_dgsem/elixir_advection_extended.jl index 8c837957ffd..41321ede5a7 100644 --- a/examples/tree_2d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_2d_dgsem/elixir_advection_extended.jl @@ -18,21 +18,20 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # 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 - periodicity=true) + initial_refinement_level = 4, + n_cells_max = 30_000, # set maximum capacity of tree data structure + periodicity = true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -47,24 +46,24 @@ 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, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.6) +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, @@ -72,14 +71,13 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_mortar.jl b/examples/tree_2d_dgsem/elixir_advection_mortar.jl index 2a283fb9008..645c55ba438 100644 --- a/examples/tree_2d_dgsem/elixir_advection_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_advection_mortar.jl @@ -9,22 +9,19 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) -refinement_patches = ( - (type="box", coordinates_min=(0.0, -1.0), coordinates_max=(1.0, 1.0)), -) +coordinates_max = (1.0, 1.0) +refinement_patches = ((type = "box", coordinates_min = (0.0, -1.0), + coordinates_max = (1.0, 1.0)),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - refinement_patches=refinement_patches, - n_cells_max=10_000,) - + initial_refinement_level = 2, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -34,28 +31,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_restart.jl b/examples/tree_2d_dgsem/elixir_advection_restart.jl index 2cb45c0b47e..bf107dc2049 100644 --- a/examples/tree_2d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_2d_dgsem/elixir_advection_restart.jl @@ -7,7 +7,6 @@ using Trixi trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl")) - ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -22,11 +21,10 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl b/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl index be87f24f817..06982bb9a27 100644 --- a/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl +++ b/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl @@ -9,18 +9,16 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = ( 5.0, 5.0) +coordinates_max = (5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -30,39 +28,38 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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=cons2cons) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2cons) -amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), - base_level=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) - ############################################################################### # run the simulation # sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), ode_algorithm = Trixi.CarpenterKennedy2N54() 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); + 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 diff --git a/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl b/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl index c5790e455bc..1393f4a6cc8 100644 --- a/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5/3 +gamma = 5 / 3 equations = CompressibleEulerEquations2D(gamma) # Initial condition adopted from @@ -13,55 +13,54 @@ equations = CompressibleEulerEquations2D(gamma) # https://tinyurl.com/c76fjtx4 # Mach = 2000 jet function initial_condition_astro_jet(x, t, equations::CompressibleEulerEquations2D) - @unpack gamma = equations - rho = 0.5 - v1 = 0 - v2 = 0 - p = 0.4127 - # add inflow for t>0 at x=-0.5 - # domain size is [-0.5,+0.5]^2 - if (t > 0) && (x[1] ≈ -0.5) && (abs(x[2]) < 0.05) - rho = 5 - v1 = 800 # about Mach number Ma = 2000 + @unpack gamma = equations + rho = 0.5 + v1 = 0 v2 = 0 p = 0.4127 - end - return prim2cons(SVector(rho, v1, v2, p), equations) + # add inflow for t>0 at x=-0.5 + # domain size is [-0.5,+0.5]^2 + if (t > 0) && (x[1] ≈ -0.5) && (abs(x[2]) < 0.05) + rho = 5 + v1 = 800 # about Mach number Ma = 2000 + v2 = 0 + p = 0.4127 + end + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_astro_jet -boundary_conditions = ( - x_neg=BoundaryConditionDirichlet(initial_condition_astro_jet), - x_pos=BoundaryConditionDirichlet(initial_condition_astro_jet), - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - ) +boundary_conditions = (x_neg = BoundaryConditionDirichlet(initial_condition_astro_jet), + x_pos = BoundaryConditionDirichlet(initial_condition_astro_jet), + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) surface_flux = flux_lax_friedrichs # HLLC needs more shock capturing (alpha_max) -volume_flux = flux_ranocha # works with Chandrashekar flux as well +volume_flux = flux_ranocha # works with Chandrashekar flux as well polydeg = 3 basis = LobattoLegendreBasis(polydeg) # shock capturing necessary for this tough example indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.3, - alpha_min=0.0001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.3, + alpha_min = 0.0001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + 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) +coordinates_max = (0.5, 0.5) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - periodicity=(false,true), - n_cells_max=100_000) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + initial_refinement_level = 6, + periodicity = (false, true), + n_cells_max = 100_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -72,43 +71,43 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -save_solution = SaveSolutionCallback(interval=5000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) - -amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0001, - alpha_smooth=false, - variable=Trixi.density) - -amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, - base_level=2, - med_level =0, med_threshold=0.0003, # med_level = current level - max_level =8, max_threshold=0.003, - max_threshold_secondary=indicator_sc.alpha_max) - -amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 5000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) + +amr_indicator = IndicatorHennemannGassner(semi, + alpha_max = 1.0, + alpha_min = 0.0001, + alpha_smooth = false, + variable = Trixi.density) + +amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, + base_level = 2, + med_level = 0, med_threshold = 0.0003, # med_level = current level + max_level = 8, max_threshold = 0.003, + max_threshold_secondary = indicator_sc.alpha_max) + +amr_callback = AMRCallback(semi, amr_controller, + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, + analysis_callback, alive_callback, amr_callback, save_solution) # positivity limiter necessary for this tough example -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation # use adaptive time stepping based on error estimates, time step roughly dt = 1e-7 sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl index 0da18b7120d..ccd7b54086b 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl @@ -16,48 +16,46 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -67,27 +65,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl index 6ce9268486c..d32c2e51b06 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl @@ -16,48 +16,46 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -67,40 +65,39 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl index 659788f2f5c..79d7474dc66 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl @@ -2,7 +2,8 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelcnn-0.964-0.001.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelcnn-0.964-0.001.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelcnn-0.964-0.001.bson", + network) model2dcnn = load(network, @__MODULE__)[:model2dcnn] using OrdinaryDiffEq @@ -28,52 +29,50 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkCNN(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=true, - alpha_amr=false, - variable=density_pressure, - network=model2dcnn) + indicator_type = NeuralNetworkCNN(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = true, + alpha_amr = false, + variable = density_pressure, + network = model2dcnn) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -83,27 +82,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl index 3f4862674d2..27398593efd 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl @@ -2,7 +2,8 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.904-0.0005.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", + network) model2d = load(network, @__MODULE__)[:model2d] using OrdinaryDiffEq @@ -28,52 +29,50 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkPerssonPeraire(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=true, - alpha_amr=false, - variable=density_pressure, - network=model2d) + indicator_type = NeuralNetworkPerssonPeraire(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = true, + alpha_amr = false, + variable = density_pressure, + network = model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -83,27 +82,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl index db2fffacb36..6c67f948636 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl @@ -3,7 +3,8 @@ using Flux using Random using BSON: load network = joinpath(@__DIR__, "modelnnrhs-0.973-0.001.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrhs-0.973-0.001.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrhs-0.973-0.001.bson", + network) model2d = load(network, @__MODULE__)[:model2d] using OrdinaryDiffEq @@ -29,54 +30,52 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkRayHesthaven(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=true, - alpha_amr=false, - variable=density_pressure, - network=model2d) + indicator_type = NeuralNetworkRayHesthaven(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = true, + alpha_amr = false, + variable = density_pressure, + network = model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) refinement_patches = () # To allow for specifying them via `trixi_include` mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - refinement_patches=refinement_patches, - n_cells_max=10_000) - + initial_refinement_level = 6, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -86,27 +85,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl index a0fc9349696..a2392d05e5a 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl @@ -16,40 +16,38 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave -surface_flux = flux_hllc +surface_flux = flux_hllc basis = LobattoLegendreBasis(3) volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=10_000) - + initial_refinement_level = 6, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -59,27 +57,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl b/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl index f4040732667..2b3659017a3 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5/3 +gamma = 5 / 3 equations = CompressibleEulerEquations2D(gamma) """ @@ -16,67 +16,67 @@ The blob test case taken from [arXiv: astro-ph/0610051](https://arxiv.org/abs/astro-ph/0610051) """ function initial_condition_blob(x, t, equations::CompressibleEulerEquations2D) - # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf - # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf - # change discontinuity to tanh - # typical domain is rectangular, we change it to a square - # resolution 128^2, 256^2 - # domain size is [-20.0,20.0]^2 - # gamma = 5/3 for this test case - R = 1.0 # radius of the blob - # background density - dens0 = 1.0 - Chi = 10.0 # density contrast - # reference time of characteristic growth of KH instability equal to 1.0 - tau_kh = 1.0 - tau_cr = tau_kh/1.6 # crushing time - # determine background velocity - velx0 = 2*R*sqrt(Chi)/tau_cr - vely0 = 0.0 - Ma0 = 2.7 # background flow Mach number Ma=v/c - c = velx0/Ma0 # sound speed - # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density - p0 = c*c*dens0/equations.gamma - # initial center of the blob - inicenter = [-15,0] - x_rel = x-inicenter - r = sqrt(x_rel[1]^2 + x_rel[2]^2) - # steepness of the tanh transition zone - slope = 2 - # density blob - dens = dens0 + (Chi-1) * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) - # velocity blob is zero - velx = velx0 - velx0 * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) - return prim2cons(SVector(dens, velx, vely0, p0), equations) + # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf + # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf + # change discontinuity to tanh + # typical domain is rectangular, we change it to a square + # resolution 128^2, 256^2 + # domain size is [-20.0,20.0]^2 + # gamma = 5/3 for this test case + R = 1.0 # radius of the blob + # background density + dens0 = 1.0 + Chi = 10.0 # density contrast + # reference time of characteristic growth of KH instability equal to 1.0 + tau_kh = 1.0 + tau_cr = tau_kh / 1.6 # crushing time + # determine background velocity + velx0 = 2 * R * sqrt(Chi) / tau_cr + vely0 = 0.0 + Ma0 = 2.7 # background flow Mach number Ma=v/c + c = velx0 / Ma0 # sound speed + # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density + p0 = c * c * dens0 / equations.gamma + # initial center of the blob + inicenter = [-15, 0] + x_rel = x - inicenter + r = sqrt(x_rel[1]^2 + x_rel[2]^2) + # steepness of the tanh transition zone + slope = 2 + # density blob + dens = dens0 + + (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) + # velocity blob is zero + velx = velx0 - velx0 * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) + return prim2cons(SVector(dens, velx, vely0, p0), equations) end initial_condition = initial_condition_blob surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.4, - alpha_min=0.0001, - alpha_smooth=true, - variable=pressure) + alpha_max = 0.4, + alpha_min = 0.0001, + alpha_smooth = true, + variable = pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-20.0, -20.0) -coordinates_max = ( 20.0, 20.0) +coordinates_max = (20.0, 20.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=100_000,) + initial_refinement_level = 6, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -86,42 +86,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0001, - alpha_smooth=false, - variable=Trixi.density) + alpha_max = 1.0, + alpha_min = 0.0001, + alpha_smooth = false, + variable = Trixi.density) amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, - base_level=4, - med_level =0, med_threshold=0.0003, # med_level = current level - max_level =7, max_threshold=0.003, - max_threshold_secondary=indicator_sc.alpha_max) + base_level = 4, + med_level = 0, med_threshold = 0.0003, # med_level = current level + max_level = 7, max_threshold = 0.003, + max_threshold_secondary = indicator_sc.alpha_max) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.25) +stepsize_callback = StepsizeCallback(cfl = 0.25) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl b/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl index 5b7365f860f..8bd5db00c9a 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5/3 +gamma = 5 / 3 equations = CompressibleEulerEquations2D(gamma) """ @@ -16,71 +16,71 @@ The blob test case taken from [arXiv: astro-ph/0610051](https://arxiv.org/abs/astro-ph/0610051) """ function initial_condition_blob(x, t, equations::CompressibleEulerEquations2D) - # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf - # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf - # change discontinuity to tanh - # typical domain is rectangular, we change it to a square - # resolution 128^2, 256^2 - # domain size is [-20.0,20.0]^2 - # gamma = 5/3 for this test case - R = 1.0 # radius of the blob - # background density - dens0 = 1.0 - Chi = 10.0 # density contrast - # reference time of characteristic growth of KH instability equal to 1.0 - tau_kh = 1.0 - tau_cr = tau_kh/1.6 # crushing time - # determine background velocity - velx0 = 2*R*sqrt(Chi)/tau_cr - vely0 = 0.0 - Ma0 = 2.7 # background flow Mach number Ma=v/c - c = velx0/Ma0 # sound speed - # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density - p0 = c*c*dens0/equations.gamma - # initial center of the blob - inicenter = [-15,0] - x_rel = x-inicenter - r = sqrt(x_rel[1]^2 + x_rel[2]^2) - # steepness of the tanh transition zone - slope = 2 - # density blob - dens = dens0 + (Chi-1) * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) - # velocity blob is zero - velx = velx0 - velx0 * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) - return prim2cons(SVector(dens, velx, vely0, p0), equations) + # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf + # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf + # change discontinuity to tanh + # typical domain is rectangular, we change it to a square + # resolution 128^2, 256^2 + # domain size is [-20.0,20.0]^2 + # gamma = 5/3 for this test case + R = 1.0 # radius of the blob + # background density + dens0 = 1.0 + Chi = 10.0 # density contrast + # reference time of characteristic growth of KH instability equal to 1.0 + tau_kh = 1.0 + tau_cr = tau_kh / 1.6 # crushing time + # determine background velocity + velx0 = 2 * R * sqrt(Chi) / tau_cr + vely0 = 0.0 + Ma0 = 2.7 # background flow Mach number Ma=v/c + c = velx0 / Ma0 # sound speed + # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density + p0 = c * c * dens0 / equations.gamma + # initial center of the blob + inicenter = [-15, 0] + x_rel = x - inicenter + r = sqrt(x_rel[1]^2 + x_rel[2]^2) + # steepness of the tanh transition zone + slope = 2 + # density blob + dens = dens0 + + (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) + # velocity blob is zero + velx = velx0 - velx0 * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) + return prim2cons(SVector(dens, velx, vely0, p0), equations) end initial_condition = initial_condition_blob surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.05, - alpha_min=0.0001, - alpha_smooth=true, - variable=pressure) + alpha_max = 0.05, + alpha_min = 0.0001, + alpha_smooth = true, + variable = pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-32.0, -32.0) -coordinates_max = ( 32.0, 32.0) -refinement_patches = ( - (type="box", coordinates_min=(-40.0, -5.0), coordinates_max=(40.0, 5.0)), - (type="box", coordinates_min=(-40.0, -5.0), coordinates_max=(40.0, 5.0)), -) +coordinates_max = (32.0, 32.0) +refinement_patches = ((type = "box", coordinates_min = (-40.0, -5.0), + coordinates_max = (40.0, 5.0)), + (type = "box", coordinates_min = (-40.0, -5.0), + coordinates_max = (40.0, 5.0))) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - refinement_patches=refinement_patches, - n_cells_max=100_000,) + initial_refinement_level = 4, + refinement_patches = refinement_patches, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -90,27 +90,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.7) +stepsize_callback = StepsizeCallback(cfl = 0.7) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl b/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl index cb2a5b16816..984ac3ff1f6 100644 --- a/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl +++ b/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl @@ -10,71 +10,71 @@ equations = CompressibleEulerEquations2D(gamma) # This is a hand made colliding flow setup without reference. Features Mach=70 inflow from both # sides, with relative low temperature, such that pressure keeps relatively small # Computed with gamma close to 1, to simulate isothermal gas -function initial_condition_colliding_flow_astro(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) - # domain size is [-64,+64]^2 - @unpack gamma = equations - # the quantities are chosen such, that they are as close as possible to the astro examples - # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) - rho = 0.0247 - c = 0.2 - p = c^2 / gamma * rho - vel = 13.907432274789372 - slope = 1.0 - v1 = -vel*tanh(slope * x[1]) - # add small initial disturbance to the field, but only close to the interface - if abs(x[1]) < 10 - v1 = v1 * (1 + 0.01 * sin(pi * x[2])) - end - v2 = 0.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_colliding_flow_astro(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) + # domain size is [-64,+64]^2 + @unpack gamma = equations + # the quantities are chosen such, that they are as close as possible to the astro examples + # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) + rho = 0.0247 + c = 0.2 + p = c^2 / gamma * rho + vel = 13.907432274789372 + slope = 1.0 + v1 = -vel * tanh(slope * x[1]) + # add small initial disturbance to the field, but only close to the interface + if abs(x[1]) < 10 + v1 = v1 * (1 + 0.01 * sin(pi * x[2])) + end + v2 = 0.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_colliding_flow_astro - -boundary_conditions = ( - x_neg=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - x_pos=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - ) - - +boundary_conditions = (x_neg = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + x_pos = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) surface_flux = flux_lax_friedrichs # HLLC needs more shock capturing (alpha_max) -volume_flux = flux_ranocha # works with Chandrashekar flux as well +volume_flux = flux_ranocha # works with Chandrashekar flux as well polydeg = 3 basis = LobattoLegendreBasis(polydeg) # shock capturing necessary for this tough example, however alpha_max = 0.5 is fine indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.0001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.0001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-64.0, -64.0) -coordinates_max = ( 64.0, 64.0) +coordinates_max = (64.0, 64.0) # only refinement in a patch. Needs x=-17/+17 to trigger refinement due to coarse base mesh -refinement_patches = ( - (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), - (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), - (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), - (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), - #(type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), # very high resolution, takes about 1000s on 2 cores -) +refinement_patches = ((type = "box", coordinates_min = (-17, -64), + coordinates_max = (17, 64)), + (type = "box", coordinates_min = (-17, -64), + coordinates_max = (17, 64)), + (type = "box", coordinates_min = (-17, -64), + coordinates_max = (17, 64)), + (type = "box", coordinates_min = (-17, -64), + coordinates_max = (17, 64)) + #(type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), # very high resolution, takes about 1000s on 2 cores + ) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - refinement_patches=refinement_patches, - periodicity=(false,true), - n_cells_max=100_000) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + initial_refinement_level = 3, + refinement_patches = refinement_patches, + periodicity = (false, true), + n_cells_max = 100_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -85,26 +85,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, + analysis_callback, alive_callback, save_solution) # positivity limiter necessary for this tough example -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation # use adaptive time stepping based on error estimates, time step roughly dt = 5e-3 sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl b/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl index 21de07147ca..a9eb671929f 100644 --- a/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl @@ -10,62 +10,59 @@ equations = CompressibleEulerEquations2D(gamma) # This is a hand made colliding flow setup without reference. Features Mach=70 inflow from both # sides, with relative low temperature, such that pressure keeps relatively small # Computed with gamma close to 1, to simulate isothermal gas -function initial_condition_colliding_flow_astro(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) - # domain size is [-64,+64]^2 - @unpack gamma = equations - # the quantities are chosen such, that they are as close as possible to the astro examples - # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) - rho = 0.0247 - c = 0.2 - p = c^2 / gamma * rho - vel = 13.907432274789372 - slope = 1.0 - v1 = -vel*tanh(slope * x[1]) - # add small initial disturbance to the field, but only close to the interface - if abs(x[1]) < 10 - v1 = v1 * (1 + 0.01 * sin(pi*x[2])) - end - v2 = 0.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_colliding_flow_astro(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) + # domain size is [-64,+64]^2 + @unpack gamma = equations + # the quantities are chosen such, that they are as close as possible to the astro examples + # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) + rho = 0.0247 + c = 0.2 + p = c^2 / gamma * rho + vel = 13.907432274789372 + slope = 1.0 + v1 = -vel * tanh(slope * x[1]) + # add small initial disturbance to the field, but only close to the interface + if abs(x[1]) < 10 + v1 = v1 * (1 + 0.01 * sin(pi * x[2])) + end + v2 = 0.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_colliding_flow_astro - -boundary_conditions = ( - x_neg=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - x_pos=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - ) - - +boundary_conditions = (x_neg = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + x_pos = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) surface_flux = flux_lax_friedrichs # HLLC needs more shock capturing (alpha_max) -volume_flux = flux_ranocha # works with Chandrashekar flux as well +volume_flux = flux_ranocha # works with Chandrashekar flux as well polydeg = 3 basis = LobattoLegendreBasis(polydeg) # shock capturing necessary for this tough example, however alpha_max = 0.5 is fine indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.0001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.0001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-64.0, -64.0) -coordinates_max = ( 64.0, 64.0) +coordinates_max = (64.0, 64.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=(false,true), - n_cells_max=100_000) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + initial_refinement_level = 4, + periodicity = (false, true), + n_cells_max = 100_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -76,44 +73,44 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # Simulation also feasible without AMR: AMR reduces CPU time by a factor of about 2 amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0001, - alpha_smooth=false, - variable=Trixi.density) + alpha_max = 1.0, + alpha_min = 0.0001, + alpha_smooth = false, + variable = Trixi.density) amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, - base_level=2, - med_level =0, med_threshold=0.0003, # med_level = current level - max_level =8, max_threshold=0.003, - max_threshold_secondary=indicator_sc.alpha_max) + base_level = 2, + med_level = 0, med_threshold = 0.0003, # med_level = current level + max_level = 8, max_threshold = 0.003, + max_threshold_secondary = indicator_sc.alpha_max) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, + analysis_callback, alive_callback, amr_callback, save_solution) # positivity limiter necessary for this tough example -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation # use adaptive time stepping based on error estimates, time step roughly dt = 5e-3 sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl b/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl index 89d7422cfe6..96184b5ba47 100644 --- a/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl +++ b/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl @@ -18,13 +18,11 @@ solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -35,16 +33,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -54,7 +52,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave.jl index a5e9d30e389..0f9e232fa14 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave.jl @@ -9,18 +9,16 @@ equations = CompressibleEulerEquations2D(gamma) initial_condition = initial_condition_density_wave -solver = DGSEM(polydeg=5, surface_flux=flux_central) +solver = DGSEM(polydeg = 5, surface_flux = flux_central) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000) - + initial_refinement_level = 2, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -30,27 +28,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.6) +stepsize_callback = StepsizeCallback(cfl = 1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_ec.jl b/examples/tree_2d_dgsem/elixir_euler_ec.jl index 88f65c3d689..e634a383cdf 100644 --- a/examples/tree_2d_dgsem/elixir_euler_ec.jl +++ b/examples/tree_2d_dgsem/elixir_euler_ec.jl @@ -9,20 +9,18 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000, - periodicity=true) - + initial_refinement_level = 5, + n_cells_max = 10_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_condition_periodic) - + boundary_conditions = boundary_condition_periodic) ############################################################################### # ODE solvers, callbacks etc. @@ -33,27 +31,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl index 4fdedf516ef..5e6b1e0cc0d 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl @@ -16,40 +16,41 @@ A version of the classical Kelvin-Helmholtz instability based on of the Euler Equations [arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) """ -function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.002, - alpha_min=0.0001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.002, + alpha_min = 0.0001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=100_000) + initial_refinement_level = 5, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) ############################################################################### @@ -61,27 +62,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=20, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 20, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.3) +stepsize_callback = StepsizeCallback(cfl = 1.3) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl index b8927c3fd6b..5c237835cc5 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl @@ -16,45 +16,44 @@ A version of the classical Kelvin-Helmholtz instability based on of the Euler Equations [arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) """ -function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.002, - alpha_min=0.0001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.002, + alpha_min = 0.0001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=100_000) - + initial_refinement_level = 5, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -64,41 +63,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0001, - alpha_smooth=false, - variable=Trixi.density) + alpha_max = 1.0, + alpha_min = 0.0001, + alpha_smooth = false, + variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - med_level=0, med_threshold=0.0003, # med_level = current level - max_level=6, max_threshold=0.003) + base_level = 4, + med_level = 0, med_threshold = 0.0003, # med_level = current level + max_level = 6, max_threshold = 0.003) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.3) +stepsize_callback = StepsizeCallback(cfl = 1.3) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl index 952fa372696..d2cab04223e 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl @@ -2,7 +2,8 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.904-0.0005.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", + network) model2d = load(network, @__MODULE__)[:model2d] using Random: seed! @@ -28,55 +29,59 @@ equations = CompressibleEulerEquations2D(gamma) A version of the classical Kelvin-Helmholtz instability based on https://rsaa.anu.edu.au/research/established-projects/fyris/2-d-kelvin-helmholtz-test. """ -function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-0.5,0.5]^2 - dens0 = 1.0 # outside density - dens1 = 2.0 # inside density - velx0 = -0.5 # outside velocity - velx1 = 0.5 # inside velocity - slope = 50 # used for tanh instead of discontinuous initial condition - # pressure equilibrium - p = 2.5 - # y velocity v2 is only white noise - v2 = 0.01*(rand(Float64,1)[1]-0.5) - # density - rho = dens0 + (dens1-dens0) * 0.5*(1+(tanh(slope*(x[2]+0.25)) - (tanh(slope*(x[2]-0.25)) + 1))) - # x velocity is also augmented with noise - v1 = velx0 + (velx1-velx0) * 0.5*(1+(tanh(slope*(x[2]+0.25)) - (tanh(slope*(x[2]-0.25)) + 1)))+0.01*(rand(Float64,1)[1]-0.5) - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-0.5,0.5]^2 + dens0 = 1.0 # outside density + dens1 = 2.0 # inside density + velx0 = -0.5 # outside velocity + velx1 = 0.5 # inside velocity + slope = 50 # used for tanh instead of discontinuous initial condition + # pressure equilibrium + p = 2.5 + # y velocity v2 is only white noise + v2 = 0.01 * (rand(Float64, 1)[1] - 0.5) + # density + rho = dens0 + + (dens1 - dens0) * 0.5 * + (1 + (tanh(slope * (x[2] + 0.25)) - (tanh(slope * (x[2] - 0.25)) + 1))) + # x velocity is also augmented with noise + v1 = velx0 + + (velx1 - velx0) * 0.5 * + (1 + (tanh(slope * (x[2] + 0.25)) - (tanh(slope * (x[2] - 0.25)) + 1))) + + 0.01 * (rand(Float64, 1)[1] - 0.5) + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkPerssonPeraire(), - alpha_max=0.002, - alpha_min=0.0001, - alpha_smooth=true, - alpha_continuous=true, - alpha_amr=false, - variable=density_pressure, - network=model2d) + indicator_type = NeuralNetworkPerssonPeraire(), + alpha_max = 0.002, + alpha_min = 0.0001, + alpha_smooth = true, + alpha_continuous = true, + alpha_amr = false, + variable = density_pressure, + network = model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + 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) +coordinates_max = (0.5, 0.5) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=100_000) - + initial_refinement_level = 5, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -86,45 +91,44 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorNeuralNetwork(semi, - indicator_type=NeuralNetworkPerssonPeraire(), - alpha_max=1.0, - alpha_min=0.0001, - alpha_smooth=false, - alpha_continuous=true, - alpha_amr=true, - variable=density_pressure, - network=model2d) + indicator_type = NeuralNetworkPerssonPeraire(), + alpha_max = 1.0, + alpha_min = 0.0001, + alpha_smooth = false, + alpha_continuous = true, + alpha_amr = true, + variable = density_pressure, + network = model2d) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - med_level=6, med_threshold=0.3, # med_level = current level - max_level=7, max_threshold=0.5) + base_level = 4, + med_level = 6, med_threshold = 0.3, # med_level = current level + max_level = 7, max_threshold = 0.5) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.3) +stepsize_callback = StepsizeCallback(cfl = 1.3) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl index 8e7484a96d4..5b2b80d84f3 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl @@ -1,7 +1,6 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the compressible Euler equations gamma = 1.4 @@ -16,83 +15,86 @@ A version of the classical Kelvin-Helmholtz instability based on solutions for hyperbolic systems of conservation laws [arXiv: 1402.0909](https://arxiv.org/abs/1402.0909) """ -function initial_condition_kelvin_helmholtz_instability_fjordholm_etal(x, t, equations::CompressibleEulerEquations2D) - # typical resolution 128^2, 256^2 - # domain size is [0,+1]^2 - # interface is sharp, but randomly perturbed - # The random numbers used in the initial conditions have been generated as follows: - # - # using StableRNGs - # - # rng = StableRNG(100) - # - # a1 = rand(rng, m) - # a2 = rand(rng, m) - # a1 .= a1 / sum(a1) - # a2 .= a2 / sum(a2) - # b1 = (rand(rng, m) .- 0.5) .* pi - # b2 = (rand(rng, m) .- 0.5) .* pi - - m = 10 - a1 = [0.04457096674422902, 0.03891512410182607, 0.0030191053979293433, 0.0993913172320319, +function initial_condition_kelvin_helmholtz_instability_fjordholm_etal(x, t, + equations::CompressibleEulerEquations2D) + # typical resolution 128^2, 256^2 + # domain size is [0,+1]^2 + # interface is sharp, but randomly perturbed + # The random numbers used in the initial conditions have been generated as follows: + # + # using StableRNGs + # + # rng = StableRNG(100) + # + # a1 = rand(rng, m) + # a2 = rand(rng, m) + # a1 .= a1 / sum(a1) + # a2 .= a2 / sum(a2) + # b1 = (rand(rng, m) .- 0.5) .* pi + # b2 = (rand(rng, m) .- 0.5) .* pi + + m = 10 + a1 = [0.04457096674422902, 0.03891512410182607, 0.0030191053979293433, + 0.0993913172320319, 0.1622302137588842, 0.1831383653456182, 0.11758003014101702, 0.07964318348142958, 0.0863245324711805, 0.18518716132585408] - a2 = [0.061688440856337096, 0.23000237877135882, 0.04453793881833177, 0.19251530387370916, + a2 = [0.061688440856337096, 0.23000237877135882, 0.04453793881833177, + 0.19251530387370916, 0.11107917357941084, 0.05898041974649702, 0.09949312336096268, 0.07022276346006465, 0.10670366489014596, 0.02477679264318211] - b1 = [0.06582340543754152, 0.9857886297001535, 0.8450452205037154, -1.279648120993805, + b1 = [0.06582340543754152, 0.9857886297001535, 0.8450452205037154, -1.279648120993805, 0.45454198915209526, -0.13359370986823993, 0.07062615913363897, -1.0097986278512623, 1.0810669017430343, -0.14207309803877177] - b2 = [-1.1376882185131414, -1.4798197129947765, 0.6139290513283818, -0.3319087388365522, + b2 = [-1.1376882185131414, -1.4798197129947765, 0.6139290513283818, -0.3319087388365522, 0.14633328999192285, -0.06373231463100072, -0.6270101051216724, 0.13941252226261905, -1.0337526453303645, 1.0441408867083155] - Y1 = 0.0 - Y2 = 0.0 - for n = 1:m - Y1 += a1[n] * cos(b1[n] + 2 * n * pi * x[1]) - Y2 += a2[n] * cos(b2[n] + 2 * n * pi * x[1]) - end - - J1 = 0.25 - J2 = 0.75 - epsilon = 0.01 - I1 = J1 + epsilon * Y1 - I2 = J2 + epsilon * Y2 - - if (x[2] > I1) && (x[2] < I2) - rho = 2 - v1 = -0.5 - else - rho = 1 - v1 = 0.5 - end - v2 = 0 - p = 2.5 - - return prim2cons(SVector(rho, v1, v2, p), equations) + Y1 = 0.0 + Y2 = 0.0 + for n in 1:m + Y1 += a1[n] * cos(b1[n] + 2 * n * pi * x[1]) + Y2 += a2[n] * cos(b2[n] + 2 * n * pi * x[1]) + end + + J1 = 0.25 + J2 = 0.75 + epsilon = 0.01 + I1 = J1 + epsilon * Y1 + I2 = J2 + epsilon * Y2 + + if (x[2] > I1) && (x[2] < I2) + rho = 2 + v1 = -0.5 + else + rho = 1 + v1 = 0.5 + end + v2 = 0 + p = 2.5 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability_fjordholm_etal surface_flux = flux_hllc -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.001, - alpha_min=0.0001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.001, + alpha_min = 0.0001, + alpha_smooth = true, + variable = density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=100_000) + initial_refinement_level = 6, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -105,14 +107,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 400 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=400, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 400, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -121,5 +123,5 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation sol = solve(ode, SSPRK43(); - ode_default_options()..., callback=callbacks); + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_positivity.jl b/examples/tree_2d_dgsem/elixir_euler_positivity.jl index e40dc3b47af..745928c5dc5 100644 --- a/examples/tree_2d_dgsem/elixir_euler_positivity.jl +++ b/examples/tree_2d_dgsem/elixir_euler_positivity.jl @@ -14,53 +14,51 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=100_000) - + initial_refinement_level = 6, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -70,42 +68,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorLöhner(semi, - variable=density_pressure) + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - med_level =0, med_threshold=0.1, # med_level = current level - max_level =6, max_threshold=0.3) + base_level = 4, + med_level = 0, med_threshold = 0.1, # med_level = current level + max_level = 6, max_threshold = 0.3) amr_callback = AMRCallback(semi, amr_controller, - interval=2, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 2, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) - -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), - variables=(Trixi.density, pressure)) - +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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 diff --git a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl index da7e1d55c91..10b5d0ce404 100644 --- a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -14,53 +14,51 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=100_000) - + initial_refinement_level = 6, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -70,29 +68,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -101,7 +99,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl index 56715789377..97060768e5e 100644 --- a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl +++ b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl @@ -2,7 +2,8 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.904-0.0005.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", + network) model2d = load(network, @__MODULE__)[:model2d] using OrdinaryDiffEq @@ -26,57 +27,55 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type=NeuralNetworkPerssonPeraire(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=true, - alpha_amr=false, - variable=density_pressure, - network=model2d) + indicator_type = NeuralNetworkPerssonPeraire(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = true, + alpha_amr = false, + variable = density_pressure, + network = model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - n_cells_max=100_000) - + initial_refinement_level = 6, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -86,33 +85,33 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorNeuralNetwork(semi, - indicator_type=NeuralNetworkPerssonPeraire(), - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - alpha_continuous=true, - alpha_amr=true, - variable=density_pressure, - network=model2d) + indicator_type = NeuralNetworkPerssonPeraire(), + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + alpha_continuous = true, + alpha_amr = true, + variable = density_pressure, + network = model2d) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.22) + base_level = 4, + max_level = 6, max_threshold = 0.22) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -121,7 +120,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl b/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl index f0a7ed0b953..40f19cbd4e2 100644 --- a/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl +++ b/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl @@ -10,28 +10,26 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_shima_etal +volume_flux = flux_shima_etal basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -41,26 +39,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_source_terms.jl b/examples/tree_2d_dgsem/elixir_euler_source_terms.jl index 36d93147289..ec230145537 100644 --- a/examples/tree_2d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_2d_dgsem/elixir_euler_source_terms.jl @@ -8,18 +8,16 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -30,16 +28,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -49,7 +47,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl b/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl index 231486b11c9..28ab4cec1d3 100644 --- a/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl +++ b/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl @@ -10,60 +10,57 @@ module TrixiExtensionEulerAMR using Trixi -struct IndicatorRefineCoarsen{Cache<:NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorRefineCoarsen{Cache <: NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorRefineCoarsen(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) - return IndicatorRefineCoarsen{typeof(cache)}(cache) + return IndicatorRefineCoarsen{typeof(cache)}(cache) end -function (indicator::IndicatorRefineCoarsen)(u::AbstractArray{<:Any,4}, +function (indicator::IndicatorRefineCoarsen)(u::AbstractArray{<:Any, 4}, mesh, equations, dg, cache; t, kwargs...) - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) - - if t >= 0.7 && t < 1.0 - # Refine to max level - alpha .= 1.0 - elseif t >= 1.0 - # Coarsen to base level - alpha .= -1.0 - else - alpha .= 0.0 - end - - return alpha + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) + + if t >= 0.7 && t < 1.0 + # Refine to max level + alpha .= 1.0 + elseif t >= 1.0 + # Coarsen to base level + alpha .= -1.0 + else + alpha .= 0.0 + end + + return alpha end end # module TrixiExtensionEulerAMR import .TrixiExtensionEulerAMR - ############################################################################### # semidiscretization of the compressible Euler equations equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000) - + initial_refinement_level = 3, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -74,25 +71,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -amr_controller = ControllerThreeLevel(semi, TrixiExtensionEulerAMR.IndicatorRefineCoarsen(semi), - base_level=3, max_level=6, - med_threshold=0.1, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, + TrixiExtensionEulerAMR.IndicatorRefineCoarsen(semi), + base_level = 3, max_level = 6, + med_threshold = 0.1, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -102,7 +100,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl index 9826a53d3d5..05ed7ba78cc 100644 --- a/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -12,26 +12,23 @@ initial_condition = initial_condition_convergence_test # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg=boundary_condition, - x_pos=boundary_condition, - y_neg=boundary_condition, - y_pos=boundary_condition,) - -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +boundary_conditions = (x_neg = boundary_condition, + x_pos = boundary_condition, + y_neg = boundary_condition, + y_pos = boundary_condition) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000, - periodicity=false) - + initial_refinement_level = 4, + n_cells_max = 10_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_convergence_test, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -42,19 +39,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -63,7 +60,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex.jl b/examples/tree_2d_dgsem/elixir_euler_vortex.jl index 14e46ce7540..c87d6f49ba8 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex.jl @@ -17,46 +17,45 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) +coordinates_max = (10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -69,30 +68,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_errors=(:conservation_error,), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_errors = (:conservation_error,), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl index 6f6eb25efa4..e9831c95526 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl @@ -7,55 +7,54 @@ module TrixiExtension using Trixi -struct IndicatorVortex{Cache<:NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorVortex{Cache <: NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorVortex(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - A = Array{real(basis), 2} - indicator_threaded = [A(undef, nnodes(basis), nnodes(basis)) - for _ in 1:Threads.nthreads()] - cache = (; semi.mesh, alpha, indicator_threaded) - - return IndicatorVortex{typeof(cache)}(cache) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + A = Array{real(basis), 2} + indicator_threaded = [A(undef, nnodes(basis), nnodes(basis)) + for _ in 1:Threads.nthreads()] + cache = (; semi.mesh, alpha, indicator_threaded) + + return IndicatorVortex{typeof(cache)}(cache) end -function (indicator_vortex::IndicatorVortex)(u::AbstractArray{<:Any,4}, +function (indicator_vortex::IndicatorVortex)(u::AbstractArray{<:Any, 4}, mesh, equations, dg, cache; t, kwargs...) - mesh = indicator_vortex.cache.mesh - alpha = indicator_vortex.cache.alpha - indicator_threaded = indicator_vortex.cache.indicator_threaded - resize!(alpha, nelements(dg, cache)) - - - # get analytical vortex center (based on assumption that center=[0.0,0.0] - # at t=0.0 and that we stop after one period) - domain_length = mesh.tree.length_level_0 - if t < 0.5 * domain_length - center = (t, t) - else - center = (t-domain_length, t-domain_length) - end - - Threads.@threads for element in eachelement(dg, cache) - cell_id = cache.elements.cell_ids[element] - coordinates = (mesh.tree.coordinates[1, cell_id], mesh.tree.coordinates[2, cell_id]) - # use the negative radius as indicator since the AMR controller increases - # the level with increasing value of the indicator and we want to use - # high levels near the vortex center - alpha[element] = -periodic_distance_2d(coordinates, center, domain_length) - end - - return alpha + mesh = indicator_vortex.cache.mesh + alpha = indicator_vortex.cache.alpha + indicator_threaded = indicator_vortex.cache.indicator_threaded + resize!(alpha, nelements(dg, cache)) + + # get analytical vortex center (based on assumption that center=[0.0,0.0] + # at t=0.0 and that we stop after one period) + domain_length = mesh.tree.length_level_0 + if t < 0.5 * domain_length + center = (t, t) + else + center = (t - domain_length, t - domain_length) + end + + Threads.@threads for element in eachelement(dg, cache) + cell_id = cache.elements.cell_ids[element] + coordinates = (mesh.tree.coordinates[1, cell_id], mesh.tree.coordinates[2, cell_id]) + # use the negative radius as indicator since the AMR controller increases + # the level with increasing value of the indicator and we want to use + # high levels near the vortex center + alpha[element] = -periodic_distance_2d(coordinates, center, domain_length) + end + + return alpha end function periodic_distance_2d(coordinates, center, domain_length) - dx = @. abs(coordinates - center) - dx_periodic = @. min(dx, domain_length - dx) - return sqrt(sum(abs2, dx_periodic)) + dx = @. abs(coordinates - center) + dx_periodic = @. min(dx, domain_length - dx) + return sqrt(sum(abs2, dx_periodic)) end end # module TrixiExtension @@ -77,48 +76,47 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - - cent = x - cent # distance to center point - - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + + cent = x - cent # distance to center point + + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) +coordinates_max = (10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000) - + initial_refinement_level = 3, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -132,39 +130,40 @@ summary_callback = SummaryCallback() analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_errors=(:conservation_error,), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_errors = (:conservation_error,), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=50, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 50, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_controller = ControllerThreeLevel(semi, TrixiExtension.IndicatorVortex(semi), - base_level=3, - med_level=4, med_threshold=-3.0, - max_level=5, max_threshold=-2.0) + base_level = 3, + med_level = 4, med_threshold = -3.0, + max_level = 5, max_threshold = -2.0) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl index 637133b9b2f..858799d2d3d 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl @@ -17,49 +17,48 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) -refinement_patches = ( - (type="box", coordinates_min=(0.0, -10.0), coordinates_max=(10.0, 10.0)), -) +coordinates_max = (10.0, 10.0) +refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0), + coordinates_max = (10.0, 10.0)),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - refinement_patches=refinement_patches, - n_cells_max=10_000,) + initial_refinement_level = 4, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -72,30 +71,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_errors=(:conservation_error,), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_errors = (:conservation_error,), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.4) +stepsize_callback = StepsizeCallback(cfl = 1.4) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl index dc6a326c5d5..026f6d1462c 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl @@ -17,36 +17,36 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex @@ -56,24 +56,23 @@ volume_flux = flux_shima_etal polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) -refinement_patches = ( - (type="box", coordinates_min=(0.0, -10.0), coordinates_max=(10.0, 10.0)), -) +coordinates_max = (10.0, 10.0) +refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0), + coordinates_max = (10.0, 10.0)),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - refinement_patches=refinement_patches, - n_cells_max=10_000,) + initial_refinement_level = 4, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -86,30 +85,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_errors=(:conservation_error,), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_errors = (:conservation_error,), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.7) +stepsize_callback = StepsizeCallback(cfl = 0.7) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl index 99036c36451..d719e01fd7c 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl @@ -17,52 +17,51 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex volume_flux = flux_shima_etal -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) -refinement_patches = ( - (type="box", coordinates_min=(0.0, -10.0), coordinates_max=(10.0, 10.0)), -) +coordinates_max = (10.0, 10.0) +refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0), + coordinates_max = (10.0, 10.0)),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - refinement_patches=refinement_patches, - n_cells_max=10_000,) + initial_refinement_level = 4, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -75,30 +74,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_errors=(:conservation_error,), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_errors = (:conservation_error,), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.4) +stepsize_callback = StepsizeCallback(cfl = 1.4) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl index 65a497374ed..99e4b090633 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl @@ -17,36 +17,36 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex @@ -56,20 +56,20 @@ volume_flux = flux_shima_etal polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) +coordinates_max = (10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000,) + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -82,22 +82,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_errors=(:conservation_error,), - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_errors = (:conservation_error,), + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.7) +stepsize_callback = StepsizeCallback(cfl = 0.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -107,7 +109,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl b/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl index 38b48b5d537..ea81bd049e4 100644 --- a/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl +++ b/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl @@ -19,203 +19,199 @@ module VortexPairSetup using LinearAlgebra: norm using Trixi - # Parameters that describe the co-rotating vortex pair -struct VortexPair{RealT<:Real} - r0::RealT # Distance between origin and each vortex center - rc::RealT # Vortex core radius - c0::RealT # Speed of sound - circulation::RealT # Circulation of the vortices - rho0::RealT # Density +struct VortexPair{RealT <: Real} + r0::RealT # Distance between origin and each vortex center + rc::RealT # Vortex core radius + c0::RealT # Speed of sound + circulation::RealT # Circulation of the vortices + rho0::RealT # Density end - # Analytical flow solution, used for the initial condition of the flow simulation function velocity(x, t, vortex_pair::VortexPair) - @unpack r0, rc, circulation = vortex_pair + @unpack r0, rc, circulation = vortex_pair - omega = circulation / (4 * pi * r0^2) - si, co = sincos(omega * t) - b = SVector(r0 * co, r0 * si) # vortex centers are b and -b - z_plus = x - b - z_minus = x + b + omega = circulation / (4 * pi * r0^2) + si, co = sincos(omega * t) + b = SVector(r0 * co, r0 * si) # vortex centers are b and -b + z_plus = x - b + z_minus = x + b - # Transform to polar coordinates - r_plus = norm(z_plus) - r_minus = norm(z_minus) - theta_plus = atan(z_plus[2], z_plus[1]) - theta_minus = atan(z_minus[2], z_minus[1]) + # Transform to polar coordinates + r_plus = norm(z_plus) + r_minus = norm(z_minus) + theta_plus = atan(z_plus[2], z_plus[1]) + theta_minus = atan(z_minus[2], z_minus[1]) - si_plus, co_plus = sincos(theta_plus) - si_minus, co_minus = sincos(theta_minus) + si_plus, co_plus = sincos(theta_plus) + si_minus, co_minus = sincos(theta_minus) - v1 = -circulation/(2 * pi) * ( r_plus /(rc^2 + r_plus^2) * si_plus + - r_minus/(rc^2 + r_minus^2) * si_minus) - v2 = circulation/(2 * pi) * ( r_plus /(rc^2 + r_plus^2) * co_plus + - r_minus/(rc^2 + r_minus^2) * co_minus ) + v1 = -circulation / (2 * pi) * (r_plus / (rc^2 + r_plus^2) * si_plus + + r_minus / (rc^2 + r_minus^2) * si_minus) + v2 = circulation / (2 * pi) * (r_plus / (rc^2 + r_plus^2) * co_plus + + r_minus / (rc^2 + r_minus^2) * co_minus) - return SVector(v1, v2) + return SVector(v1, v2) end - # Initial condition of the flow simulation. Uses constant density rho0 and analytical velocities. # The pressure is calculated using the given speed of sound c0 and Bernoulli's principle -struct InitialCondition{RealT<:Real} - vortex_pair::VortexPair{RealT} +struct InitialCondition{RealT <: Real} + vortex_pair::VortexPair{RealT} end -function (initial_condition::InitialCondition)(x, t, equations::CompressibleEulerEquations2D) - @unpack vortex_pair = initial_condition - @unpack rho0, c0 = vortex_pair - gamma = equations.gamma +function (initial_condition::InitialCondition)(x, t, + equations::CompressibleEulerEquations2D) + @unpack vortex_pair = initial_condition + @unpack rho0, c0 = vortex_pair + gamma = equations.gamma - v = velocity(x, t, vortex_pair) - p0 = rho0 * c0^2 / gamma - p = p0 - 0.5 * (gamma-1)/gamma * sum(v.^2) # Bernoulli's principle + v = velocity(x, t, vortex_pair) + p0 = rho0 * c0^2 / gamma + p = p0 - 0.5 * (gamma - 1) / gamma * sum(v .^ 2) # Bernoulli's principle - prim = SVector(rho0, v[1], v[2], p) - return prim2cons(prim, equations) + prim = SVector(rho0, v[1], v[2], p) + return prim2cons(prim, equations) end - # For both the flow and acoustics solvers, a sponge layer is used to dampen the density # and pressure towards the freestream values (for the flow solver) and the perturbed pressure # to zero (for the acoustics solver). -struct SpongeLayer{RealT<:Real, uEltype<:Real, N, SourceTerms} - sponge_layer_min::NTuple{4, RealT} # (-x,+x,-y,+y) min coordinates of sponge layer per direction - sponge_layer_max::NTuple{4, RealT} # (-x,+x,-y,+y) max coordinates of sponge layer per direction - reference_values::NTuple{N, uEltype} # reference values for variables affected by sponge layer - source_terms::SourceTerms # source terms to be used outside the sponge zone +struct SpongeLayer{RealT <: Real, uEltype <: Real, N, SourceTerms} + sponge_layer_min::NTuple{4, RealT} # (-x,+x,-y,+y) min coordinates of sponge layer per direction + sponge_layer_max::NTuple{4, RealT} # (-x,+x,-y,+y) max coordinates of sponge layer per direction + reference_values::NTuple{N, uEltype} # reference values for variables affected by sponge layer + source_terms::SourceTerms # source terms to be used outside the sponge zone end -function SpongeLayer(; sponge_layer_min, sponge_layer_max, reference_values, source_terms=nothing) - return SpongeLayer(sponge_layer_min, sponge_layer_max, reference_values, source_terms) +function SpongeLayer(; sponge_layer_min, sponge_layer_max, reference_values, + source_terms = nothing) + return SpongeLayer(sponge_layer_min, sponge_layer_max, reference_values, source_terms) end function (sponge_layer::SpongeLayer)(u, x, t, equations) - @unpack sponge_layer_min, sponge_layer_max, reference_values, source_terms = sponge_layer - - if lies_in_sponge_layer(x, sponge_layer_min, sponge_layer_max) - return source_term_sponge_layer(u, x, t, equations, sponge_layer_min, sponge_layer_max, - reference_values) - elseif source_terms !== nothing - return source_terms(u, x, t, equations) - else - return SVector(ntuple(v -> zero(eltype(u)), Val(nvariables(equations)))) - end + @unpack sponge_layer_min, sponge_layer_max, reference_values, source_terms = sponge_layer + + if lies_in_sponge_layer(x, sponge_layer_min, sponge_layer_max) + return source_term_sponge_layer(u, x, t, equations, sponge_layer_min, + sponge_layer_max, + reference_values) + elseif source_terms !== nothing + return source_terms(u, x, t, equations) + else + return SVector(ntuple(v -> zero(eltype(u)), Val(nvariables(equations)))) + end end function lies_in_sponge_layer(x, sponge_layer_min, sponge_layer_max) - return (sponge_layer_min[1] <= x[1] <= sponge_layer_max[1]) || # -x direction - (sponge_layer_min[2] <= x[1] <= sponge_layer_max[2]) || # +x direction - (sponge_layer_min[3] <= x[2] <= sponge_layer_max[3]) || # -y direction - (sponge_layer_min[4] <= x[2] <= sponge_layer_max[4]) # +y direction + return (sponge_layer_min[1] <= x[1] <= sponge_layer_max[1]) || # -x direction + (sponge_layer_min[2] <= x[1] <= sponge_layer_max[2]) || # +x direction + (sponge_layer_min[3] <= x[2] <= sponge_layer_max[3]) || # -y direction + (sponge_layer_min[4] <= x[2] <= sponge_layer_max[4]) # +y direction end function source_term_sponge_layer(u, x, t, equations::AcousticPerturbationEquations2D, sponge_layer_min::NTuple{4}, sponge_layer_max::NTuple{4}, reference_values) - # Perturbed pressure source is -alpha^2 * (u - reference_value) where alpha in [0,1] is a damping - # factor depending on the position inside the sponge layer + # Perturbed pressure source is -alpha^2 * (u - reference_value) where alpha in [0,1] is a damping + # factor depending on the position inside the sponge layer - # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge - # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge - # zones for two directions overlap - alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), - Val(2*ndims(equations))) - alpha_square = maximum(alphas)^2 + # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge + # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge + # zones for two directions overlap + alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), + Val(2 * ndims(equations))) + alpha_square = maximum(alphas)^2 - return SVector(0, 0, -alpha_square*(u[3] - reference_values[1]/u[6]^2), 0, 0, 0, 0) + return SVector(0, 0, -alpha_square * (u[3] - reference_values[1] / u[6]^2), 0, 0, 0, 0) end function source_term_sponge_layer(u, x, t, equations::CompressibleEulerEquations2D, sponge_layer_min::NTuple{4}, sponge_layer_max::NTuple{4}, reference_values) - # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge - # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge - # zones for two directions overlap - alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), - Val(2*ndims(equations))) - alpha_square = maximum(alphas)^2 - - u_prim = cons2prim(u, equations) - s = SVector(-alpha_square*(u_prim[1] - reference_values[1]), 0, 0, - -alpha_square*(u_prim[4] - reference_values[2])) - - return prim2cons(s, equations) + # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge + # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge + # zones for two directions overlap + alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), + Val(2 * ndims(equations))) + alpha_square = maximum(alphas)^2 + + u_prim = cons2prim(u, equations) + s = SVector(-alpha_square * (u_prim[1] - reference_values[1]), 0, 0, + -alpha_square * (u_prim[4] - reference_values[2])) + + return prim2cons(s, equations) end function calc_damping_factor(x, direction, sponge_layer_min, sponge_layer_max) - # Damping factor alpha grows linearly from 0 to 1 depending on how deep x lies in the sponge layer - # If x does not lie in the sponge layer, this returns 0 - - # Get the coordinate that determines how deep we are in the sponge zone - if direction in (1, 2) - pos = x[1] - else - pos = x[2] - end - - # Determine where the sponge layer begins/ends to allow calculating the damping factor - if iseven(direction) - sponge_begin = sponge_layer_min[direction] - sponge_end = sponge_layer_max[direction] - else - sponge_begin = sponge_layer_max[direction] - sponge_end = sponge_layer_min[direction] - end - - alpha = (pos - sponge_begin) / (sponge_end - sponge_begin) - - # alpha lies in [0, 1] if and only if x lies in the sponge zone - if 0 <= alpha <= 1 - return alpha - else - return zero(alpha) - end + # Damping factor alpha grows linearly from 0 to 1 depending on how deep x lies in the sponge layer + # If x does not lie in the sponge layer, this returns 0 + + # Get the coordinate that determines how deep we are in the sponge zone + if direction in (1, 2) + pos = x[1] + else + pos = x[2] + end + + # Determine where the sponge layer begins/ends to allow calculating the damping factor + if iseven(direction) + sponge_begin = sponge_layer_min[direction] + sponge_end = sponge_layer_max[direction] + else + sponge_begin = sponge_layer_max[direction] + sponge_end = sponge_layer_min[direction] + end + + alpha = (pos - sponge_begin) / (sponge_end - sponge_begin) + + # alpha lies in [0, 1] if and only if x lies in the sponge zone + if 0 <= alpha <= 1 + return alpha + else + return zero(alpha) + end end - # Boundary condition for the flow problem: The sponge layer dampens density and pressure towards the # freestream values. The freestream values (converted into conservative variables) are therefore # used as a Dirichlet boundary struct BoundaryCondition{uEltype} - rho::uEltype - rho_e::uEltype + rho::uEltype + rho_e::uEltype end function (bc::BoundaryCondition)(u_inner, orientation, direction, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) - u_boundary = SVector(bc.rho, zero(bc.rho), zero(bc.rho), bc.rho_e) + u_boundary = SVector(bc.rho, zero(bc.rho), zero(bc.rho), bc.rho_e) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end - return flux + return flux end end # module - import .VortexPairSetup - ############################################################################### # shared parameters, mesh and solver for both semidiscretizations # Parameters of the vortex pair -Mach = 1/9 +Mach = 1 / 9 c0 = 1.0 r0 = 1.0 circulation = 4 * pi * r0 * c0 * Mach rho = 1.0 -rc = 2/9 * r0 * 1.0 +rc = 2 / 9 * r0 * 1.0 T_r = 8 * pi^2 * r0^2 / circulation # Rotational period of the vortex pair T_a = T_r / 2 # Acoustic period of the vortex pair @@ -223,24 +219,22 @@ T_a = T_r / 2 # Acoustic period of the vortex pair vortex_pair = VortexPairSetup.VortexPair(r0, rc, c0, circulation, rho) # Shared mesh for both semidiscretizations -coordinates_min = (-135*r0, -135*r0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 135*r0, 135*r0) # maximum coordinates (max(x), max(y)) -refinement_patches = ( - (type="sphere", center=(0.0, 0.0), radius=85.0*r0), - (type="sphere", center=(0.0, 0.0), radius=20.0*r0), - (type="sphere", center=(0.0, 0.0), radius=10.0*r0), - (type="sphere", center=(0.0, 0.0), radius=5.0*r0) -) -initial_refinement_level=7 -n_cells_max=500_000 +coordinates_min = (-135 * r0, -135 * r0) # minimum coordinates (min(x), min(y)) +coordinates_max = (135 * r0, 135 * r0) # maximum coordinates (max(x), max(y)) +refinement_patches = ((type = "sphere", center = (0.0, 0.0), radius = 85.0 * r0), + (type = "sphere", center = (0.0, 0.0), radius = 20.0 * r0), + (type = "sphere", center = (0.0, 0.0), radius = 10.0 * r0), + (type = "sphere", center = (0.0, 0.0), radius = 5.0 * r0)) +initial_refinement_level = 7 +n_cells_max = 500_000 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=initial_refinement_level, - refinement_patches=refinement_patches, - n_cells_max=n_cells_max, # set maximum capacity of tree data structure - periodicity=false) + initial_refinement_level = initial_refinement_level, + refinement_patches = refinement_patches, + n_cells_max = n_cells_max, # set maximum capacity of tree data structure + periodicity = false) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) ############################################################################### # semidiscretization Euler equations @@ -250,24 +244,37 @@ equations_euler = CompressibleEulerEquations2D(gamma) initial_condition_euler = VortexPairSetup.InitialCondition(vortex_pair) -sponge_layer_euler = VortexPairSetup.SpongeLayer(sponge_layer_min=(-135*r0, 115*r0, -135*r0, 115*r0), - sponge_layer_max=(-115*r0, 135*r0, -115*r0, 135*r0), - reference_values=(rho, rho * c0^2 / gamma)) # (rho0, p0) +sponge_layer_euler = VortexPairSetup.SpongeLayer(sponge_layer_min = (-135 * r0, 115 * r0, + -135 * r0, 115 * r0), + sponge_layer_max = (-115 * r0, 135 * r0, + -115 * r0, 135 * r0), + reference_values = (rho, + rho * c0^2 / gamma)) # (rho0, p0) -boundary_condition_euler = VortexPairSetup.BoundaryCondition(rho, (rho * c0^2 / gamma) / (gamma-1)) +boundary_condition_euler = VortexPairSetup.BoundaryCondition(rho, + (rho * c0^2 / gamma) / + (gamma - 1)) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition_euler, solver, - boundary_conditions=boundary_condition_euler, - source_terms=sponge_layer_euler) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition_euler, + solver, + boundary_conditions = boundary_condition_euler, + source_terms = sponge_layer_euler) ############################################################################### # semidiscretization acoustic perturbation equations -equations_acoustics = AcousticPerturbationEquations2D(v_mean_global=(13.0, 26.0), c_mean_global=39.0, - rho_mean_global=52.0) # global mean values will be overwritten - -sponge_layer_acoustics = VortexPairSetup.SpongeLayer(sponge_layer_min=(-135*r0, 100*r0, -135*r0, 100*r0), - sponge_layer_max=(-100*r0, 135*r0, -100*r0, 135*r0), - reference_values=(0.0,)) +equations_acoustics = AcousticPerturbationEquations2D(v_mean_global = (13.0, 26.0), + c_mean_global = 39.0, + rho_mean_global = 52.0) # global mean values will be overwritten + +sponge_layer_acoustics = VortexPairSetup.SpongeLayer(sponge_layer_min = (-135 * r0, + 100 * r0, + -135 * r0, + 100 * r0), + sponge_layer_max = (-100 * r0, + 135 * r0, + -100 * r0, + 135 * r0), + reference_values = (0.0,)) """ boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function, @@ -276,24 +283,27 @@ sponge_layer_acoustics = VortexPairSetup.SpongeLayer(sponge_layer_min=(-135*r0, Boundary condition that uses a boundary state where the state variables are zero and the mean variables are the same as in `u_inner`. """ -function boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function, +function boundary_condition_zero(u_inner, orientation, direction, x, t, + surface_flux_function, equations::AcousticPerturbationEquations2D) - value = zero(eltype(u_inner)) - u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) + value = zero(eltype(u_inner)) + u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end - return flux + return flux end -semi_acoustics = SemidiscretizationHyperbolic(mesh, equations_acoustics, initial_condition_constant, - solver, boundary_conditions=boundary_condition_zero, - source_terms=sponge_layer_acoustics) +semi_acoustics = SemidiscretizationHyperbolic(mesh, equations_acoustics, + initial_condition_constant, + solver, + boundary_conditions = boundary_condition_zero, + source_terms = sponge_layer_acoustics) ############################################################################### # ODE solvers, callbacks etc. for averaging the flow field @@ -307,12 +317,12 @@ ode_averaging = semidiscretize(semi_euler, tspan1) summary_callback = SummaryCallback() analysis_interval = 5000 -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) tspan_averaging = (50.0, 400.0) averaging_callback = AveragingCallback(semi_euler, tspan_averaging) -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) callbacks_averaging = CallbackSet(summary_callback, alive_callback, averaging_callback, stepsize_callback) @@ -321,14 +331,13 @@ callbacks_averaging = CallbackSet(summary_callback, alive_callback, averaging_ca # run simulation for averaging the flow field # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks -sol_averaging = solve(ode_averaging, 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_averaging); +sol_averaging = solve(ode_averaging, 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_averaging); # Print the timer summary summary_callback() - ############################################################################### # set up coupled semidiscretization @@ -337,13 +346,13 @@ source_region(x) = sum(abs2, x) < 6.0^2 # calculate sources within radius 6 arou weights(x) = sum(abs2, x) < 5.0^2 ? 1.0 : cospi(0.5 * (norm(x) - 5.0)) semi = SemidiscretizationEulerAcoustics(semi_acoustics, semi_euler, - source_region=source_region, weights=weights) + source_region = source_region, weights = weights) ############################################################################### # ODE solvers, callbacks etc. for the coupled simulation # Create ODE problem -tspan = (0.0, 7.0*T_a) +tspan = (0.0, 7.0 * T_a) ode = semidiscretize(semi, tspan) # We need an additional ODE for the pure flow problem ode_euler = semidiscretize(semi.semi_euler, tspan) @@ -351,28 +360,30 @@ ode_euler = semidiscretize(semi.semi_euler, tspan) # Set up coupling callback cfl_acoustics = 0.8 cfl_euler = 0.8 -euler_acoustics_coupling = EulerAcousticsCouplingCallback( - ode_euler, "out/averaging.h5", CarpenterKennedy2N54(williamson_condition=false), - cfl_acoustics, cfl_euler, callback=SaveRestartCallback(interval=2300, output_directory="out/euler/")) +euler_acoustics_coupling = EulerAcousticsCouplingCallback(ode_euler, "out/averaging.h5", + CarpenterKennedy2N54(williamson_condition = false), + cfl_acoustics, cfl_euler, + callback = SaveRestartCallback(interval = 2300, + output_directory = "out/euler/")) # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup # and resets the timers summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) output_directory = "out/" -save_solution = SaveSolutionCallback(interval=2300, output_directory=output_directory) -save_restart = SaveRestartCallback(interval=2300, output_directory=output_directory) +save_solution = SaveSolutionCallback(interval = 2300, output_directory = output_directory) +save_restart = SaveRestartCallback(interval = 2300, output_directory = output_directory) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback, save_solution, save_restart, euler_acoustics_coupling) -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); +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); # Print the timer summary -summary_callback() \ No newline at end of file +summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl index d423b800fd0..bc4859e5760 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -33,27 +31,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl index 62c5bab51ea..771343937a4 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -33,27 +31,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.5) +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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl b/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl index 0715dfe35d6..d912a280e49 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl @@ -4,26 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = 1.4, +equations = CompressibleEulerMulticomponentEquations2D(gammas = 1.4, gas_constants = 0.4) - initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -34,28 +31,27 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(Trixi.density,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (Trixi.density,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_es.jl b/examples/tree_2d_dgsem/elixir_eulermulti_es.jl index a3e5580b572..470e533ab8d 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_es.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_es.jl @@ -4,25 +4,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4, 1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4, 1.4, 1.4), gas_constants = (0.4, 0.4, 0.4, 0.4)) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=10_000) - + initial_refinement_level = 5, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,30 +30,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl b/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl index 38510446cb1..f5ef51c108a 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl @@ -5,7 +5,7 @@ using Trixi # semidiscretization of the compressible Euler multicomponent equations # 1) Dry Air 2) Helium + 28% Air -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.648), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.648), gas_constants = (0.287, 1.578)) """ @@ -16,124 +16,126 @@ A shock-bubble testcase for multicomponent Euler equations Formulation of Entropy-Stable schemes for the multicomponent compressible Euler equations [arXiv: 1904.00972](https://arxiv.org/abs/1904.00972) """ -function initial_condition_shock_bubble(x, t, equations::CompressibleEulerMulticomponentEquations2D{5, 2}) - # bubble test case, see Gouasmi et al. https://arxiv.org/pdf/1904.00972 - # other reference: https://www.researchgate.net/profile/Pep_Mulet/publication/222675930_A_flux-split_algorithm_applied_to_conservative_models_for_multicomponent_compressible_flows/links/568da54508aeaa1481ae7af0.pdf - # typical domain is rectangular, we change it to a square, as Trixi can only do squares - @unpack gas_constants = equations - - # Positivity Preserving Parameter, can be set to zero if scheme is positivity preserving - delta = 0.03 - - # Region I - rho1_1 = delta - rho2_1 = 1.225 * gas_constants[1]/gas_constants[2] - delta - v1_1 = zero(delta) - v2_1 = zero(delta) - p_1 = 101325 - - # Region II - rho1_2 = 1.225-delta - rho2_2 = delta - v1_2 = zero(delta) - v2_2 = zero(delta) - p_2 = 101325 - - # Region III - rho1_3 = 1.6861 - delta - rho2_3 = delta - v1_3 = -113.5243 - v2_3 = zero(delta) - p_3 = 159060 - - # Set up Region I & II: - inicenter = SVector(zero(delta), zero(delta)) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - - if (x[1] > 0.50) - # Set up Region III - rho1 = rho1_3 - rho2 = rho2_3 - v1 = v1_3 - v2 = v2_3 - p = p_3 - elseif (r < 0.25) - # Set up Region I - rho1 = rho1_1 - rho2 = rho2_1 - v1 = v1_1 - v2 = v2_1 - p = p_1 - else - # Set up Region II - rho1 = rho1_2 - rho2 = rho2_2 - v1 = v1_2 - v2 = v2_2 - p = p_2 - end - - return prim2cons(SVector(v1, v2, p, rho1, rho2), equations) +function initial_condition_shock_bubble(x, t, + equations::CompressibleEulerMulticomponentEquations2D{ + 5, + 2 + }) + # bubble test case, see Gouasmi et al. https://arxiv.org/pdf/1904.00972 + # other reference: https://www.researchgate.net/profile/Pep_Mulet/publication/222675930_A_flux-split_algorithm_applied_to_conservative_models_for_multicomponent_compressible_flows/links/568da54508aeaa1481ae7af0.pdf + # typical domain is rectangular, we change it to a square, as Trixi can only do squares + @unpack gas_constants = equations + + # Positivity Preserving Parameter, can be set to zero if scheme is positivity preserving + delta = 0.03 + + # Region I + rho1_1 = delta + rho2_1 = 1.225 * gas_constants[1] / gas_constants[2] - delta + v1_1 = zero(delta) + v2_1 = zero(delta) + p_1 = 101325 + + # Region II + rho1_2 = 1.225 - delta + rho2_2 = delta + v1_2 = zero(delta) + v2_2 = zero(delta) + p_2 = 101325 + + # Region III + rho1_3 = 1.6861 - delta + rho2_3 = delta + v1_3 = -113.5243 + v2_3 = zero(delta) + p_3 = 159060 + + # Set up Region I & II: + inicenter = SVector(zero(delta), zero(delta)) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + + if (x[1] > 0.50) + # Set up Region III + rho1 = rho1_3 + rho2 = rho2_3 + v1 = v1_3 + v2 = v2_3 + p = p_3 + elseif (r < 0.25) + # Set up Region I + rho1 = rho1_1 + rho2 = rho2_1 + v1 = v1_1 + v2 = v2_1 + p = p_1 + else + # Set up Region II + rho1 = rho1_2 + rho2 = rho2_2 + v1 = v1_2 + v2 = v2_2 + p = p_2 + end + + return prim2cons(SVector(v1, v2, p, rho1, rho2), equations) end initial_condition = initial_condition_shock_bubble -surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha -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 = (-2.25, -2.225) -coordinates_max = ( 2.20, 2.225) -mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=1_000_000) - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - +surface_flux = flux_lax_friedrichs +volume_flux = flux_ranocha +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 = (-2.25, -2.225) +coordinates_max = (2.20, 2.225) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 3, + n_cells_max = 1_000_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 0.01) -ode = semidiscretize(semi, tspan) - -summary_callback = SummaryCallback() +tspan = (0.0, 0.01) +ode = semidiscretize(semi, tspan) -analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(Trixi.density,)) +summary_callback = SummaryCallback() -alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_interval = 300 +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (Trixi.density,)) -save_solution = SaveSolutionCallback(interval=300, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl=0.3) +save_solution = SaveSolutionCallback(interval = 300, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -callbacks = CallbackSet(summary_callback, - analysis_callback, - alive_callback, - save_solution, - stepsize_callback) +stepsize_callback = StepsizeCallback(cfl = 0.3) +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, - maxiters=1e5); -summary_callback() # print the timer summary \ No newline at end of file +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, + maxiters = 1e5); +summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl b/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl index abf9735fd28..1700957d900 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl @@ -8,51 +8,50 @@ using Trixi equations = HyperbolicDiffusionEquations2D() function initial_condition_poisson_periodic(x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # depending on initial constant state, c, for phi this converges to the solution ϕ + c - if iszero(t) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - else - phi = sin(2.0*pi*x[1])*sin(2.0*pi*x[2]) - q1 = 2*pi*cos(2.0*pi*x[1])*sin(2.0*pi*x[2]) - q2 = 2*pi*sin(2.0*pi*x[1])*cos(2.0*pi*x[2]) - end - return SVector(phi, q1, q2) + # elliptic equation: -νΔϕ = f + # depending on initial constant state, c, for phi this converges to the solution ϕ + c + if iszero(t) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + else + phi = sin(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) + q1 = 2 * pi * cos(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) + q2 = 2 * pi * sin(2.0 * pi * x[1]) * cos(2.0 * pi * x[2]) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_poisson_periodic -@inline function source_terms_poisson_periodic(u, x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) - @unpack inv_Tr = equations - C = -8 * equations.nu * pi^2 - - x1, x2 = x - tmp1 = sinpi(2 * x1) - tmp2 = sinpi(2 * x2) - du1 = -C*tmp1*tmp2 - du2 = -inv_Tr * u[2] - du3 = -inv_Tr * u[3] - - return SVector(du1, du2, du3) +@inline function source_terms_poisson_periodic(u, x, t, + equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -νΔϕ = f + # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) + @unpack inv_Tr = equations + C = -8 * equations.nu * pi^2 + + x1, x2 = x + tmp1 = sinpi(2 * x1) + tmp2 = sinpi(2 * x2) + du1 = -C * tmp1 * tmp2 + du2 = -inv_Tr * u[2] + du3 = -inv_Tr * u[3] + + return SVector(du1, du2, du3) end volume_flux = flux_central -solver = DGSEM(polydeg=4, surface_flux=flux_godunov, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = flux_godunov, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_poisson_periodic) - + source_terms = source_terms_poisson_periodic) ############################################################################### # ODE solvers, callbacks etc. @@ -63,30 +62,29 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl index c144ef47a63..e70b91906b1 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl @@ -7,44 +7,43 @@ using Trixi equations = HyperbolicDiffusionEquations2D() -@inline function initial_condition_harmonic_nonperiodic(x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω - if t == 0.0 - phi = 1.0 - q1 = 1.0 - q2 = 1.0 - else - C = inv(sinh(pi)) - sinpi_x1, cospi_x1 = sincos(pi*x[1]) - sinpi_x2, cospi_x2 = sincos(pi*x[2]) - sinh_pix1 = sinh(pi*x[1]) - cosh_pix1 = cosh(pi*x[1]) - sinh_pix2 = sinh(pi*x[2]) - cosh_pix2 = cosh(pi*x[2]) - phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) - q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) - q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) - end - return SVector(phi, q1, q2) +@inline function initial_condition_harmonic_nonperiodic(x, t, + equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω + if t == 0.0 + phi = 1.0 + q1 = 1.0 + q2 = 1.0 + else + C = inv(sinh(pi)) + sinpi_x1, cospi_x1 = sincos(pi * x[1]) + sinpi_x2, cospi_x2 = sincos(pi * x[2]) + sinh_pix1 = sinh(pi * x[1]) + cosh_pix1 = cosh(pi * x[1]) + sinh_pix2 = sinh(pi * x[2]) + cosh_pix2 = cosh(pi * x[2]) + phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) + q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) + q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_harmonic_nonperiodic boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg=4, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 4, surface_flux = flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000, - periodicity=false) - + initial_refinement_level = 3, + n_cells_max = 30_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions, - source_terms=source_terms_harmonic) - + boundary_conditions = boundary_conditions, + source_terms = source_terms_harmonic) ############################################################################### # ODE solvers, callbacks etc. @@ -55,30 +54,29 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl b/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl index d0d706981a2..a1a0397a46c 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl @@ -8,49 +8,48 @@ using Trixi equations = HyperbolicDiffusionEquations2D() function initial_condition_poisson_periodic(x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # depending on initial constant state, c, for phi this converges to the solution ϕ + c - if iszero(t) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - else - phi = sin(2.0*pi*x[1])*sin(2.0*pi*x[2]) - q1 = 2*pi*cos(2.0*pi*x[1])*sin(2.0*pi*x[2]) - q2 = 2*pi*sin(2.0*pi*x[1])*cos(2.0*pi*x[2]) - end - return SVector(phi, q1, q2) + # elliptic equation: -νΔϕ = f + # depending on initial constant state, c, for phi this converges to the solution ϕ + c + if iszero(t) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + else + phi = sin(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) + q1 = 2 * pi * cos(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) + q2 = 2 * pi * sin(2.0 * pi * x[1]) * cos(2.0 * pi * x[2]) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_poisson_periodic -@inline function source_terms_poisson_periodic(u, x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) - @unpack inv_Tr = equations - C = -8 * equations.nu * pi^2 - - x1, x2 = x - tmp1 = sinpi(2 * x1) - tmp2 = sinpi(2 * x2) - du1 = -C*tmp1*tmp2 - du2 = -inv_Tr * u[2] - du3 = -inv_Tr * u[3] - - return SVector(du1, du2, du3) +@inline function source_terms_poisson_periodic(u, x, t, + equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -νΔϕ = f + # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) + @unpack inv_Tr = equations + C = -8 * equations.nu * pi^2 + + x1, x2 = x + tmp1 = sinpi(2 * x1) + tmp2 = sinpi(2 * x2) + du1 = -C * tmp1 * tmp2 + du2 = -inv_Tr * u[2] + du3 = -inv_Tr * u[3] + + return SVector(du1, du2, du3) end -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_poisson_periodic) - + source_terms = source_terms_poisson_periodic) ############################################################################### # ODE solvers, callbacks etc. @@ -61,31 +60,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) - ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=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 diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl index fc825660f1e..1396481a3f1 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -9,25 +9,23 @@ equations = HyperbolicDiffusionEquations2D() initial_condition = initial_condition_poisson_nonperiodic # 1 => -x, 2 => +x, 3 => -y, 4 => +y as usual for orientations -boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, - x_pos=boundary_condition_poisson_nonperiodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic) +boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, + x_pos = boundary_condition_poisson_nonperiodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000, - periodicity=(false, true)) - + initial_refinement_level = 3, + n_cells_max = 30_000, + periodicity = (false, true)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions, - source_terms=source_terms_poisson_nonperiodic) - + boundary_conditions = boundary_conditions, + source_terms = source_terms_poisson_nonperiodic) ############################################################################### # ODE solvers, callbacks etc. @@ -38,30 +36,29 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_kpp.jl b/examples/tree_2d_dgsem/elixir_kpp.jl index f3cbc1cb664..3b9dc9c59ce 100644 --- a/examples/tree_2d_dgsem/elixir_kpp.jl +++ b/examples/tree_2d_dgsem/elixir_kpp.jl @@ -25,22 +25,31 @@ end @inline function Trixi.flux_ec(u_ll, u_rr, orientation::Integer, ::KPPEquation2D) # The tolerance of 1e-12 is based on experience and somewhat arbitrarily chosen if abs(u_ll[1] - u_rr[1]) < 1e-12 - return 0.5 * (flux(u_ll, orientation, KPPEquation2D()) + flux(u_rr, orientation, KPPEquation2D())) + return 0.5 * (flux(u_ll, orientation, KPPEquation2D()) + + flux(u_rr, orientation, KPPEquation2D())) else factor = 1.0 / (u_rr[1] - u_ll[1]) if orientation == 1 - return SVector(factor*(-cos(u_rr[1]) + cos(u_ll[1]))) + return SVector(factor * (-cos(u_rr[1]) + cos(u_ll[1]))) else - return SVector(factor*(sin(u_rr[1]) - sin(u_ll[1]))) + return SVector(factor * (sin(u_rr[1]) - sin(u_ll[1]))) end end end # Wavespeeds @inline wavespeed(::KPPEquation2D) = 1.0 -@inline Trixi.max_abs_speeds(u, equation::KPPEquation2D) = (wavespeed(equation), wavespeed(equation)) -@inline Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, equation::KPPEquation2D) = wavespeed(equation) -@inline Trixi.max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equation::KPPEquation2D) = wavespeed(equation) * norm(normal_direction) +@inline function Trixi.max_abs_speeds(u, equation::KPPEquation2D) + (wavespeed(equation), wavespeed(equation)) +end +@inline function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, + equation::KPPEquation2D) + wavespeed(equation) +end +@inline function Trixi.max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equation::KPPEquation2D) + wavespeed(equation) * norm(normal_direction) +end # Compute entropy: we use the square entropy @inline Trixi.entropy(u::Real, ::KPPEquation2D) = 0.5 * u^2 @@ -74,24 +83,25 @@ volume_flux = flux_ec polydeg = 3 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equation, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=first) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = first) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) ############################################################################### # Set up the tree mesh (initially a Cartesian grid of [-2,2]^2) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=6, - periodicity=true, - n_cells_max=500_000) + initial_refinement_level = 6, + periodicity = true, + n_cells_max = 500_000) ############################################################################### # Create the semi discretization object @@ -100,23 +110,24 @@ semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_kpp, solve ############################################################################### # Set up adaptive mesh refinement amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0001, - alpha_smooth=false, - variable=first) + alpha_max = 1.0, + alpha_min = 0.0001, + alpha_smooth = false, + variable = first) max_refinement_level = 8 amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, shock_indicator, - base_level=2, - med_level=0, med_threshold=0.0003, - max_level=max_refinement_level, max_threshold=0.003, - max_threshold_secondary=shock_indicator.alpha_max) + base_level = 2, + med_level = 0, med_threshold = 0.0003, + max_level = max_refinement_level, + max_threshold = 0.003, + max_threshold_secondary = shock_indicator.alpha_max) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) ############################################################################### # ODE solvers, callbacks etc. @@ -125,14 +136,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval=200) +analysis_callback = AnalysisCallback(semi, interval = 200) -alive_callback = AliveCallback(analysis_interval=200) +alive_callback = AliveCallback(analysis_interval = 200) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2cons) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2cons) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -140,6 +151,6 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); ode_default_options()..., callback = callbacks) summary_callback() # Print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_lbm_constant.jl b/examples/tree_2d_dgsem/elixir_lbm_constant.jl index 40b16f41ef6..5a4f3074e4e 100644 --- a/examples/tree_2d_dgsem/elixir_lbm_constant.jl +++ b/examples/tree_2d_dgsem/elixir_lbm_constant.jl @@ -5,22 +5,20 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D2Q9 scheme -equations = LatticeBoltzmannEquations2D(Ma=0.1, Re=Inf) +equations = LatticeBoltzmannEquations2D(Ma = 0.1, Re = Inf) initial_condition = initial_condition_constant -solver = DGSEM(polydeg=3, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000,) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -30,19 +28,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2macroscopic) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) collision_callback = LBMCollisionCallback() @@ -52,11 +50,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_lbm_couette.jl b/examples/tree_2d_dgsem/elixir_lbm_couette.jl index 6a33b2fb0ee..1ba040405d1 100644 --- a/examples/tree_2d_dgsem/elixir_lbm_couette.jl +++ b/examples/tree_2d_dgsem/elixir_lbm_couette.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D2Q9 scheme -equations = LatticeBoltzmannEquations2D(Ma=0.05, Re=2000) +equations = LatticeBoltzmannEquations2D(Ma = 0.05, Re = 2000) """ initial_condition_couette_unsteady(x, t, equations::LatticeBoltzmannEquations2D) @@ -16,19 +16,20 @@ incompressible Navier-Stokes equations. To be used in combination with this setup will converge to the state set in [`initial_condition_couette_steady`](@ref). """ function initial_condition_couette_unsteady(x, t, equations::LatticeBoltzmannEquations2D) - @unpack L, u0, rho0, nu = equations + @unpack L, u0, rho0, nu = equations - x1, x2 = x - v1 = u0*x2/L - for m in 1:100 - lambda_m = m * pi / L - v1 += 2 * u0 * (-1)^m/(lambda_m * L) * exp(-nu * lambda_m^2 * t) * sin(lambda_m * x2) - end + x1, x2 = x + v1 = u0 * x2 / L + for m in 1:100 + lambda_m = m * pi / L + v1 += 2 * u0 * (-1)^m / (lambda_m * L) * exp(-nu * lambda_m^2 * t) * + sin(lambda_m * x2) + end - rho = 1 - v2 = 0 + rho = 1 + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) + return equilibrium_distribution(rho, v1, v2, equations) end initial_condition = initial_condition_couette_unsteady @@ -44,53 +45,49 @@ Moving *upper* wall boundary condition for a Couette flow setup. To be used in c function boundary_condition_couette(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, - surface_flux_function, equations) + return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, + surface_flux_function, equations) end function boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - @assert direction == 4 "moving wall assumed in +y direction" + @assert direction==4 "moving wall assumed in +y direction" - @unpack rho0, u0, weights, c_s = equations - cs_squared = c_s^2 + @unpack rho0, u0, weights, c_s = equations + cs_squared = c_s^2 - pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared - pdf2 = u_inner[2] # outgoing - pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared - pdf4 = u_inner[2] - pdf5 = u_inner[5] # outgoing - pdf6 = u_inner[6] # outgoing - pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared - pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared - pdf9 = u_inner[9] + pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared + pdf2 = u_inner[2] # outgoing + pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared + pdf4 = u_inner[2] + pdf5 = u_inner[5] # outgoing + pdf6 = u_inner[6] # outgoing + pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared + pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared + pdf9 = u_inner[9] - u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) + u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) - # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) - return surface_flux_function(u_inner, u_boundary, orientation, equations) + # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) + return surface_flux_function(u_inner, u_boundary, orientation, equations) end -boundary_conditions = ( - x_neg=boundary_condition_periodic, - x_pos=boundary_condition_periodic, - y_neg=boundary_condition_noslip_wall, - y_pos=boundary_condition_couette, - ) +boundary_conditions = (x_neg = boundary_condition_periodic, + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_noslip_wall, + y_pos = boundary_condition_couette) -solver = DGSEM(polydeg=3, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - periodicity=(true, false), - n_cells_max=10_000,) - + initial_refinement_level = 3, + periodicity = (true, false), + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -101,26 +98,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # Custom solution variables: normalize velocities by reference speed `u0` @inline function macroscopic_normalized(u, equations::LatticeBoltzmannEquations2D) - macroscopic = cons2macroscopic(u, equations) - rho, v1, v2, p = macroscopic + macroscopic = cons2macroscopic(u, equations) + rho, v1, v2, p = macroscopic - # Use `typeof(macroscopic)` to avoid having to explicitly add `using StaticArrays` - convert(typeof(macroscopic), (rho, v1/equations.u0, v2/equations.u0, p)) + # Use `typeof(macroscopic)` to avoid having to explicitly add `using StaticArrays` + convert(typeof(macroscopic), (rho, v1 / equations.u0, v2 / equations.u0, p)) +end +function Trixi.varnames(::typeof(macroscopic_normalized), + equations::LatticeBoltzmannEquations2D) + ("rho", "v1_normalized", "v2_normalized", "p") end -Trixi.varnames(::typeof(macroscopic_normalized), equations::LatticeBoltzmannEquations2D) = ("rho", "v1_normalized", "v2_normalized", "p") -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=macroscopic_normalized) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = macroscopic_normalized) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) collision_callback = LBMCollisionCallback() @@ -130,11 +130,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl b/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl index a34e784e7ac..d00926cafad 100644 --- a/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl +++ b/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D2Q9 scheme -equations = LatticeBoltzmannEquations2D(Ma=0.1, Re=1000) +equations = LatticeBoltzmannEquations2D(Ma = 0.1, Re = 1000) """ initial_condition_lid_driven_cavity(x, t, equations::LatticeBoltzmannEquations2D) @@ -14,13 +14,13 @@ Initial state for a lid-driven cavity flow setup. To be used in combination with [`boundary_condition_lid_driven_cavity`](@ref) and [`boundary_condition_noslip_wall`](@ref). """ function initial_condition_lid_driven_cavity(x, t, equations::LatticeBoltzmannEquations2D) - @unpack L, u0, nu = equations + @unpack L, u0, nu = equations - rho = 1 - v1 = 0 - v2 = 0 + rho = 1 + v1 = 0 + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) + return equilibrium_distribution(rho, v1, v2, equations) end initial_condition = initial_condition_lid_driven_cavity @@ -35,53 +35,49 @@ no-slip wall. To be used in combination with [`initial_condition_lid_driven_cavi function boundary_condition_lid_driven_cavity(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, - surface_flux_function, equations) + return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, + surface_flux_function, equations) end function boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - @assert direction == 4 "moving wall assumed in +y direction" + @assert direction==4 "moving wall assumed in +y direction" - @unpack rho0, u0, weights, c_s = equations - cs_squared = c_s^2 + @unpack rho0, u0, weights, c_s = equations + cs_squared = c_s^2 - pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared - pdf2 = u_inner[2] # outgoing - pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared - pdf4 = u_inner[2] - pdf5 = u_inner[5] # outgoing - pdf6 = u_inner[6] # outgoing - pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared - pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared - pdf9 = u_inner[9] + pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared + pdf2 = u_inner[2] # outgoing + pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared + pdf4 = u_inner[2] + pdf5 = u_inner[5] # outgoing + pdf6 = u_inner[6] # outgoing + pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared + pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared + pdf9 = u_inner[9] - u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) + u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) - # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) - return surface_flux_function(u_inner, u_boundary, orientation, equations) + # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) + return surface_flux_function(u_inner, u_boundary, orientation, equations) end -boundary_conditions = ( - x_neg=boundary_condition_noslip_wall, - x_pos=boundary_condition_noslip_wall, - y_neg=boundary_condition_noslip_wall, - y_pos=boundary_condition_lid_driven_cavity, - ) +boundary_conditions = (x_neg = boundary_condition_noslip_wall, + x_pos = boundary_condition_noslip_wall, + y_neg = boundary_condition_noslip_wall, + y_pos = boundary_condition_lid_driven_cavity) -solver = DGSEM(polydeg=5, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 5, surface_flux = flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=false, - n_cells_max=10_000,) - + initial_refinement_level = 4, + periodicity = false, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -92,16 +88,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2macroscopic) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) collision_callback = LBMCollisionCallback() @@ -111,11 +107,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl b/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl index 14459fa4cb8..93272833b74 100644 --- a/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl @@ -4,25 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the linearized Euler equations -equations = LinearizedEulerEquations2D(v_mean_global=(0.0, 0.0), c_mean_global=1.0, rho_mean_global=1.0) +equations = LinearizedEulerEquations2D(v_mean_global = (0.0, 0.0), c_mean_global = 1.0, + rho_mean_global = 1.0) initial_condition = initial_condition_convergence_test # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) + initial_refinement_level = 4, + n_cells_max = 30_000) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -37,28 +37,29 @@ summary_callback = SummaryCallback() analysis_interval = 100 # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=analysis_interval, solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = analysis_interval, + solution_variables = cons2prim) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=0.8) +stepsize_callback = StepsizeCallback(cfl = 0.8) # 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, alive_callback, stepsize_callback) - +callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, alive_callback, + 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # print the timer summary summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl index d9e59160e7d..377a07e947e 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -4,25 +4,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,22 +31,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.5 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -56,11 +58,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl index 6632331eb37..aee430e9cf9 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl @@ -4,25 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) -refinement_patches = ( - (type="box", coordinates_min=0.25 .* coordinates_max, - coordinates_max=0.75 .* coordinates_max), -) +refinement_patches = ((type = "box", coordinates_min = 0.25 .* coordinates_max, + coordinates_max = 0.75 .* coordinates_max),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - refinement_patches=refinement_patches, - n_cells_max=10_000,) + initial_refinement_level = 4, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -35,22 +35,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -62,7 +65,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl b/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl index af05fffaf54..a0909ca7580 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl @@ -16,52 +16,50 @@ An MHD blast wave taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ 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) - f = (0.1 - r)/0.01 - if r <= 0.09 - p = 1000.0 - elseif r >= 0.1 - p = 0.1 - else - p = 0.1 + 999.9*f - end - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - B1 = 100.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) + # 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) + f = (0.1 - r) / 0.01 + if r <= 0.09 + p = 1000.0 + elseif r >= 0.1 + p = 0.1 + else + p = 0.1 + 999.9 * f + end + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + B1 = 100.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) -volume_flux = (flux_central, flux_nonconservative_powell) +volume_flux = (flux_central, flux_nonconservative_powell) basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + 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) +coordinates_max = (0.5, 0.5) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -71,32 +69,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=false, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=7, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 7, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) cfl = 0.8 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -109,7 +107,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_ec.jl b/examples/tree_2d_dgsem/elixir_mhd_ec.jl index 5873388f798..173d3ed448f 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_ec.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_ec.jl @@ -10,19 +10,18 @@ equations = IdealGlmMhdEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,19 +31,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -53,11 +52,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl b/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl index 460b24e02b2..7f26f270d6e 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations2D(gamma) """ @@ -16,44 +16,42 @@ The classical Orszag-Tang vortex test case. Here, the setup is taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ function initial_condition_orszag_tang(x, t, equations::IdealGlmMhdEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 5/3 - rho = 1.0 - v1 = -sin(2.0*pi*x[2]) - v2 = sin(2.0*pi*x[1]) - v3 = 0.0 - p = 1.0 / equations.gamma - B1 = -sin(2.0*pi*x[2]) / equations.gamma - B2 = sin(4.0*pi*x[1]) / equations.gamma - B3 = 0.0 - psi = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 5/3 + rho = 1.0 + v1 = -sin(2.0 * pi * x[2]) + v2 = sin(2.0 * pi * x[1]) + v3 = 0.0 + p = 1.0 / equations.gamma + B1 = -sin(2.0 * pi * x[2]) / equations.gamma + B2 = sin(4.0 * pi * x[1]) / equations.gamma + B3 = 0.0 + psi = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) end initial_condition = initial_condition_orszag_tang surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_central, flux_nonconservative_powell) +volume_flux = (flux_central, flux_nonconservative_powell) basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -63,32 +61,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=false, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=6, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 6, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) cfl = 1.25 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -101,7 +99,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_rotor.jl b/examples/tree_2d_dgsem/elixir_mhd_rotor.jl index c6d880e9e9d..3109b1ce303 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_rotor.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_rotor.jl @@ -2,7 +2,6 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations equations = IdealGlmMhdEquations2D(1.4) @@ -16,59 +15,57 @@ The classical MHD rotor test case. Here, the setup is taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ function initial_condition_rotor(x, t, equations::IdealGlmMhdEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 1.4 - dx = x[1] - 0.5 - dy = x[2] - 0.5 - r = sqrt(dx^2 + dy^2) - f = (0.115 - r)/0.015 - if r <= 0.1 - rho = 10.0 - v1 = -20.0*dy - v2 = 20.0*dx - elseif r >= 0.115 - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - else - rho = 1.0 + 9.0*f - v1 = -20.0*f*dy - v2 = 20.0*f*dx - end - v3 = 0.0 - p = 1.0 - B1 = 5.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) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 1.4 + dx = x[1] - 0.5 + dy = x[2] - 0.5 + r = sqrt(dx^2 + dy^2) + f = (0.115 - r) / 0.015 + if r <= 0.1 + rho = 10.0 + v1 = -20.0 * dy + v2 = 20.0 * dx + elseif r >= 0.115 + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + else + rho = 1.0 + 9.0 * f + v1 = -20.0 * f * dy + v2 = 20.0 * f * dx + end + v3 = 0.0 + p = 1.0 + B1 = 5.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_rotor surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -78,32 +75,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=false, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=6, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 6, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) cfl = 0.35 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -116,7 +113,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl index a7551f48937..4f1f8c5f2b7 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl @@ -5,25 +5,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5/3, 5/3, 5/3), - gas_constants = (2.08, 2.08, 2.08)) +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5 / 3, 5 / 3, 5 / 3), + gas_constants = (2.08, 2.08, 2.08)) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2), sqrt(2)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -33,19 +32,20 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -54,11 +54,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl index ec2f3c21cdd..a7db9eeee96 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl @@ -5,25 +5,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), - gas_constants = (1.0, 1.0)) +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), + gas_constants = (1.0, 1.0)) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -33,19 +32,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -54,11 +53,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl index 3cd9c621ae3..fcaabdc7a58 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl @@ -5,25 +5,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5/3, 5/3), - gas_constants = (0.2, 0.2)) +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5 / 3, 5 / 3), + gas_constants = (0.2, 0.2)) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = ( 2.0, 2.0) +coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -33,19 +32,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -54,11 +53,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl index 55a4004f794..5ca21cc5e9c 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl @@ -2,10 +2,9 @@ using OrdinaryDiffEq using Trixi - ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), gas_constants = (1.0, 1.0)) """ @@ -14,62 +13,60 @@ equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), The classical MHD rotor test case adapted to two density components. """ function initial_condition_rotor(x, t, equations::IdealGlmMhdMulticomponentEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 1.4 - dx = x[1] - 0.5 - dy = x[2] - 0.5 - r = sqrt(dx^2 + dy^2) - f = (0.115 - r)/0.015 - if r <= 0.1 - rho1 = 10.0 - rho2 = 5.0 - v1 = -20.0*dy - v2 = 20.0*dx - elseif r >= 0.115 - rho1 = 1.0 - rho2 = 0.5 - v1 = 0.0 - v2 = 0.0 - else - rho1 = 1.0 + 9.0*f - rho2 = 0.5 + 4.5*f - v1 = -20.0*f*dy - v2 = 20.0*f*dx - end - v3 = 0.0 - p = 1.0 - B1 = 5.0/sqrt(4.0*pi) - B2 = 0.0 - B3 = 0.0 - psi = 0.0 - return prim2cons(SVector(v1, v2, v3, p, B1, B2, B3, psi, rho1, rho2), equations) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 1.4 + dx = x[1] - 0.5 + dy = x[2] - 0.5 + r = sqrt(dx^2 + dy^2) + f = (0.115 - r) / 0.015 + if r <= 0.1 + rho1 = 10.0 + rho2 = 5.0 + v1 = -20.0 * dy + v2 = 20.0 * dx + elseif r >= 0.115 + rho1 = 1.0 + rho2 = 0.5 + v1 = 0.0 + v2 = 0.0 + else + rho1 = 1.0 + 9.0 * f + rho2 = 0.5 + 4.5 * f + v1 = -20.0 * f * dy + v2 = 20.0 * f * dx + end + v3 = 0.0 + p = 1.0 + B1 = 5.0 / sqrt(4.0 * pi) + B2 = 0.0 + B3 = 0.0 + psi = 0.0 + return prim2cons(SVector(v1, v2, v3, p, B1, B2, B3, psi, rho1, rho2), equations) end initial_condition = initial_condition_rotor surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.8, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.8, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -79,32 +76,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=false, - variable=density_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=4, - max_level =6, max_threshold=0.01) + base_level = 4, + max_level = 6, max_threshold = 0.01) amr_callback = AMRCallback(semi, amr_controller, - interval=6, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 6, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -117,7 +114,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl b/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl index 36a9f52e39d..f6f0f7ca13e 100644 --- a/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl @@ -8,187 +8,234 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations2D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), Prandtl=prandtl_number(), - gradient_variables=GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesPrimitive()) # 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, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=(true, false), - n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 4, + periodicity = (true, false), + n_cells_max = 30_000) # set maximum capacity of tree data structure # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion2D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion2D`) # and by the initial condition (which passes in `CompressibleEulerEquations2D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Amplitude and shift - A = 0.5 - c = 2.0 + # Amplitude and shift + A = 0.5 + c = 2.0 - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0)) ) * cos(pi_t) - v2 = v1 - p = rho^2 + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0))) * cos(pi_t) + v2 = v1 + p = rho^2 - return prim2cons(SVector(rho, v1, v2, p), equations) + return prim2cons(SVector(rho, v1, v2, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - y = x[2] - - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Same settings as in `initial_condition` - # Amplitude and shift - A = 0.5 - c = 2.0 - - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t - - # compute the manufactured solution and all necessary derivatives - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) - rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) - rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) - rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - - v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) - v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_y = sin(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_xy = pi * cos(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_yy = (sin(pi_x) * ( 2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) - - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) - - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_xx = v1_xx - v2_xy = v1_xy - v2_yy = v1_yy - - p = rho * rho - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x - p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y - - # Note this simplifies slightly because the ansatz assumes that v1 = v2 - E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) - E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y - - # Some convenience constants - T_const = equations.gamma * inv_gamma_minus_one / Pr - inv_rho_cubed = 1.0 / (rho^3) - - # compute the source terms - # density equation - du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y - - # x-momentum equation - du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - # stress tensor from x-direction - - 4.0 / 3.0 * v1_xx * mu_ - + 2.0 / 3.0 * v2_xy * mu_ - - v1_yy * mu_ - - v2_xy * mu_ ) - # y-momentum equation - du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - # stress tensor from y-direction - - v1_xy * mu_ - - v2_xx * mu_ - - 4.0 / 3.0 * v2_yy * mu_ - + 2.0 / 3.0 * v1_xy * mu_ ) - # total energy equation - du4 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - # stress tensor and temperature gradient terms from x-direction - - 4.0 / 3.0 * v1_xx * v1 * mu_ - + 2.0 / 3.0 * v2_xy * v1 * mu_ - - 4.0 / 3.0 * v1_x * v1_x * mu_ - + 2.0 / 3.0 * v2_y * v1_x * mu_ - - v1_xy * v2 * mu_ - - v2_xx * v2 * mu_ - - v1_y * v2_x * mu_ - - v2_x * v2_x * mu_ - - T_const * inv_rho_cubed * ( p_xx * rho * rho - - 2.0 * p_x * rho * rho_x - + 2.0 * p * rho_x * rho_x - - p * rho * rho_xx ) * mu_ - # stress tensor and temperature gradient terms from y-direction - - v1_yy * v1 * mu_ - - v2_xy * v1 * mu_ - - v1_y * v1_y * mu_ - - v2_x * v1_y * mu_ - - 4.0 / 3.0 * v2_yy * v2 * mu_ - + 2.0 / 3.0 * v1_xy * v2 * mu_ - - 4.0 / 3.0 * v2_y * v2_y * mu_ - + 2.0 / 3.0 * v1_x * v2_y * mu_ - - T_const * inv_rho_cubed * ( p_yy * rho * rho - - 2.0 * p_y * rho * rho_y - + 2.0 * p * rho_y * rho_y - - p * rho * rho_yy ) * mu_ ) - - return SVector(du1, du2, du3, du4) + y = x[2] + + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Same settings as in `initial_condition` + # Amplitude and shift + A = 0.5 + c = 2.0 + + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t + + # compute the manufactured solution and all necessary derivatives + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) + rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) + rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) + rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + + v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) + v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_y = sin(pi_x) * + (A * log(y + 2.0) * exp(-A * (y - 1.0)) + + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_xy = pi * cos(pi_x) * + (A * log(y + 2.0) * exp(-A * (y - 1.0)) + + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_yy = (sin(pi_x) * + (2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) + - + A * A * log(y + 2.0) * exp(-A * (y - 1.0)) + - + (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_xx = v1_xx + v2_xy = v1_xy + v2_yy = v1_yy + + p = rho * rho + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x + p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y + + # Note this simplifies slightly because the ansatz assumes that v1 = v2 + E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) + E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y + + # Some convenience constants + T_const = equations.gamma * inv_gamma_minus_one / Pr + inv_rho_cubed = 1.0 / (rho^3) + + # compute the source terms + # density equation + du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y + + # x-momentum equation + du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + # stress tensor from x-direction + - + 4.0 / 3.0 * v1_xx * mu_ + + + 2.0 / 3.0 * v2_xy * mu_ + - + v1_yy * mu_ + - + v2_xy * mu_) + # y-momentum equation + du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + # stress tensor from y-direction + - + v1_xy * mu_ + - + v2_xx * mu_ + - + 4.0 / 3.0 * v2_yy * mu_ + + + 2.0 / 3.0 * v1_xy * mu_) + # total energy equation + du4 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + # stress tensor and temperature gradient terms from x-direction + - + 4.0 / 3.0 * v1_xx * v1 * mu_ + + + 2.0 / 3.0 * v2_xy * v1 * mu_ + - + 4.0 / 3.0 * v1_x * v1_x * mu_ + + + 2.0 / 3.0 * v2_y * v1_x * mu_ + - + v1_xy * v2 * mu_ + - + v2_xx * v2 * mu_ + - + v1_y * v2_x * mu_ + - + v2_x * v2_x * mu_ + - + T_const * inv_rho_cubed * + (p_xx * rho * rho + - + 2.0 * p_x * rho * rho_x + + + 2.0 * p * rho_x * rho_x + - + p * rho * rho_xx) * mu_ + # stress tensor and temperature gradient terms from y-direction + - + v1_yy * v1 * mu_ + - + v2_xy * v1 * mu_ + - + v1_y * v1_y * mu_ + - + v2_x * v1_y * mu_ + - + 4.0 / 3.0 * v2_yy * v2 * mu_ + + + 2.0 / 3.0 * v1_xy * v2 * mu_ + - + 4.0 / 3.0 * v2_y * v2_y * mu_ + + + 2.0 / 3.0 * v1_x * v2_y * mu_ + - + T_const * inv_rho_cubed * + (p_yy * rho * rho + - + 2.0 * p_y * rho * rho_y + + + 2.0 * p * rho_y * rho_y + - + p * rho * rho_yy) * mu_) + + return SVector(du1, du2, du3, du4) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, + t, + equations)[2:3]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, + heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_slip_wall, - y_pos = boundary_condition_slip_wall) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_slip_wall, + y_pos = boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_top_bottom, - y_pos = boundary_condition_top_bottom) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_top_bottom, + y_pos = boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, solver; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -198,16 +245,15 @@ tspan = (0.0, 0.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, dt = 1e-5, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, dt = 1e-5, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary - diff --git a/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl b/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl index 81e48737e79..4e3c14c9ed7 100644 --- a/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl +++ b/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl @@ -9,28 +9,27 @@ prandtl_number() = 0.72 mu() = 0.001 equations = CompressibleEulerEquations2D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), - Prandtl=prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), + Prandtl = prandtl_number()) # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - periodicity=false, - n_cells_max=30_000) # set maximum capacity of tree data structure - + initial_refinement_level = 4, + periodicity = false, + n_cells_max = 30_000) # set maximum capacity of tree data structure function initial_condition_cavity(x, t, equations::CompressibleEulerEquations2D) - Ma = 0.1 - rho = 1.0 - u, v = 0.0, 0.0 - p = 1.0 / (Ma^2 * equations.gamma) - return prim2cons(SVector(rho, u, v, p), equations) + Ma = 0.1 + rho = 1.0 + u, v = 0.0, 0.0 + p = 1.0 / (Ma^2 * equations.gamma) + return prim2cons(SVector(rho, u, v, p), equations) end initial_condition = initial_condition_cavity @@ -45,15 +44,15 @@ boundary_condition_cavity = BoundaryConditionNavierStokesWall(velocity_bc_cavity boundary_conditions = boundary_condition_slip_wall boundary_conditions_parabolic = (; x_neg = boundary_condition_cavity, - y_neg = boundary_condition_cavity, - y_pos = boundary_condition_lid, - x_pos = boundary_condition_cavity) + y_neg = boundary_condition_cavity, + y_pos = boundary_condition_lid, + x_pos = boundary_condition_cavity) # 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)) + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -63,17 +62,15 @@ tspan = (0.0, 25.0) ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=100) +alive_callback = AliveCallback(alive_interval = 100) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary - - diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl b/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl index eed0a350e7e..bc528ae7756 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) # Note, this initial condition is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_ec_discontinuous_bottom` below. @@ -16,17 +16,18 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) + initial_refinement_level = 2, + n_cells_max = 10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -46,45 +47,48 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the TreeMesh2D with initial_refinement_level=2. -function initial_condition_ec_discontinuous_bottom(x, t, element_id, equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.7, 0.7) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Set the background values - H = 4.25 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # setup the discontinuous water height and velocities - if element_id == 10 - H = 5.0 - v1 = 0.1882 * cos_phi - v2 = 0.1882 * sin_phi - end - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_ec_discontinuous_bottom(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 4.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 5.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, + equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -93,15 +97,15 @@ end summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(dt=0.2, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(dt = 0.2, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -109,7 +113,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl index 6d4f6fe518c..c92e885c161 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,17 +5,17 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test # MMS EOC test - ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -23,13 +23,13 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservativ coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,13 +40,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -54,6 +54,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl index c3da957b764..f7544b1e32e 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test @@ -15,8 +15,9 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -24,14 +25,14 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservativ coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=false) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions = boundary_condition, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -42,13 +43,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -56,6 +57,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl index 402361c8823..f7c8ab3a249 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl @@ -5,7 +5,8 @@ using Trixi ############################################################################### # Semidiscretization of the two-layer shallow water equations -equations = ShallowWaterTwoLayerEquations2D(gravity_constant=10.0, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 10.0, rho_upper = 0.9, + rho_lower = 1.0) initial_condition = initial_condition_convergence_test @@ -13,9 +14,9 @@ initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) - +solver = DGSEM(polydeg = 3, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -23,13 +24,13 @@ solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservativ coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=20_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 20_000, + periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,13 +41,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=500, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 500, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -54,6 +55,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, -save_everystep=false, callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-8, reltol = 1.0e-8, + save_everystep = false, callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl index ba4bcd25774..1495e6d8568 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl @@ -6,21 +6,24 @@ using Trixi # Semidiscretization of the two-layer shallow water equations with a bottom topography function # to test well-balancedness -equations = ShallowWaterTwoLayerEquations2D(gravity_constant=9.81, H0=0.6, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 9.81, H0 = 0.6, + rho_upper = 0.9, rho_lower = 1.0) # An initial condition with constant total water height, zero velocities and a bottom topography to # test well-balancedness function initial_condition_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations2D) - H_lower = 0.5 - H_upper = 0.6 - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + - -0.5)^2)) + 1) : 0.0) - - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) + H_lower = 0.5 + H_upper = 0.6 + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? + 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + + -0.5)^2)) + 1) : 0.0) + + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), + equations) end initial_condition = initial_condition_well_balanced @@ -30,8 +33,8 @@ initial_condition = initial_condition_well_balanced volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=3, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -39,9 +42,9 @@ solver = DGSEM(polydeg=3, surface_flux=surface_flux, coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 10_000, + periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -55,16 +58,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -72,7 +75,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl index 23efdcb7366..3408b130620 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl @@ -6,21 +6,22 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.25) +equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) - + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -30,17 +31,17 @@ initial_condition = initial_condition_well_balancedness volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=4, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) + initial_refinement_level = 2, + n_cells_max = 10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -61,30 +62,33 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the TreeMesh2D with initial_refinement_level=2. -function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), + element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -93,16 +97,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -110,7 +114,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl index 66cd27f6864..7facf1170d0 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl @@ -5,21 +5,22 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.25) +equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) - + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -31,8 +32,8 @@ boundary_condition = boundary_condition_slip_wall volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=4, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -40,8 +41,8 @@ solver = DGSEM(polydeg=4, surface_flux=surface_flux, coordinates_min = (-1.0, -1.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000, + initial_refinement_level = 2, + n_cells_max = 10_000, periodicity = false) # create the semi discretization object @@ -64,30 +65,33 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the TreeMesh2D with initial_refinement_level=2. -function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), + element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -96,16 +100,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -113,7 +117,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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 \ No newline at end of file +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 diff --git a/examples/tree_2d_fdsbp/elixir_advection_extended.jl b/examples/tree_2d_fdsbp/elixir_advection_extended.jl index 6e599d9f42d..8716a9a6b78 100644 --- a/examples/tree_2d_fdsbp/elixir_advection_extended.jl +++ b/examples/tree_2d_fdsbp/elixir_advection_extended.jl @@ -13,22 +13,21 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=100) + derivative_order = 1, accuracy_order = 4, + xmin = 0.0, xmax = 1.0, N = 100) solver = FDSBP(D_SBP, - surface_integral=SurfaceIntegralStrongForm(flux_lax_friedrichs), - volume_integral=VolumeIntegralStrongForm()) + surface_integral = SurfaceIntegralStrongForm(flux_lax_friedrichs), + volume_integral = VolumeIntegralStrongForm()) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=1, - n_cells_max=30_000, - periodicity=true) + initial_refinement_level = 1, + n_cells_max = 30_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -38,19 +37,18 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(energy_total,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (energy_total,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-9, reltol=1.0e-9, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-9, reltol = 1.0e-9, + ode_default_options()..., callback = callbacks) summary_callback() diff --git a/examples/tree_2d_fdsbp/elixir_euler_convergence.jl b/examples/tree_2d_fdsbp/elixir_euler_convergence.jl index 0843cece67e..604ae395105 100644 --- a/examples/tree_2d_fdsbp/elixir_euler_convergence.jl +++ b/examples/tree_2d_fdsbp/elixir_euler_convergence.jl @@ -12,23 +12,24 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 30_000, + periodicity = true) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, source_terms = source_terms_convergence_test) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -39,15 +40,15 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(energy_total,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (energy_total,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -57,6 +58,6 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-9, reltol=1.0e-9, - ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); abstol = 1.0e-9, reltol = 1.0e-9, + ode_default_options()..., callback = callbacks) summary_callback() diff --git a/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl b/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl index 1e58badf47a..c8148793542 100644 --- a/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl +++ b/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl @@ -8,42 +8,42 @@ using Trixi # semidiscretization of the linear advection equation equations = CompressibleEulerEquations2D(1.4) -function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, + equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_vanleer_haenel solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-1.0, -1.0) -coordinates_max = ( 1.0, 1.0) +coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000, - periodicity=true) + initial_refinement_level = 4, + n_cells_max = 30_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -53,27 +53,26 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(entropy, - energy_total,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (entropy, + energy_total)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, alive_callback) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, dt=1e-3, - ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, dt = 1e-3, + ode_default_options()..., callback = callbacks) summary_callback() diff --git a/examples/tree_2d_fdsbp/elixir_euler_vortex.jl b/examples/tree_2d_fdsbp/elixir_euler_vortex.jl index abaf3d494d4..abac64d008b 100644 --- a/examples/tree_2d_fdsbp/elixir_euler_vortex.jl +++ b/examples/tree_2d_fdsbp/elixir_euler_vortex.jl @@ -18,62 +18,61 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel*t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - - cent = x - cent # distance to center point - - #cent=cross(iniaxis,cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude/(2*π)*exp(0.5*(1-r2)) # vel. perturbation - dtemp = -(equations.gamma-1)/(2*equations.gamma*rt)*du^2 # isentropic - rho = rho * (1+dtemp)^(1/(equations.gamma-1)) - vel = vel + du*cent - v1, v2 = vel - p = p * (1+dtemp)^(equations.gamma/(equations.gamma-1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel * t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + + cent = x - cent # distance to center point + + #cent=cross(iniaxis,cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-10.0, -10.0) -coordinates_max = ( 10.0, 10.0) +coordinates_max = (10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000, - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 30_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -83,24 +82,23 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, alive_callback) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, dt=1e-3, - ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, dt = 1e-3, + ode_default_options()..., callback = callbacks) summary_callback() diff --git a/examples/tree_3d_dgsem/elixir_advection_amr.jl b/examples/tree_3d_dgsem/elixir_advection_amr.jl index 67664eed563..19a9bd18a8a 100644 --- a/examples/tree_3d_dgsem/elixir_advection_amr.jl +++ b/examples/tree_3d_dgsem/elixir_advection_amr.jl @@ -9,18 +9,16 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0, -5.0) -coordinates_max = ( 5.0, 5.0, 5.0) +coordinates_max = (5.0, 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=30_000) - + initial_refinement_level = 4, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -30,26 +28,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +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=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -61,7 +59,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_advection_basic.jl b/examples/tree_3d_dgsem/elixir_advection_basic.jl index da91a70fe6d..3ea50423be7 100644 --- a/examples/tree_3d_dgsem/elixir_advection_basic.jl +++ b/examples/tree_3d_dgsem/elixir_advection_basic.jl @@ -9,19 +9,19 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) # set maximum capacity of tree data structure + initial_refinement_level = 3, + 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) - +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -34,26 +34,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) # 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) - +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_3d_dgsem/elixir_advection_extended.jl b/examples/tree_3d_dgsem/elixir_advection_extended.jl index d820f47f25c..efc20c64f6d 100644 --- a/examples/tree_3d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_3d_dgsem/elixir_advection_extended.jl @@ -18,21 +18,20 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000, # set maximum capacity of tree data structure - periodicity=true) + initial_refinement_level = 3, + n_cells_max = 30_000, # set maximum capacity of tree data structure + periodicity = true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -47,24 +46,24 @@ 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, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi simulation can be restarted -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, @@ -72,14 +71,13 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_3d_dgsem/elixir_advection_mortar.jl b/examples/tree_3d_dgsem/elixir_advection_mortar.jl index 7b24f152b6a..d27a19c7dcf 100644 --- a/examples/tree_3d_dgsem/elixir_advection_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_advection_mortar.jl @@ -9,23 +9,21 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +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) -refinement_patches = ( - (type="box", coordinates_min=(0.0, -1.0, -1.0), coordinates_max=(1.0, 1.0, 1.0)), - (type="box", coordinates_min=(0.0, -0.5, -0.5), coordinates_max=(0.5, 0.5, 0.5)), -) +coordinates_max = (1.0, 1.0, 1.0) +refinement_patches = ((type = "box", coordinates_min = (0.0, -1.0, -1.0), + coordinates_max = (1.0, 1.0, 1.0)), + (type = "box", coordinates_min = (0.0, -0.5, -0.5), + coordinates_max = (0.5, 0.5, 0.5))) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - refinement_patches=refinement_patches, - n_cells_max=10_000,) - + initial_refinement_level = 2, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -35,17 +33,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.2) +stepsize_callback = StepsizeCallback(cfl = 1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -53,11 +51,10 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_advection_restart.jl b/examples/tree_3d_dgsem/elixir_advection_restart.jl index 83bf4418b98..a8e1fb3edde 100644 --- a/examples/tree_3d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_3d_dgsem/elixir_advection_restart.jl @@ -7,7 +7,6 @@ using Trixi trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl")) - ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -22,11 +21,10 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_amr.jl b/examples/tree_3d_dgsem/elixir_euler_amr.jl index f226a6b446d..9bd7f74c688 100644 --- a/examples/tree_3d_dgsem/elixir_euler_amr.jl +++ b/examples/tree_3d_dgsem/elixir_euler_amr.jl @@ -14,30 +14,28 @@ A Gaussian pulse in the density with constant velocity and pressure; reduces the compressible Euler equations to the linear advection equations. """ function initial_condition_density_pulse(x, t, equations::CompressibleEulerEquations3D) - rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2))/2 - v1 = 1 - v2 = 1 - v3 = 1 - rho_v1 = rho * v1 - rho_v2 = rho * v2 - rho_v3 = rho * v3 - p = 1 - rho_e = p/(equations.gamma - 1) + 1/2 * rho * (v1^2 + v2^2 + v3^2) - return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) + rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2)) / 2 + v1 = 1 + v2 = 1 + v3 = 1 + rho_v1 = rho * v1 + rho_v2 = rho * v2 + rho_v3 = rho * v3 + p = 1 + rho_e = p / (equations.gamma - 1) + 1 / 2 * rho * (v1^2 + v2^2 + v3^2) + return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) end initial_condition = initial_condition_density_pulse -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (-5.0, -5.0, -5.0) -coordinates_max = ( 5.0, 5.0, 5.0) +coordinates_max = (5.0, 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=4, - n_cells_max=10_000) - + initial_refinement_level = 4, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -47,40 +45,39 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +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=4, - med_level=5, med_threshold=1.05, - max_level=6, max_threshold=1.3) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 1.05, + max_level = 6, max_threshold = 1.3) amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 5, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl b/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl index a8d112f5b05..0ce886620cc 100644 --- a/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl +++ b/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5/3 +gamma = 5 / 3 equations = CompressibleEulerEquations3D(gamma) """ @@ -16,63 +16,65 @@ The blob test case taken from [arXiv: astro-ph/0610051](https://arxiv.org/abs/astro-ph/0610051) """ function initial_condition_blob(x, t, equations::CompressibleEulerEquations3D) - # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf - # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf - # change discontinuity to tanh - # typical domain is rectangular, we change it to a square - # resolution 128^3, 256^3 - # domain size is [-20.0,20.0]^3 - # gamma = 5/3 for this test case - R = 1.0 # radius of the blob - # background density - rho = 1.0 - Chi = 10.0 # density contrast - # reference time of characteristic growth of KH instability equal to 1.0 - tau_kh = 1.0 - tau_cr = tau_kh / 1.6 # crushing time - # determine background velocity - v1 = 2 * R * sqrt(Chi) / tau_cr - v2 = 0.0 - v3 = 0.0 - Ma0 = 2.7 # background flow Mach number Ma=v/c - c = v1 / Ma0 # sound speed - # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density - p = c * c * rho / equations.gamma - # initial center of the blob - inicenter = [-15, 0, 0] - x_rel = x - inicenter - r = sqrt(x_rel[1]^2 + x_rel[2]^2 + x_rel[3]^2) - # steepness of the tanh transition zone - slope = 2 - # density blob - rho = rho + (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope *(r - R)) + 1))) - # velocity blob is zero - v1 = v1 - v1 * 0.5 * (1 + (tanh(slope *(r + R)) - (tanh(slope *(r - R)) + 1))) - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf + # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf + # change discontinuity to tanh + # typical domain is rectangular, we change it to a square + # resolution 128^3, 256^3 + # domain size is [-20.0,20.0]^3 + # gamma = 5/3 for this test case + R = 1.0 # radius of the blob + # background density + rho = 1.0 + Chi = 10.0 # density contrast + # reference time of characteristic growth of KH instability equal to 1.0 + tau_kh = 1.0 + tau_cr = tau_kh / 1.6 # crushing time + # determine background velocity + v1 = 2 * R * sqrt(Chi) / tau_cr + v2 = 0.0 + v3 = 0.0 + Ma0 = 2.7 # background flow Mach number Ma=v/c + c = v1 / Ma0 # sound speed + # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density + p = c * c * rho / equations.gamma + # initial center of the blob + inicenter = [-15, 0, 0] + x_rel = x - inicenter + r = sqrt(x_rel[1]^2 + x_rel[2]^2 + x_rel[3]^2) + # steepness of the tanh transition zone + slope = 2 + # density blob + rho = rho + + (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) + # velocity blob is zero + v1 = v1 - v1 * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_blob volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_hllc, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-20.0, -20.0, -20.0) -coordinates_max = ( 20.0, 20.0, 20.0) - -refinement_patches = ( - (type="box", coordinates_min=(-20.0, -10.0, -10.0), coordinates_max=(-10.0, 10.0, 10.0)), - (type="box", coordinates_min=(-20.0, -5.0, -5.0), coordinates_max=(-10.0, 5.0, 5.0)), - (type="box", coordinates_min=(-17.0, -2.0, -2.0), coordinates_max=(-13.0, 2.0, 2.0)), - (type="box", coordinates_min=(-17.0, -2.0, -2.0), coordinates_max=(-13.0, 2.0, 2.0)), -) +coordinates_max = (20.0, 20.0, 20.0) + +refinement_patches = ((type = "box", coordinates_min = (-20.0, -10.0, -10.0), + coordinates_max = (-10.0, 10.0, 10.0)), + (type = "box", coordinates_min = (-20.0, -5.0, -5.0), + coordinates_max = (-10.0, 5.0, 5.0)), + (type = "box", coordinates_min = (-17.0, -2.0, -2.0), + coordinates_max = (-13.0, 2.0, 2.0)), + (type = "box", coordinates_min = (-17.0, -2.0, -2.0), + coordinates_max = (-13.0, 2.0, 2.0))) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - refinement_patches=refinement_patches, - n_cells_max=100_000,) + initial_refinement_level = 2, + refinement_patches = refinement_patches, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -82,41 +84,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=200, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 200, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorLöhner(semi, - variable=Trixi.density) + variable = Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=1, - med_level =0, med_threshold=0.1, # med_level = current level - max_level =6, max_threshold=0.3) + base_level = 1, + med_level = 0, med_threshold = 0.1, # med_level = current level + max_level = 6, max_threshold = 0.3) amr_callback = AMRCallback(semi, amr_controller, - interval=3, - adapt_initial_condition=false, - adapt_initial_condition_only_refine=true) + interval = 3, + adapt_initial_condition = false, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.7) +stepsize_callback = StepsizeCallback(cfl = 1.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) - -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(1.0e-4, 1.0e-4), - variables=(Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (1.0e-4, 1.0e-4), + variables = (Trixi.density, pressure)) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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 diff --git a/examples/tree_3d_dgsem/elixir_euler_convergence.jl b/examples/tree_3d_dgsem/elixir_euler_convergence.jl index 493fef8309b..5c9675d1711 100644 --- a/examples/tree_3d_dgsem/elixir_euler_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_euler_convergence.jl @@ -9,19 +9,17 @@ equations = CompressibleEulerEquations3D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = FluxHLL(min_max_speed_naive), + volume_integral = VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_eoc_test_euler) - + source_terms = source_terms_eoc_test_euler) ############################################################################### # ODE solvers, callbacks etc. @@ -32,27 +30,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl b/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl index dbf5747784c..4789b46dacc 100644 --- a/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl +++ b/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl @@ -9,19 +9,17 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_hllc, - volume_integral=VolumeIntegralPureLGLFiniteVolume(flux_hllc)) +solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, + volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -32,27 +30,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl b/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl index ee788321c66..cad8fc578c8 100644 --- a/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl +++ b/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl @@ -14,33 +14,31 @@ A Gaussian pulse in the density with constant velocity and pressure; reduces the compressible Euler equations to the linear advection equations. """ function initial_condition_density_pulse(x, t, equations::CompressibleEulerEquations3D) - rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2))/2 - v1 = 1 - v2 = 1 - v3 = 1 - rho_v1 = rho * v1 - rho_v2 = rho * v2 - rho_v3 = rho * v3 - p = 1 - rho_e = p/(equations.gamma - 1) + 1/2 * rho * (v1^2 + v2^2 + v3^2) - return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) + rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2)) / 2 + v1 = 1 + v2 = 1 + v3 = 1 + rho_v1 = rho * v1 + rho_v2 = rho * v2 + rho_v3 = rho * v3 + p = 1 + rho_e = p / (equations.gamma - 1) + 1 / 2 * rho * (v1^2 + v2^2 + v3^2) + return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) end initial_condition = initial_condition_density_pulse volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = ( 2.0, 2.0, 2.0) +coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=100_000) - + initial_refinement_level = 3, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -50,30 +48,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_ec.jl b/examples/tree_3d_dgsem/elixir_euler_ec.jl index 08fd1b998d5..88d7cbc7ba5 100644 --- a/examples/tree_3d_dgsem/elixir_euler_ec.jl +++ b/examples/tree_3d_dgsem/elixir_euler_ec.jl @@ -10,19 +10,17 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = ( 2.0, 2.0, 2.0) +coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=100_000) - + initial_refinement_level = 3, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,27 +30,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.3) +stepsize_callback = StepsizeCallback(cfl = 1.3) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_mortar.jl b/examples/tree_3d_dgsem/elixir_euler_mortar.jl index c9fc2dfed50..cf103dc26cf 100644 --- a/examples/tree_3d_dgsem/elixir_euler_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_euler_mortar.jl @@ -8,22 +8,19 @@ using Trixi equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) -refinement_patches = ( - (type="box", coordinates_min=(0.5, 0.5, 0.5), coordinates_max=(1.5, 1.5, 1.5)), -) +refinement_patches = ((type = "box", coordinates_min = (0.5, 0.5, 0.5), + coordinates_max = (1.5, 1.5, 1.5)),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - refinement_patches=refinement_patches, - n_cells_max=10_000) - + initial_refinement_level = 2, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -34,16 +31,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -53,7 +50,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl index 8e0625dea3a..f76272f1dde 100644 --- a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -19,34 +19,34 @@ based on Should be used together with [`boundary_condition_sedov_self_gravity`](@ref). """ function initial_condition_sedov_self_gravity(x, t, equations::CompressibleEulerEquations3D) - # Calculate radius as distance from origin - r = sqrt(x[1]^2 + x[2]^2 + x[3]^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 - r0 = 0.25 # = 4.0 * smallest dx (for domain length=8 and max-ref=7) - E = 1.0 - p_inner = (equations.gamma - 1) * E / (4/3 * pi * r0^3) - p_ambient = 1e-5 # = true Sedov setup - - # Calculate primitive variables - # use a logistic function to transfer density value smoothly - L = 1.0 # maximum of function - x0 = 1.0 # center point of function - k = -50.0 # sharpness of transfer - logistic_function_rho = L/(1.0 + exp(-k*(r - x0))) - rho_ambient = 1e-5 - rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny - - # velocities are zero - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - - # use a logistic function to transfer pressure value smoothly - logistic_function_p = p_inner/(1.0 + exp(-k*(r - r0))) - p = max(logistic_function_p, p_ambient) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Calculate radius as distance from origin + r = sqrt(x[1]^2 + x[2]^2 + x[3]^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 + r0 = 0.25 # = 4.0 * smallest dx (for domain length=8 and max-ref=7) + E = 1.0 + p_inner = (equations.gamma - 1) * E / (4 / 3 * pi * r0^3) + p_ambient = 1e-5 # = true Sedov setup + + # Calculate primitive variables + # use a logistic function to transfer density value smoothly + L = 1.0 # maximum of function + x0 = 1.0 # center point of function + k = -50.0 # sharpness of transfer + logistic_function_rho = L / (1.0 + exp(-k * (r - x0))) + rho_ambient = 1e-5 + rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny + + # velocities are zero + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + + # use a logistic function to transfer pressure value smoothly + logistic_function_p = p_inner / (1.0 + exp(-k * (r - r0))) + p = max(logistic_function_p, p_ambient) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_sedov_self_gravity @@ -64,26 +64,26 @@ based on Should be used together with [`initial_condition_sedov_self_gravity`](@ref). """ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, x, t, - surface_flux_function, - equations::CompressibleEulerEquations3D) - # velocities are zero, density/pressure are ambient values according to - # initial_condition_sedov_self_gravity - rho = 1e-5 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = 1e-5 - - u_boundary = prim2cons(SVector(rho, v1, v2, v3, p), equations) - - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end - - return flux + surface_flux_function, + equations::CompressibleEulerEquations3D) + # velocities are zero, density/pressure are ambient values according to + # initial_condition_sedov_self_gravity + rho = 1e-5 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = 1e-5 + + u_boundary = prim2cons(SVector(rho, v1, v2, v3, p), equations) + + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end + + return flux end boundary_conditions = boundary_condition_sedov_self_gravity @@ -92,26 +92,24 @@ volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.7, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 0.7, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-4.0, -4.0, -4.0) -coordinates_max = ( 4.0, 4.0, 4.0) +coordinates_max = (4.0, 4.0, 4.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=1_000_000, - periodicity=false) - + initial_refinement_level = 2, + n_cells_max = 1_000_000, + periodicity = false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -122,42 +120,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max=1.0, - alpha_min=0.0, - alpha_smooth=false, - variable=density_pressure) + alpha_max = 1.0, + alpha_min = 0.0, + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=2, - max_level =7, max_threshold=0.0003) + base_level = 2, + max_level = 7, max_threshold = 0.0003) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=0.35) +stepsize_callback = StepsizeCallback(cfl = 0.35) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl b/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl index 3015f6c50a4..0a90615016c 100644 --- a/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl +++ b/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl @@ -10,30 +10,28 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_ranocha # OBS! Using a non-dissipative flux is only sensible to test EC, - # but not for real shock simulations +# but not for real shock simulations volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = ( 2.0, 2.0, 2.0) +coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=100_000) - + initial_refinement_level = 3, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -43,27 +41,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.4) +stepsize_callback = StepsizeCallback(cfl = 1.4) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl b/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl index 3d338cd7f01..be31fbbc42c 100644 --- a/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl +++ b/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl @@ -10,30 +10,28 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_ranocha # OBS! Using a non-dissipative flux is only sensible to test EC, - # but not for real shock simulations +# but not for real shock simulations volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = ( 2.0, 2.0, 2.0) +coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=100_000) - + initial_refinement_level = 3, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -43,41 +41,39 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_smooth=false, - variable=density_pressure) + alpha_smooth = false, + variable = density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level=2, - max_level =4, max_threshold=0.0003) + base_level = 2, + max_level = 4, max_threshold = 0.0003) amr_callback = AMRCallback(semi, amr_controller, - interval=1, - adapt_initial_condition=true, - adapt_initial_condition_only_refine=true) + interval = 1, + adapt_initial_condition = true, + adapt_initial_condition_only_refine = true) -stepsize_callback = StepsizeCallback(cfl=1.3) +stepsize_callback = StepsizeCallback(cfl = 1.3) 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); +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 - diff --git a/examples/tree_3d_dgsem/elixir_euler_source_terms.jl b/examples/tree_3d_dgsem/elixir_euler_source_terms.jl index 3445e9fc433..f0246c30490 100644 --- a/examples/tree_3d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_3d_dgsem/elixir_euler_source_terms.jl @@ -9,19 +9,17 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -32,27 +30,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=0.6) +stepsize_callback = StepsizeCallback(cfl = 0.6) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl b/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl index 693f9ce9049..135ee673e44 100644 --- a/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl +++ b/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl @@ -12,35 +12,37 @@ equations = CompressibleEulerEquations3D(1.4) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, + equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + + 1.0 / 16.0 * A^2 * rho * + (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + + cos(2 * x[2]) * cos(2 * x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = ( 1.0, 1.0, 1.0) .* pi +coordinates_max = (1.0, 1.0, 1.0) .* pi mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=100_000) - + initial_refinement_level = 3, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -50,27 +52,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.4) +stepsize_callback = StepsizeCallback(cfl = 1.4) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl index 3935a219a96..0a8c427bf8d 100644 --- a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl @@ -15,12 +15,12 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, - source_terms=source_terms_eoc_test_coupled_euler_gravity) + initial_refinement_level = 2, + n_cells_max = 10_000) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, + solver_euler, + source_terms = source_terms_eoc_test_coupled_euler_gravity) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -28,22 +28,21 @@ equations_gravity = HyperbolicDiffusionEquations3D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, - source_terms=source_terms_harmonic) - +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, + solver_gravity, + source_terms = source_terms_harmonic) ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 - gravitational_constant=1.0, # aka G - cfl=1.5, - resid_tol=1.0e-10, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!) +parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 + gravitational_constant = 1.0, # aka G + cfl = 1.5, + resid_tol = 1.0e-10, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) - ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -52,20 +51,20 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, - save_analysis=true) +analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, + save_analysis = true) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -74,11 +73,10 @@ callbacks = CallbackSet(summary_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl b/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl index c7744ce23bd..7bba154a925 100644 --- a/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl +++ b/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl @@ -8,53 +8,52 @@ using Trixi equations = HyperbolicDiffusionEquations3D() function initial_condition_poisson_periodic(x, t, equations::HyperbolicDiffusionEquations3D) - # elliptic equation: -νΔϕ = f - # depending on initial constant state, c, for phi this converges to the solution ϕ + c - if iszero(t) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - q3 = 0.0 - else - phi = sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) - q1 = 2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) - q2 = 2 * pi * sin(2 * pi * x[1]) * cos(2 * pi * x[2]) * sin(2 * pi * x[3]) - q3 = 2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * x[3]) - end - return SVector(phi, q1, q2, q3) + # elliptic equation: -νΔϕ = f + # depending on initial constant state, c, for phi this converges to the solution ϕ + c + if iszero(t) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + q3 = 0.0 + else + phi = sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) + q1 = 2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) + q2 = 2 * pi * sin(2 * pi * x[1]) * cos(2 * pi * x[2]) * sin(2 * pi * x[3]) + q3 = 2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * x[3]) + end + return SVector(phi, q1, q2, q3) end initial_condition = initial_condition_poisson_periodic -@inline function source_terms_poisson_periodic(u, x, t, equations::HyperbolicDiffusionEquations3D) - # elliptic equation: -νΔϕ = f - # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) - @unpack inv_Tr = equations - C = -12 * equations.nu * pi^2 - - x1, x2, x3 = x - tmp1 = sinpi(2 * x1) - tmp2 = sinpi(2 * x2) - tmp3 = sinpi(2 * x3) - du1 = -C*tmp1*tmp2*tmp3 - du2 = -inv_Tr * u[2] - du3 = -inv_Tr * u[3] - du4 = -inv_Tr * u[4] - - return SVector(du1, du2, du3, du4) +@inline function source_terms_poisson_periodic(u, x, t, + equations::HyperbolicDiffusionEquations3D) + # elliptic equation: -νΔϕ = f + # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) + @unpack inv_Tr = equations + C = -12 * equations.nu * pi^2 + + x1, x2, x3 = x + tmp1 = sinpi(2 * x1) + tmp2 = sinpi(2 * x2) + tmp3 = sinpi(2 * x3) + du1 = -C * tmp1 * tmp2 * tmp3 + du2 = -inv_Tr * u[2] + du3 = -inv_Tr * u[3] + du4 = -inv_Tr * u[4] + + return SVector(du1, du2, du3, du4) end -solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=30_000) - + initial_refinement_level = 3, + n_cells_max = 30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_poisson_periodic) - + source_terms = source_terms_poisson_periodic) ############################################################################### # ODE solvers, callbacks etc. @@ -65,20 +64,20 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=2.4) +stepsize_callback = StepsizeCallback(cfl = 2.4) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, @@ -89,6 +88,6 @@ callbacks = CallbackSet(summary_callback, steady_state_callback, # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=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 diff --git a/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl index beefb22ea1e..831e01519b6 100644 --- a/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -8,27 +8,25 @@ using Trixi equations = HyperbolicDiffusionEquations3D() initial_condition = initial_condition_poisson_nonperiodic -boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, - x_pos=boundary_condition_poisson_nonperiodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - z_neg=boundary_condition_periodic, - z_pos=boundary_condition_periodic) +boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, + x_pos = boundary_condition_poisson_nonperiodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic, + z_neg = boundary_condition_periodic, + z_pos = boundary_condition_periodic) -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=30_000, - periodicity=(false, true, true)) - + initial_refinement_level = 2, + n_cells_max = 30_000, + periodicity = (false, true, true)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_poisson_nonperiodic, - boundary_conditions=boundary_conditions) - + source_terms = source_terms_poisson_nonperiodic, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -39,31 +37,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 1.0e-5 -steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.8) +stepsize_callback = StepsizeCallback(cfl = 1.8) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) - ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep=false, callback=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 diff --git a/examples/tree_3d_dgsem/elixir_lbm_constant.jl b/examples/tree_3d_dgsem/elixir_lbm_constant.jl index 269a0da2d50..ee38f62887d 100644 --- a/examples/tree_3d_dgsem/elixir_lbm_constant.jl +++ b/examples/tree_3d_dgsem/elixir_lbm_constant.jl @@ -5,22 +5,20 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D3Q27 scheme -equations = LatticeBoltzmannEquations3D(Ma=0.1, Re=Inf) +equations = LatticeBoltzmannEquations3D(Ma = 0.1, Re = Inf) initial_condition = initial_condition_constant -solver = DGSEM(polydeg=3, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = ( 1.0, 1.0, 1.0) +coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000,) - + initial_refinement_level = 3, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -30,19 +28,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=100, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 100, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2macroscopic) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) collision_callback = LBMCollisionCallback() @@ -52,11 +50,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl b/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl index b3835eb1287..0980ee56be3 100644 --- a/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl +++ b/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the Lattice-Boltzmann equations for the D3Q27 scheme L = 1.0 # reference length -equations = LatticeBoltzmannEquations3D(Ma=0.1, Re=1600.0; L=L) +equations = LatticeBoltzmannEquations3D(Ma = 0.1, Re = 1600.0; L = L) """ initial_condition_taylor_green_vortex(x, t, equations::LatticeBoltzmannEquations3D) @@ -14,52 +14,51 @@ equations = LatticeBoltzmannEquations3D(Ma=0.1, Re=1600.0; L=L) Initialize the flow field to the Taylor-Green vortex setup """ function initial_condition_taylor_green_vortex(x, t, equations::LatticeBoltzmannEquations3D) - @unpack u0, rho0, L = equations + @unpack u0, rho0, L = equations - v1 = u0 * sin(x[1] / L) * cos(x[2] / L) * cos(x[3] / L) - v2 = -u0 * cos(x[1] / L) * sin(x[2] / L) * cos(x[3] / L) - v3 = 0 - p0 = (pressure(rho0, equations) + - rho0 * u0^2 / 16 * (cos(2 * x[1] / L) + cos(2 * x[2] / L)) * (cos(2 * x[3] / L) + 2)) - rho = density(p0, equations) + v1 = u0 * sin(x[1] / L) * cos(x[2] / L) * cos(x[3] / L) + v2 = -u0 * cos(x[1] / L) * sin(x[2] / L) * cos(x[3] / L) + v3 = 0 + p0 = (pressure(rho0, equations) + + rho0 * u0^2 / 16 * (cos(2 * x[1] / L) + cos(2 * x[2] / L)) * + (cos(2 * x[3] / L) + 2)) + rho = density(p0, equations) - return equilibrium_distribution(rho, v1, v2, v3, equations) + return equilibrium_distribution(rho, v1, v2, v3, equations) end initial_condition = initial_condition_taylor_green_vortex -solver = DGSEM(polydeg=3, surface_flux=flux_godunov) +solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) -coordinates_min = (-pi*L, -pi*L, -pi*L) -coordinates_max = ( pi*L, pi*L, pi*L) +coordinates_min = (-pi * L, -pi * L, -pi * L) +coordinates_max = (pi * L, pi * L, pi * L) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=5, - n_cells_max=300_000,) - + initial_refinement_level = 5, + n_cells_max = 300_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 20*equations.L/equations.u0) # Final time is `20` in non-dimensional time +tspan = (0.0, 20 * equations.L / equations.u0) # Final time is `20` in non-dimensional time ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 20 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(Trixi.energy_kinetic_nondimensional,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (Trixi.energy_kinetic_nondimensional,)) -alive_callback = AliveCallback(analysis_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=cons2macroscopic) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl=0.3) +stepsize_callback = StepsizeCallback(cfl = 0.3) collision_callback = LBMCollisionCallback() @@ -69,12 +68,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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, - save_start=false, alias_u0=true); +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, + save_start = false, alias_u0 = true); summary_callback() # print the timer summary diff --git a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl index 191982bf2d6..9aab5e58788 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,24 +5,23 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5/3) +equations = IdealGlmMhdEquations3D(5 / 3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = ( 1.0, 1.0, 1.0) +coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,18 +31,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.5 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -51,11 +50,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl index 1d173922391..f5f6e70a592 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl @@ -5,24 +5,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5/3) +equations = IdealGlmMhdEquations3D(5 / 3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = ( 1.0, 1.0, 1.0) -refinement_patches = ( - (type="box", coordinates_min=(-0.5, -0.5, -0.5), - coordinates_max=( 0.5, 0.5, 0.5)), -) +coordinates_max = (1.0, 1.0, 1.0) +refinement_patches = ((type = "box", coordinates_min = (-0.5, -0.5, -0.5), + coordinates_max = (0.5, 0.5, 0.5)),) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - refinement_patches=refinement_patches, - n_cells_max=10_000) + initial_refinement_level = 2, + refinement_patches = refinement_patches, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -35,18 +35,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -54,11 +54,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_mhd_ec.jl b/examples/tree_3d_dgsem/elixir_mhd_ec.jl index 057ffcb031f..1f0088e82c9 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_ec.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_ec.jl @@ -10,19 +10,18 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, + surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = ( 2.0, 2.0, 2.0) +coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) - + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -32,19 +31,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -52,11 +51,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl b/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl index 6b4f6e310ce..f8a72b6f452 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl @@ -10,25 +10,26 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = ( 2.0, 2.0, 2.0) +coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=10_000) + initial_refinement_level = 3, + n_cells_max = 10_000) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -42,25 +43,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl b/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl index b32355c48df..7d6f6acd166 100644 --- a/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl @@ -8,241 +8,257 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), Prandtl=prandtl_number(), - gradient_variables=GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesPrimitive()) # 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, - volume_integral=VolumeIntegralWeakForm()) +solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, + volume_integral = VolumeIntegralWeakForm()) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - periodicity=(true, false, true), - n_cells_max=50_000) # set maximum capacity of tree data structure + initial_refinement_level = 3, + periodicity = (true, false, true), + n_cells_max = 50_000) # set maximum capacity of tree data structure # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion3D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion3D`) # and by the initial condition (which passes in `CompressibleEulerEquations3D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * cos(pi_t) - v2 = v1 - v3 = v1 - p = rho^2 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * + cos(pi_t) + v2 = v1 + v3 = v1 + p = rho^2 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - # Define auxiliary functions for the strange function of the y variable - # to make expressions easier to read - g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) - g_y = ( A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) - + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0) ) - g_yy = ( 2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) - - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) - - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) ) - - # Density and its derivatives - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) - rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) - rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) - rho_xx = -pi^2 * (rho - c) - rho_yy = -pi^2 * (rho - c) - rho_zz = -pi^2 * (rho - c) - - # Velocities and their derivatives - # v1 terms - v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) - v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_xx = -pi^2 * v1 - v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) - v1_zz = -pi^2 * v1 - v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) - # v2 terms (simplifies from ansatz) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_z = v1_z - v2_xx = v1_xx - v2_yy = v1_yy - v2_zz = v1_zz - v2_xy = v1_xy - v2_yz = v1_yz - # v3 terms (simplifies from ansatz) - v3 = v1 - v3_t = v1_t - v3_x = v1_x - v3_y = v1_y - v3_z = v1_z - v3_xx = v1_xx - v3_yy = v1_yy - v3_zz = v1_zz - v3_xz = v1_xz - v3_yz = v1_yz - - # Pressure and its derivatives - p = rho^2 - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_z = 2.0 * rho * rho_z - - # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 - E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 - E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y - E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z - - # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho - kappa = equations.gamma * inv_gamma_minus_one / Pr - q_xx = kappa * rho_xx # kappa T_xx - q_yy = kappa * rho_yy # kappa T_yy - q_zz = kappa * rho_zz # kappa T_zz - - # Stress tensor and its derivatives (exploit symmetry) - tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) - tau12 = v1_y + v2_x - tau13 = v1_z + v3_x - tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) - tau23 = v2_z + v3_y - tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) - - tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) - tau12_x = v1_xy + v2_xx - tau13_x = v1_xz + v3_xx - - tau12_y = v1_yy + v2_xy - tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) - tau23_y = v2_yz + v3_yy - - tau13_z = v1_zz + v3_xz - tau23_z = v2_zz + v3_yz - tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) - - # Compute the source terms - # Density equation - du1 = ( rho_t + rho_x * v1 + rho * v1_x - + rho_y * v2 + rho * v2_y - + rho_z * v3 + rho * v3_z ) - # x-momentum equation - du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - + rho_z * v1 * v3 - + rho * v1_z * v3 - + rho * v1 * v3_z - - mu_ * (tau11_x + tau12_y + tau13_z) ) - # y-momentum equation - du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - + rho_z * v2 * v3 - + rho * v2_z * v3 - + rho * v2 * v3_z - - mu_ * (tau12_x + tau22_y + tau23_z) ) - # z-momentum equation - du4 = ( rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 - + rho * v1_x * v3 - + rho * v1 * v3_x - + rho_y * v2 * v3 - + rho * v2_y * v3 - + rho * v2 * v3_y - + rho_z * v3^2 - + 2.0 * rho * v3 * v3_z - - mu_ * (tau13_x + tau23_y + tau33_z) ) - # Total energy equation - du5 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - + v3_z * (E + p) + v3 * (E_z + p_z) - # stress tensor and temperature gradient from x-direction - - mu_ * ( q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 - + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) - # stress tensor and temperature gradient terms from y-direction - - mu_ * ( q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 - + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) - # stress tensor and temperature gradient terms from z-direction - - mu_ * ( q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 - + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z) ) - - return SVector(du1, du2, du3, du4, du5) + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + # Define auxiliary functions for the strange function of the y variable + # to make expressions easier to read + g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) + g_y = (A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) + + + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0)) + g_yy = (2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) + - + (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) + - + A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0))) + + # Density and its derivatives + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) + rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) + rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) + rho_xx = -pi^2 * (rho - c) + rho_yy = -pi^2 * (rho - c) + rho_zz = -pi^2 * (rho - c) + + # Velocities and their derivatives + # v1 terms + v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) + v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_xx = -pi^2 * v1 + v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) + v1_zz = -pi^2 * v1 + v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) + # v2 terms (simplifies from ansatz) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_z = v1_z + v2_xx = v1_xx + v2_yy = v1_yy + v2_zz = v1_zz + v2_xy = v1_xy + v2_yz = v1_yz + # v3 terms (simplifies from ansatz) + v3 = v1 + v3_t = v1_t + v3_x = v1_x + v3_y = v1_y + v3_z = v1_z + v3_xx = v1_xx + v3_yy = v1_yy + v3_zz = v1_zz + v3_xz = v1_xz + v3_yz = v1_yz + + # Pressure and its derivatives + p = rho^2 + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_z = 2.0 * rho * rho_z + + # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 + E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 + E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y + E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z + + # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho + kappa = equations.gamma * inv_gamma_minus_one / Pr + q_xx = kappa * rho_xx # kappa T_xx + q_yy = kappa * rho_yy # kappa T_yy + q_zz = kappa * rho_zz # kappa T_zz + + # Stress tensor and its derivatives (exploit symmetry) + tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) + tau12 = v1_y + v2_x + tau13 = v1_z + v3_x + tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) + tau23 = v2_z + v3_y + tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) + + tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) + tau12_x = v1_xy + v2_xx + tau13_x = v1_xz + v3_xx + + tau12_y = v1_yy + v2_xy + tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) + tau23_y = v2_yz + v3_yy + + tau13_z = v1_zz + v3_xz + tau23_z = v2_zz + v3_yz + tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) + + # Compute the source terms + # Density equation + du1 = (rho_t + rho_x * v1 + rho * v1_x + + rho_y * v2 + rho * v2_y + + rho_z * v3 + rho * v3_z) + # x-momentum equation + du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + + rho_z * v1 * v3 + + rho * v1_z * v3 + + rho * v1 * v3_z + - + mu_ * (tau11_x + tau12_y + tau13_z)) + # y-momentum equation + du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + + rho_z * v2 * v3 + + rho * v2_z * v3 + + rho * v2 * v3_z + - + mu_ * (tau12_x + tau22_y + tau23_z)) + # z-momentum equation + du4 = (rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 + + rho * v1_x * v3 + + rho * v1 * v3_x + + rho_y * v2 * v3 + + rho * v2_y * v3 + + rho * v2 * v3_y + + rho_z * v3^2 + + 2.0 * rho * v3 * v3_z + - + mu_ * (tau13_x + tau23_y + tau33_z)) + # Total energy equation + du5 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + + v3_z * (E + p) + v3 * (E_z + p_z) + # stress tensor and temperature gradient from x-direction + - + mu_ * (q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 + + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) + # stress tensor and temperature gradient terms from y-direction + - + mu_ * (q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 + + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) + # stress tensor and temperature gradient terms from z-direction + - + mu_ * (q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 + + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z)) + + return SVector(du1, du2, du3, du4, du5) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, + t, + equations)[2:4]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, + heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_slip_wall, - y_pos = boundary_condition_slip_wall, - z_neg = boundary_condition_periodic, - z_pos = boundary_condition_periodic) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_slip_wall, + y_pos = boundary_condition_slip_wall, + z_neg = boundary_condition_periodic, + z_pos = boundary_condition_periodic) # define viscous boundary conditions boundary_conditions_parabolic = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_top_bottom, - y_pos = boundary_condition_top_bottom, - z_neg = boundary_condition_periodic, - z_pos = boundary_condition_periodic) - -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_top_bottom, + y_pos = boundary_condition_top_bottom, + z_neg = boundary_condition_periodic, + z_pos = boundary_condition_periodic) + +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, solver; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -252,16 +268,15 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval=10) +alive_callback = AliveCallback(alive_interval = 10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, dt = 1e-5, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, dt = 1e-5, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary - diff --git a/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl b/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl index 9cb73a462b7..5e2fb4e395e 100644 --- a/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl +++ b/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl @@ -10,39 +10,42 @@ prandtl_number() = 0.72 mu() = 6.25e-4 # equivalent to Re = 1600 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), - Prandtl=prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), + Prandtl = prandtl_number()) """ initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, + equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + + 1.0 / 16.0 * A^2 * rho * + (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + + cos(2 * x[2]) * cos(2 * x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=flux_hllc, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = ( 1.0, 1.0, 1.0) .* pi +coordinates_max = (1.0, 1.0, 1.0) .* pi mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=3, - n_cells_max=100_000) - + initial_refinement_level = 3, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver) @@ -56,12 +59,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 50 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_integrals=(energy_kinetic, - energy_internal, - enstrophy)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (energy_kinetic, + energy_internal, + enstrophy)) -alive_callback = AliveCallback(analysis_interval=analysis_interval,) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -71,6 +75,6 @@ callbacks = CallbackSet(summary_callback, # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/tree_3d_fdsbp/elixir_advection_extended.jl b/examples/tree_3d_fdsbp/elixir_advection_extended.jl index 241e0698649..22085a63510 100644 --- a/examples/tree_3d_fdsbp/elixir_advection_extended.jl +++ b/examples/tree_3d_fdsbp/elixir_advection_extended.jl @@ -13,22 +13,21 @@ equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_convergence_test D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=10) + derivative_order = 1, accuracy_order = 4, + xmin = 0.0, xmax = 1.0, N = 10) solver = FDSBP(D_SBP, - surface_integral=SurfaceIntegralStrongForm(flux_lax_friedrichs), - volume_integral=VolumeIntegralStrongForm()) + surface_integral = SurfaceIntegralStrongForm(flux_lax_friedrichs), + volume_integral = VolumeIntegralStrongForm()) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = ( 1.0, 1.0, 1.0) +coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=1, - n_cells_max=30_000, - periodicity=true) + initial_refinement_level = 1, + n_cells_max = 30_000, + periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -38,19 +37,18 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(energy_total,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (energy_total,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) - ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-9, reltol=1.0e-9, - ode_default_options()..., callback=callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-9, reltol = 1.0e-9, + ode_default_options()..., callback = callbacks) summary_callback() diff --git a/examples/tree_3d_fdsbp/elixir_euler_convergence.jl b/examples/tree_3d_fdsbp/elixir_euler_convergence.jl index 576a07e6aba..8a59af1f921 100644 --- a/examples/tree_3d_fdsbp/elixir_euler_convergence.jl +++ b/examples/tree_3d_fdsbp/elixir_euler_convergence.jl @@ -12,24 +12,23 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=10_000) + initial_refinement_level = 2, + n_cells_max = 10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) - + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,27 +39,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl=1.1) +stepsize_callback = StepsizeCallback(cfl = 1.1) 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); +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 diff --git a/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl b/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl index d2495cff5cd..0354200ae42 100644 --- a/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl +++ b/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl @@ -14,40 +14,43 @@ equations = CompressibleEulerEquations3D(1.4) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, + equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + + 1.0 / 16.0 * A^2 * rho * + (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + + cos(2 * x[2]) * cos(2 * x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order=1, - accuracy_order=4, - xmin=-1.0, xmax=1.0, - N=16) + derivative_order = 1, + accuracy_order = 4, + xmin = -1.0, xmax = 1.0, + N = 16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral=SurfaceIntegralUpwind(flux_splitting), - volume_integral=VolumeIntegralUpwind(flux_splitting)) + surface_integral = SurfaceIntegralUpwind(flux_splitting), + volume_integral = VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = ( 1.0, 1.0, 1.0) .* pi +coordinates_max = (1.0, 1.0, 1.0) .* pi mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level=2, - n_cells_max=100_000) + initial_refinement_level = 2, + n_cells_max = 100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - ############################################################################### # ODE solvers, callbacks etc. @@ -57,28 +60,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(energy_total, - energy_kinetic, - energy_internal,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) - ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks) +sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks) summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl b/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl index 2f8228dffb8..8f8e867dca8 100644 --- a/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl +++ b/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl @@ -6,16 +6,18 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global=(0.0, -0.5), c_mean_global=1.0, - rho_mean_global=1.0) +equations = AcousticPerturbationEquations2D(v_mean_global = (0.0, -0.5), + c_mean_global = 1.0, + rho_mean_global = 1.0) # Create DG solver with polynomial degree = 4 and (local) Lax-Friedrichs/Rusanov flux -solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) # Create unstructured quadrilateral mesh from a file default_mesh_file = joinpath(@__DIR__, "mesh_five_circles_in_circle.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/3c79baad6b4d73bb26ec6420b5d16f45/raw/22aefc4ec2107cf0bffc40e81dfbc52240c625b1/mesh_five_circles_in_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/3c79baad6b4d73bb26ec6420b5d16f45/raw/22aefc4ec2107cf0bffc40e81dfbc52240c625b1/mesh_five_circles_in_circle.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = UnstructuredMesh2D(mesh_file) @@ -27,27 +29,26 @@ A Gaussian pulse, used in the `gauss_wall` example elixir in combination with [`boundary_condition_wall`](@ref). Uses the global mean values from `equations`. """ function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D) - v1_prime = 0.0 - v2_prime = 0.0 - p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) + v1_prime = 0.0 + v2_prime = 0.0 + p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) - prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) + prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) - return prim2cons(prim, equations) + return prim2cons(prim, equations) end initial_condition = initial_condition_gauss_wall -boundary_conditions = Dict( :OuterCircle => boundary_condition_slip_wall, - :InnerCircle1 => boundary_condition_slip_wall, - :InnerCircle2 => boundary_condition_slip_wall, - :InnerCircle3 => boundary_condition_slip_wall, - :InnerCircle4 => boundary_condition_slip_wall, - :InnerCircle5 => boundary_condition_slip_wall ) +boundary_conditions = Dict(:OuterCircle => boundary_condition_slip_wall, + :InnerCircle1 => boundary_condition_slip_wall, + :InnerCircle2 => boundary_condition_slip_wall, + :InnerCircle3 => boundary_condition_slip_wall, + :InnerCircle4 => boundary_condition_slip_wall, + :InnerCircle5 => boundary_condition_slip_wall) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -61,10 +62,10 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +analysis_callback = AnalysisCallback(semi, interval = 100) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval=50, solution_variables=cons2state) +save_solution = SaveSolutionCallback(interval = 50, solution_variables = cons2state) # 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) @@ -73,7 +74,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, save_solution) # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, + ode_default_options()..., callback = callbacks); # Print the timer summary summary_callback() diff --git a/examples/unstructured_2d_dgsem/elixir_advection_basic.jl b/examples/unstructured_2d_dgsem/elixir_advection_basic.jl index 274978d48b0..afef6c2c38f 100644 --- a/examples/unstructured_2d_dgsem/elixir_advection_basic.jl +++ b/examples/unstructured_2d_dgsem/elixir_advection_basic.jl @@ -12,22 +12,24 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=6, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 6, surface_flux = flux_lax_friedrichs) ############################################################################### # 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) ############################################################################### # create the semi discretization object -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, + solver) ############################################################################### # ODE solvers, callbacks etc. @@ -40,22 +42,23 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval=100) +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) +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) +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) +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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_basic.jl b/examples/unstructured_2d_dgsem/elixir_euler_basic.jl index 9fbea47a9d5..cd6a1995757 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_basic.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_basic.jl @@ -12,23 +12,24 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict( :Slant => boundary_condition_convergence_test, - :Bezier => boundary_condition_convergence_test, - :Right => boundary_condition_convergence_test, - :Bottom => boundary_condition_convergence_test, - :Top => boundary_condition_convergence_test ) +boundary_conditions = Dict(:Slant => boundary_condition_convergence_test, + :Bezier => boundary_condition_convergence_test, + :Right => boundary_condition_convergence_test, + :Bottom => boundary_condition_convergence_test, + :Top => boundary_condition_convergence_test) ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=8, surface_flux=flux_lax_friedrichs) +solver = DGSEM(polydeg = 8, surface_flux = flux_lax_friedrichs) ############################################################################### # Get the curved quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_trixi_unstructured_mesh_docs.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = UnstructuredMesh2D(mesh_file) @@ -37,8 +38,8 @@ mesh = UnstructuredMesh2D(mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms, - boundary_conditions=boundary_conditions) + source_terms = source_terms, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -49,18 +50,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_restart = SaveRestartCallback(interval=50, - save_final_restart=true) +save_restart = SaveRestartCallback(interval = 50, + save_final_restart = true) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=0.9) +stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -72,7 +73,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_ec.jl b/examples/unstructured_2d_dgsem/elixir_euler_ec.jl index 2725142fd17..0f53aa62a18 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_ec.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_ec.jl @@ -6,7 +6,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerEquations2D(5/3) +equations = CompressibleEulerEquations2D(5 / 3) initial_condition = initial_condition_weak_blast_wave @@ -14,18 +14,19 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg=6, surface_flux=flux_ranocha, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 6, surface_flux = flux_ranocha, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the curved quad mesh from a file 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) ############################################################################### # create the semi discretization object @@ -41,15 +42,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -60,7 +61,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl index cb289848039..1110ebd003f 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl @@ -11,25 +11,26 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_constant 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 ) +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 DG approximation space -solver = DGSEM(polydeg=6, surface_flux=FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg = 6, surface_flux = FluxHLL(min_max_speed_naive)) ############################################################################### # 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) +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) @@ -38,7 +39,7 @@ mesh = UnstructuredMesh2D(mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -49,15 +50,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -65,7 +66,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl index 5f248eb110d..7e90431f5b6 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl @@ -15,24 +15,25 @@ boundary_conditions = boundary_condition_periodic ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=6, surface_flux=FluxRotated(FluxHLL(min_max_speed_naive))) +solver = DGSEM(polydeg = 6, surface_flux = FluxRotated(FluxHLL(min_max_speed_naive))) ############################################################################### # 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) ############################################################################### # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms, - boundary_conditions=boundary_conditions) + source_terms = source_terms, + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -43,14 +44,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); ode_default_options()..., callback=callbacks); +sol = solve(ode, SSPRK43(); ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_euler_restart.jl b/examples/unstructured_2d_dgsem/elixir_euler_restart.jl index 2ac67652023..5f66ad15cbd 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_restart.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_restart.jl @@ -7,7 +7,6 @@ using Trixi trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_basic.jl")) - ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -18,18 +17,16 @@ restart_filename = joinpath("out", "restart_000050.h5") mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms, - boundary_conditions=boundary_conditions) + source_terms = source_terms, + boundary_conditions = boundary_conditions) tspan = (load_time(restart_filename), 1.0) ode = semidiscretize(semi, tspan, restart_filename); - ############################################################################### # 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); +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 - diff --git a/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl b/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl index 3d5a391bd90..55d63deb135 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) - p0_outer = 1.0e-5 # = true Sedov 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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) + p0_outer = 1.0e-5 # = true Sedov 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 @@ -43,23 +43,25 @@ volume_flux = flux_ranocha polydeg = 6 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=1.0, - alpha_min=0.001, - alpha_smooth=true, - variable=density_pressure) + alpha_max = 1.0, + 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) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) # Get the curved quad mesh from a file 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # create the semidiscretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -73,15 +75,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=300, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 300, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=0.5) +stepsize_callback = StepsizeCallback(cfl = 0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -92,7 +94,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl index e300b39c01e..702fe74c73b 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl @@ -10,40 +10,41 @@ equations = CompressibleEulerEquations2D(1.4) @inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.0 - u_freestream = 0.3 - p_freestream = inv(equations.gamma) - - theta = pi / 90.0 # analogous with a two degree angle of attack - si, co = sincos(theta) - v1 = u_freestream * co - v2 = u_freestream * si - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.0 + u_freestream = 0.3 + p_freestream = inv(equations.gamma) + + theta = pi / 90.0 # analogous with a two degree angle of attack + si, co = sincos(theta) + v1 = u_freestream * co + v2 = u_freestream * si + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = uniform_flow_state boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state) -boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, - :Top => boundary_condition_uniform_flow, - :Right => boundary_condition_uniform_flow, - :Left => boundary_condition_uniform_flow, - :Circle => boundary_condition_slip_wall ) +boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow, + :Top => boundary_condition_uniform_flow, + :Right => boundary_condition_uniform_flow, + :Left => boundary_condition_uniform_flow, + :Circle => boundary_condition_slip_wall) ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=4, surface_flux=FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg = 4, surface_flux = FluxHLL(min_max_speed_naive)) ############################################################################### # Get the curved quad mesh from a file default_mesh_file = joinpath(@__DIR__, "mesh_box_around_circle.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8b9b11a1eedfa54b215c122c3d17b271/raw/0d2b5d98c87e67a6f384693a8b8e54b4c9fcbf3d/mesh_box_around_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8b9b11a1eedfa54b215c122c3d17b271/raw/0d2b5d98c87e67a6f384693a8b8e54b4c9fcbf3d/mesh_box_around_circle.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = UnstructuredMesh2D(mesh_file) @@ -52,7 +53,7 @@ mesh = UnstructuredMesh2D(mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -63,22 +64,23 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=10, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 10, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) +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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl index fe7f9851514..2db133ebb7b 100644 --- a/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,22 +5,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5/3 +gamma = 5 / 3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg=7, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 7, + surface_flux = (FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -33,21 +36,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) - -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) + +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.9 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -56,11 +62,10 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl b/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl index d75079bb8d7..a40f92cac02 100644 --- a/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl +++ b/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl @@ -6,40 +6,42 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations2D(5/3) +equations = IdealGlmMhdEquations2D(5 / 3) function initial_condition_shifted_weak_blast_wave(x, t, equations::IdealGlmMhdEquations2D) - # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) - # Shift blastwave to center of domain - inicenter = (sqrt(2)/2, sqrt(2)/2) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) - v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) - p = r > 0.5 ? 1.0 : 1.245 - - return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) + # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) + # Shift blastwave to center of domain + inicenter = (sqrt(2) / 2, sqrt(2) / 2) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) + v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) + p = r > 0.5 ? 1.0 : 1.245 + + return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) end initial_condition = initial_condition_shifted_weak_blast_wave # Get the DG approximation space volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg=6, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 6, + surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -53,21 +55,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(entropy, energy_total, - energy_kinetic, energy_internal, - energy_magnetic, cross_helicity)) - -alive_callback = AliveCallback(analysis_interval=analysis_interval) - -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true, - solution_variables=cons2prim) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (entropy, energy_total, + energy_kinetic, + energy_internal, + energy_magnetic, + cross_helicity)) + +alive_callback = AliveCallback(analysis_interval = analysis_interval) + +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true, + solution_variables = cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl=cfl) +stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -79,7 +84,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl index 9a8a02feaed..07e0bbdd3ca 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl @@ -7,47 +7,51 @@ using Trixi # semidiscretization of the shallow water equations with a continuous # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant=1.0, H0=3.0) +equations = ShallowWaterEquations2D(gravity_constant = 1.0, H0 = 3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) - + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness boundary_condition_constant = BoundaryConditionDirichlet(initial_condition) -boundary_condition = Dict( :OuterCircle => boundary_condition_constant ) +boundary_condition = Dict(:OuterCircle => boundary_condition_constant) ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 4, + surface_flux = (FluxHLL(min_max_speed_naive), + flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form well-balancedness testing # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_outer_circle.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.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_condition) + boundary_conditions = boundary_condition) ############################################################################### # ODE solvers, callbacks, etc. @@ -58,15 +62,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - save_analysis=true, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -74,6 +78,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-11, reltol=1.0e-11, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-11, reltol = 1.0e-11, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl index 138b256c08b..8e9d396d826 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl @@ -7,7 +7,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) # Note, this initial condition is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_ec_discontinuous_bottom` below. @@ -17,19 +17,21 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=6, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 6, + surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form entropy conservation testing (needs periodic BCs) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -49,45 +51,48 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_ec_discontinuous_bottom(x, t, element_id, equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.7, 0.7) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Set the background values - H = 3.25 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # setup the discontinuous water height and velocities - if element_id == 10 - H = 4.0 - v1 = 0.1882 * cos_phi - v2 = 0.1882 * sin_phi - end - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_ec_discontinuous_bottom(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 3.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 4.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, + equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -96,15 +101,15 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -112,7 +117,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl index ee3650f3bb5..94202b81df0 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl @@ -7,7 +7,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) # Note, this initial condition is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_ec_discontinuous_bottom` below. @@ -17,17 +17,17 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) polydeg = 6 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=waterheight_pressure) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = waterheight_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) ############################################################################### @@ -35,11 +35,12 @@ solver = DGSEM(basis, surface_flux, volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -59,45 +60,48 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_ec_discontinuous_bottom(x, t, element_id, equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.7, 0.7) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Set the background values - H = 3.25 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # setup the discontinuous water height and velocities - if element_id == 10 - H = 4.0 - v1 = 0.1882 * cos_phi - v2 = 0.1882 * sin_phi - end - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_ec_discontinuous_bottom(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 3.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 4.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, + equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -106,11 +110,11 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback) @@ -118,7 +122,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl index e0b64802ff8..07668688406 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -7,7 +7,7 @@ using Trixi # semidiscretization of the shallow water equations with a periodic # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant=9.81) +equations = ShallowWaterEquations2D(gravity_constant = 9.81) initial_condition = initial_condition_convergence_test @@ -16,23 +16,24 @@ initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=6, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 6, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form convergence test on a periodic domain # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -43,15 +44,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -59,7 +60,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl index d9e71e4aa44..2cab68b1cb5 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl @@ -7,7 +7,8 @@ using Trixi # Semidiscretization of the two-layer shallow water equations with a periodic # bottom topography function (set in the initial conditions) -equations = ShallowWaterTwoLayerEquations2D(gravity_constant=10.0, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 10.0, rho_upper = 0.9, + rho_lower = 1.0) initial_condition = initial_condition_convergence_test @@ -16,23 +17,24 @@ initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=6, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 6, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form convergence test on a periodic domain # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # Create the semidiscretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms=source_terms_convergence_test) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -43,15 +45,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=500, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 500, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -59,7 +61,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl index 4295f93b342..9d70e9287cf 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl @@ -7,62 +7,64 @@ using Trixi # Semidiscretization of the two-layer shallow water equations for a dam break test with a # discontinuous bottom topography function to test energy conservation -equations = ShallowWaterTwoLayerEquations2D(gravity_constant=1.0, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 1.0, rho_upper = 0.9, + rho_lower = 1.0) # This test case uses a special work around to setup a truly discontinuous bottom topography # function and initial condition for this academic testcase of entropy conservation. First, a # dummy initial_condition_dam_break is introduced to create the semidiscretization. Then the initial # condition is reset with the true discontinuous values from initial_condition_discontinuous_dam_break. -function initial_condition_dam_break(x, t,equations::ShallowWaterTwoLayerEquations2D) - if x[1] < sqrt(2)/2 - H_upper = 1.0 - H_lower = 0.6 - b = 0.1 - else - H_upper = 0.9 - H_lower = 0.5 - b = 0.0 - end - - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) +function initial_condition_dam_break(x, t, equations::ShallowWaterTwoLayerEquations2D) + if x[1] < sqrt(2) / 2 + H_upper = 1.0 + H_lower = 0.6 + b = 0.1 + else + H_upper = 0.9 + H_lower = 0.5 + b = 0.0 + end + + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), + equations) end initial_condition = initial_condition_dam_break boundary_condition_constant = BoundaryConditionDirichlet(initial_condition_dam_break) - ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux= (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=6, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) +solver = DGSEM(polydeg = 6, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=false) +mesh = UnstructuredMesh2D(mesh_file, periodicity = false) # Boundary conditions -boundary_condition = Dict(:Top => boundary_condition_slip_wall, - :Left => boundary_condition_slip_wall, - :Right => boundary_condition_slip_wall, +boundary_condition = Dict(:Top => boundary_condition_slip_wall, + :Left => boundary_condition_slip_wall, + :Right => boundary_condition_slip_wall, :Bottom => boundary_condition_slip_wall) # Create the semi discretization object -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, - solver, boundary_conditions=boundary_condition) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver, boundary_conditions = boundary_condition) ############################################################################### # ODE solver @@ -79,58 +81,63 @@ ode = semidiscretize(semi, tspan) # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_discontinuous_dam_break(x, t, element_id, +function initial_condition_discontinuous_dam_break(x, t, element_id, equations::ShallowWaterTwoLayerEquations2D) - # Constant values - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - - # Left side of discontinuity - IDs = [1, 2, 5, 6, 9, 10, 13, 14] - if element_id in IDs - H_upper = 1.0 - H_lower = 0.6 - b = 0.0 - # Right side of discontinuity - else - H_upper = 0.9 - H_lower = 0.5 - b = 0.1 - end - - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) + # Constant values + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + + # Left side of discontinuity + IDs = [1, 2, 5, 6, 9, 10, 13, 14] + if element_id in IDs + H_upper = 1.0 + H_lower = 0.6 + b = 0.0 + # Right side of discontinuity + else + H_upper = 0.9 + H_lower = 0.5 + b = 0.1 + end + + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), + equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_discontinuous_dam_break(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_discontinuous_dam_break(x_node, first(tspan), element, + equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end - ############################################################################### # Callbacks summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval,save_analysis=false, - extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (energy_total, + energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=500, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 500, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -138,7 +145,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl index 40bc9f2ab42..35b027c3a81 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl @@ -7,22 +7,25 @@ using Trixi # Semidiscretization of the two-layer shallow water equations with a discontinuous bottom # topography to test well-balancedness -equations = ShallowWaterTwoLayerEquations2D(gravity_constant=1.0, H0=0.6, rho_upper=0.9, rho_lower=1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 1.0, H0 = 0.6, + rho_upper = 0.9, rho_lower = 1.0) # An initial condition with constant total water height, zero velocities and a bottom topography to # test well-balancedness function initial_condition_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations2D) - H_lower = 0.5 - H_upper = 0.6 - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - - # Bottom Topography - b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + - -0.5)^2)) + 1) : 0.0) - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) + H_lower = 0.5 + H_upper = 0.6 + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + + # Bottom Topography + b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? + 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + + -0.5)^2)) + 1) : 0.0) + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), + equations) end initial_condition = initial_condition_well_balanced @@ -32,19 +35,20 @@ initial_condition = initial_condition_well_balanced volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=6, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 6, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form well-balancedness testing # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -58,16 +62,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -stepsize_callback = StepsizeCallback(cfl=1.0) +stepsize_callback = StepsizeCallback(cfl = 1.0) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -75,7 +79,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl index ad1471a2d1a..f64fc54eef4 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl @@ -7,63 +7,67 @@ using Trixi # semidiscretization of the shallow water equations with a continuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant=9.812, H0=2.0) +equations = ShallowWaterEquations2D(gravity_constant = 9.812, H0 = 2.0) function initial_condition_stone_throw(x, t, equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.15, 0.15) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - - # Calculate primitive variables - H = equations.H0 - v1 = r < 0.6 ? 2.0 : 0.0 - v2 = r < 0.6 ? -2.0 : 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) - + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) - - return prim2cons(SVector(H, v1, v2, b), equations) + # Set up polar coordinates + inicenter = SVector(0.15, 0.15) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + + # Calculate primitive variables + H = equations.H0 + v1 = r < 0.6 ? 2.0 : 0.0 + v2 = r < 0.6 ? -2.0 : 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) + + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_stone_throw -boundary_condition = Dict( :OuterCircle => boundary_condition_slip_wall ) +boundary_condition = Dict(:OuterCircle => boundary_condition_slip_wall) ############################################################################### # Get the DG approximation space -surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), - flux_nonconservative_audusse_etal) +surface_flux = (FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal) volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) polydeg = 6 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max=0.5, - alpha_min=0.001, - alpha_smooth=true, - variable=Trixi.waterheight) + alpha_max = 0.5, + alpha_min = 0.001, + alpha_smooth = true, + variable = Trixi.waterheight) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg=volume_flux, - volume_flux_fv=surface_flux) + volume_flux_dg = volume_flux, + volume_flux_fv = surface_flux) -solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) +solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, + volume_integral = volume_integral) ############################################################################### # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_outer_circle.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.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_condition) + boundary_conditions = boundary_condition) ############################################################################### # ODE solvers, callbacks, etc. @@ -74,15 +78,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, - extra_analysis_integrals=(energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = false, + extra_analysis_integrals = (energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=100, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 100, + save_initial_solution = true, + save_final_solution = true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -90,6 +95,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, - ode_default_options()..., callback=callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, + ode_default_options()..., callback = callbacks); summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl index 645f985d10d..944f1f7a746 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl @@ -7,21 +7,22 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.0) +equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) - + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) + + + 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -30,20 +31,21 @@ initial_condition = initial_condition_well_balancedness # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg=6, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) +solver = DGSEM(polydeg = 6, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form well-balancedness testing # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || + download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity=true) +mesh = UnstructuredMesh2D(mesh_file, periodicity = true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -64,30 +66,33 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, + equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, + semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), + element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -96,16 +101,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + extra_analysis_integrals = (lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval = analysis_interval) -save_solution = SaveSolutionCallback(interval=1000, - save_initial_solution=true, - save_final_solution=true) +save_solution = SaveSolutionCallback(interval = 1000, + save_initial_solution = true, + save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl=3.0) +stepsize_callback = StepsizeCallback(cfl = 3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -113,7 +118,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/src/equations/linearized_euler_2d.jl b/src/equations/linearized_euler_2d.jl index 3ebd0f736ba..d35e077e4e8 100644 --- a/src/equations/linearized_euler_2d.jl +++ b/src/equations/linearized_euler_2d.jl @@ -177,8 +177,8 @@ end norm_ = norm(normal_direction) - v_normal = - v_mean_global[1] * normal_direction[1] + v_mean_global[2] * normal_direction[2] + v_normal = v_mean_global[1] * normal_direction[1] + + v_mean_global[2] * normal_direction[2] # The v_normals are already scaled by the norm λ_min = v_normal - c_mean_global * norm_ diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index d8cf9d51b46..3a94db49f93 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -621,11 +621,11 @@ Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - - v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr)/(h_ll_sqrt + h_rr_sqrt) + + v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr) / (h_ll_sqrt + h_rr_sqrt) return v_roe, c_roe -end +end # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations1D) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index 321d923ffbe..f39f3de5d1d 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -966,15 +966,15 @@ slides 8 and 9. h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - + if orientation == 1 # x-direction - v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) + v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr) / (h_ll_sqrt + h_rr_sqrt) else # y-direction - v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) + v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr) / (h_ll_sqrt + h_rr_sqrt) end return v_roe, c_roe -end +end @inline function calc_wavespeed_roe(u_ll, u_rr, normal_direction::AbstractVector, equations::ShallowWaterEquations2D) @@ -990,14 +990,14 @@ end h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - - v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) - v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) + + v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr) / (h_ll_sqrt + h_rr_sqrt) + v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr) / (h_ll_sqrt + h_rr_sqrt) v_roe = (v1_roe * normal_direction[1] + v2_roe * normal_direction[2]) return v_roe, c_roe -end +end # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations2D) diff --git a/test/coverage/coverage.jl b/test/coverage/coverage.jl index fbe89acf702..5f1ae8af8fc 100644 --- a/test/coverage/coverage.jl +++ b/test/coverage/coverage.jl @@ -9,28 +9,28 @@ const lcov_info_file = "lcov.info" # Change path to root directory cd(joinpath(@__DIR__, "..", "..")) do - # Process coverage files - processed = process_folder("src") - - # Uncomment the following line once Codecov support is enabled - # Codecov.submit_local(processed) - - # Calculate coverage - covered_lines, total_lines = get_summary(processed) - percentage = covered_lines / total_lines * 100 - - # Print coverage in a format that can be easily parsed - println("($(percentage)%) covered") - - # Try to generate a coverage report - isdir(report_dir) || mkdir(report_dir) - tracefile = joinpath(report_dir, lcov_info_file) - Coverage.LCOV.writefile(tracefile, processed) - branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) - commit = strip(read(`git rev-parse --short HEAD`, String)) - title = "commit $(commit) on branch $(branch)" - run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`) - - # Clean up .cov files - clean_folder("src") + # Process coverage files + processed = process_folder("src") + + # Uncomment the following line once Codecov support is enabled + # Codecov.submit_local(processed) + + # Calculate coverage + covered_lines, total_lines = get_summary(processed) + percentage = covered_lines / total_lines * 100 + + # Print coverage in a format that can be easily parsed + println("($(percentage)%) covered") + + # Try to generate a coverage report + isdir(report_dir) || mkdir(report_dir) + tracefile = joinpath(report_dir, lcov_info_file) + Coverage.LCOV.writefile(tracefile, processed) + branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) + commit = strip(read(`git rev-parse --short HEAD`, String)) + title = "commit $(commit) on branch $(branch)" + run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`) + + # Clean up .cov files + clean_folder("src") end diff --git a/test/runtests.jl b/test/runtests.jl index f76811dddbf..6c8687039b9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,113 +4,115 @@ using MPI: mpiexec # run tests on Travis CI in parallel const TRIXI_TEST = get(ENV, "TRIXI_TEST", "all") const TRIXI_MPI_NPROCS = clamp(Sys.CPU_THREADS, 2, 3) -const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) +const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) @time @testset "Trixi.jl tests" begin - # This is placed first since tests error out otherwise if `TRIXI_TEST == "all"`, - # at least on some systems. - @time if TRIXI_TEST == "all" || TRIXI_TEST == "mpi" - # Do a dummy `@test true`: - # If the process errors out the testset would error out as well, - # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 - @test true - - # There are spurious test failures of Trixi.jl with MPI on Windows, see - # https://github.com/trixi-framework/Trixi.jl/issues/901 - # To reduce their impact, we do not test MPI with coverage on Windows. - # This reduces the chance to hit a spurious test failure by one half. - # In addition, it looks like the Linux GitHub runners run out of memory during the 3D tests - # with coverage, so we currently do not test MPI with coverage on Linux. For more details, - # see the discussion at https://github.com/trixi-framework/Trixi.jl/pull/1062#issuecomment-1035901020 - cmd = string(Base.julia_cmd()) - coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) - if !(coverage && Sys.iswindows()) && !(coverage && Sys.islinux()) - # We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing - mpiexec() do cmd - run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=1G $(abspath("test_mpi.jl"))`) - end - end - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "threaded" || TRIXI_TEST == "threaded_legacy" - # Do a dummy `@test true`: - # If the process errors out the testset would error out as well, - # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 - @test true - - run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1" - include("test_tree_1d.jl") - include("test_tree_2d_part1.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part2" - include("test_tree_2d_part2.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part3" - include("test_tree_2d_part3.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part4" - include("test_tree_3d_part1.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part5" - include("test_tree_3d_part2.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part6" - include("test_tree_3d_part3.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "structured" - include("test_structured_1d.jl") - include("test_structured_2d.jl") - include("test_structured_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part1" - include("test_p4est_2d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part2" - include("test_p4est_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "unstructured_dgmulti" - include("test_unstructured_2d.jl") - include("test_dgmulti_1d.jl") - include("test_dgmulti_2d.jl") - include("test_dgmulti_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "parabolic" - include("test_parabolic_1d.jl") - include("test_parabolic_2d.jl") - include("test_parabolic_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part1" - include("test_unit.jl") - include("test_visualization.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part2" - include("test_special_elixirs.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part1" - include("test_performance_specializations_2d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part2" - include("test_performance_specializations_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "paper_self_gravitating_gas_dynamics" - include("test_paper_self_gravitating_gas_dynamics.jl") - end + # This is placed first since tests error out otherwise if `TRIXI_TEST == "all"`, + # at least on some systems. + @time if TRIXI_TEST == "all" || TRIXI_TEST == "mpi" + # Do a dummy `@test true`: + # If the process errors out the testset would error out as well, + # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 + @test true + + # There are spurious test failures of Trixi.jl with MPI on Windows, see + # https://github.com/trixi-framework/Trixi.jl/issues/901 + # To reduce their impact, we do not test MPI with coverage on Windows. + # This reduces the chance to hit a spurious test failure by one half. + # In addition, it looks like the Linux GitHub runners run out of memory during the 3D tests + # with coverage, so we currently do not test MPI with coverage on Linux. For more details, + # see the discussion at https://github.com/trixi-framework/Trixi.jl/pull/1062#issuecomment-1035901020 + cmd = string(Base.julia_cmd()) + coverage = occursin("--code-coverage", cmd) && + !occursin("--code-coverage=none", cmd) + if !(coverage && Sys.iswindows()) && !(coverage && Sys.islinux()) + # We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing + mpiexec() do cmd + run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=1G $(abspath("test_mpi.jl"))`) + end + end + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "threaded" || + TRIXI_TEST == "threaded_legacy" + # Do a dummy `@test true`: + # If the process errors out the testset would error out as well, + # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 + @test true + + run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1" + include("test_tree_1d.jl") + include("test_tree_2d_part1.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part2" + include("test_tree_2d_part2.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part3" + include("test_tree_2d_part3.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part4" + include("test_tree_3d_part1.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part5" + include("test_tree_3d_part2.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part6" + include("test_tree_3d_part3.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "structured" + include("test_structured_1d.jl") + include("test_structured_2d.jl") + include("test_structured_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part1" + include("test_p4est_2d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part2" + include("test_p4est_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "unstructured_dgmulti" + include("test_unstructured_2d.jl") + include("test_dgmulti_1d.jl") + include("test_dgmulti_2d.jl") + include("test_dgmulti_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "parabolic" + include("test_parabolic_1d.jl") + include("test_parabolic_2d.jl") + include("test_parabolic_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part1" + include("test_unit.jl") + include("test_visualization.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part2" + include("test_special_elixirs.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part1" + include("test_performance_specializations_2d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part2" + include("test_performance_specializations_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "paper_self_gravitating_gas_dynamics" + include("test_paper_self_gravitating_gas_dynamics.jl") + end end diff --git a/test/test_dgmulti_1d.jl b/test/test_dgmulti_1d.jl index 7cc31c33040..3d7730f0d44 100644 --- a/test/test_dgmulti_1d.jl +++ b/test/test_dgmulti_1d.jl @@ -9,78 +9,111 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_1d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "DGMulti 1D" begin + @trixi_testset "elixir_advection_gauss_sbp.jl " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"), + cells_per_dimension=(8,), + l2=[2.9953644500009865e-5], + linf=[4.467840577382365e-5]) + end - @trixi_testset "elixir_advection_gauss_sbp.jl " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"), - cells_per_dimension = (8,), - l2 = [2.9953644500009865e-5], - linf = [4.467840577382365e-5] - ) - end + @trixi_testset "elixir_euler_flux_diff.jl " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), + cells_per_dimension=(16,), + # division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 7.853842541289665e-7, + 9.609905503440606e-7, + 2.832322219966481e-6, + ] ./ sqrt(2.0), + linf=[ + 1.5003758788711963e-6, + 1.802998748523521e-6, + 4.83599270806323e-6, + ]) + end - @trixi_testset "elixir_euler_flux_diff.jl " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension = (16,), - # division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain - l2 = [7.853842541289665e-7, 9.609905503440606e-7, 2.832322219966481e-6] ./ sqrt(2.0), - linf = [1.5003758788711963e-6, 1.802998748523521e-6, 4.83599270806323e-6] - ) - end + @trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "elixir_euler_flux_diff.jl"), 3) + @test isapprox(mean_convergence[:l2], + [4.1558759698638434, 3.977911306037128, 4.041421206468769], + rtol = 0.05) + end - @trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), 3) - @test isapprox(mean_convergence[:l2], [4.1558759698638434, 3.977911306037128, 4.041421206468769], rtol=0.05) - end + @trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), + cells_per_dimension=(16,), + approximation_type=SBP(), + l2=[ + 6.437827414849647e-6, + 2.1840558851820947e-6, + 1.3245669629438228e-5, + ], + linf=[ + 2.0715843751295537e-5, + 8.519520630301258e-6, + 4.2642194098885255e-5, + ]) + end - @trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension = (16,), - approximation_type = SBP(), - l2 = [6.437827414849647e-6, 2.1840558851820947e-6, 1.3245669629438228e-5], - linf = [2.0715843751295537e-5, 8.519520630301258e-6, 4.2642194098885255e-5] - ) - end + @trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), + cells_per_dimension=(4,), + approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 16), + l2=[ + 1.8684509287853788e-5, + 1.0641411823379635e-5, + 5.178010291876143e-5, + ], + linf=[ + 6.933493585936645e-5, + 3.0277366229292113e-5, + 0.0002220020568932668, + ]) + show(stdout, semi.solver.basis) + show(stdout, MIME"text/plain"(), semi.solver.basis) + end - @trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension = (4,), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=16), - l2 = [1.8684509287853788e-5, 1.0641411823379635e-5, 5.178010291876143e-5], - linf = [6.933493585936645e-5, 3.0277366229292113e-5, 0.0002220020568932668] - ) - show(stdout, semi.solver.basis) - show(stdout, MIME"text/plain"(), semi.solver.basis) - end + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + l2=[ + 9.146929180585711e-7, + 1.8997616878017292e-6, + 3.991417702211889e-6, + ], + linf=[ + 1.7321089884614338e-6, + 3.3252888855805907e-6, + 6.5252787737613005e-6, + ]) + show(stdout, semi.solver.basis) + show(stdout, MIME"text/plain"(), semi.solver.basis) + end - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2 = [9.146929180585711e-7, 1.8997616878017292e-6, 3.991417702211889e-6], - linf = [1.7321089884614338e-6, 3.3252888855805907e-6, 6.5252787737613005e-6] - ) - show(stdout, semi.solver.basis) - show(stdout, MIME"text/plain"(), semi.solver.basis) - end - - @trixi_testset "DGMulti with periodic SBP unit test" begin - # see https://github.com/trixi-framework/Trixi.jl/pull/1013 - dg = DGMulti(element_type = Line(), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=-5.0, xmax=10.0, N=50)) - mesh = DGMultiMesh(dg) - @test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst) - # check to make sure nodes are rescaled to [-1, 1] - @test minimum(dg.basis.rst[1]) ≈ -1 - @test maximum(dg.basis.rst[1]) ≈ 1 atol=0.35 - end + @trixi_testset "DGMulti with periodic SBP unit test" begin + # see https://github.com/trixi-framework/Trixi.jl/pull/1013 + dg = DGMulti(element_type = Line(), + approximation_type = periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = -5.0, + xmax = 10.0, N = 50)) + mesh = DGMultiMesh(dg) + @test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst) + # check to make sure nodes are rescaled to [-1, 1] + @test minimum(dg.basis.rst[1]) ≈ -1 + @test maximum(dg.basis.rst[1])≈1 atol=0.35 + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_dgmulti_2d.jl b/test/test_dgmulti_2d.jl index 861e30045ce..9c6105d85db 100644 --- a/test/test_dgmulti_2d.jl +++ b/test/test_dgmulti_2d.jl @@ -9,357 +9,673 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_2d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "DGMulti 2D" begin - - @trixi_testset "elixir_euler_weakform.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0013536930300254945, 0.0014315603442106193, 0.001431560344211359, 0.0047393341007602625] ./ 2.0, - linf = [0.001514260921466004, 0.0020623991944839215, 0.002062399194485476, 0.004897700392503701] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - approximation_type = SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0074706882014934735, 0.005306220583603261, 0.005306220583613591, 0.014724842607716771] ./ 2.0, - linf = [0.021563604940952885, 0.01359397832530762, 0.013593978324845324, 0.03270995869587523] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - element_type = Quad(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.00031892254415307093, 0.00033637562986771894, 0.0003363756298680649, 0.0011100259064243145] ./ 2.0, - linf = [0.001073298211445639, 0.0013568139808282087, 0.0013568139808290969, 0.0032249020004324613] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (EC) " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.007801417730672109, 0.00708583561714128, 0.0070858356171393, 0.015217574294198809] ./ 2.0, - linf = [0.011572828457858897, 0.013965298735070686, 0.01396529873508534, 0.04227683691807904] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.01280067571168776, 0.010607599608273302, 0.010607599608239775, 0.026408338014056548] ./ 2.0, - linf = [0.037983023185674814, 0.05321027922533417, 0.05321027922608157, 0.13392025411844033] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - element_type = Quad(), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0029373718090697975, 0.0030629360605489465, 0.003062936060545615, 0.0068486089344859755] ./ 2.0, - linf = [0.01360165305316885, 0.01267402847925303, 0.012674028479251254, 0.02210545278615017] - ) - end - - @trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_bilinear.jl"), - l2 = [1.0259435706215337e-5, 9.014090233720625e-6, 9.014090233223014e-6, 2.738953587401793e-5], - linf = [7.362609083649829e-5, 6.874188055272512e-5, 6.874188052830021e-5, 0.0001912435192696904] - ) - end - - @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - l2 = [1.720476068165337e-5, 1.592168205710526e-5, 1.592168205812963e-5, 4.894094865697305e-5], - linf = [0.00010525416930584619, 0.00010003778091061122, 0.00010003778085621029, 0.00036426282101720275] - ) - end - - @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - approximation_type = GaussSBP(), - l2 = [3.4666312079259457e-6, 3.4392774480368986e-6, 3.439277447953705e-6, 1.0965598424665836e-5], - linf = [1.1327280377004811e-5, 1.1343911926253725e-5, 1.1343911906935844e-5, 3.679582619220412e-5], - rtol = 2 * sqrt(eps()) - ) - end - - @trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - element_type = Tri(), approximation_type = Polynomial(), volume_integral = VolumeIntegralWeakForm(), - l2 = [7.905498158659466e-6, 8.731690809663625e-6, 8.731690811576996e-6, 2.9113296018693953e-5], - linf = [3.298811230090237e-5, 4.032272476939269e-5, 4.032272526011127e-5, 0.00012013725458537294] - ) - end - - @trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_hohqmesh.jl"), - l2 = [0.0008153911341517156, 0.0007768159701964676, 0.00047902606811690694, 0.0015551846076348535], - linf = [0.0029301131365355726, 0.0034427051471457304, 0.0028721569841545502, 0.011125365074589944] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (convergence)" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), 2) - @test isapprox(mean_convergence[:l2], [4.243843382379403, 4.128314378833922, 4.128314378397532, 4.081366752807379], rtol=0.05) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0014986508075708323, 0.001528523420746786, 0.0015285234207473158, 0.004846505183839211] ./ 2.0, - linf = [0.0015062108658376872, 0.0019373508504645365, 0.0019373508504538783, 0.004742686826709086] - ) - end - - @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_triangulate_pkg_mesh.jl"), - l2 = [2.344080455438114e-6, 1.8610038753097983e-6, 2.4095165666095305e-6, 6.373308158814308e-6], - linf = [2.5099852761334418e-5, 2.2683684021362893e-5, 2.6180448559287584e-5, 5.5752932611508044e-5] - ) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - cells_per_dimension = (32, 32), tspan = (0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.11140378947116614, 0.06598161188703612, 0.10448953167839563, 0.16023209181809595] ./ 2.0, - linf = [0.24033843177853664, 0.1659992245272325, 0.1235468309508845, 0.26911424973147735] - ) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - cells_per_dimension = (32, 32), element_type = Quad(), approximation_type=GaussSBP(), tspan = (0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.11141270656347146, 0.06598888014584121, 0.1044902203749932, 0.16023037364774995] ./ 2.0, - linf = [0.2414760062126462, 0.1662111846065654, 0.12344140473946856, 0.26978428189564774] - ) - end - - @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_rayleigh_taylor_instability.jl"), - cells_per_dimension = (8, 8), tspan = (0.0, 0.2), - l2 = [0.0709665896982514, 0.005182828752164663, 0.013832655585206478, 0.03247013800580221], - linf = [0.4783963902824797, 0.022527207050681054, 0.040307056293369226, 0.0852365428206836] - ) - end - - @trixi_testset "elixir_euler_brown_minion_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_brown_minion_vortex.jl"), - cells_per_dimension = 4, tspan = (0.0, 0.1), - l2 = [0.006680001611078062, 0.02151676347585447, 0.010696524235364626, 0.15052841129694647], - linf = [0.01544756362800248, 0.09517304772476806, 0.021957154972646383, 0.33773439650806303] - ) - end - - @trixi_testset "elixir_euler_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - cells_per_dimension = 4, tspan = (0.0, 0.1), - l2 = [0.05685148333985476, 0.04308122135907089, 0.043081221359070915, 0.21098131003847664], - linf = [0.2360672306096051, 0.16684417686971842, 0.1668441768697189, 0.8572572782118661] - ) - end - - @trixi_testset "elixir_euler_shockcapturing_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_curved.jl"), - cells_per_dimension = 4, tspan = (0.0, 0.1), - l2 = [0.05565849298766252, 0.042322816017256494, 0.042322816017256466, 0.2064212098324083], - linf = [0.23633287875008924, 0.16930148707515683, 0.16930148707515688, 0.8587706761131937] - ) - end - - - @trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (2, 2), - element_type = Quad(), - cfl = 1.0, - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=12), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0008966318978421226, 0.0011418826379110242, 0.001141882637910878, 0.0030918374335671393] ./ 2.0, - linf = [0.0015281525343109337, 0.00162430960401716, 0.0016243096040242655, 0.004447503691245913] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (2, 2), - element_type = Quad(), - cfl = 1.0, - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=12), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0014018725496871129, 0.0015887007320868913, 0.001588700732086329, 0.003870926821031202] ./ 2.0, - linf = [0.0029541996523780867, 0.0034520465226108854, 0.003452046522624652, 0.007677153211004928] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2 = [1.3333320340010056e-6, 2.044834627970641e-6, 2.044834627855601e-6, 5.282189803559564e-6], - linf = [2.7000151718858945e-6, 3.988595028259212e-6, 3.9885950273710336e-6, 8.848583042286862e-6] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - xmin=-200.0, xmax=100.0 #= parameters for reference interval =#, - l2 = [1.333332034149886e-6, 2.0448346280892024e-6, 2.0448346279766305e-6, 5.282189803510037e-6], - linf = [2.700015170553627e-6, 3.988595024262409e-6, 3.988595024928543e-6, 8.84858303740188e-6] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=-200.0, xmax=100.0, N=100), - coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0), - l2 = [0.07318831033918516, 0.10039910610067465, 0.1003991061006748, 0.2642450566234564], - linf = [0.36081081739439735, 0.5244468027020845, 0.5244468027020814, 1.2210130256735705] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - approximation_type = SummationByPartsOperators.couple_continuously( - SummationByPartsOperators.legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4), - SummationByPartsOperators.UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10)), - l2 = [1.5440402410017893e-5, 1.4913189903083485e-5, 1.4913189902797073e-5, 2.6104615985156992e-5], - linf = [4.16334345412217e-5, 5.067812788173143e-5, 5.067812786885284e-5, 9.887976803746312e-5] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), - cells_per_dimension = 4, - l2 = [0.03906769915509508, 0.04923079758984701, 0.049230797589847136, 0.02660348840973283, - 0.18054907061740028, 0.019195256934309846, 0.019195256934310016, 0.027856113419468087, - 0.0016567799774264065], - linf = [0.16447597822733662, 0.244157345789029, 0.24415734578903472, 0.11982440036793476, - 0.7450328339751362, 0.06357382685763713, 0.0635738268576378, 0.1058830287485999, - 0.005740591170062146] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), - cells_per_dimension = 4, element_type = Tri(), - l2 = [0.03372468091254386, 0.03971626483409167, 0.03971626483409208, 0.021427571421535722, - 0.15079331840847413, 0.015716300366650286, 0.015716300366652128, 0.022365252076279075, - 0.0009232971979900358], - linf = [0.16290247390873458, 0.2256891306641319, 0.2256891306641336, 0.09476017042552534, - 0.6906308908961734, 0.05349939593012487, 0.05349939593013042, 0.08830587480616725, - 0.0029551359803035027] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin - # These setups do not pass CI reliably, see - # https://github.com/trixi-framework/Trixi.jl/pull/880 and - # https://github.com/trixi-framework/Trixi.jl/issues/881 - @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave_SBP.jl"), - cells_per_dimension = 4, - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.15825983698241494, 0.19897219694837923, 0.19784182473275247, 0.10482833997417325, - 0.7310752391255246, 0.07374056714564853, 0.07371172293240634, 0.10782032253431281, - 0.004921676235111545] ./ 2.0, - linf = [0.1765644464978685, 0.2627803272865769, 0.26358136695848144, 0.12347681727447984, - 0.7733289736898254, 0.06695360844467957, 0.06650382120802623, 0.10885097000919097, - 0.007212567638078835] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin - # These setups do not pass CI reliably, see - # https://github.com/trixi-framework/Trixi.jl/pull/880 and - # https://github.com/trixi-framework/Trixi.jl/issues/881 - @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave_SBP.jl"), - cells_per_dimension = 4, element_type=Tri(), tspan = (0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.13825044764021147, 0.15472815448314997, 0.1549093274293255, 0.053103596213755405, - 0.7246162776815603, 0.07730777596615901, 0.07733438386480523, 0.109893463921706, - 0.00617678167062838] ./ 2.0, - linf = [0.22701306227317952, 0.2905255794821543, 0.2912409425436937, 0.08051361477962096, - 1.0842974228656006, 0.07866000368926784, 0.0786646354518149, 0.1614896380292925, - 0.010358210347485542] - ) - end - - @trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_reflective_wall.jl"), - cells_per_dimension = 4, - l2 = [0.0036019536614619687, 0.001734097206958611, 0.008375221008997178, 0.0, 0.028596796602124414, 0.0018573693138866614, 0.0020807798141551166, 0.0, 5.301188920230166e-5], - linf = [0.01692601228199253, 0.009369662298436778, 0.04145169295835428, 0.0, 0.11569908670112738, 0.00984964453299233, 0.01141708032148614, 0.0, 0.0002992631411931389] - ) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Quad(), approximation_type = SBP(), - l2 = [0.0020316462913319046, 0.023669019044882247, 0.03446194752754684, 1.9333465252381796e-15], - linf = [0.010385010095182778, 0.08750628939565086, 0.12088392994348407, 9.325873406851315e-15] - ) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Tri(), approximation_type = SBP(), - l2 = [0.004180680322490383, 0.07026192411558974, 0.11815151697006446, 2.329788936151192e-15], - linf = [0.02076003852980346, 0.29169601664914424, 0.5674183379872275, 1.1546319456101628e-14] - ) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Tri(), approximation_type = Polynomial(), - # The last l2, linf error are the L2 projection error in approximating `b`, so they are not - # zero for general non-collocated quadrature rules (e.g., for `element_type=Tri()`, `polydeg > 2`). - l2 = [0.0008309356912456799, 0.01522451288799231, 0.016033969387208476, 1.2820247308150876e-5], - linf = [0.001888045014140971, 0.05466838692127718, 0.06345885709961152, 3.3989933098554914e-5] - ) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Quad(), approximation_type = Polynomial(), - # The last l2, linf error are the L2 projection error in approximating `b`. However, this is zero - # for `Quad()` elements with `Polynomial()` approximations because the quadrature rule defaults to - # a `(polydeg + 1)`-point Gauss quadrature rule in each coordinate (in general, StartUpDG.jl defaults - # to the quadrature rule with the fewest number of points which exactly integrates the mass matrix). - l2 = [7.460461950323111e-5, 0.003685589808444905, 0.0039101604749887785, 2.0636891126652983e-15], - linf = [0.000259995400729629, 0.0072236204211630906, 0.010364675200833062, 1.021405182655144e-14] - ) - end - - + @trixi_testset "elixir_euler_weakform.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0013536930300254945, + 0.0014315603442106193, + 0.001431560344211359, + 0.0047393341007602625, + ] ./ 2.0, + linf=[ + 0.001514260921466004, + 0.0020623991944839215, + 0.002062399194485476, + 0.004897700392503701, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + approximation_type=SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0074706882014934735, + 0.005306220583603261, + 0.005306220583613591, + 0.014724842607716771, + ] ./ 2.0, + linf=[ + 0.021563604940952885, + 0.01359397832530762, + 0.013593978324845324, + 0.03270995869587523, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + element_type=Quad(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.00031892254415307093, + 0.00033637562986771894, + 0.0003363756298680649, + 0.0011100259064243145, + ] ./ 2.0, + linf=[ + 0.001073298211445639, + 0.0013568139808282087, + 0.0013568139808290969, + 0.0032249020004324613, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (EC) " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.007801417730672109, + 0.00708583561714128, + 0.0070858356171393, + 0.015217574294198809, + ] ./ 2.0, + linf=[ + 0.011572828457858897, + 0.013965298735070686, + 0.01396529873508534, + 0.04227683691807904, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.01280067571168776, + 0.010607599608273302, + 0.010607599608239775, + 0.026408338014056548, + ] ./ 2.0, + linf=[ + 0.037983023185674814, + 0.05321027922533417, + 0.05321027922608157, + 0.13392025411844033, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + element_type=Quad(), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0029373718090697975, + 0.0030629360605489465, + 0.003062936060545615, + 0.0068486089344859755, + ] ./ 2.0, + linf=[ + 0.01360165305316885, + 0.01267402847925303, + 0.012674028479251254, + 0.02210545278615017, + ]) + end + + @trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_bilinear.jl"), + l2=[ + 1.0259435706215337e-5, + 9.014090233720625e-6, + 9.014090233223014e-6, + 2.738953587401793e-5, + ], + linf=[ + 7.362609083649829e-5, + 6.874188055272512e-5, + 6.874188052830021e-5, + 0.0001912435192696904, + ]) + end + + @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + l2=[ + 1.720476068165337e-5, + 1.592168205710526e-5, + 1.592168205812963e-5, + 4.894094865697305e-5, + ], + linf=[ + 0.00010525416930584619, + 0.00010003778091061122, + 0.00010003778085621029, + 0.00036426282101720275, + ]) + end + + @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + approximation_type=GaussSBP(), + l2=[ + 3.4666312079259457e-6, + 3.4392774480368986e-6, + 3.439277447953705e-6, + 1.0965598424665836e-5, + ], + linf=[ + 1.1327280377004811e-5, + 1.1343911926253725e-5, + 1.1343911906935844e-5, + 3.679582619220412e-5, + ], + rtol=2 * sqrt(eps())) + end + + @trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + element_type=Tri(), approximation_type=Polynomial(), + volume_integral=VolumeIntegralWeakForm(), + l2=[ + 7.905498158659466e-6, + 8.731690809663625e-6, + 8.731690811576996e-6, + 2.9113296018693953e-5, + ], + linf=[ + 3.298811230090237e-5, + 4.032272476939269e-5, + 4.032272526011127e-5, + 0.00012013725458537294, + ]) + end + + @trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_hohqmesh.jl"), + l2=[ + 0.0008153911341517156, + 0.0007768159701964676, + 0.00047902606811690694, + 0.0015551846076348535, + ], + linf=[ + 0.0029301131365355726, + 0.0034427051471457304, + 0.0028721569841545502, + 0.011125365074589944, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (convergence)" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "elixir_euler_weakform.jl"), 2) + @test isapprox(mean_convergence[:l2], + [ + 4.243843382379403, + 4.128314378833922, + 4.128314378397532, + 4.081366752807379, + ], rtol = 0.05) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0014986508075708323, + 0.001528523420746786, + 0.0015285234207473158, + 0.004846505183839211, + ] ./ 2.0, + linf=[ + 0.0015062108658376872, + 0.0019373508504645365, + 0.0019373508504538783, + 0.004742686826709086, + ]) + end + + @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_triangulate_pkg_mesh.jl"), + l2=[ + 2.344080455438114e-6, + 1.8610038753097983e-6, + 2.4095165666095305e-6, + 6.373308158814308e-6, + ], + linf=[ + 2.5099852761334418e-5, + 2.2683684021362893e-5, + 2.6180448559287584e-5, + 5.5752932611508044e-5, + ]) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + cells_per_dimension=(32, 32), tspan=(0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.11140378947116614, + 0.06598161188703612, + 0.10448953167839563, + 0.16023209181809595, + ] ./ 2.0, + linf=[ + 0.24033843177853664, + 0.1659992245272325, + 0.1235468309508845, + 0.26911424973147735, + ]) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + cells_per_dimension=(32, 32), element_type=Quad(), + approximation_type=GaussSBP(), tspan=(0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.11141270656347146, + 0.06598888014584121, + 0.1044902203749932, + 0.16023037364774995, + ] ./ 2.0, + linf=[ + 0.2414760062126462, + 0.1662111846065654, + 0.12344140473946856, + 0.26978428189564774, + ]) + end + + @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_rayleigh_taylor_instability.jl"), + cells_per_dimension=(8, 8), tspan=(0.0, 0.2), + l2=[ + 0.0709665896982514, + 0.005182828752164663, + 0.013832655585206478, + 0.03247013800580221, + ], + linf=[ + 0.4783963902824797, + 0.022527207050681054, + 0.040307056293369226, + 0.0852365428206836, + ]) + end + + @trixi_testset "elixir_euler_brown_minion_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_brown_minion_vortex.jl"), + cells_per_dimension=4, tspan=(0.0, 0.1), + l2=[ + 0.006680001611078062, + 0.02151676347585447, + 0.010696524235364626, + 0.15052841129694647, + ], + linf=[ + 0.01544756362800248, + 0.09517304772476806, + 0.021957154972646383, + 0.33773439650806303, + ]) + end + + @trixi_testset "elixir_euler_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), + cells_per_dimension=4, tspan=(0.0, 0.1), + l2=[ + 0.05685148333985476, + 0.04308122135907089, + 0.043081221359070915, + 0.21098131003847664, + ], + linf=[ + 0.2360672306096051, + 0.16684417686971842, + 0.1668441768697189, + 0.8572572782118661, + ]) + end + + @trixi_testset "elixir_euler_shockcapturing_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_curved.jl"), + cells_per_dimension=4, tspan=(0.0, 0.1), + l2=[ + 0.05565849298766252, + 0.042322816017256494, + 0.042322816017256466, + 0.2064212098324083, + ], + linf=[ + 0.23633287875008924, + 0.16930148707515683, + 0.16930148707515688, + 0.8587706761131937, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(2, 2), + element_type=Quad(), + cfl=1.0, + approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 12), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0008966318978421226, + 0.0011418826379110242, + 0.001141882637910878, + 0.0030918374335671393, + ] ./ 2.0, + linf=[ + 0.0015281525343109337, + 0.00162430960401716, + 0.0016243096040242655, + 0.004447503691245913, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension=(2, 2), + element_type=Quad(), + cfl=1.0, + approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 12), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0014018725496871129, + 0.0015887007320868913, + 0.001588700732086329, + 0.003870926821031202, + ] ./ 2.0, + linf=[ + 0.0029541996523780867, + 0.0034520465226108854, + 0.003452046522624652, + 0.007677153211004928, + ]) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + l2=[ + 1.3333320340010056e-6, + 2.044834627970641e-6, + 2.044834627855601e-6, + 5.282189803559564e-6, + ], + linf=[ + 2.7000151718858945e-6, + 3.988595028259212e-6, + 3.9885950273710336e-6, + 8.848583042286862e-6, + ]) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + xmin=-200.0, xmax=100.0, #= parameters for reference interval =# + l2=[ + 1.333332034149886e-6, + 2.0448346280892024e-6, + 2.0448346279766305e-6, + 5.282189803510037e-6, + ], + linf=[ + 2.700015170553627e-6, + 3.988595024262409e-6, + 3.988595024928543e-6, + 8.84858303740188e-6, + ]) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + approximation_type=periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = -200.0, + xmax = 100.0, + N = 100), + coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0), + l2=[ + 0.07318831033918516, + 0.10039910610067465, + 0.1003991061006748, + 0.2642450566234564, + ], + linf=[ + 0.36081081739439735, + 0.5244468027020845, + 0.5244468027020814, + 1.2210130256735705, + ]) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + approximation_type=SummationByPartsOperators.couple_continuously(SummationByPartsOperators.legendre_derivative_operator(xmin = 0.0, + xmax = 1.0, + N = 4), + SummationByPartsOperators.UniformPeriodicMesh1D(xmin = -1.0, + xmax = 1.0, + Nx = 10)), + l2=[ + 1.5440402410017893e-5, + 1.4913189903083485e-5, + 1.4913189902797073e-5, + 2.6104615985156992e-5, + ], + linf=[ + 4.16334345412217e-5, + 5.067812788173143e-5, + 5.067812786885284e-5, + 9.887976803746312e-5, + ]) + end + + @trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), + cells_per_dimension=4, + l2=[0.03906769915509508, 0.04923079758984701, + 0.049230797589847136, 0.02660348840973283, + 0.18054907061740028, 0.019195256934309846, + 0.019195256934310016, 0.027856113419468087, + 0.0016567799774264065], + linf=[0.16447597822733662, 0.244157345789029, + 0.24415734578903472, 0.11982440036793476, + 0.7450328339751362, 0.06357382685763713, 0.0635738268576378, + 0.1058830287485999, + 0.005740591170062146]) + end + + @trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), + cells_per_dimension=4, element_type=Tri(), + l2=[0.03372468091254386, 0.03971626483409167, + 0.03971626483409208, 0.021427571421535722, + 0.15079331840847413, 0.015716300366650286, + 0.015716300366652128, 0.022365252076279075, + 0.0009232971979900358], + linf=[0.16290247390873458, 0.2256891306641319, + 0.2256891306641336, 0.09476017042552534, + 0.6906308908961734, 0.05349939593012487, + 0.05349939593013042, 0.08830587480616725, + 0.0029551359803035027]) + end + + @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin + # These setups do not pass CI reliably, see + # https://github.com/trixi-framework/Trixi.jl/pull/880 and + # https://github.com/trixi-framework/Trixi.jl/issues/881 + @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_mhd_weak_blast_wave_SBP.jl"), + cells_per_dimension=4, + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[0.15825983698241494, 0.19897219694837923, + 0.19784182473275247, 0.10482833997417325, + 0.7310752391255246, 0.07374056714564853, + 0.07371172293240634, 0.10782032253431281, + 0.004921676235111545] ./ 2.0, + linf=[0.1765644464978685, 0.2627803272865769, + 0.26358136695848144, 0.12347681727447984, + 0.7733289736898254, 0.06695360844467957, + 0.06650382120802623, 0.10885097000919097, + 0.007212567638078835]) + end + + @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin + # These setups do not pass CI reliably, see + # https://github.com/trixi-framework/Trixi.jl/pull/880 and + # https://github.com/trixi-framework/Trixi.jl/issues/881 + @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_mhd_weak_blast_wave_SBP.jl"), + cells_per_dimension=4, element_type=Tri(), + tspan=(0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[0.13825044764021147, 0.15472815448314997, + 0.1549093274293255, 0.053103596213755405, + 0.7246162776815603, 0.07730777596615901, + 0.07733438386480523, 0.109893463921706, + 0.00617678167062838] ./ 2.0, + linf=[0.22701306227317952, 0.2905255794821543, + 0.2912409425436937, 0.08051361477962096, + 1.0842974228656006, 0.07866000368926784, + 0.0786646354518149, 0.1614896380292925, + 0.010358210347485542]) + end + + @trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_reflective_wall.jl"), + cells_per_dimension=4, + l2=[ + 0.0036019536614619687, + 0.001734097206958611, + 0.008375221008997178, + 0.0, + 0.028596796602124414, + 0.0018573693138866614, + 0.0020807798141551166, + 0.0, + 5.301188920230166e-5, + ], + linf=[ + 0.01692601228199253, + 0.009369662298436778, + 0.04145169295835428, + 0.0, + 0.11569908670112738, + 0.00984964453299233, + 0.01141708032148614, + 0.0, + 0.0002992631411931389, + ]) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension=8, element_type=Quad(), + approximation_type=SBP(), + l2=[ + 0.0020316462913319046, + 0.023669019044882247, + 0.03446194752754684, + 1.9333465252381796e-15, + ], + linf=[ + 0.010385010095182778, + 0.08750628939565086, + 0.12088392994348407, + 9.325873406851315e-15, + ]) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension=8, element_type=Tri(), + approximation_type=SBP(), + l2=[ + 0.004180680322490383, + 0.07026192411558974, + 0.11815151697006446, + 2.329788936151192e-15, + ], + linf=[ + 0.02076003852980346, + 0.29169601664914424, + 0.5674183379872275, + 1.1546319456101628e-14, + ]) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension=8, element_type=Tri(), + approximation_type=Polynomial(), + # The last l2, linf error are the L2 projection error in approximating `b`, so they are not + # zero for general non-collocated quadrature rules (e.g., for `element_type=Tri()`, `polydeg > 2`). + l2=[ + 0.0008309356912456799, + 0.01522451288799231, + 0.016033969387208476, + 1.2820247308150876e-5, + ], + linf=[ + 0.001888045014140971, + 0.05466838692127718, + 0.06345885709961152, + 3.3989933098554914e-5, + ]) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension=8, element_type=Quad(), + approximation_type=Polynomial(), + # The last l2, linf error are the L2 projection error in approximating `b`. However, this is zero + # for `Quad()` elements with `Polynomial()` approximations because the quadrature rule defaults to + # a `(polydeg + 1)`-point Gauss quadrature rule in each coordinate (in general, StartUpDG.jl defaults + # to the quadrature rule with the fewest number of points which exactly integrates the mass matrix). + l2=[ + 7.460461950323111e-5, + 0.003685589808444905, + 0.0039101604749887785, + 2.0636891126652983e-15, + ], + linf=[ + 0.000259995400729629, + 0.0072236204211630906, + 0.010364675200833062, + 1.021405182655144e-14, + ]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_dgmulti_3d.jl b/test/test_dgmulti_3d.jl index 68fa1d13304..d76da04d5c7 100644 --- a/test/test_dgmulti_3d.jl +++ b/test/test_dgmulti_3d.jl @@ -9,141 +9,286 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "dgmulti_3d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "DGMulti 3D" begin - # 3d tet/hex tests - @trixi_testset "elixir_euler_weakform.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.0010029534292051608, 0.0011682205957721673, 0.001072975385793516, 0.000997247778892257, 0.0039364354651358294] ./ sqrt(8), - linf = [0.003660737033303718, 0.005625620600749226, 0.0030566354814669516, 0.0041580358824311325, 0.019326660236036464] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.014932088450136542, 0.017080219613061526, 0.016589517840793006, 0.015905000907070196, 0.03903416208587798] ./ sqrt(8), - linf = [0.06856547797256729, 0.08225664880340489, 0.06925055630951782, 0.06913016119820181, 0.19161418499621874] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - element_type = Hex(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.00030580190715769566, 0.00040146357607439464, 0.00040146357607564597, 0.000401463576075708, 0.0015749412434154315] ./ sqrt(8), - linf = [0.00036910287847780054, 0.00042659774184228283, 0.0004265977427213574, 0.00042659774250686233, 0.00143803344597071] - ) - end - - @trixi_testset "elixir_euler_curved.jl (Hex elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - l2 = [0.018354883045936066, 0.024412704052042846, 0.024408520416087945, 0.01816314570880129, 0.039342805507972006], - linf = [0.14862225990775757, 0.28952368161864683, 0.2912054484817035, 0.1456603133854122, 0.3315354586775472] - ) - end - - @trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - approximation_type=GaussSBP(), - l2 = [0.002631131519508634, 0.0029144224044954105, 0.002913889110662827, 0.002615140832314194, 0.006881528610614373], - linf = [0.020996114874140215, 0.021314522450134543, 0.021288322783006297, 0.020273381695435244, 0.052598740390024545] - ) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.0010317074322517949, 0.0012277090547035293, 0.0011273991123913515, 0.0010418496196130177, 0.004058878478404962] ./ sqrt(8), - linf = [0.003227752881827861, 0.005620317864620361, 0.0030514833972379307, 0.003987027618439498, 0.019282224709831652] - ) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.00034230612468547436, 0.00044397204714598747, 0.0004439720471461567, 0.0004439720471464591, 0.0016639410646990126] ./ sqrt(8), - linf = [0.0003674374460325147, 0.0004253921341716982, 0.0004253921340786615, 0.0004253921340831024, 0.0014333414071048267] - ) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.001712443468716032, 0.002491315550718859, 0.0024913155507195303, 0.002491315550720031, 0.008585818982343299] ./ sqrt(8), - linf = [0.003810078279323559, 0.004998778644230928, 0.004998778643986235, 0.0049987786444081195, 0.016455044373650196] - ) - end - - @trixi_testset "elixir_euler_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - polydeg = 3, tspan = (0.0, 1.0), cells_per_dimension = (2, 2, 2), - l2 = [0.0003612827827560599, 0.06219350883951729, 0.062193508839503864, 0.08121963221634831, 0.07082703570808184], - linf = [0.0007893509649821162, 0.1481953939988877, 0.14819539399791176, 0.14847291108358926, 0.21313533492212855] - ) - end - - @trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - polydeg = 3, approximation_type = GaussSBP(), tspan = (0.0, 1.0), cells_per_dimension = (2, 2, 2), - l2 = [0.00036128278275524326, 0.062193508839511434, 0.06219350883949677, 0.08121963221635205, 0.07082703570765223], - linf = [0.000789350964946367, 0.14819539399525805, 0.14819539399590542, 0.14847291107658706, 0.21313533492059378] - ) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - cells_per_dimension = (2, 2, 2), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=8), - l2 = [0.0024092707138829925, 0.003318758964118284, 0.0033187589641182386, 0.003318758964118252, 0.012689348410504253], - linf = [0.006118565824207778, 0.008486456080185167, 0.008486456080180282, 0.008486456080185611, 0.035113544599208346] - ) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - cells_per_dimension = (2, 2, 2), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=8), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - l2 = [0.0034543609010604407, 0.004944363692625066, 0.0049443636926250435, 0.004944363692625037, 0.01788695279620914], - linf = [0.013861851418853988, 0.02126572106620328, 0.021265721066209053, 0.021265721066210386, 0.0771455289446683] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2 = [7.561896970325353e-5, 6.884047859361093e-5, 6.884047859363204e-5, 6.884047859361148e-5, 0.000201107274617457], - linf = [0.0001337520020225913, 0.00011571467799287305, 0.0001157146779990903, 0.00011571467799376123, 0.0003446082308800058] - ) - end - - @trixi_testset "elixir_advection_tensor_wedge.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"), - l2 = [2.30487910e-04] , - linf = [6.31795281e-04] ) - end + # 3d tet/hex tests + @trixi_testset "elixir_euler_weakform.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0010029534292051608, + 0.0011682205957721673, + 0.001072975385793516, + 0.000997247778892257, + 0.0039364354651358294, + ] ./ sqrt(8), + linf=[ + 0.003660737033303718, + 0.005625620600749226, + 0.0030566354814669516, + 0.0041580358824311325, + 0.019326660236036464, + ]) + end + @trixi_testset "elixir_euler_weakform.jl (EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.014932088450136542, + 0.017080219613061526, + 0.016589517840793006, + 0.015905000907070196, + 0.03903416208587798, + ] ./ sqrt(8), + linf=[ + 0.06856547797256729, + 0.08225664880340489, + 0.06925055630951782, + 0.06913016119820181, + 0.19161418499621874, + ]) + end + + @trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + element_type=Hex(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.00030580190715769566, + 0.00040146357607439464, + 0.00040146357607564597, + 0.000401463576075708, + 0.0015749412434154315, + ] ./ sqrt(8), + linf=[ + 0.00036910287847780054, + 0.00042659774184228283, + 0.0004265977427213574, + 0.00042659774250686233, + 0.00143803344597071, + ]) + end + + @trixi_testset "elixir_euler_curved.jl (Hex elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + l2=[ + 0.018354883045936066, + 0.024412704052042846, + 0.024408520416087945, + 0.01816314570880129, + 0.039342805507972006, + ], + linf=[ + 0.14862225990775757, + 0.28952368161864683, + 0.2912054484817035, + 0.1456603133854122, + 0.3315354586775472, + ]) + end + + @trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + approximation_type=GaussSBP(), + l2=[ + 0.002631131519508634, + 0.0029144224044954105, + 0.002913889110662827, + 0.002615140832314194, + 0.006881528610614373, + ], + linf=[ + 0.020996114874140215, + 0.021314522450134543, + 0.021288322783006297, + 0.020273381695435244, + 0.052598740390024545, + ]) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0010317074322517949, + 0.0012277090547035293, + 0.0011273991123913515, + 0.0010418496196130177, + 0.004058878478404962, + ] ./ sqrt(8), + linf=[ + 0.003227752881827861, + 0.005620317864620361, + 0.0030514833972379307, + 0.003987027618439498, + 0.019282224709831652, + ]) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type=Hex(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.00034230612468547436, + 0.00044397204714598747, + 0.0004439720471461567, + 0.0004439720471464591, + 0.0016639410646990126, + ] ./ sqrt(8), + linf=[ + 0.0003674374460325147, + 0.0004253921341716982, + 0.0004253921340786615, + 0.0004253921340831024, + 0.0014333414071048267, + ]) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type=Hex(), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.001712443468716032, + 0.002491315550718859, + 0.0024913155507195303, + 0.002491315550720031, + 0.008585818982343299, + ] ./ sqrt(8), + linf=[ + 0.003810078279323559, + 0.004998778644230928, + 0.004998778643986235, + 0.0049987786444081195, + 0.016455044373650196, + ]) + end + + @trixi_testset "elixir_euler_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), + polydeg=3, tspan=(0.0, 1.0), cells_per_dimension=(2, 2, 2), + l2=[ + 0.0003612827827560599, + 0.06219350883951729, + 0.062193508839503864, + 0.08121963221634831, + 0.07082703570808184, + ], + linf=[ + 0.0007893509649821162, + 0.1481953939988877, + 0.14819539399791176, + 0.14847291108358926, + 0.21313533492212855, + ]) + end + + @trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), + polydeg=3, approximation_type=GaussSBP(), tspan=(0.0, 1.0), + cells_per_dimension=(2, 2, 2), + l2=[ + 0.00036128278275524326, + 0.062193508839511434, + 0.06219350883949677, + 0.08121963221635205, + 0.07082703570765223, + ], + linf=[ + 0.000789350964946367, + 0.14819539399525805, + 0.14819539399590542, + 0.14847291107658706, + 0.21313533492059378, + ]) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type=Hex(), + cells_per_dimension=(2, 2, 2), + approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 2, + xmin = 0.0, xmax = 1.0, + N = 8), + l2=[ + 0.0024092707138829925, + 0.003318758964118284, + 0.0033187589641182386, + 0.003318758964118252, + 0.012689348410504253, + ], + linf=[ + 0.006118565824207778, + 0.008486456080185167, + 0.008486456080180282, + 0.008486456080185611, + 0.035113544599208346, + ]) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type=Hex(), + cells_per_dimension=(2, 2, 2), + approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 2, + xmin = 0.0, xmax = 1.0, + N = 8), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + l2=[ + 0.0034543609010604407, + 0.004944363692625066, + 0.0049443636926250435, + 0.004944363692625037, + 0.01788695279620914, + ], + linf=[ + 0.013861851418853988, + 0.02126572106620328, + 0.021265721066209053, + 0.021265721066210386, + 0.0771455289446683, + ]) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + l2=[ + 7.561896970325353e-5, + 6.884047859361093e-5, + 6.884047859363204e-5, + 6.884047859361148e-5, + 0.000201107274617457, + ], + linf=[ + 0.0001337520020225913, + 0.00011571467799287305, + 0.0001157146779990903, + 0.00011571467799376123, + 0.0003446082308800058, + ]) + end + + @trixi_testset "elixir_advection_tensor_wedge.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"), + l2=[2.30487910e-04], + linf=[6.31795281e-04]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_mpi.jl b/test/test_mpi.jl index 34febf7e268..ad1ba4e835d 100644 --- a/test/test_mpi.jl +++ b/test/test_mpi.jl @@ -7,7 +7,7 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) +Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) # CI with MPI and some tests fails often on Windows. Thus, we check whether this # is the case here. We use GitHub Actions, so we can check whether we run CI @@ -16,33 +16,32 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @testset "MPI" begin - # TreeMesh tests - include("test_mpi_tree.jl") - - # P4estMesh tests - include("test_mpi_p4est_2d.jl") - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` above - include("test_mpi_p4est_3d.jl") - end + # TreeMesh tests + include("test_mpi_tree.jl") + + # P4estMesh tests + include("test_mpi_p4est_2d.jl") + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` above + include("test_mpi_p4est_3d.jl") + end end # MPI - @trixi_testset "MPI supporting functionality" begin - using OrdinaryDiffEq - - t = 0.5 - let u = 1.0 - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end - let u = [1.0, -2.0] - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end - let u = [SVector(1.0, -2.0), SVector(0.5, -0.1)] - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end + using OrdinaryDiffEq + + t = 0.5 + let u = 1.0 + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end + let u = [1.0, -2.0] + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end + let u = [SVector(1.0, -2.0), SVector(0.5, -0.1)] + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end end # MPI supporting functionality # Clean up afterwards: delete Trixi.jl output directory -Trixi.mpi_isroot() && @test_nowarn rm(outdir, recursive=true) +Trixi.mpi_isroot() && @test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_mpi_p4est_2d.jl b/test/test_mpi_p4est_2d.jl index 4023997eaf3..be1d6597155 100644 --- a/test/test_mpi_p4est_2d.jl +++ b/test/test_mpi_p4est_2d.jl @@ -9,69 +9,85 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_2d_dgsem") @testset "P4estMesh MPI 2D" begin -# Run basic tests -@testset "Examples 2D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) + # Run basic tests + @testset "Examples 2D" begin + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && println("elixir_advection_basic.jl with error-based step size control") + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && + println("elixir_advection_basic.jl with error-based step size control") - sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, - ode_default_options()..., callback=callbacks); summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2 ≈ [3.3022040342579066e-5] rtol=1.0e-4 - @test errors.linf ≈ [0.00011787417954578494] rtol=1.0e-4 - end - end - end - - @trixi_testset "elixir_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), - l2 = [3.198940059144588e-5], - linf = [0.00030636069494005547]) - end + sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, + ode_default_options()..., callback = callbacks) + summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2≈[3.3022040342579066e-5] rtol=1.0e-4 + @test errors.linf≈[0.00011787417954578494] rtol=1.0e-4 + end + end + end - @trixi_testset "elixir_advection_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), - l2 = [0.0005379687442422346], - linf = [0.007438525029884735]) - end + @trixi_testset "elixir_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonconforming_flag.jl"), + l2=[3.198940059144588e-5], + linf=[0.00030636069494005547]) + end - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [4.949660644033807e-5], - linf = [0.0004867846262313763], - coverage_override = (maxiters=6,)) - end + @trixi_testset "elixir_advection_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_unstructured_flag.jl"), + l2=[0.0005379687442422346], + linf=[0.007438525029884735]) + end - @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_flag.jl"), - l2 = [0.0012766060609964525], - linf = [0.01750280631586159], - coverage_override = (maxiters=6,)) - end + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + end - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [4.507575525876275e-6], - linf = [6.21489667023134e-5]) - end + @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_flag.jl"), + l2=[0.0012766060609964525], + linf=[0.01750280631586159], + coverage_override=(maxiters = 6,)) + end - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) - end -end + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[4.507575525876275e-6], + linf=[6.21489667023134e-5]) + end + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) + end + end end # P4estMesh MPI end # module diff --git a/test/test_mpi_p4est_3d.jl b/test/test_mpi_p4est_3d.jl index f92feb1eed9..c8542747b44 100644 --- a/test/test_mpi_p4est_3d.jl +++ b/test/test_mpi_p4est_3d.jl @@ -9,89 +9,148 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem") @testset "P4estMesh MPI 3D" begin -# Run basic tests -@testset "Examples 3D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && println("elixir_advection_basic.jl with error-based step size control") - - sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, - ode_default_options()..., callback=callbacks); summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2 ≈ [0.00016800412839949264] rtol=1.0e-4 - @test errors.linf ≈ [0.0014548839020096516] rtol=1.0e-4 - end + # Run basic tests + @testset "Examples 3D" begin + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && + println("elixir_advection_basic.jl with error-based step size control") + + sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, + ode_default_options()..., callback = callbacks) + summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2≈[0.00016800412839949264] rtol=1.0e-4 + @test errors.linf≈[0.0014548839020096516] rtol=1.0e-4 + end + end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[9.773852895157622e-6], + linf=[0.0005853874124926162], + # override values are different from the serial tests to ensure each process holds at least + # one element, otherwise OrdinaryDiffEq fails during initialization + coverage_override=(maxiters = 6, + initial_refinement_level = 2, + base_level = 2, med_level = 3, + max_level = 4)) + end + + @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_curved.jl"), + l2=[1.6236411810065552e-5], + linf=[0.0010554006923731395], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6, + initial_refinement_level = 0, + base_level = 0, med_level = 1, + max_level = 2)) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[0.002590388934758452], + linf=[0.01840757696885409]) + end + + @trixi_testset "elixir_advection_cubed_sphere.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), + l2=[0.002006918015656413], + linf=[0.027655117058380085]) + end + + # Compressible Euler + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), + l2=[ + 4.070355207909268e-5, + 4.4993257426833716e-5, + 5.10588457841744e-5, + 5.102840924036687e-5, + 0.00019986264001630542, + ], + linf=[ + 0.0016987332417202072, + 0.003622956808262634, + 0.002029576258317789, + 0.0024206977281964193, + 0.008526972236273522, + ], + tspan=(0.0, 0.01)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 0.0015106060984283647, + 0.0014733349038567685, + 0.00147333490385685, + 0.001473334903856929, + 0.0028149479453087093, + ], + linf=[ + 0.008070806335238156, + 0.009007245083113125, + 0.009007245083121784, + 0.009007245083102688, + 0.01562861968368434, + ], + tspan=(0.0, 1.0)) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.010380390326164493, + 0.006192950051354618, + 0.005970674274073704, + 0.005965831290564327, + 0.02628875593094754, + ], + linf=[ + 0.3326911600075694, + 0.2824952141320467, + 0.41401037398065543, + 0.45574161423218573, + 0.8099577682187109, + ], + tspan=(0.0, 0.2), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), + l2=[ + 0.0042023406458005464, + 0.004122532789279737, + 0.0042448149597303616, + 0.0036361316700401765, + 0.007389845952982495, + ], + linf=[ + 0.04530610539892499, + 0.02765695110527666, + 0.05670295599308606, + 0.048396544302230504, + 0.1154589758186293, + ]) + end end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [9.773852895157622e-6], - linf = [0.0005853874124926162], - # override values are different from the serial tests to ensure each process holds at least - # one element, otherwise OrdinaryDiffEq fails during initialization - coverage_override = (maxiters=6, initial_refinement_level=2, base_level=2, med_level=3, max_level=4)) - end - - @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_curved.jl"), - l2 = [1.6236411810065552e-5], - linf = [0.0010554006923731395], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=1, max_level=2)) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.002590388934758452], - linf = [0.01840757696885409]) - end - - @trixi_testset "elixir_advection_cubed_sphere.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), - l2 = [0.002006918015656413], - linf = [0.027655117058380085]) - end - - # Compressible Euler - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), - l2 = [4.070355207909268e-5, 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, 0.00019986264001630542], - linf = [0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, 0.008526972236273522], - tspan = (0.0, 0.01)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [0.0015106060984283647, 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, 0.0028149479453087093], - linf = [0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, 0.01562861968368434], - tspan = (0.0, 1.0)) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.010380390326164493, 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, 0.02628875593094754], - linf = [0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, 0.8099577682187109], - tspan = (0.0, 0.2), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), - l2 = [0.0042023406458005464, 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, 0.007389845952982495], - linf = [0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, 0.1154589758186293]) - end -end - end # P4estMesh MPI end # module diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 84d2609cbb1..7b0a58a3bd9 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -12,179 +12,309 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @testset "TreeMesh MPI" begin -# Run basic tests -@testset "Examples 2D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) - end - - @trixi_testset "elixir_advection_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [0.0015188466707237375], - linf = [0.008446655719187679]) - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [4.913300828257469e-5], - linf = [0.00045263895394385967], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [3.2207388565869075e-5], - linf = [0.0007508059772436404], - coverage_override = (maxiters=6,)) - end - - # Linear scalar advection with AMR - # These example files are only for testing purposes and have no practical use - @trixi_testset "elixir_advection_amr_refine_twice.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_refine_twice.jl"), - l2 = [0.00020547512522578292], - linf = [0.007831753383083506], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_coarsen_twice.jl"), - l2 = [0.0014321062757891826], - linf = [0.0253454486893413], - coverage_override = (maxiters=6,)) - end - - # Hyperbolic diffusion - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2 = [0.00015687751816056159, 0.001025986772217084, 0.0010259867722169909], - linf = [0.0011986956416591976, 0.006423873516411049, 0.006423873516411049]) - end - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [8.61813235543625e-8, 5.619399844542781e-7, 5.6193998447443e-7], - linf = [1.124861862180196e-6, 8.622436471039663e-6, 8.622436470151484e-6]) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [8.523077653955306e-6, 2.8779323653065056e-5, 5.4549427691297846e-5], - linf = [5.5227409524905013e-5, 0.0001454489597927185, 0.00032396328684569653]) - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_hypdiff_godunov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), - l2 = [5.868147556427088e-6, 3.80517927324465e-5, 3.805179273249344e-5], - linf = [3.701965498725812e-5, 0.0002122422943138247, 0.00021224229431116015], - atol = 2.0e-12 #= required for CI on macOS =#) - end - end - - - # Compressible Euler - # Note: Some tests here have manually increased relative tolerances since reduction via MPI can - # slightly change the L2 error norms (different floating point truncation errors) - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], - rtol = 2000*sqrt(eps())) - end - end - - # This example file is only for testing purposes and has no practical use - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_amr_refine_coarsen.jl"), - l2 = [4.8226610349853444e-5, 4.117706709270575e-5, 4.1177067092959676e-5, 0.00012205252427437389], - linf = [0.0003543874851490436, 0.0002973166773747593, 0.0002973166773760916, 0.001154106793870291], - # Let this test run until the end to cover the time-dependent lines - # of the indicator and the MPI-specific AMR code. - coverage_override = (maxiters=10^5,)) - end - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], - linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5], - rtol = 0.001) - end - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], - linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) - - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && println("elixir_euler_ec.jl with error-based step size control") - - sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, - ode_default_options()..., callback=callbacks); summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2 ≈ [0.061653630426688116, 0.05006930431098764, 0.05007694316484242, 0.22550689872331683] rtol=1.0e-4 - @test errors.linf ≈ [0.28516937484583693, 0.2983633696512788, 0.297812036335975, 1.027368795517512] rtol=1.0e-4 - end - end - end - end - - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [0.00013492249515826863, 0.006615696236378061, 0.006782108219800376, 0.016393831451740604], - linf = [0.0020782600954247776, 0.08150078921935999, 0.08663621974991986, 0.2829930622010579], - rtol = 0.001) - end - - @trixi_testset "elixir_euler_vortex_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [0.0017208369388227673, 0.09628684992237334, 0.09620157717330868, 0.1758809552387432], - linf = [0.021869936355319086, 0.9956698009442038, 1.0002507727219028, 2.223249697515648]) - end - - @trixi_testset "elixir_euler_vortex_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [5.051719943432265e-5, 0.0022574259317084747, 0.0021755998463189713, 0.004346492398617521], - linf = [0.0012880114865917447, 0.03857193149447702, 0.031090457959835893, 0.12125130332971423], - coverage_override = (maxiters=6,)) - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), - l2 = [0.0017158367642679273, 0.09619888722871434, 0.09616432767924141, 0.17553381166255197], - linf = [0.021853862449723982, 0.9878047229255944, 0.9880191167111795, 2.2154030488035588], - rtol = 0.001) - end - end -end + # Run basic tests + @testset "Examples 2D" begin + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[7.81674284320524e-6], + linf=[6.314906965243505e-5]) + end + + @trixi_testset "elixir_advection_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[0.0015188466707237375], + linf=[0.008446655719187679]) + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[4.913300828257469e-5], + linf=[0.00045263895394385967], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_nonperiodic.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[3.2207388565869075e-5], + linf=[0.0007508059772436404], + coverage_override=(maxiters = 6,)) + end + + # Linear scalar advection with AMR + # These example files are only for testing purposes and have no practical use + @trixi_testset "elixir_advection_amr_refine_twice.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_refine_twice.jl"), + l2=[0.00020547512522578292], + linf=[0.007831753383083506], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_coarsen_twice.jl"), + l2=[0.0014321062757891826], + linf=[0.0253454486893413], + coverage_override=(maxiters = 6,)) + end + + # Hyperbolic diffusion + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_lax_friedrichs.jl"), + l2=[ + 0.00015687751816056159, + 0.001025986772217084, + 0.0010259867722169909, + ], + linf=[ + 0.0011986956416591976, + 0.006423873516411049, + 0.006423873516411049, + ]) + end + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[ + 8.61813235543625e-8, + 5.619399844542781e-7, + 5.6193998447443e-7, + ], + linf=[ + 1.124861862180196e-6, + 8.622436471039663e-6, + 8.622436470151484e-6, + ]) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2=[ + 8.523077653955306e-6, + 2.8779323653065056e-5, + 5.4549427691297846e-5, + ], + linf=[ + 5.5227409524905013e-5, + 0.0001454489597927185, + 0.00032396328684569653, + ]) + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_hypdiff_godunov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), + l2=[ + 5.868147556427088e-6, + 3.80517927324465e-5, + 3.805179273249344e-5, + ], + linf=[ + 3.701965498725812e-5, + 0.0002122422943138247, + 0.00021224229431116015, + ], + atol=2.0e-12) #= required for CI on macOS =# + end + end + + # Compressible Euler + # Note: Some tests here have manually increased relative tolerances since reduction via MPI can + # slightly change the L2 error norms (different floating point truncation errors) + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ], + rtol=2000 * sqrt(eps())) + end + end + + # This example file is only for testing purposes and has no practical use + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_amr_refine_coarsen.jl"), + l2=[ + 4.8226610349853444e-5, + 4.117706709270575e-5, + 4.1177067092959676e-5, + 0.00012205252427437389, + ], + linf=[ + 0.0003543874851490436, + 0.0002973166773747593, + 0.0002973166773760916, + 0.001154106793870291, + ], + # Let this test run until the end to cover the time-dependent lines + # of the indicator and the MPI-specific AMR code. + coverage_override=(maxiters = 10^5,)) + end + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511766445e-6, + 2.318888155713922e-6, + 2.3188881557894307e-6, + 6.3327863238858925e-6, + ], + linf=[ + 1.498738264560373e-5, + 1.9182011928187137e-5, + 1.918201192685487e-5, + 6.0526717141407005e-5, + ], + rtol=0.001) + end + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.061751715597716854, + 0.05018223615408711, + 0.05018989446443463, + 0.225871559730513, + ], + linf=[ + 0.29347582879608825, + 0.31081249232844693, + 0.3107380389947736, + 1.0540358049885143, + ]) + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && + println("elixir_euler_ec.jl with error-based step size control") + + sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, + ode_default_options()..., callback = callbacks) + summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2≈[ + 0.061653630426688116, + 0.05006930431098764, + 0.05007694316484242, + 0.22550689872331683, + ] rtol=1.0e-4 + @test errors.linf≈[ + 0.28516937484583693, + 0.2983633696512788, + 0.297812036335975, + 1.027368795517512, + ] rtol=1.0e-4 + end + end + end + end + + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 0.00013492249515826863, + 0.006615696236378061, + 0.006782108219800376, + 0.016393831451740604, + ], + linf=[ + 0.0020782600954247776, + 0.08150078921935999, + 0.08663621974991986, + 0.2829930622010579, + ], + rtol=0.001) + end + + @trixi_testset "elixir_euler_vortex_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[ + 0.0017208369388227673, + 0.09628684992237334, + 0.09620157717330868, + 0.1758809552387432, + ], + linf=[ + 0.021869936355319086, + 0.9956698009442038, + 1.0002507727219028, + 2.223249697515648, + ]) + end + + @trixi_testset "elixir_euler_vortex_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[ + 5.051719943432265e-5, + 0.0022574259317084747, + 0.0021755998463189713, + 0.004346492398617521, + ], + linf=[ + 0.0012880114865917447, + 0.03857193149447702, + 0.031090457959835893, + 0.12125130332971423, + ], + coverage_override=(maxiters = 6,)) + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_vortex_shockcapturing.jl"), + l2=[ + 0.0017158367642679273, + 0.09619888722871434, + 0.09616432767924141, + 0.17553381166255197, + ], + linf=[ + 0.021853862449723982, + 0.9878047229255944, + 0.9880191167111795, + 2.2154030488035588, + ], + rtol=0.001) + end + end + end end # TreeMesh MPI end # module diff --git a/test/test_p4est_2d.jl b/test/test_p4est_2d.jl index f66664c7a89..50e80ecd1e2 100644 --- a/test/test_p4est_2d.jl +++ b/test/test_p4est_2d.jl @@ -9,164 +9,279 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "P4estMesh2D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), - l2 = [3.198940059144588e-5], - linf = [0.00030636069494005547]) - - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end - - @trixi_testset "elixir_advection_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), - l2 = [0.0005379687442422346], - linf = [0.007438525029884735]) - end - - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with StructuredMesh! - l2 = [4.949660644033807e-5], - linf = [0.0004867846262313763], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_flag.jl"), - l2 = [0.0012766060609964525], - linf = [0.01750280631586159], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [4.507575525876275e-6], - linf = [6.21489667023134e-5]) - end - - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], - linf = [1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], - atol = 2.0e-12, # required to make CI tests pass on macOS - ) - end - - @trixi_testset "elixir_euler_shockcapturing_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), - l2 = [9.53984675e-02, 1.05633455e-01, 1.05636158e-01, 3.50747237e-01], - linf = [2.94357464e-01, 4.07893014e-01, 3.97334516e-01, 1.08142520e+00], - tspan = (0.0, 1.0)) - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [3.76149952e-01, 2.46970327e-01, 2.46970327e-01, 1.28889042e+00], - linf = [1.22139001e+00, 1.17742626e+00, 1.17742626e+00, 6.20638482e+00], - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_euler_blast_wave_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), - l2 = [6.32183914e-01, 3.86914231e-01, 3.86869171e-01, 1.06575688e+00], - linf = [2.76020890e+00, 2.32659890e+00, 2.32580837e+00, 2.15778188e+00], - tspan = (0.0, 0.3), - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_wall_bc_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"), - l2 = [0.020291447969983396, 0.017479614254319948, 0.011387644425613437, 0.0514420126021293], - linf = [0.3582779022370579, 0.32073537890751663, 0.221818049107692, 0.9209559420400415], - tspan = (0.0, 0.15)) - end - - @trixi_testset "elixir_euler_forward_step_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_forward_step_amr.jl"), - l2 = [0.004194875320833303, 0.003785140699353966, 0.0013696609105790351, 0.03265268616046424], - linf = [2.0585399781442852, 2.213428805506876, 3.862362410419163, 17.75187237459251], - tspan = (0.0, 0.0001), - rtol = 1.0e-7, - skip_coverage=true) - end - - @trixi_testset "elixir_euler_double_mach_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_double_mach_amr.jl"), - l2 = [0.051359355290192046, 0.4266034859911273, 0.2438304855475594, 4.11487176105527], - linf = [6.902000373057003, 53.95714139820832, 24.241610279839758, 561.0630401858057], - tspan = (0.0, 0.0001), - skip_coverage=true) - end - - @trixi_testset "elixir_euler_supersonic_cylinder.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_supersonic_cylinder.jl"), - l2 = [0.026798021911954406, 0.05118546368109259, 0.03206703583774831, 0.19680026567208672], - linf = [3.653905721692421, 4.285035711361009, 6.8544353186357645, 31.748244912257533], - tspan = (0.0, 0.001), - skip_coverage=true) - end - - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [9.168126407325352e-5, 0.0009795410115453788, 0.002546408320320785, 3.941189812642317e-6], - linf = [0.0009903782521019089, 0.0059752684687262025, 0.010941106525454103, 1.2129488214718265e-5], - tspan = (0.0, 0.1)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.0513414461545583e-5, 1.0517900957166411e-6, 1.0517900957304043e-6, 1.511816606372376e-6, - 1.0443997728645063e-6, 7.879639064990798e-7, 7.879639065049896e-7, 1.0628631669056271e-6, - 4.3382328912336153e-7], - linf = [4.255466285174592e-5, 1.0029706745823264e-5, 1.0029706747467781e-5, 1.2122265939010224e-5, - 5.4791097160444835e-6, 5.18922042269665e-6, 5.189220422141538e-6, 9.552667261422676e-6, - 1.4237578427628152e-6]) - end - - @trixi_testset "elixir_mhd_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2 = [0.4552084651735862, 0.8918048264575757, 0.832471223081887, 0.0, - 0.9801264164951583, 0.10475690769435382, 0.1555132409149897, 0.0, - 2.0597079362763556e-5], - linf = [10.194181233788775, 18.25472397868819, 10.031307436191334, 0.0, - 19.647239392277378, 1.3938810140985936, 1.8724965294853084, 0.0, - 0.0016290067532561904], - tspan = (0.0, 0.02)) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonconforming_flag.jl"), + l2=[3.198940059144588e-5], + linf=[0.00030636069494005547]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + end + + @trixi_testset "elixir_advection_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), + l2=[0.0005379687442422346], + linf=[0.007438525029884735]) + end + + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with StructuredMesh! + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_flag.jl"), + l2=[0.0012766060609964525], + linf=[0.01750280631586159], + coverage_override=(maxiters = 6,)) + end + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[4.507575525876275e-6], + linf=[6.21489667023134e-5]) + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], + atol=2.0e-12,) + end + + @trixi_testset "elixir_euler_shockcapturing_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), + l2=[ + 9.53984675e-02, + 1.05633455e-01, + 1.05636158e-01, + 3.50747237e-01, + ], + linf=[ + 2.94357464e-01, + 4.07893014e-01, + 3.97334516e-01, + 1.08142520e+00, + ], + tspan=(0.0, 1.0)) + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2=[ + 3.76149952e-01, + 2.46970327e-01, + 2.46970327e-01, + 1.28889042e+00, + ], + linf=[ + 1.22139001e+00, + 1.17742626e+00, + 1.17742626e+00, + 6.20638482e+00, + ], + tspan=(0.0, 0.3)) + end + + @trixi_testset "elixir_euler_blast_wave_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), + l2=[ + 6.32183914e-01, + 3.86914231e-01, + 3.86869171e-01, + 1.06575688e+00, + ], + linf=[ + 2.76020890e+00, + 2.32659890e+00, + 2.32580837e+00, + 2.15778188e+00, + ], + tspan=(0.0, 0.3), + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_wall_bc_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"), + l2=[ + 0.020291447969983396, + 0.017479614254319948, + 0.011387644425613437, + 0.0514420126021293, + ], + linf=[ + 0.3582779022370579, + 0.32073537890751663, + 0.221818049107692, + 0.9209559420400415, + ], + tspan=(0.0, 0.15)) + end + + @trixi_testset "elixir_euler_forward_step_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_forward_step_amr.jl"), + l2=[ + 0.004194875320833303, + 0.003785140699353966, + 0.0013696609105790351, + 0.03265268616046424, + ], + linf=[ + 2.0585399781442852, + 2.213428805506876, + 3.862362410419163, + 17.75187237459251, + ], + tspan=(0.0, 0.0001), + rtol=1.0e-7, + skip_coverage=true) + end + + @trixi_testset "elixir_euler_double_mach_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_double_mach_amr.jl"), + l2=[ + 0.051359355290192046, + 0.4266034859911273, + 0.2438304855475594, + 4.11487176105527, + ], + linf=[ + 6.902000373057003, + 53.95714139820832, + 24.241610279839758, + 561.0630401858057, + ], + tspan=(0.0, 0.0001), + skip_coverage=true) + end + + @trixi_testset "elixir_euler_supersonic_cylinder.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_supersonic_cylinder.jl"), + l2=[ + 0.026798021911954406, + 0.05118546368109259, + 0.03206703583774831, + 0.19680026567208672, + ], + linf=[ + 3.653905721692421, + 4.285035711361009, + 6.8544353186357645, + 31.748244912257533, + ], + tspan=(0.0, 0.001), + skip_coverage=true) + end + + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2=[ + 9.168126407325352e-5, + 0.0009795410115453788, + 0.002546408320320785, + 3.941189812642317e-6, + ], + linf=[ + 0.0009903782521019089, + 0.0059752684687262025, + 0.010941106525454103, + 1.2129488214718265e-5, + ], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[1.0513414461545583e-5, 1.0517900957166411e-6, + 1.0517900957304043e-6, 1.511816606372376e-6, + 1.0443997728645063e-6, 7.879639064990798e-7, + 7.879639065049896e-7, 1.0628631669056271e-6, + 4.3382328912336153e-7], + linf=[4.255466285174592e-5, 1.0029706745823264e-5, + 1.0029706747467781e-5, 1.2122265939010224e-5, + 5.4791097160444835e-6, 5.18922042269665e-6, + 5.189220422141538e-6, 9.552667261422676e-6, + 1.4237578427628152e-6]) + end + + @trixi_testset "elixir_mhd_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), + l2=[0.4552084651735862, 0.8918048264575757, 0.832471223081887, + 0.0, + 0.9801264164951583, 0.10475690769435382, 0.1555132409149897, + 0.0, + 2.0597079362763556e-5], + linf=[10.194181233788775, 18.25472397868819, 10.031307436191334, + 0.0, + 19.647239392277378, 1.3938810140985936, 1.8724965294853084, + 0.0, + 0.0016290067532561904], + tspan=(0.0, 0.02)) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_p4est_3d.jl b/test/test_p4est_3d.jl index f22e98456ae..bdc0a4410ce 100644 --- a/test/test_p4est_3d.jl +++ b/test/test_p4est_3d.jl @@ -9,168 +9,308 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_3d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "P4estMesh3D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - end - - @trixi_testset "elixir_advection_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_curved.jl"), - l2 = [0.0004750004258546538], - linf = [0.026527551737137167]) - end - - @trixi_testset "elixir_advection_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"), - l2 = [0.00253595715323843], - linf = [0.016486952252155795]) - - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [9.773852895157622e-6], - linf = [0.0005853874124926162], - coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, med_level=2, max_level=3)) - end - - @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_curved.jl"), - l2 = [1.6236411810065552e-5], - linf = [0.0010554006923731395], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=1, max_level=2)) - end - - @trixi_testset "elixir_advection_cubed_sphere.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), - l2 = [0.002006918015656413], - linf = [0.027655117058380085]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.002590388934758452], - linf = [0.01840757696885409]) - end - - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), - l2 = [4.070355207909268e-5, 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, 0.00019986264001630542], - linf = [0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, 0.008526972236273522], - tspan = (0.0, 0.01)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [0.0015106060984283647, 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, 0.0028149479453087093], - linf = [0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, 0.01562861968368434], - tspan = (0.0, 1.0)) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [5.162664597942288e-15, 1.941857343642486e-14, 2.0232366394187278e-14, 2.3381518645408552e-14, 7.083114561232324e-14], - linf = [7.269740365245525e-13, 3.289868377720495e-12, 4.440087186807773e-12, 3.8686831516088205e-12, 9.412914891981927e-12], - tspan = (0.0, 0.03)) - end - - @trixi_testset "elixir_euler_free_stream_extruded.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream_extruded.jl"), - l2 = [8.444868392439035e-16, 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, 1.1356712092620279e-14], - linf = [7.749356711883593e-14, 2.8792246364872653e-13, 1.1121659149182506e-13, 3.3228975127030935e-13, 9.592326932761353e-13], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.010380390326164493, 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, 0.02628875593094754], - linf = [0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, 0.8099577682187109], - tspan = (0.0, 0.2), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [7.82070951e-02, 4.33260474e-02, 4.33260474e-02, 4.33260474e-02, 3.75260911e-01], - linf = [7.45329845e-01, 3.21754792e-01, 3.21754792e-01, 3.21754792e-01, 4.76151527e+00], - tspan = (0.0, 0.3), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonconforming_earth.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_earth.jl"), - l2 = [6.040180337738628e-6, 5.4254175153621895e-6, 5.677698851333843e-6, 5.8017136892469794e-6, 1.3637854615117974e-5], - linf = [0.00013996924184311865, 0.00013681539559939893, 0.00013681539539733834, 0.00013681539541021692, 0.00016833038543762058], - # Decrease tolerance of adaptive time stepping to get similar results across different systems - abstol=1.0e-11, reltol=1.0e-11, - coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_circular_wind_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_circular_wind_nonconforming.jl"), - l2 = [1.573832094977477e-7, 3.863090659429634e-5, 3.867293305754584e-5, 3.686550296950078e-5, 0.05508968493733932], - linf = [2.2695202613887133e-6, 0.0005314968179916946, 0.0005314969614147458, 0.0005130280733059617, 0.7944959432352334], - tspan = (0.0, 2e2), - coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_baroclinic_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_baroclinic_instability.jl"), - l2 = [6.725065410642336e-7, 0.00021710117340245454, 0.000438679759422352, 0.00020836356588024185, 0.07602006689579247], - linf = [1.9101671995258585e-5, 0.029803626911022396, 0.04847630924006063, 0.022001371349740104, 4.847761006938526], - tspan = (0.0, 1e2), - # Decrease tolerance of adaptive time stepping to get similar results across different systems - abstol=1.0e-9, reltol=1.0e-9, - coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), - l2 = [0.0042023406458005464, 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, 0.007389845952982495], - linf = [0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, 0.1154589758186293]) - end - - @trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_nonconforming.jl"), - l2 = [0.00019018725889431733, 0.0006523517707148006, 0.0002401595437705759, 0.0007796920661427565, - 0.0007095787460334334, 0.0006558819731628876, 0.0003565026134076906, 0.0007904654548841712, - 9.437300326448332e-7], - linf = [0.0012482306861187897, 0.006408776208178299, 0.0016845452099629663, 0.0068711236542984555, - 0.004626581522263695, 0.006614624811393632, 0.0030068344747734566, 0.008277825749754025, - 1.3475027166309006e-5], - tspan = (0.0, 0.25), - coverage_override = (trees_per_dimension=(1, 1, 1),)) - end - - @trixi_testset "elixir_mhd_shockcapturing_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shockcapturing_amr.jl"), - l2 = [0.006298541670176575, 0.0064368506652601265, 0.007108729762852636, 0.006530420607206385, - 0.02061185869237284, 0.005562033787605515, 0.007571716276627825, 0.005571862660453231, - 3.909755063709152e-6], - linf = [0.20904054009050665, 0.18622917151105936, 0.2347957890323218, 0.19432508025509926, - 0.6858860133405615, 0.15172116633332622, 0.22432820727833747, 0.16805989780225183, - 0.000535219040687628], - tspan = (0.0, 0.04), - coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, max_level=2)) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + end + + @trixi_testset "elixir_advection_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_unstructured_curved.jl"), + l2=[0.0004750004258546538], + linf=[0.026527551737137167]) + end + + @trixi_testset "elixir_advection_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"), + l2=[0.00253595715323843], + linf=[0.016486952252155795]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[9.773852895157622e-6], + linf=[0.0005853874124926162], + coverage_override=(maxiters = 6, initial_refinement_level = 1, + base_level = 1, med_level = 2, max_level = 3)) + end + + @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_curved.jl"), + l2=[1.6236411810065552e-5], + linf=[0.0010554006923731395], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6, initial_refinement_level = 0, + base_level = 0, med_level = 1, max_level = 2)) + end + + @trixi_testset "elixir_advection_cubed_sphere.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), + l2=[0.002006918015656413], + linf=[0.027655117058380085]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[0.002590388934758452], + linf=[0.01840757696885409]) + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), + l2=[ + 4.070355207909268e-5, + 4.4993257426833716e-5, + 5.10588457841744e-5, + 5.102840924036687e-5, + 0.00019986264001630542, + ], + linf=[ + 0.0016987332417202072, + 0.003622956808262634, + 0.002029576258317789, + 0.0024206977281964193, + 0.008526972236273522, + ], + tspan=(0.0, 0.01)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 0.0015106060984283647, + 0.0014733349038567685, + 0.00147333490385685, + 0.001473334903856929, + 0.0028149479453087093, + ], + linf=[ + 0.008070806335238156, + 0.009007245083113125, + 0.009007245083121784, + 0.009007245083102688, + 0.01562861968368434, + ], + tspan=(0.0, 1.0)) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2=[ + 5.162664597942288e-15, + 1.941857343642486e-14, + 2.0232366394187278e-14, + 2.3381518645408552e-14, + 7.083114561232324e-14, + ], + linf=[ + 7.269740365245525e-13, + 3.289868377720495e-12, + 4.440087186807773e-12, + 3.8686831516088205e-12, + 9.412914891981927e-12, + ], + tspan=(0.0, 0.03)) + end + + @trixi_testset "elixir_euler_free_stream_extruded.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream_extruded.jl"), + l2=[ + 8.444868392439035e-16, + 4.889826056731442e-15, + 2.2921260987087585e-15, + 4.268460455702414e-15, + 1.1356712092620279e-14, + ], + linf=[ + 7.749356711883593e-14, + 2.8792246364872653e-13, + 1.1121659149182506e-13, + 3.3228975127030935e-13, + 9.592326932761353e-13, + ], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.010380390326164493, + 0.006192950051354618, + 0.005970674274073704, + 0.005965831290564327, + 0.02628875593094754, + ], + linf=[ + 0.3326911600075694, + 0.2824952141320467, + 0.41401037398065543, + 0.45574161423218573, + 0.8099577682187109, + ], + tspan=(0.0, 0.2), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2=[ + 7.82070951e-02, + 4.33260474e-02, + 4.33260474e-02, + 4.33260474e-02, + 3.75260911e-01, + ], + linf=[ + 7.45329845e-01, + 3.21754792e-01, + 3.21754792e-01, + 3.21754792e-01, + 4.76151527e+00, + ], + tspan=(0.0, 0.3), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_earth.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_earth.jl"), + l2=[ + 6.040180337738628e-6, + 5.4254175153621895e-6, + 5.677698851333843e-6, + 5.8017136892469794e-6, + 1.3637854615117974e-5, + ], + linf=[ + 0.00013996924184311865, + 0.00013681539559939893, + 0.00013681539539733834, + 0.00013681539541021692, + 0.00016833038543762058, + ], + # Decrease tolerance of adaptive time stepping to get similar results across different systems + abstol=1.0e-11, reltol=1.0e-11, + coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_circular_wind_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_circular_wind_nonconforming.jl"), + l2=[ + 1.573832094977477e-7, + 3.863090659429634e-5, + 3.867293305754584e-5, + 3.686550296950078e-5, + 0.05508968493733932, + ], + linf=[ + 2.2695202613887133e-6, + 0.0005314968179916946, + 0.0005314969614147458, + 0.0005130280733059617, + 0.7944959432352334, + ], + tspan=(0.0, 2e2), + coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_baroclinic_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_baroclinic_instability.jl"), + l2=[ + 6.725065410642336e-7, + 0.00021710117340245454, + 0.000438679759422352, + 0.00020836356588024185, + 0.07602006689579247, + ], + linf=[ + 1.9101671995258585e-5, + 0.029803626911022396, + 0.04847630924006063, + 0.022001371349740104, + 4.847761006938526, + ], + tspan=(0.0, 1e2), + # Decrease tolerance of adaptive time stepping to get similar results across different systems + abstol=1.0e-9, reltol=1.0e-9, + coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), + l2=[ + 0.0042023406458005464, + 0.004122532789279737, + 0.0042448149597303616, + 0.0036361316700401765, + 0.007389845952982495, + ], + linf=[ + 0.04530610539892499, + 0.02765695110527666, + 0.05670295599308606, + 0.048396544302230504, + 0.1154589758186293, + ]) + end + + @trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_mhd_alfven_wave_nonconforming.jl"), + l2=[0.00019018725889431733, 0.0006523517707148006, + 0.0002401595437705759, 0.0007796920661427565, + 0.0007095787460334334, 0.0006558819731628876, + 0.0003565026134076906, 0.0007904654548841712, + 9.437300326448332e-7], + linf=[0.0012482306861187897, 0.006408776208178299, + 0.0016845452099629663, 0.0068711236542984555, + 0.004626581522263695, 0.006614624811393632, + 0.0030068344747734566, 0.008277825749754025, + 1.3475027166309006e-5], + tspan=(0.0, 0.25), + coverage_override=(trees_per_dimension = (1, 1, 1),)) + end + + @trixi_testset "elixir_mhd_shockcapturing_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shockcapturing_amr.jl"), + l2=[0.006298541670176575, 0.0064368506652601265, + 0.007108729762852636, 0.006530420607206385, + 0.02061185869237284, 0.005562033787605515, + 0.007571716276627825, 0.005571862660453231, + 3.909755063709152e-6], + linf=[0.20904054009050665, 0.18622917151105936, + 0.2347957890323218, 0.19432508025509926, + 0.6858860133405615, 0.15172116633332622, + 0.22432820727833747, 0.16805989780225183, + 0.000535219040687628], + tspan=(0.0, 0.04), + coverage_override=(maxiters = 6, initial_refinement_level = 1, + base_level = 1, max_level = 2)) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_paper_self_gravitating_gas_dynamics.jl b/test/test_paper_self_gravitating_gas_dynamics.jl index 6a35543fe47..801a95b1467 100644 --- a/test/test_paper_self_gravitating_gas_dynamics.jl +++ b/test/test_paper_self_gravitating_gas_dynamics.jl @@ -7,127 +7,246 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) const EXAMPLES_DIR = pkgdir(Trixi, "examples", "paper_self_gravitating_gas_dynamics") # Numerical examples from the Euler-gravity paper @testset "paper_self_gravitating_gas_dynamics" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [0.0001740977055972079, 0.0003369355182519592, 0.0003369355182518708, 0.0006099171220334989], - linf = [0.001079347149189669, 0.0018836938381321389, 0.001883693838132583, 0.003971575376718217]) - end - - @trixi_testset "elixir_euler_convergence.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [1.7187201161597772e-5, 2.678065111772951e-5, 2.678065111783027e-5, 4.952504160091526e-5], - linf = [0.0001501749544159381, 0.00016549482504535362, 0.00016549482504601976, 0.0004372960291432193], - polydeg = 4) - end - - - @trixi_testset "elixir_hypdiff_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), - l2 = [0.003154024896093942, 0.012394432074951856, 0.02185973823794725], - linf = [0.01731850928579215, 0.07843510773347553, 0.11242300176349201]) - end - - @trixi_testset "elixir_hypdiff_convergence.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), - l2 = [0.0002511283012128458, 0.0008808243846610255, 0.0016313343228567005], - linf = [0.0017290715087938668, 0.003129184465704738, 0.01000728849316701], - polydeg = 4) - end - - - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) - end - - @trixi_testset "elixir_eulergravity_convergence.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [1.9537712148648045e-5, 2.7564396197947587e-5, 2.7564396197967635e-5, 5.688838772067586e-5], - linf = [0.00012335710672761735, 0.00020086268350816283, 0.00020086268350727465, 0.0004962155455632278], - tspan = (0.0, 0.1), polydeg = 4) - end - - @trixi_testset "elixir_eulergravity_convergence.jl with 1st order RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138959434, 0.000337007710281087, 0.0003370077102811394, 0.0007231525515231289], - linf = [0.0015813032941613958, 0.002049428843978518, 0.0020494288439798503, 0.004793821198143977], - tspan = (0.0, 0.1), timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!) - end - - @trixi_testset "elixir_eulergravity_convergence.jl with 3rd order RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.0002487126513894034, 0.00033700771023049785, 0.00033700771023048245, 0.0007231525514158737], - linf = [0.0015813032943847727, 0.002049428842844314, 0.0020494288428452023, 0.004793821195971937], - tspan = (0.0, 0.1), timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!) - end - - - @trixi_testset "elixir_eulergravity_jeans_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), - l2 = [10733.63378538114, 13356.780607423452, 1.6722844879795038e-6, 26834.076821148774], - linf = [15194.296424901113, 18881.481685044182, 6.809726988008751e-6, 37972.99700513482], - tspan = (0.0, 0.1), - atol = 4.0e-6 # the background field is reatively large, so this corresponds to our usual atol - ) - end - - @trixi_testset "elixir_eulergravity_jeans_instability.jl with RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), - l2 = [10734.598193238024, 13358.217234481384, 1.911011743371934e-6, 26836.487841241516], - linf = [15195.661004798487, 18883.512035906537, 7.867948710816926e-6, 37976.408478975296], - tspan = (0.0, 0.1), - atol = 4.0e-6, # the background field is reatively large, so this corresponds to our usual atol - parameters=ParametersEulerGravity(background_density=1.5e7, - gravitational_constant=6.674e-8, - cfl=2.4, - resid_tol=1.0e-4, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!)) - end - - @trixi_testset "Printing" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), - tspan = (0.0, 1.0e-5), - parameters=ParametersEulerGravity(background_density=1.5e7, - gravitational_constant=6.674e-8, - cfl=2.4, - resid_tol=1.0e-4, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!)) - - show(stdout, parameters) - show(stdout, semi) - show(stdout, semi_euler.boundary_conditions) - show(stdout, TrivialCallback()) - show(stdout, equations_euler) - end - - - @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_sedov_blast_wave.jl"), - l2 = [0.046315994852653024, 0.0650818006233669, 0.06508180062336677, 0.4896707211656037], - linf = [2.3874843337593776, 4.07876384374792, 4.07876384374792, 16.23914384809855], - tspan = (0.0, 0.05), - coverage_override = (maxiters=2,)) - end - - @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_sedov_blast_wave.jl"), - l2 = [0.00289222135995042, 0.013724813590853825, 0.013724813590853832, 0.05822904710548214], - linf = [0.26361780693997594, 1.3908873830688688, 1.3908873830688688, 4.066701303607613], - tspan = (0.0, 0.005), initial_refinement_level=8, amr_callback=TrivialCallback()) - end + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 0.0001740977055972079, + 0.0003369355182519592, + 0.0003369355182518708, + 0.0006099171220334989, + ], + linf=[ + 0.001079347149189669, + 0.0018836938381321389, + 0.001883693838132583, + 0.003971575376718217, + ]) + end + + @trixi_testset "elixir_euler_convergence.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 1.7187201161597772e-5, + 2.678065111772951e-5, + 2.678065111783027e-5, + 4.952504160091526e-5, + ], + linf=[ + 0.0001501749544159381, + 0.00016549482504535362, + 0.00016549482504601976, + 0.0004372960291432193, + ], + polydeg=4) + end + + @trixi_testset "elixir_hypdiff_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), + l2=[ + 0.003154024896093942, + 0.012394432074951856, + 0.02185973823794725, + ], + linf=[ + 0.01731850928579215, + 0.07843510773347553, + 0.11242300176349201, + ]) + end + + @trixi_testset "elixir_hypdiff_convergence.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), + l2=[ + 0.0002511283012128458, + 0.0008808243846610255, + 0.0016313343228567005, + ], + linf=[ + 0.0017290715087938668, + 0.003129184465704738, + 0.01000728849316701, + ], + polydeg=4) + end + + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_eulergravity_convergence.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2=[ + 1.9537712148648045e-5, + 2.7564396197947587e-5, + 2.7564396197967635e-5, + 5.688838772067586e-5, + ], + linf=[ + 0.00012335710672761735, + 0.00020086268350816283, + 0.00020086268350727465, + 0.0004962155455632278, + ], + tspan=(0.0, 0.1), polydeg=4) + end + + @trixi_testset "elixir_eulergravity_convergence.jl with 1st order RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2=[ + 0.00024871265138959434, + 0.000337007710281087, + 0.0003370077102811394, + 0.0007231525515231289, + ], + linf=[ + 0.0015813032941613958, + 0.002049428843978518, + 0.0020494288439798503, + 0.004793821198143977, + ], + tspan=(0.0, 0.1), + timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!) + end + + @trixi_testset "elixir_eulergravity_convergence.jl with 3rd order RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2=[ + 0.0002487126513894034, + 0.00033700771023049785, + 0.00033700771023048245, + 0.0007231525514158737, + ], + linf=[ + 0.0015813032943847727, + 0.002049428842844314, + 0.0020494288428452023, + 0.004793821195971937, + ], + tspan=(0.0, 0.1), + timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!) + end + + @trixi_testset "elixir_eulergravity_jeans_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_jeans_instability.jl"), + l2=[ + 10733.63378538114, + 13356.780607423452, + 1.6722844879795038e-6, + 26834.076821148774, + ], + linf=[ + 15194.296424901113, + 18881.481685044182, + 6.809726988008751e-6, + 37972.99700513482, + ], + tspan=(0.0, 0.1), + atol=4.0e-6) + end + + @trixi_testset "elixir_eulergravity_jeans_instability.jl with RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_jeans_instability.jl"), + l2=[ + 10734.598193238024, + 13358.217234481384, + 1.911011743371934e-6, + 26836.487841241516, + ], + linf=[ + 15195.661004798487, + 18883.512035906537, + 7.867948710816926e-6, + 37976.408478975296, + ], + tspan=(0.0, 0.1), + atol=4.0e-6, # the background field is reatively large, so this corresponds to our usual atol + parameters=ParametersEulerGravity(background_density = 1.5e7, + gravitational_constant = 6.674e-8, + cfl = 2.4, + resid_tol = 1.0e-4, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!)) + end + + @trixi_testset "Printing" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_jeans_instability.jl"), + tspan=(0.0, 1.0e-5), + parameters=ParametersEulerGravity(background_density = 1.5e7, + gravitational_constant = 6.674e-8, + cfl = 2.4, + resid_tol = 1.0e-4, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!)) + + show(stdout, parameters) + show(stdout, semi) + show(stdout, semi_euler.boundary_conditions) + show(stdout, TrivialCallback()) + show(stdout, equations_euler) + end + + @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_sedov_blast_wave.jl"), + l2=[ + 0.046315994852653024, + 0.0650818006233669, + 0.06508180062336677, + 0.4896707211656037, + ], + linf=[ + 2.3874843337593776, + 4.07876384374792, + 4.07876384374792, + 16.23914384809855, + ], + tspan=(0.0, 0.05), + coverage_override=(maxiters = 2,)) + end + + @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_sedov_blast_wave.jl"), + l2=[ + 0.00289222135995042, + 0.013724813590853825, + 0.013724813590853832, + 0.05822904710548214, + ], + linf=[ + 0.26361780693997594, + 1.3908873830688688, + 1.3908873830688688, + 4.066701303607613, + ], + tspan=(0.0, 0.005), initial_refinement_level=8, + amr_callback=TrivialCallback()) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_parabolic_1d.jl b/test/test_parabolic_1d.jl index 1aaf23d576a..e33edc1a68b 100644 --- a/test/test_parabolic_1d.jl +++ b/test/test_parabolic_1d.jl @@ -5,24 +5,21 @@ using Trixi include("test_trixi.jl") - # Start with a clean environment: remove Trixi output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "SemidiscretizationHyperbolicParabolic (1D)" begin - - @trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_advection_diffusion.jl"), - initial_refinement_level = 4, tspan=(0.0, 0.4), polydeg=3, - l2 = [8.389498188525518e-06], - linf = [2.847421658558336e-05] - ) - end - + @trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_advection_diffusion.jl"), + initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3, + l2=[8.389498188525518e-06], + linf=[2.847421658558336e-05]) + end end # Clean up afterwards: delete Trixi output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index b0ac63d4ce9..5be1d7870ca 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -5,204 +5,302 @@ using Trixi include("test_trixi.jl") - # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "SemidiscretizationHyperbolicParabolic (2D)" begin + @trixi_testset "DGMulti 2D rhs_parabolic!" begin + dg = DGMulti(polydeg = 2, element_type = Quad(), approximation_type = Polynomial(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralWeakForm()) + mesh = DGMultiMesh(dg, cells_per_dimension = (2, 2)) + + # test with polynomial initial condition x^2 * y + # test if we recover the exact second derivative + initial_condition = (x, t, equations) -> SVector(x[1]^2 * x[2]) + + equations = LinearScalarAdvectionEquation2D(1.0, 1.0) + equations_parabolic = LaplaceDiffusion2D(1.0, equations) + + semi = SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabolic, + initial_condition, dg) + @test_nowarn_mod show(stdout, semi) + @test_nowarn_mod show(stdout, MIME"text/plain"(), semi) + @test_nowarn_mod show(stdout, boundary_condition_do_nothing) + + @test nvariables(semi) == nvariables(equations) + @test Base.ndims(semi) == Base.ndims(mesh) + @test Base.real(semi) == Base.real(dg) + + ode = semidiscretize(semi, (0.0, 0.01)) + u0 = similar(ode.u0) + Trixi.compute_coefficients!(u0, 0.0, semi) + @test u0 ≈ ode.u0 + + # test "do nothing" BC just returns first argument + @test boundary_condition_do_nothing(u0, nothing) == u0 + + @unpack cache, cache_parabolic, equations_parabolic = semi + @unpack gradients = cache_parabolic + for dim in eachindex(gradients) + fill!(gradients[dim], zero(eltype(gradients[dim]))) + end + + t = 0.0 + # pass in `boundary_condition_periodic` to skip boundary flux/integral evaluation + Trixi.calc_gradient!(gradients, ode.u0, t, mesh, equations_parabolic, + boundary_condition_periodic, dg, cache, cache_parabolic) + @unpack x, y, xq, yq = mesh.md + @test getindex.(gradients[1], 1) ≈ 2 * xq .* yq + @test getindex.(gradients[2], 1) ≈ xq .^ 2 + + u_flux = similar.(gradients) + Trixi.calc_viscous_fluxes!(u_flux, ode.u0, gradients, mesh, equations_parabolic, + dg, cache, cache_parabolic) + @test u_flux[1] ≈ gradients[1] + @test u_flux[2] ≈ gradients[2] + + du = similar(ode.u0) + Trixi.calc_divergence!(du, ode.u0, t, u_flux, mesh, equations_parabolic, + boundary_condition_periodic, + dg, semi.solver_parabolic, cache, cache_parabolic) + @test getindex.(du, 1) ≈ 2 * y + end + + @trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_advection_diffusion.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[0.2485803335154642], + linf=[1.079606969242132]) + end + + @trixi_testset "DGMulti: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_advection_diffusion_periodic.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[0.03180371984888462], + linf=[0.2136821621370909]) + end + + @trixi_testset "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_advection_diffusion_nonperiodic.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[0.002123168335604323], + linf=[0.00963640423513712]) + end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_navierstokes_convergence.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[ + 0.0015355076812510957, + 0.0033843168272696756, + 0.0036531858107443434, + 0.009948436427519214, + ], + linf=[ + 0.005522560467190019, + 0.013425258500730508, + 0.013962115643482154, + 0.027483102120502423, + ]) + end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_navierstokes_convergence_curved.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[ + 0.004255101916146187, + 0.011118488923215765, + 0.011281831283462686, + 0.03573656447388509, + ], + linf=[ + 0.015071710669706473, + 0.04103132025858458, + 0.03990424085750277, + 0.1309401718598764, + ],) + end + + @trixi_testset "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_navierstokes_lid_driven_cavity.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.5), + l2=[ + 0.00022156125227115747, + 0.028318325921401, + 0.009509168701070296, + 0.028267900513550506, + ], + linf=[ + 0.001562278941298234, + 0.14886653390744856, + 0.0716323565533752, + 0.19472785105241996, + ]) + end + + @trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_diffusion.jl"), + initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5, + l2=[4.0915532997994255e-6], + linf=[2.3040850347877395e-5]) + end - @trixi_testset "DGMulti 2D rhs_parabolic!" begin - - dg = DGMulti(polydeg = 2, element_type = Quad(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralWeakForm()) - mesh = DGMultiMesh(dg, cells_per_dimension=(2, 2)) - - # test with polynomial initial condition x^2 * y - # test if we recover the exact second derivative - initial_condition = (x, t, equations) -> SVector(x[1]^2 * x[2]) - - equations = LinearScalarAdvectionEquation2D(1.0, 1.0) - equations_parabolic = LaplaceDiffusion2D(1.0, equations) - - semi = SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabolic, initial_condition, dg) - @test_nowarn_mod show(stdout, semi) - @test_nowarn_mod show(stdout, MIME"text/plain"(), semi) - @test_nowarn_mod show(stdout, boundary_condition_do_nothing) - - @test nvariables(semi) == nvariables(equations) - @test Base.ndims(semi) == Base.ndims(mesh) - @test Base.real(semi) == Base.real(dg) - - ode = semidiscretize(semi, (0.0, 0.01)) - u0 = similar(ode.u0) - Trixi.compute_coefficients!(u0, 0.0, semi) - @test u0 ≈ ode.u0 - - # test "do nothing" BC just returns first argument - @test boundary_condition_do_nothing(u0, nothing) == u0 - - @unpack cache, cache_parabolic, equations_parabolic = semi - @unpack gradients = cache_parabolic - for dim in eachindex(gradients) - fill!(gradients[dim], zero(eltype(gradients[dim]))) - end - - t = 0.0 - # pass in `boundary_condition_periodic` to skip boundary flux/integral evaluation - Trixi.calc_gradient!(gradients, ode.u0, t, mesh, equations_parabolic, - boundary_condition_periodic, dg, cache, cache_parabolic) - @unpack x, y, xq, yq = mesh.md - @test getindex.(gradients[1], 1) ≈ 2 * xq .* yq - @test getindex.(gradients[2], 1) ≈ xq.^2 - - u_flux = similar.(gradients) - Trixi.calc_viscous_fluxes!(u_flux, ode.u0, gradients, mesh, equations_parabolic, - dg, cache, cache_parabolic) - @test u_flux[1] ≈ gradients[1] - @test u_flux[2] ≈ gradients[2] - - du = similar(ode.u0) - Trixi.calc_divergence!(du, ode.u0, t, u_flux, mesh, equations_parabolic, boundary_condition_periodic, - dg, semi.solver_parabolic, cache, cache_parabolic) - @test getindex.(du, 1) ≈ 2 * y - end - - @trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.2485803335154642], - linf = [1.079606969242132] - ) - end - - @trixi_testset "DGMulti: elixir_advection_diffusion_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion_periodic.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.03180371984888462], - linf = [0.2136821621370909] - ) - end - - @trixi_testset "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion_nonperiodic.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.002123168335604323], - linf = [0.00963640423513712] - ) - end - - @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_convergence.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.0015355076812510957, 0.0033843168272696756, 0.0036531858107443434, 0.009948436427519214], - linf = [0.005522560467190019, 0.013425258500730508, 0.013962115643482154, 0.027483102120502423] - ) - end - - @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_convergence_curved.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.004255101916146187, 0.011118488923215765, 0.011281831283462686, 0.03573656447388509], - linf = [0.015071710669706473, 0.04103132025858458, 0.03990424085750277, 0.1309401718598764], - ) - end - - @trixi_testset "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_lid_driven_cavity.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.5), - l2 = [0.00022156125227115747, 0.028318325921401, 0.009509168701070296, 0.028267900513550506], - linf = [0.001562278941298234, 0.14886653390744856, 0.0716323565533752, 0.19472785105241996] - ) - end - - @trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.4), polydeg=5, - l2 = [4.0915532997994255e-6], - linf = [2.3040850347877395e-5] - ) - end - - @trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion_nonperiodic.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - l2 = [0.007646800618485118], - linf = [0.10067621050468958] - ) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - l2 = [0.002111672530658797, 0.0034322351490857846, 0.0038742528195910416, 0.012469246082568561], - linf = [0.012006418939223495, 0.035520871209746126, 0.024512747492231427, 0.11191122588756564] - ) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.002103629650383915, 0.003435843933396454, 0.00386735987813341, 0.012670355349235728], - linf = [0.012006261793147788, 0.03550212518982032, 0.025107947319661185, 0.11647078036571124] - ) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - l2 = [0.0021403742517389513, 0.0034258287094908572, 0.0038915122886898517, 0.012506862343013842], - linf = [0.012244412004628336, 0.03507559186162224, 0.024580892345558894, 0.11425600758350107] - ) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.0021349737347844907, 0.0034301388278203033, 0.0038928324474291572, 0.012693611436230873], - linf = [0.01224423627586213, 0.035054066314102905, 0.025099598504931965, 0.11795616324751634] - ) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - volume_integral=VolumeIntegralFluxDifferencing(flux_central), - l2 = [0.0021116725306633594, 0.0034322351490827557, 0.0038742528196093542, 0.012469246082526909], - linf = [0.012006418939291663, 0.035520871209594115, 0.024512747491801577, 0.11191122588591007] - ) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_lid_driven_cavity.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.00015144571529699053, 0.018766076072331623, 0.007065070765652574, 0.0208399005734258], - linf = [0.0014523369373669048, 0.12366779944955864, 0.05532450997115432, 0.16099927805328207] - ) - end - - @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic.jl"), - trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.0023754695605828443], - linf = [0.008154128363741964] - ) - end - - @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic_curved.jl"), - trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.012380458938507371], - linf = [0.10860506906472567] - ) - end + @trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_diffusion_nonperiodic.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + l2=[0.007646800618485118], + linf=[0.10067621050468958]) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + l2=[ + 0.002111672530658797, + 0.0034322351490857846, + 0.0038742528195910416, + 0.012469246082568561, + ], + linf=[ + 0.012006418939223495, + 0.035520871209746126, + 0.024512747492231427, + 0.11191122588756564, + ]) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.002103629650383915, + 0.003435843933396454, + 0.00386735987813341, + 0.012670355349235728, + ], + linf=[ + 0.012006261793147788, + 0.03550212518982032, + 0.025107947319661185, + 0.11647078036571124, + ]) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + l2=[ + 0.0021403742517389513, + 0.0034258287094908572, + 0.0038915122886898517, + 0.012506862343013842, + ], + linf=[ + 0.012244412004628336, + 0.03507559186162224, + 0.024580892345558894, + 0.11425600758350107, + ]) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.0021349737347844907, + 0.0034301388278203033, + 0.0038928324474291572, + 0.012693611436230873, + ], + linf=[ + 0.01224423627586213, + 0.035054066314102905, + 0.025099598504931965, + 0.11795616324751634, + ]) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + volume_integral=VolumeIntegralFluxDifferencing(flux_central), + l2=[ + 0.0021116725306633594, + 0.0034322351490827557, + 0.0038742528196093542, + 0.012469246082526909, + ], + linf=[ + 0.012006418939291663, + 0.035520871209594115, + 0.024512747491801577, + 0.11191122588591007, + ]) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_lid_driven_cavity.jl"), + initial_refinement_level=2, tspan=(0.0, 0.5), + l2=[ + 0.00015144571529699053, + 0.018766076072331623, + 0.007065070765652574, + 0.0208399005734258, + ], + linf=[ + 0.0014523369373669048, + 0.12366779944955864, + 0.05532450997115432, + 0.16099927805328207, + ]) + end + + @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_advection_diffusion_periodic.jl"), + trees_per_dimension=(1, 1), initial_refinement_level=2, + tspan=(0.0, 0.5), + l2=[0.0023754695605828443], + linf=[0.008154128363741964]) + end + @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_advection_diffusion_periodic_curved.jl"), + trees_per_dimension=(1, 1), initial_refinement_level=2, + tspan=(0.0, 0.5), + l2=[0.012380458938507371], + linf=[0.10860506906472567]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_parabolic_3d.jl b/test/test_parabolic_3d.jl index 1ae5eed44ae..62fcc5c950e 100644 --- a/test/test_parabolic_3d.jl +++ b/test/test_parabolic_3d.jl @@ -7,88 +7,202 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "SemidiscretizationHyperbolicParabolic (3D)" begin - - @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_convergence.jl"), - cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.1), - l2 = [0.0005532847115849239, 0.000659263490965341, 0.0007776436127362806, 0.0006592634909662951, 0.0038073628897809185], - linf = [0.0017039861523615585, 0.002628561703560073, 0.003531057425112172, 0.0026285617036090336, 0.015587829540351095] - ) - end - - @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_convergence_curved.jl"), - cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.1), - l2 = [0.0014027227251207474, 0.0021322235533273513, 0.0027873741447455194, 0.0024587473070627423, 0.00997836818019202], - linf = [0.006341750402837576, 0.010306014252246865, 0.01520740250924979, 0.010968264045485565, 0.047454389831591115] - ) - end - - @trixi_testset "DGMulti: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_taylor_green_vortex.jl"), - cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.25), - l2 = [0.0001825713444029892, 0.015589736382772248, 0.015589736382771884, 0.021943924667273653, 0.01927370280244222], - linf = [0.0006268463584697681, 0.03218881662749007, 0.03218881662697948, 0.053872495395614256, 0.05183822000984151] - ) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - l2 = [0.0019582188528512257, 0.002653449504302844, 0.002898264205184629, 0.002653449504302853, 0.009511572365085706], - linf = [0.013680656759085918, 0.0356910450154318, 0.023526343547736236, 0.035691045015431855, 0.11482570604041165] - ) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.00195468651965362, 0.0026554367897028506, 0.002892730402724066, 0.002655436789702817, 0.009596351796609566], - linf = [0.013680508110645473, 0.035673446359424356, 0.024024936779729028, 0.03567344635942474, 0.11839497110809383] - ) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - l2 = [0.0019770444875099307, 0.0026524750946399327, 0.00290860030832445, 0.0026524750946399396, 0.009509568981439294], - linf = [0.01387936112914212, 0.03526260609304053, 0.023554197097368997, 0.035262606093040896, 0.11719963716509518] - ) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.001974631423398113, 0.002654768259143932, 0.002907031063651286, 0.002654768259143901, 0.009587792882971452], - linf = [0.01387919380137137, 0.035244084526358944, 0.02398614622061363, 0.03524408452635828, 0.12005056512506407] - ) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (flux differencing)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - volume_integral=VolumeIntegralFluxDifferencing(flux_central), - l2 = [0.0019582188528180213, 0.002653449504301736, 0.0028982642051960006, 0.0026534495043017384, 0.009511572364811033], - linf = [0.013680656758949583, 0.035691045015224444, 0.02352634354676752, 0.035691045015223424, 0.11482570603751441] - ) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.25), - l2 = [0.00024173250389635442, 0.015684268393762454, 0.01568426839376248, 0.021991909545192333, 0.02825413672911425], - linf = [0.0008410587892853094, 0.04740176181772552, 0.04740176181772507, 0.07483494924031157, 0.150181591534448] - ) - end - + @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", + "elixir_navierstokes_convergence.jl"), + cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1), + l2=[ + 0.0005532847115849239, + 0.000659263490965341, + 0.0007776436127362806, + 0.0006592634909662951, + 0.0038073628897809185, + ], + linf=[ + 0.0017039861523615585, + 0.002628561703560073, + 0.003531057425112172, + 0.0026285617036090336, + 0.015587829540351095, + ]) + end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", + "elixir_navierstokes_convergence_curved.jl"), + cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1), + l2=[ + 0.0014027227251207474, + 0.0021322235533273513, + 0.0027873741447455194, + 0.0024587473070627423, + 0.00997836818019202, + ], + linf=[ + 0.006341750402837576, + 0.010306014252246865, + 0.01520740250924979, + 0.010968264045485565, + 0.047454389831591115, + ]) + end + + @trixi_testset "DGMulti: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", + "elixir_navierstokes_taylor_green_vortex.jl"), + cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.25), + l2=[ + 0.0001825713444029892, + 0.015589736382772248, + 0.015589736382771884, + 0.021943924667273653, + 0.01927370280244222, + ], + linf=[ + 0.0006268463584697681, + 0.03218881662749007, + 0.03218881662697948, + 0.053872495395614256, + 0.05183822000984151, + ]) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + l2=[ + 0.0019582188528512257, + 0.002653449504302844, + 0.002898264205184629, + 0.002653449504302853, + 0.009511572365085706, + ], + linf=[ + 0.013680656759085918, + 0.0356910450154318, + 0.023526343547736236, + 0.035691045015431855, + 0.11482570604041165, + ]) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.00195468651965362, + 0.0026554367897028506, + 0.002892730402724066, + 0.002655436789702817, + 0.009596351796609566, + ], + linf=[ + 0.013680508110645473, + 0.035673446359424356, + 0.024024936779729028, + 0.03567344635942474, + 0.11839497110809383, + ]) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + l2=[ + 0.0019770444875099307, + 0.0026524750946399327, + 0.00290860030832445, + 0.0026524750946399396, + 0.009509568981439294, + ], + linf=[ + 0.01387936112914212, + 0.03526260609304053, + 0.023554197097368997, + 0.035262606093040896, + 0.11719963716509518, + ]) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.001974631423398113, + 0.002654768259143932, + 0.002907031063651286, + 0.002654768259143901, + 0.009587792882971452, + ], + linf=[ + 0.01387919380137137, + 0.035244084526358944, + 0.02398614622061363, + 0.03524408452635828, + 0.12005056512506407, + ]) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (flux differencing)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + volume_integral=VolumeIntegralFluxDifferencing(flux_central), + l2=[ + 0.0019582188528180213, + 0.002653449504301736, + 0.0028982642051960006, + 0.0026534495043017384, + 0.009511572364811033, + ], + linf=[ + 0.013680656758949583, + 0.035691045015224444, + 0.02352634354676752, + 0.035691045015223424, + 0.11482570603751441, + ]) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_taylor_green_vortex.jl"), + initial_refinement_level=2, tspan=(0.0, 0.25), + l2=[ + 0.00024173250389635442, + 0.015684268393762454, + 0.01568426839376248, + 0.021991909545192333, + 0.02825413672911425, + ], + linf=[ + 0.0008410587892853094, + 0.04740176181772552, + 0.04740176181772507, + 0.07483494924031157, + 0.150181591534448, + ]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_performance_specializations_2d.jl b/test/test_performance_specializations_2d.jl index eaf2a66e84f..f0100b76cfa 100644 --- a/test/test_performance_specializations_2d.jl +++ b/test/test_performance_specializations_2d.jl @@ -7,169 +7,169 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) - +isdir(outdir) && rm(outdir, recursive = true) @testset "Performance specializations 2D" begin - @timed_testset "TreeMesh2D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + @timed_testset "TreeMesh2D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end - - @timed_testset "TreeMesh2D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + + @timed_testset "TreeMesh2D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end - - @timed_testset "StructuredMesh2D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + + @timed_testset "StructuredMesh2D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end - - @timed_testset "StructuredMesh2D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + + @timed_testset "StructuredMesh2D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_performance_specializations_3d.jl b/test/test_performance_specializations_3d.jl index f767930996a..71c11742212 100644 --- a/test/test_performance_specializations_3d.jl +++ b/test/test_performance_specializations_3d.jl @@ -7,169 +7,169 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) - +isdir(outdir) && rm(outdir, recursive = true) @testset "Performance specializations 3D" begin - @timed_testset "TreeMesh3D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + @timed_testset "TreeMesh3D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end - - @timed_testset "TreeMesh3D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + + @timed_testset "TreeMesh3D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end - - @timed_testset "StructuredMesh3D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + + @timed_testset "StructuredMesh3D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end - - @timed_testset "StructuredMesh3D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + + @timed_testset "StructuredMesh3D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline + end end - end end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_special_elixirs.jl b/test/test_special_elixirs.jl index 35f5b5cfbf8..6d1a1fe6f96 100644 --- a/test/test_special_elixirs.jl +++ b/test/test_special_elixirs.jl @@ -10,7 +10,7 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) const EXAMPLES_DIR = pkgdir(Trixi, "examples") @@ -18,250 +18,315 @@ cmd = string(Base.julia_cmd()) coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) @testset "Special elixirs" begin - @testset "Convergence test" begin - if !coverage - @timed_testset "tree_2d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), 3, initial_refinement_level=2) - @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) - end - - @timed_testset "structured_2d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_extended.jl"), 3, cells_per_dimension=(5, 9)) - @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) - end - - @timed_testset "structured_2d_dgsem coupled" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_coupled.jl"), 3) - @test isapprox(mean_convergence[1][:l2], [4.0], rtol=0.05) - @test isapprox(mean_convergence[2][:l2], [4.0], rtol=0.05) - end - - @timed_testset "p4est_2d_dgsem" begin - # Run convergence test on unrefined mesh - no_refine = @cfunction((p4est, which_tree, quadrant) -> Cint(0), Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), 2, refine_fn_c=no_refine) - @test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol=0.05) - end - - @timed_testset "structured_3d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_3d_dgsem", "elixir_advection_basic.jl"), 2, cells_per_dimension=(7, 4, 5)) - @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) - end - - @timed_testset "p4est_3d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "p4est_3d_dgsem", "elixir_advection_unstructured_curved.jl"), 2, initial_refinement_level=0) - @test isapprox(mean_convergence[:l2], [2.7], rtol=0.05) - end - - @timed_testset "paper_self_gravitating_gas_dynamics" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "paper_self_gravitating_gas_dynamics", "elixir_eulergravity_convergence.jl"), 2, tspan=(0.0, 0.25), initial_refinement_level=1) - @test isapprox(mean_convergence[:l2], 4 * ones(4), atol=0.4) - end - else - # Without coverage, just run simple convergence tests to cover - # the convergence test logic - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_basic.jl"), 2, tspan=(0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), 2, initial_refinement_level=0, tspan=(0.0, 0.1)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_basic.jl"), 2, tspan=(0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_coupled.jl"), 2, tspan=(0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_extended.jl"), 2, cells_per_dimension=(1, 1), tspan=(0.0, 0.1)) - end - end - - - @timed_testset "Test linear structure (2D)" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) - A, b = linear_structure(semi) - λ = eigvals(Matrix(A)) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_hypdiff_lax_friedrichs.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) - A, b = linear_structure(semi) - λ = eigvals(Matrix(A)) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - # check whether the user can modify `b` without changing `A` - x = vec(ode.u0) - Ax = A * x - @. b = 2 * b + x - @test A * x ≈ Ax - end - - - @testset "Test Jacobian of DG (2D)" begin - @timed_testset "Linear advection" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) - A, _ = linear_structure(semi) - - J = jacobian_ad_forward(semi) - @test Matrix(A) ≈ J - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - J = jacobian_fd(semi) - @test Matrix(A) ≈ J - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + @testset "Convergence test" begin + if !coverage + @timed_testset "tree_2d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), + 3, initial_refinement_level = 2) + @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) + end + + @timed_testset "structured_2d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "structured_2d_dgsem", + "elixir_advection_extended.jl"), + 3, cells_per_dimension = (5, 9)) + @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) + end + + @timed_testset "structured_2d_dgsem coupled" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "structured_2d_dgsem", + "elixir_advection_coupled.jl"), + 3) + @test isapprox(mean_convergence[1][:l2], [4.0], rtol = 0.05) + @test isapprox(mean_convergence[2][:l2], [4.0], rtol = 0.05) + end + + @timed_testset "p4est_2d_dgsem" begin + # Run convergence test on unrefined mesh + no_refine = @cfunction((p4est, which_tree, quadrant)->Cint(0), Cint, + (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p4est_quadrant_t})) + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "p4est_2d_dgsem", + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + 2, refine_fn_c = no_refine) + @test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol = 0.05) + end + + @timed_testset "structured_3d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "structured_3d_dgsem", + "elixir_advection_basic.jl"), + 2, cells_per_dimension = (7, 4, 5)) + @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) + end + + @timed_testset "p4est_3d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "p4est_3d_dgsem", + "elixir_advection_unstructured_curved.jl"), + 2, initial_refinement_level = 0) + @test isapprox(mean_convergence[:l2], [2.7], rtol = 0.05) + end + + @timed_testset "paper_self_gravitating_gas_dynamics" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "paper_self_gravitating_gas_dynamics", + "elixir_eulergravity_convergence.jl"), + 2, tspan = (0.0, 0.25), + initial_refinement_level = 1) + @test isapprox(mean_convergence[:l2], 4 * ones(4), atol = 0.4) + end + else + # Without coverage, just run simple convergence tests to cover + # the convergence test logic + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_basic.jl"), 2, + tspan = (0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), 2, + initial_refinement_level = 0, + tspan = (0.0, 0.1)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "structured_2d_dgsem", + "elixir_advection_basic.jl"), 2, + tspan = (0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "structured_2d_dgsem", + "elixir_advection_coupled.jl"), 2, + tspan = (0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "structured_2d_dgsem", + "elixir_advection_extended.jl"), 2, + cells_per_dimension = (1, 1), + tspan = (0.0, 0.1)) + end end - @timed_testset "Compressible Euler equations" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_euler_density_wave.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) - - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - - J = jacobian_fd(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-3 + @timed_testset "Test linear structure (2D)" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) + A, b = linear_structure(semi) + λ = eigvals(Matrix(A)) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_hypdiff_lax_friedrichs.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) + A, b = linear_structure(semi) + λ = eigvals(Matrix(A)) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + # check whether the user can modify `b` without changing `A` + x = vec(ode.u0) + Ax = A * x + @. b = 2 * b + x + @test A * x ≈ Ax + end - # This does not work yet because of the indicators... - @test_skip begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_euler_shockcapturing.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) - jacobian_ad_forward(semi) - end + @testset "Test Jacobian of DG (2D)" begin + @timed_testset "Linear advection" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) + A, _ = linear_structure(semi) + + J = jacobian_ad_forward(semi) + @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + J = jacobian_fd(semi) + @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + end - @timed_testset "DGMulti (weak form)" begin - gamma = 1.4 - equations = CompressibleEulerEquations2D(gamma) - initial_condition = initial_condition_density_wave + @timed_testset "Compressible Euler equations" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_euler_density_wave.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) + + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + + J = jacobian_fd(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-3 + + # This does not work yet because of the indicators... + @test_skip begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_euler_shockcapturing.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) + jacobian_ad_forward(semi) + end + + @timed_testset "DGMulti (weak form)" begin + gamma = 1.4 + equations = CompressibleEulerEquations2D(gamma) + initial_condition = initial_condition_density_wave + + solver = DGMulti(polydeg = 5, element_type = Quad(), + approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralWeakForm()) + + # DGMultiMesh is on [-1, 1]^ndims by default + mesh = DGMultiMesh(solver, cells_per_dimension = (2, 2), + periodicity = (true, true)) + + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver) + + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + end + + @timed_testset "DGMulti (SBP, flux differencing)" begin + gamma = 1.4 + equations = CompressibleEulerEquations2D(gamma) + initial_condition = initial_condition_density_wave + + solver = DGMulti(polydeg = 5, element_type = Quad(), + approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralFluxDifferencing(flux_central)) + + # DGMultiMesh is on [-1, 1]^ndims by default + mesh = DGMultiMesh(solver, cells_per_dimension = (2, 2), + periodicity = (true, true)) + + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver) + + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + end + end - solver = DGMulti(polydeg = 5, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralWeakForm()) + @timed_testset "MHD" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_mhd_alfven_wave.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 0) + @test_nowarn jacobian_ad_forward(semi) + end + end - # DGMultiMesh is on [-1, 1]^ndims by default - mesh = DGMultiMesh(solver, cells_per_dimension=(2, 2), periodicity=(true, true)) + @timed_testset "Test linear structure (3D)" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_3d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) + A, b = linear_structure(semi) + λ = eigvals(Matrix(A)) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + @timed_testset "Test Jacobian of DG (3D)" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_3d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) + A, _ = linear_structure(semi) J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - end + @test Matrix(A) ≈ J - @timed_testset "DGMulti (SBP, flux differencing)" begin - gamma = 1.4 - equations = CompressibleEulerEquations2D(gamma) - initial_condition = initial_condition_density_wave - - solver = DGMulti(polydeg = 5, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralFluxDifferencing(flux_central)) - - # DGMultiMesh is on [-1, 1]^ndims by default - mesh = DGMultiMesh(solver, cells_per_dimension=(2, 2), periodicity=(true, true)) - - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) - - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - end + J = jacobian_fd(semi) + @test Matrix(A) ≈ J end - @timed_testset "MHD" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_mhd_alfven_wave.jl"), - tspan=(0.0, 0.0), initial_refinement_level=0) - @test_nowarn jacobian_ad_forward(semi) - end - end - - - @timed_testset "Test linear structure (3D)" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_3d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) - A, b = linear_structure(semi) - λ = eigvals(Matrix(A)) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - end - - - @timed_testset "Test Jacobian of DG (3D)" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_3d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) - A, _ = linear_structure(semi) - - J = jacobian_ad_forward(semi) - @test Matrix(A) ≈ J - - J = jacobian_fd(semi) - @test Matrix(A) ≈ J - end - - - @testset "AD using ForwardDiff" begin - @timed_testset "Euler equations 1D" begin - function entropy_at_final_time(k) # k is the wave number of the initial condition - equations = CompressibleEulerEquations1D(1.4) - mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=3, n_cells_max=10^4) - solver = DGSEM(3, FluxHLL(min_max_speed_naive), VolumeIntegralFluxDifferencing(flux_ranocha)) - initial_condition = (x, t, equations) -> begin - rho = 2 + sinpi(k * sum(x)) - v1 = 0.1 - p = 10.0 - return prim2cons(SVector(rho, v1, p), equations) + @testset "AD using ForwardDiff" begin + @timed_testset "Euler equations 1D" begin + function entropy_at_final_time(k) # k is the wave number of the initial condition + equations = CompressibleEulerEquations1D(1.4) + mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level = 3, + n_cells_max = 10^4) + solver = DGSEM(3, FluxHLL(min_max_speed_naive), + VolumeIntegralFluxDifferencing(flux_ranocha)) + initial_condition = (x, t, equations) -> begin + rho = 2 + sinpi(k * sum(x)) + v1 = 0.1 + p = 10.0 + return prim2cons(SVector(rho, v1, p), equations) + end + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver, + uEltype = typeof(k)) + ode = semidiscretize(semi, (0.0, 1.0)) + summary_callback = SummaryCallback() + analysis_interval = 100 + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + alive_callback = AliveCallback(analysis_interval = analysis_interval) + callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback) + sol = solve(ode, SSPRK43(), callback = callbacks) + Trixi.integrate(entropy, sol.u[end], semi) + end + ForwardDiff.derivative(entropy_at_final_time, 1.0) ≈ -0.4524664696235628 end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)) - ode = semidiscretize(semi, (0.0, 1.0)) - summary_callback = SummaryCallback() - analysis_interval = 100 - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - alive_callback = AliveCallback(analysis_interval=analysis_interval) - callbacks = CallbackSet( - summary_callback, - analysis_callback, - alive_callback - ) - sol = solve(ode, SSPRK43(), callback=callbacks) - Trixi.integrate(entropy, sol.u[end], semi) - end - ForwardDiff.derivative(entropy_at_final_time, 1.0) ≈ -0.4524664696235628 - end - @timed_testset "Linear advection 2D" begin - function energy_at_final_time(k) # k is the wave number of the initial condition - equations = LinearScalarAdvectionEquation2D(0.2, -0.7) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) - solver = DGSEM(3, flux_lax_friedrichs) - initial_condition = (x, t, equation) -> begin - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) - return SVector(sinpi(k * sum(x_trans))) + @timed_testset "Linear advection 2D" begin + function energy_at_final_time(k) # k is the wave number of the initial condition + equations = LinearScalarAdvectionEquation2D(0.2, -0.7) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, + n_cells_max = 10^4) + solver = DGSEM(3, flux_lax_friedrichs) + initial_condition = (x, t, equation) -> begin + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) + return SVector(sinpi(k * sum(x_trans))) + end + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver, + uEltype = typeof(k)) + ode = semidiscretize(semi, (0.0, 1.0)) + summary_callback = SummaryCallback() + analysis_interval = 100 + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + alive_callback = AliveCallback(analysis_interval = analysis_interval) + stepsize_callback = StepsizeCallback(cfl = 1.6) + callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback, + stepsize_callback) + sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + save_everystep = false, adaptive = false, dt = 1.0, + callback = callbacks) + Trixi.integrate(energy_total, sol.u[end], semi) + end + ForwardDiff.derivative(energy_at_final_time, 1.0) ≈ 1.4388628342896945e-5 end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)) - ode = semidiscretize(semi, (0.0, 1.0)) - summary_callback = SummaryCallback() - analysis_interval = 100 - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - alive_callback = AliveCallback(analysis_interval=analysis_interval) - stepsize_callback = StepsizeCallback(cfl=1.6) - callbacks = CallbackSet( - summary_callback, - analysis_callback, - alive_callback, - stepsize_callback - ) - sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), save_everystep=false, adaptive=false, dt=1.0, callback=callbacks) - Trixi.integrate(energy_total, sol.u[end], semi) - end - ForwardDiff.derivative(energy_at_final_time, 1.0) ≈ 1.4388628342896945e-5 - end - @timed_testset "elixir_euler_ad.jl" begin - @test_trixi_include(joinpath(examples_dir(), "special_elixirs", "elixir_euler_ad.jl")) + @timed_testset "elixir_euler_ad.jl" begin + @test_trixi_include(joinpath(examples_dir(), "special_elixirs", + "elixir_euler_ad.jl")) + end end - end end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_structured_1d.jl b/test/test_structured_1d.jl index ec8c7a138d5..c9f6fa2fc6f 100644 --- a/test/test_structured_1d.jl +++ b/test/test_structured_1d.jl @@ -9,51 +9,68 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_1d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "StructuredMesh1D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [6.0388296447998465e-6], - linf = [3.217887726258972e-5]) - end - - @trixi_testset "elixir_advection_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), - l2 = [5.641921365468918e-5], - linf = [0.00021049780975179733]) - end - - @trixi_testset "elixir_advection_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_shockcapturing.jl"), - l2 = [0.08015029105233593], - linf = [0.610709468736576], - atol = 1.0e-5) - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [3.67478226e-01, 3.49491179e-01, 8.08910759e-01], - linf = [1.58971947e+00, 1.59812384e+00, 1.94732969e+00], - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [2.2527950196212703e-8, 1.8187357193835156e-8, 7.705669939973104e-8], - linf = [1.6205433861493646e-7, 1.465427772462391e-7, 5.372255111879554e-7]) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [3.8099996914101204e-6, 1.6745575717106341e-6, 7.732189531480852e-6], - linf = [1.2971473393186272e-5, 9.270328934274374e-6, 3.092514399671842e-5]) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[6.0388296447998465e-6], + linf=[3.217887726258972e-5]) + end + + @trixi_testset "elixir_advection_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), + l2=[5.641921365468918e-5], + linf=[0.00021049780975179733]) + end + + @trixi_testset "elixir_advection_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_shockcapturing.jl"), + l2=[0.08015029105233593], + linf=[0.610709468736576], + atol=1.0e-5) + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2=[3.67478226e-01, 3.49491179e-01, 8.08910759e-01], + linf=[1.58971947e+00, 1.59812384e+00, 1.94732969e+00], + tspan=(0.0, 0.3)) + end + + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[ + 2.2527950196212703e-8, + 1.8187357193835156e-8, + 7.705669939973104e-8, + ], + linf=[ + 1.6205433861493646e-7, + 1.465427772462391e-7, + 5.372255111879554e-7, + ]) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 3.8099996914101204e-6, + 1.6745575717106341e-6, + 7.732189531480852e-6, + ], + linf=[ + 1.2971473393186272e-5, + 9.270328934274374e-6, + 3.092514399671842e-5, + ]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 16fc72f0a46..b7022a42811 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -9,279 +9,458 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "StructuredMesh2D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_coupled.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"), - l2 = [7.816742843181738e-6, 7.816742843196112e-6], - linf = [6.314906965543265e-5, 6.314906965410039e-5], - coverage_override = (maxiters=10^5,)) - - @testset "analysis_callback(sol) for AnalysisCallbackCoupled" begin - errors = analysis_callback(sol) - @test errors.l2 ≈ [7.816742843181738e-6, 7.816742843196112e-6] rtol=1.0e-4 - @test errors.linf ≈ [6.314906965543265e-5, 6.314906965410039e-5] rtol=1.0e-4 + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) end - end - - @trixi_testset "elixir_advection_extended.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [4.220397559713772e-6], - linf = [3.477948874874848e-5]) - end - - @trixi_testset "elixir_advection_extended.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [5.32996976442737e-7], - linf = [4.1344662966569246e-6], - atol = 1e-12, # required to make CI tests pass on macOS - cells_per_dimension = (16, 23), - polydeg = 4, - cfl = 1.4) - end - - @testset "elixir_advection_rotated.jl" begin - @trixi_testset "elixir_advection_rotated.jl with α = 0.0" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5], - alpha = 0.0) + + @trixi_testset "elixir_advection_coupled.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"), + l2=[7.816742843181738e-6, 7.816742843196112e-6], + linf=[6.314906965543265e-5, 6.314906965410039e-5], + coverage_override=(maxiters = 10^5,)) + + @testset "analysis_callback(sol) for AnalysisCallbackCoupled" begin + errors = analysis_callback(sol) + @test errors.l2≈[7.816742843181738e-6, 7.816742843196112e-6] rtol=1.0e-4 + @test errors.linf≈[6.314906965543265e-5, 6.314906965410039e-5] rtol=1.0e-4 + end + end + + @trixi_testset "elixir_advection_extended.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[4.220397559713772e-6], + linf=[3.477948874874848e-5]) + end + + @trixi_testset "elixir_advection_extended.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[5.32996976442737e-7], + linf=[4.1344662966569246e-6], + atol=1e-12, # required to make CI tests pass on macOS + cells_per_dimension=(16, 23), + polydeg=4, + cfl=1.4) + end + + @testset "elixir_advection_rotated.jl" begin + @trixi_testset "elixir_advection_rotated.jl with α = 0.0" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5], + alpha=0.0) + end + + @trixi_testset "elixir_advection_rotated.jl with α = 0.1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors differ only slightly from elixir_advection_basic! + l2=[8.3122750550501e-6], + linf=[6.626802581322089e-5], + alpha=0.1) + end + + @trixi_testset "elixir_advection_rotated.jl with α = 0.5 * pi" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5], + alpha=0.5 * pi) + end + end + + @trixi_testset "elixir_advection_parallelogram.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_parallelogram.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_waving_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_waving_flag.jl"), + l2=[0.00018553859900545866], + linf=[0.0016167719118129753]) + end + + @trixi_testset "elixir_advection_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), + l2=[6.8925194184204476e-15], + linf=[9.903189379656396e-14]) + end + + @trixi_testset "elixir_advection_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), + l2=[0.00025552740731641223], + linf=[0.007252625722805939]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[4.219208035582454e-6], + linf=[3.438434404412494e-5]) + end + + @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[0.00016265538265929818], + linf=[0.0015194252169410394], + rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) + elixir_file="elixir_advection_waving_flag.jl", + restart_file="restart_000021.h5") + end + + @trixi_testset "elixir_advection_restart.jl with free stream mesh" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[7.841217436552029e-15], + linf=[1.0857981180834031e-13], + elixir_file="elixir_advection_free_stream.jl", + restart_file="restart_000036.h5") + end + + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ]) + end + + @testset "elixir_euler_source_terms_rotated.jl" begin + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.0" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors are exactly the same as in elixir_euler_source_terms! + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ], + alpha=0.0) + end + + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors differ only slightly from elixir_euler_source_terms! + l2=[ + 9.321188057029291e-7, + 1.3195106906473365e-6, + 1.510307360354032e-6, + 4.82455408101712e-6, + ], + linf=[ + 9.57723626271445e-6, + 1.0480225511866337e-5, + 1.2817828088262928e-5, + 4.886962393513272e-5, + ], + alpha=0.1) + end + + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.2 * pi" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors differ only slightly from elixir_euler_source_terms! + l2=[ + 9.32127973957391e-7, + 8.477824799744325e-7, + 1.8175286311402784e-6, + 4.824562453521076e-6, + ], + linf=[ + 9.576898420737834e-6, + 5.057704352218195e-6, + 1.635260719945464e-5, + 4.886978754825577e-5, + ], + alpha=0.2 * pi) + end + + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.5 * pi" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors are exactly the same as in elixir_euler_source_terms! + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ], + alpha=0.5 * pi) + end + end + + @trixi_testset "elixir_euler_source_terms_parallelogram.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_parallelogram.jl"), + l2=[ + 1.1167802955144833e-5, + 1.0805775514153104e-5, + 1.953188337010932e-5, + 5.5033856574857146e-5, + ], + linf=[ + 8.297006495561199e-5, + 8.663281475951301e-5, + 0.00012264160606778596, + 0.00041818802502024965, + ]) + end + + @trixi_testset "elixir_euler_source_terms_waving_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_waving_flag.jl"), + l2=[ + 2.991891317562739e-5, + 3.6063177168283174e-5, + 2.7082941743640572e-5, + 0.00011414695350996946, + ], + linf=[ + 0.0002437454930492855, + 0.0003438936171968887, + 0.00024217622945688078, + 0.001266380414757684, + ]) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[ + 1.9539925233402755e-14, + 2.9791447087035294e-13, + 6.502853810985698e-13, + 2.7000623958883807e-13, + ], + atol=7.0e-13) + end + + @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + surface_flux=FluxRotated(flux_lax_friedrichs), + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[ + 1.9539925233402755e-14, + 2.9791447087035294e-13, + 6.502853810985698e-13, + 2.7000623958883807e-13, + ], + atol=7.0e-13) end - @trixi_testset "elixir_advection_rotated.jl with α = 0.1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors differ only slightly from elixir_advection_basic! - l2 = [8.3122750550501e-6], - linf = [6.626802581322089e-5], - alpha = 0.1) + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511901724e-6, + 2.3188881559075347e-6, + 2.3188881559568146e-6, + 6.332786324137878e-6, + ], + linf=[ + 1.4987382622067003e-5, + 1.918201192063762e-5, + 1.918201192019353e-5, + 6.052671713430158e-5, + ]) end - @trixi_testset "elixir_advection_rotated.jl with α = 0.5 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5], - alpha = 0.5 * pi) + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.03774907669925568, + 0.02845190575242045, + 0.028262802829412605, + 0.13785915638851698, + ], + linf=[ + 0.3368296929764073, + 0.27644083771519773, + 0.27990039685141377, + 1.1971436487402016, + ], + tspan=(0.0, 0.3)) end - end - - @trixi_testset "elixir_advection_parallelogram.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_parallelogram.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_waving_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_waving_flag.jl"), - l2 = [0.00018553859900545866], - linf = [0.0016167719118129753]) - end - - @trixi_testset "elixir_advection_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), - l2 = [6.8925194184204476e-15], - linf = [9.903189379656396e-14]) - end - - @trixi_testset "elixir_advection_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), - l2 = [0.00025552740731641223], - linf = [0.007252625722805939]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [4.219208035582454e-6], - linf = [3.438434404412494e-5]) - end - - @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.00016265538265929818], - linf = [0.0015194252169410394], - rtol = 5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) - elixir_file="elixir_advection_waving_flag.jl", - restart_file="restart_000021.h5") - end - - @trixi_testset "elixir_advection_restart.jl with free stream mesh" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [7.841217436552029e-15], - linf = [1.0857981180834031e-13], - elixir_file="elixir_advection_free_stream.jl", - restart_file="restart_000036.h5") - end - - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5]) - end - - @testset "elixir_euler_source_terms_rotated.jl" begin - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.0" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors are exactly the same as in elixir_euler_source_terms! - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], - alpha = 0.0) + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2=[ + 3.69856202e-01, + 2.35242180e-01, + 2.41444928e-01, + 1.28807120e+00, + ], + linf=[ + 1.82786223e+00, + 1.30452904e+00, + 1.40347257e+00, + 6.21791658e+00, + ], + tspan=(0.0, 0.3)) + end + + @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_rayleigh_taylor_instability.jl"), + l2=[ + 0.06365630381017849, + 0.007166887387738937, + 0.002878708825497772, + 0.010247678114070121, + ], + linf=[ + 0.4799214336153155, + 0.024595483032220266, + 0.02059808120543466, + 0.03190756362943725, + ], + cells_per_dimension=(8, 8), + tspan=(0.0, 0.3)) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2=[0.8799744480157664, 0.8535008397034816, 0.7851383019164209], + linf=[1.0771947577311836, 1.9143913544309838, 2.149549109115789], + tspan=(0.0, 0.1), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[ + 0.19357947606509474, + 0.47041398037626814, + 0.4704139803762686, + ], + linf=[ + 0.35026352556630114, + 0.8344372248051408, + 0.8344372248051408, + ], + tspan=(0.0, 0.1), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2=[0.04937480811868297, 0.06117033019988596, + 0.060998028674664716, 0.03155145889799417, + 0.2319175391388658, 0.02476283192966346, + 0.024483244374818587, 0.035439957899127385, + 0.0016022148194667542], + linf=[0.24749024430983746, 0.2990608279625713, + 0.3966937932860247, 0.22265033744519683, + 0.9757376320946505, 0.12123736788315098, + 0.12837436699267113, 0.17793825293524734, + 0.03460761690059514], + tspan=(0.0, 0.3)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[0.02890769490562535, 0.0062599448721613205, + 0.005650300017676721, 0.007334415940022972, + 0.00490446035599909, 0.007202284100220619, + 0.007003258686714405, 0.006734267830082687, + 0.004253003868791559], + linf=[0.17517380432288565, 0.06197353710696667, + 0.038494840938641646, 0.05293345499813148, + 0.03817506476831778, 0.042847170999492534, + 0.03761563456810613, 0.048184237474911844, + 0.04114666955364693], + tspan=(0.0, 1.0)) end - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors differ only slightly from elixir_euler_source_terms! - l2 = [9.321188057029291e-7, 1.3195106906473365e-6, 1.510307360354032e-6, 4.82455408101712e-6], - linf = [9.57723626271445e-6, 1.0480225511866337e-5, 1.2817828088262928e-5, 4.886962393513272e-5], - alpha = 0.1) + @trixi_testset "elixir_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2=[ + 0.0017285599436729316, + 0.025584610912606776, + 0.028373834961180594, + 6.274146767730866e-5, + ], + linf=[ + 0.012972309788264802, + 0.108283714215621, + 0.15831585777928936, + 0.00018196759554722775, + ], + tspan=(0.0, 0.05)) end - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.2 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors differ only slightly from elixir_euler_source_terms! - l2 = [9.32127973957391e-7, 8.477824799744325e-7, 1.8175286311402784e-6, 4.824562453521076e-6], - linf = [9.576898420737834e-6, 5.057704352218195e-6, 1.635260719945464e-5, 4.886978754825577e-5], - alpha = 0.2 * pi) + @trixi_testset "elixir_shallowwater_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), + l2=[ + 0.7920927046419308, + 9.92129670988898e-15, + 1.0118635033124588e-14, + 0.7920927046419308, + ], + linf=[ + 2.408429868800133, + 5.5835419986809516e-14, + 5.448874313931364e-14, + 2.4084298688001335, + ], + tspan=(0.0, 0.25)) end - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.5 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors are exactly the same as in elixir_euler_source_terms! - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], - alpha = 0.5 * pi) + @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), + l2=[0.0364192725149364, 0.0426667193422069, 0.04261673001449095, + 0.025884071405646924, + 0.16181626564020496, 0.017346518770783536, + 0.017291573200291104, 0.026856206495339655, + 0.0007443858043598808], + linf=[0.25144373906033013, 0.32881947152723745, + 0.3053266801502693, 0.20989755319972866, + 0.9927517314507455, 0.1105172121361323, 0.1257708104676617, + 0.1628334844841588, + 0.02624301627479052]) end - end - - @trixi_testset "elixir_euler_source_terms_parallelogram.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_parallelogram.jl"), - l2 = [1.1167802955144833e-5, 1.0805775514153104e-5, 1.953188337010932e-5, 5.5033856574857146e-5], - linf = [8.297006495561199e-5, 8.663281475951301e-5, 0.00012264160606778596, 0.00041818802502024965]) - end - - @trixi_testset "elixir_euler_source_terms_waving_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_waving_flag.jl"), - l2 = [2.991891317562739e-5, 3.6063177168283174e-5, 2.7082941743640572e-5, 0.00011414695350996946], - linf = [0.0002437454930492855, 0.0003438936171968887, 0.00024217622945688078, 0.001266380414757684]) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], - linf = [1.9539925233402755e-14, 2.9791447087035294e-13, 6.502853810985698e-13, 2.7000623958883807e-13], - atol = 7.0e-13) - end - - @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - surface_flux=FluxRotated(flux_lax_friedrichs), - l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], - linf = [1.9539925233402755e-14, 2.9791447087035294e-13, 6.502853810985698e-13, 2.7000623958883807e-13], - atol = 7.0e-13) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511901724e-6, 2.3188881559075347e-6, 2.3188881559568146e-6, 6.332786324137878e-6], - linf = [1.4987382622067003e-5, 1.918201192063762e-5, 1.918201192019353e-5, 6.052671713430158e-5]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03774907669925568, 0.02845190575242045, 0.028262802829412605, 0.13785915638851698], - linf = [0.3368296929764073, 0.27644083771519773, 0.27990039685141377, 1.1971436487402016], - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [3.69856202e-01, 2.35242180e-01, 2.41444928e-01, 1.28807120e+00], - linf = [1.82786223e+00, 1.30452904e+00, 1.40347257e+00, 6.21791658e+00], - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_rayleigh_taylor_instability.jl"), - l2 = [0.06365630381017849, 0.007166887387738937, 0.002878708825497772, 0.010247678114070121], - linf = [0.4799214336153155, 0.024595483032220266, 0.02059808120543466, 0.03190756362943725], - cells_per_dimension = (8,8), - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [0.8799744480157664, 0.8535008397034816, 0.7851383019164209], - linf = [1.0771947577311836, 1.9143913544309838, 2.149549109115789], - tspan = (0.0, 0.1), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [0.19357947606509474, 0.47041398037626814, 0.4704139803762686], - linf = [0.35026352556630114, 0.8344372248051408, 0.8344372248051408], - tspan = (0.0, 0.1), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.04937480811868297, 0.06117033019988596, 0.060998028674664716, 0.03155145889799417, - 0.2319175391388658, 0.02476283192966346, 0.024483244374818587, 0.035439957899127385, - 0.0016022148194667542], - linf = [0.24749024430983746, 0.2990608279625713, 0.3966937932860247, 0.22265033744519683, - 0.9757376320946505, 0.12123736788315098, 0.12837436699267113, 0.17793825293524734, - 0.03460761690059514], - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.02890769490562535, 0.0062599448721613205, 0.005650300017676721, 0.007334415940022972, - 0.00490446035599909, 0.007202284100220619, 0.007003258686714405, 0.006734267830082687, - 0.004253003868791559], - linf = [0.17517380432288565, 0.06197353710696667, 0.038494840938641646, 0.05293345499813148, - 0.03817506476831778, 0.042847170999492534, 0.03761563456810613, 0.048184237474911844, - 0.04114666955364693], - tspan = (0.0, 1.0)) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0017285599436729316, 0.025584610912606776, 0.028373834961180594, 6.274146767730866e-5], - linf = [0.012972309788264802, 0.108283714215621, 0.15831585777928936, 0.00018196759554722775], - tspan = (0.0, 0.05)) - end - - @trixi_testset "elixir_shallowwater_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.7920927046419308, 9.92129670988898e-15, 1.0118635033124588e-14, 0.7920927046419308], - linf = [2.408429868800133, 5.5835419986809516e-14, 5.448874313931364e-14, 2.4084298688001335], - tspan = (0.0, 0.25)) - end - - @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2 = [0.0364192725149364, 0.0426667193422069, 0.04261673001449095, 0.025884071405646924, - 0.16181626564020496, 0.017346518770783536, 0.017291573200291104, 0.026856206495339655, - 0.0007443858043598808], - linf = [0.25144373906033013, 0.32881947152723745, 0.3053266801502693, 0.20989755319972866, - 0.9927517314507455, 0.1105172121361323, 0.1257708104676617, 0.1628334844841588, - 0.02624301627479052]) - end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_structured_3d.jl b/test/test_structured_3d.jl index 124c073f2d6..55634ae0a5f 100644 --- a/test/test_structured_3d.jl +++ b/test/test_structured_3d.jl @@ -9,128 +9,217 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_3d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "Structured mesh" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - end - - @trixi_testset "elixir_advection_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), - l2 = [1.2908196366970896e-14], - linf = [1.0262901639634947e-12], - atol = 8e-13, # required to make tests pass on Windows - ) - end - - @trixi_testset "elixir_advection_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic_curved.jl"), - l2 = [0.0004483892474201268], - linf = [0.009201820593762955]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.0025903889347585777], - linf = [0.018407576968841655]) - end - - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.010385936842224346, 0.009776048833895767, 0.00977604883389591, 0.009776048833895733, 0.01506687097416608], - linf = [0.03285848350791731, 0.0321792316408982, 0.032179231640894645, 0.032179231640895534, 0.0655408023333299]) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [2.8815700334367128e-15, 9.361915278236651e-15, 9.95614203619935e-15, 1.6809941842374106e-14, 1.4815037041566735e-14], - linf = [4.1300296516055823e-14, 2.0444756998472258e-13, 1.0133560657266116e-13, 2.0627943797535409e-13, 2.8954616482224083e-13]) - end - - @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - surface_flux=FluxRotated(flux_lax_friedrichs), - l2 = [2.8815700334367128e-15, 9.361915278236651e-15, 9.95614203619935e-15, 1.6809941842374106e-14, 1.4815037041566735e-14], - linf = [4.1300296516055823e-14, 2.0444756998472258e-13, 1.0133560657266116e-13, 2.0627943797535409e-13, 2.8954616482224083e-13]) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_curved.jl"), - l2 = [0.0032940531178824463, 0.003275679548217804, 0.0030020672748714084, 0.00324007343451744, 0.005721986362580164], - linf = [0.03156756290660656, 0.033597629023726316, 0.02095783702361409, 0.03353574465232212, 0.05873635745032857]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.011367083018614027, 0.007022020327490176, 0.006759580335962235, 0.006820337637760632, 0.02912659127566544], - linf = [0.2761764220925329, 0.20286331858055706, 0.18763944865434593, 0.19313636558790004, 0.707563913727584], - tspan = (0.0, 0.25), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [5.30310390e-02, 2.53167260e-02, 2.64276438e-02, 2.52195992e-02, 3.56830295e-01], - linf = [6.16356950e-01, 2.50600049e-01, 2.74796377e-01, 2.46448217e-01, 4.77888479e+00], - tspan = (0.0, 0.3)) - end - - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.009082353036644902, 0.007128360240528109, 0.006970330025996491, 0.006898850266874514, - 0.03302008823756457, 0.003203389099143526, 0.003077498677885352, 0.0030740006760477624, - 4.192129696970217e-5], - linf = [0.2883946030582689, 0.25956437344015054, 0.2614364943543665, 0.24617277938134657, - 1.1370443512475847, 0.1278041831463388, 0.13347391885068594, 0.1457563463643099, - 0.0021174246048172563], - tspan = (0.0, 0.25)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.003015476175153681, 0.00145499403283373, 0.0009125744757935803, 0.0017703080480578979, - 0.0013046447673965966, 0.0014564863387645508, 0.0013332311430907598, 0.001647832598455728, - 0.0013647609788548722], - linf = [0.027510637768610846, 0.02797062834945721, 0.01274249949295704, 0.038940694415543736, - 0.02200825678588325, 0.03167600959583505, 0.021420957993862344, 0.03386589835999665, - 0.01888303191983353], - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override = (polydeg=3,)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl with flux_lax_friedrichs" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.003047854479955232, 0.0014572199588782184, 0.0009093737183251411, 0.0017937548694553895, - 0.0013010437110755424, 0.0014545607744895874, 0.001328514015121245, 0.001671342529206066, - 0.0013653963058149186], - linf = [0.027719103797310463, 0.027570111789910784, 0.012561901006903103, 0.03903568568480584, - 0.021311996934554767, 0.03154849824135775, 0.020996033645485412, 0.03403185137382961, - 0.019488952445771597], - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override = (polydeg=3,)) - end - - @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2 = [0.009352631220872144, 0.008058649103542618, 0.008027041293333663, 0.008071417851552725, - 0.034909149665869485, 0.00393019428600812, 0.0039219074393817, 0.003906321245184237, - 4.197255300781248e-5], - linf = [0.30749098250807516, 0.2679008863509767, 0.271243087484388, 0.26545396569129537, - 0.9620950892188596, 0.18163281157498123, 0.15995708312378454, 0.17918221526906408, - 0.015138346608166353], - tspan = (0.0, 0.25), - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override = (polydeg=3,)) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + end + + @trixi_testset "elixir_advection_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), + l2=[1.2908196366970896e-14], + linf=[1.0262901639634947e-12], + atol=8e-13,) + end + + @trixi_testset "elixir_advection_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonperiodic_curved.jl"), + l2=[0.0004483892474201268], + linf=[0.009201820593762955]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[0.0025903889347585777], + linf=[0.018407576968841655]) + end + + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[ + 0.010385936842224346, + 0.009776048833895767, + 0.00977604883389591, + 0.009776048833895733, + 0.01506687097416608, + ], + linf=[ + 0.03285848350791731, + 0.0321792316408982, + 0.032179231640894645, + 0.032179231640895534, + 0.0655408023333299, + ]) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2=[ + 2.8815700334367128e-15, + 9.361915278236651e-15, + 9.95614203619935e-15, + 1.6809941842374106e-14, + 1.4815037041566735e-14, + ], + linf=[ + 4.1300296516055823e-14, + 2.0444756998472258e-13, + 1.0133560657266116e-13, + 2.0627943797535409e-13, + 2.8954616482224083e-13, + ]) + end + + @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + surface_flux=FluxRotated(flux_lax_friedrichs), + l2=[ + 2.8815700334367128e-15, + 9.361915278236651e-15, + 9.95614203619935e-15, + 1.6809941842374106e-14, + 1.4815037041566735e-14, + ], + linf=[ + 4.1300296516055823e-14, + 2.0444756998472258e-13, + 1.0133560657266116e-13, + 2.0627943797535409e-13, + 2.8954616482224083e-13, + ]) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic_curved.jl"), + l2=[ + 0.0032940531178824463, + 0.003275679548217804, + 0.0030020672748714084, + 0.00324007343451744, + 0.005721986362580164, + ], + linf=[ + 0.03156756290660656, + 0.033597629023726316, + 0.02095783702361409, + 0.03353574465232212, + 0.05873635745032857, + ]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.011367083018614027, + 0.007022020327490176, + 0.006759580335962235, + 0.006820337637760632, + 0.02912659127566544, + ], + linf=[ + 0.2761764220925329, + 0.20286331858055706, + 0.18763944865434593, + 0.19313636558790004, + 0.707563913727584, + ], + tspan=(0.0, 0.25), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2=[ + 5.30310390e-02, + 2.53167260e-02, + 2.64276438e-02, + 2.52195992e-02, + 3.56830295e-01, + ], + linf=[ + 6.16356950e-01, + 2.50600049e-01, + 2.74796377e-01, + 2.46448217e-01, + 4.77888479e+00, + ], + tspan=(0.0, 0.3)) + end + + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2=[0.009082353036644902, 0.007128360240528109, + 0.006970330025996491, 0.006898850266874514, + 0.03302008823756457, 0.003203389099143526, + 0.003077498677885352, 0.0030740006760477624, + 4.192129696970217e-5], + linf=[0.2883946030582689, 0.25956437344015054, + 0.2614364943543665, 0.24617277938134657, + 1.1370443512475847, 0.1278041831463388, 0.13347391885068594, + 0.1457563463643099, + 0.0021174246048172563], + tspan=(0.0, 0.25)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[0.003015476175153681, 0.00145499403283373, + 0.0009125744757935803, 0.0017703080480578979, + 0.0013046447673965966, 0.0014564863387645508, + 0.0013332311430907598, 0.001647832598455728, + 0.0013647609788548722], + linf=[0.027510637768610846, 0.02797062834945721, + 0.01274249949295704, 0.038940694415543736, + 0.02200825678588325, 0.03167600959583505, + 0.021420957993862344, 0.03386589835999665, + 0.01888303191983353], + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override=(polydeg = 3,)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl with flux_lax_friedrichs" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[0.003047854479955232, 0.0014572199588782184, + 0.0009093737183251411, 0.0017937548694553895, + 0.0013010437110755424, 0.0014545607744895874, + 0.001328514015121245, 0.001671342529206066, + 0.0013653963058149186], + linf=[0.027719103797310463, 0.027570111789910784, + 0.012561901006903103, 0.03903568568480584, + 0.021311996934554767, 0.03154849824135775, + 0.020996033645485412, 0.03403185137382961, + 0.019488952445771597], + surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override=(polydeg = 3,)) + end + + @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), + l2=[0.009352631220872144, 0.008058649103542618, + 0.008027041293333663, 0.008071417851552725, + 0.034909149665869485, 0.00393019428600812, + 0.0039219074393817, 0.003906321245184237, + 4.197255300781248e-5], + linf=[0.30749098250807516, 0.2679008863509767, + 0.271243087484388, 0.26545396569129537, + 0.9620950892188596, 0.18163281157498123, + 0.15995708312378454, 0.17918221526906408, + 0.015138346608166353], + tspan=(0.0, 0.25), + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override=(polydeg = 3,)) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 1e750707981..4ad619ccf65 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -7,124 +7,208 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) +Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) @testset "Threaded tests" begin - @testset "TreeMesh" begin - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) + @testset "TreeMesh" begin + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_restart.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[7.81674284320524e-6], + linf=[6.314906965243505e-5]) + end + + @trixi_testset "elixir_advection_amr_refine_twice.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_amr_refine_twice.jl"), + l2=[0.00020547512522578292], + linf=[0.007831753383083506]) + end + + @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_amr_coarsen_twice.jl"), + l2=[0.0014321062757891826], + linf=[0.0253454486893413]) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511766445e-6, + 2.318888155713922e-6, + 2.3188881557894307e-6, + 6.3327863238858925e-6, + ], + linf=[ + 1.498738264560373e-5, + 1.9182011928187137e-5, + 1.918201192685487e-5, + 6.0526717141407005e-5, + ], + rtol=0.001) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_euler_ec.jl"), + l2=[ + 0.061751715597716854, + 0.05018223615408711, + 0.05018989446443463, + 0.225871559730513, + ], + linf=[ + 0.29347582879608825, + 0.31081249232844693, + 0.3107380389947736, + 1.0540358049885143, + ]) + end end - @trixi_testset "elixir_advection_amr_refine_twice.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_refine_twice.jl"), - l2 = [0.00020547512522578292], - linf = [0.007831753383083506]) + @testset "StructuredMesh" begin + @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin + @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", + "elixir_advection_restart.jl"), + l2=[0.00016265538265929818], + linf=[0.0015194252169410394], + rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) + elixir_file="elixir_advection_waving_flag.jl", + restart_file="restart_000021.h5") + end + + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", + "elixir_mhd_ec.jl"), + l2=[0.04937480811868297, 0.06117033019988596, + 0.060998028674664716, 0.03155145889799417, + 0.2319175391388658, 0.02476283192966346, + 0.024483244374818587, 0.035439957899127385, + 0.0016022148194667542], + linf=[0.24749024430983746, 0.2990608279625713, + 0.3966937932860247, 0.22265033744519683, + 0.9757376320946505, 0.12123736788315098, + 0.12837436699267113, 0.17793825293524734, + 0.03460761690059514], + tspan=(0.0, 0.3)) + end end - @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_coarsen_twice.jl"), - l2 = [0.0014321062757891826], - linf = [0.0253454486893413]) + @testset "UnstructuredMesh" begin + @trixi_testset "elixir_acoustics_gauss_wall.jl" begin + @test_trixi_include(joinpath(examples_dir(), "unstructured_2d_dgsem", + "elixir_acoustics_gauss_wall.jl"), + l2=[0.029330394861252995, 0.029345079728907965, + 0.03803795043486467, 0.0, + 7.175152371650832e-16, 1.4350304743301665e-15, + 1.4350304743301665e-15], + linf=[0.36236334472179443, 0.3690785638275256, + 0.8475748723784078, 0.0, + 8.881784197001252e-16, 1.7763568394002505e-15, + 1.7763568394002505e-15], + tspan=(0.0, 5.0)) + end end - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], - linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5], - rtol = 0.001) + @testset "P4estMesh" begin + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) + end + + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_eulergravity_convergence.jl"), + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) + end end - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], - linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) + @testset "DGMulti" begin + @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + l2=[ + 0.006400337855843578, + 0.005303799804137764, + 0.005303799804119745, + 0.013204169007030144, + ], + linf=[ + 0.03798302318566282, + 0.05321027922532284, + 0.05321027922605448, + 0.13392025411839015, + ],) + end + + @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_triangulate_pkg_mesh.jl"), + l2=[ + 2.344080455438114e-6, + 1.8610038753097983e-6, + 2.4095165666095305e-6, + 6.373308158814308e-6, + ], + linf=[ + 2.5099852761334418e-5, + 2.2683684021362893e-5, + 2.6180448559287584e-5, + 5.5752932611508044e-5, + ]) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_fdsbp_periodic.jl"), + l2=[ + 1.3333320340010056e-6, + 2.044834627970641e-6, + 2.044834627855601e-6, + 5.282189803559564e-6, + ], + linf=[ + 2.7000151718858945e-6, + 3.988595028259212e-6, + 3.9885950273710336e-6, + 8.848583042286862e-6, + ]) + end end - end - - - @testset "StructuredMesh" begin - @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin - @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", "elixir_advection_restart.jl"), - l2 = [0.00016265538265929818], - linf = [0.0015194252169410394], - rtol = 5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) - elixir_file="elixir_advection_waving_flag.jl", - restart_file="restart_000021.h5") - end - - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", "elixir_mhd_ec.jl"), - l2 = [0.04937480811868297, 0.06117033019988596, 0.060998028674664716, 0.03155145889799417, - 0.2319175391388658, 0.02476283192966346, 0.024483244374818587, 0.035439957899127385, - 0.0016022148194667542], - linf = [0.24749024430983746, 0.2990608279625713, 0.3966937932860247, 0.22265033744519683, - 0.9757376320946505, 0.12123736788315098, 0.12837436699267113, 0.17793825293524734, - 0.03460761690059514], - tspan = (0.0, 0.3)) - end - end - - - @testset "UnstructuredMesh" begin - @trixi_testset "elixir_acoustics_gauss_wall.jl" begin - @test_trixi_include(joinpath(examples_dir(), "unstructured_2d_dgsem", "elixir_acoustics_gauss_wall.jl"), - l2 = [0.029330394861252995, 0.029345079728907965, 0.03803795043486467, 0.0, - 7.175152371650832e-16, 1.4350304743301665e-15, 1.4350304743301665e-15], - linf = [0.36236334472179443, 0.3690785638275256, 0.8475748723784078, 0.0, - 8.881784197001252e-16, 1.7763568394002505e-15, 1.7763568394002505e-15], - tspan = (0.0, 5.0)) - end - end - - - @testset "P4estMesh" begin - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) - end - - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) - end - end - - - @testset "DGMulti" begin - @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - l2 = [0.006400337855843578, 0.005303799804137764, 0.005303799804119745, 0.013204169007030144], - linf = [0.03798302318566282, 0.05321027922532284, 0.05321027922605448, 0.13392025411839015], - ) - end - - @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_triangulate_pkg_mesh.jl"), - l2 = [2.344080455438114e-6, 1.8610038753097983e-6, 2.4095165666095305e-6, 6.373308158814308e-6], - linf = [2.5099852761334418e-5, 2.2683684021362893e-5, 2.6180448559287584e-5, 5.5752932611508044e-5] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_fdsbp_periodic.jl"), - l2 = [1.3333320340010056e-6, 2.044834627970641e-6, 2.044834627855601e-6, 5.282189803559564e-6], - linf = [2.7000151718858945e-6, 3.988595028259212e-6, 3.9885950273710336e-6, 8.848583042286862e-6] - ) - end - end end # Clean up afterwards: delete Trixi.jl output directory -Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive=true) +Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_tree_1d.jl b/test/test_tree_1d.jl index 7737a93a15a..ce01edf6046 100644 --- a/test/test_tree_1d.jl +++ b/test/test_tree_1d.jl @@ -9,275 +9,295 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh1D" begin -# Run basic tests -@testset "Examples 1D" begin - # Linear scalar advection - include("test_tree_1d_advection.jl") - - # Burgers - include("test_tree_1d_burgers.jl") - - # Hyperbolic diffusion - include("test_tree_1d_hypdiff.jl") - - # Compressible Euler - include("test_tree_1d_euler.jl") - - # Compressible Euler Multicomponent - include("test_tree_1d_eulermulti.jl") - - # MHD - include("test_tree_1d_mhd.jl") - - # MHD Multicomponent - include("test_tree_1d_mhdmulti.jl") - - # Compressible Euler with self-gravity - include("test_tree_1d_eulergravity.jl") - - # Shallow water - include("test_tree_1d_shallowwater.jl") - # Two-layer Shallow Water - include("test_tree_1d_shallowwater_twolayer.jl") - - # FDSBP methods on the TreeMesh - include("test_tree_1d_fdsbp.jl") -end - -# Coverage test for all initial conditions -@testset "Tests for initial conditions" begin - # Linear scalar advection - @trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.00017373554109980247], - linf = [0.0006021275678165239], - maxiters = 1, - initial_condition = Trixi.initial_condition_sin) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [2.441369287653687e-16], - linf = [4.440892098500626e-16], - maxiters = 1, - initial_condition = initial_condition_constant) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.9882464973192864e-16], - linf = [1.4432899320127035e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_x, - boundary_conditions = Trixi.boundary_condition_linear_x, - periodicity=false) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_convergence_test" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [6.1803596620800215e-6], - linf = [2.4858560899509996e-5], - maxiters = 1, - initial_condition = initial_condition_convergence_test, - boundary_conditions = BoundaryConditionDirichlet(initial_condition_convergence_test), - periodicity=false) - end -end - - -@testset "Displaying components 1D" begin - @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) - - # test both short and long printing formats - @test_nowarn show(mesh); println() - @test_nowarn println(mesh) - @test_nowarn display(mesh) - - @test_nowarn show(equations); println() - @test_nowarn println(equations) - @test_nowarn display(equations) - - @test_nowarn show(solver); println() - @test_nowarn println(solver) - @test_nowarn display(solver) - - @test_nowarn show(solver.basis); println() - @test_nowarn println(solver.basis) - @test_nowarn display(solver.basis) - - @test_nowarn show(solver.mortar); println() - @test_nowarn println(solver.mortar) - @test_nowarn display(solver.mortar) - - @test_nowarn show(solver.volume_integral); println() - @test_nowarn println(solver.volume_integral) - @test_nowarn display(solver.volume_integral) - - @test_nowarn show(semi); println() - @test_nowarn println(semi) - @test_nowarn display(semi) - - @test_nowarn show(summary_callback); println() - @test_nowarn println(summary_callback) - @test_nowarn display(summary_callback) - - @test_nowarn show(amr_controller); println() - @test_nowarn println(amr_controller) - @test_nowarn display(amr_controller) - - @test_nowarn show(amr_callback); println() - @test_nowarn println(amr_callback) - @test_nowarn display(amr_callback) - - @test_nowarn show(stepsize_callback); println() - @test_nowarn println(stepsize_callback) - @test_nowarn display(stepsize_callback) - - @test_nowarn show(save_solution); println() - @test_nowarn println(save_solution) - @test_nowarn display(save_solution) - - @test_nowarn show(analysis_callback); println() - @test_nowarn println(analysis_callback) - @test_nowarn display(analysis_callback) - - @test_nowarn show(alive_callback); println() - @test_nowarn println(alive_callback) - @test_nowarn display(alive_callback) - - @test_nowarn println(callbacks) - - # Check whether all output is suppressed if the summary, analysis and alive - # callbacks are set to the TrivialCallback(). Modelled using `@test_nowarn` - # as basis. - let fname = tempname() - try - open(fname, "w") do f - redirect_stderr(f) do - trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - summary_callback=TrivialCallback(), - analysis_callback=TrivialCallback(), - alive_callback=TrivialCallback()) - end - end - output = read(fname, String) - output = replace(output, "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n" => "") - @test isempty(output) - finally - rm(fname, force=true) - end - end -end + # Run basic tests + @testset "Examples 1D" begin + # Linear scalar advection + include("test_tree_1d_advection.jl") + + # Burgers + include("test_tree_1d_burgers.jl") + + # Hyperbolic diffusion + include("test_tree_1d_hypdiff.jl") + + # Compressible Euler + include("test_tree_1d_euler.jl") + + # Compressible Euler Multicomponent + include("test_tree_1d_eulermulti.jl") + + # MHD + include("test_tree_1d_mhd.jl") + # MHD Multicomponent + include("test_tree_1d_mhdmulti.jl") -@testset "Additional tests in 1D" begin - @testset "compressible Euler" begin - eqn = CompressibleEulerEquations1D(1.4) + # Compressible Euler with self-gravity + include("test_tree_1d_eulergravity.jl") - @test isapprox(Trixi.entropy_thermodynamic([1.0, 2.0, 20.0], eqn), 1.9740810260220094) - @test isapprox(Trixi.entropy_math([1.0, 2.0, 20.0], eqn), -4.935202565055024) - @test isapprox(Trixi.entropy([1.0, 2.0, 20.0], eqn), -4.935202565055024) + # Shallow water + include("test_tree_1d_shallowwater.jl") + # Two-layer Shallow Water + include("test_tree_1d_shallowwater_twolayer.jl") - @test isapprox(energy_total([1.0, 2.0, 20.0], eqn), 20.0) - @test isapprox(energy_kinetic([1.0, 2.0, 20.0], eqn), 2.0) - @test isapprox(energy_internal([1.0, 2.0, 20.0], eqn), 18.0) - end -end + # FDSBP methods on the TreeMesh + include("test_tree_1d_fdsbp.jl") + end + + # Coverage test for all initial conditions + @testset "Tests for initial conditions" begin + # Linear scalar advection + @trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[0.00017373554109980247], + linf=[0.0006021275678165239], + maxiters=1, + initial_condition=Trixi.initial_condition_sin) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[2.441369287653687e-16], + linf=[4.440892098500626e-16], + maxiters=1, + initial_condition=initial_condition_constant) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[1.9882464973192864e-16], + linf=[1.4432899320127035e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_x, + boundary_conditions=Trixi.boundary_condition_linear_x, + periodicity=false) + end -@trixi_testset "Nonconservative terms in 1D (linear advection)" begin - # Same setup as docs/src/adding_new_equations/nonconservative_advection.md + @trixi_testset "elixir_advection_extended.jl with initial_condition_convergence_test" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[6.1803596620800215e-6], + linf=[2.4858560899509996e-5], + maxiters=1, + initial_condition=initial_condition_convergence_test, + boundary_conditions=BoundaryConditionDirichlet(initial_condition_convergence_test), + periodicity=false) + end + end - # Define new physics - using Trixi - using Trixi: AbstractEquations, get_node_vars + @testset "Displaying components 1D" begin + @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) + + # test both short and long printing formats + @test_nowarn show(mesh) + println() + @test_nowarn println(mesh) + @test_nowarn display(mesh) + + @test_nowarn show(equations) + println() + @test_nowarn println(equations) + @test_nowarn display(equations) + + @test_nowarn show(solver) + println() + @test_nowarn println(solver) + @test_nowarn display(solver) + + @test_nowarn show(solver.basis) + println() + @test_nowarn println(solver.basis) + @test_nowarn display(solver.basis) + + @test_nowarn show(solver.mortar) + println() + @test_nowarn println(solver.mortar) + @test_nowarn display(solver.mortar) + + @test_nowarn show(solver.volume_integral) + println() + @test_nowarn println(solver.volume_integral) + @test_nowarn display(solver.volume_integral) + + @test_nowarn show(semi) + println() + @test_nowarn println(semi) + @test_nowarn display(semi) + + @test_nowarn show(summary_callback) + println() + @test_nowarn println(summary_callback) + @test_nowarn display(summary_callback) + + @test_nowarn show(amr_controller) + println() + @test_nowarn println(amr_controller) + @test_nowarn display(amr_controller) + + @test_nowarn show(amr_callback) + println() + @test_nowarn println(amr_callback) + @test_nowarn display(amr_callback) + + @test_nowarn show(stepsize_callback) + println() + @test_nowarn println(stepsize_callback) + @test_nowarn display(stepsize_callback) + + @test_nowarn show(save_solution) + println() + @test_nowarn println(save_solution) + @test_nowarn display(save_solution) + + @test_nowarn show(analysis_callback) + println() + @test_nowarn println(analysis_callback) + @test_nowarn display(analysis_callback) + + @test_nowarn show(alive_callback) + println() + @test_nowarn println(alive_callback) + @test_nowarn display(alive_callback) + + @test_nowarn println(callbacks) + + # Check whether all output is suppressed if the summary, analysis and alive + # callbacks are set to the TrivialCallback(). Modelled using `@test_nowarn` + # as basis. + let fname = tempname() + try + open(fname, "w") do f + redirect_stderr(f) do + trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_extended.jl"), + summary_callback = TrivialCallback(), + analysis_callback = TrivialCallback(), + alive_callback = TrivialCallback()) + end + end + output = read(fname, String) + output = replace(output, + "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n" => "") + @test isempty(output) + finally + rm(fname, force = true) + end + end + end - # Since there is no native support for variable coefficients, we use two - # variables: one for the basic unknown `u` and another one for the coefficient `a` - struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, - 2 #= two variables (u,a) =#} - end + @testset "Additional tests in 1D" begin + @testset "compressible Euler" begin + eqn = CompressibleEulerEquations1D(1.4) - Trixi.varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") + @test isapprox(Trixi.entropy_thermodynamic([1.0, 2.0, 20.0], eqn), + 1.9740810260220094) + @test isapprox(Trixi.entropy_math([1.0, 2.0, 20.0], eqn), -4.935202565055024) + @test isapprox(Trixi.entropy([1.0, 2.0, 20.0], eqn), -4.935202565055024) - Trixi.default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () + @test isapprox(energy_total([1.0, 2.0, 20.0], eqn), 20.0) + @test isapprox(energy_kinetic([1.0, 2.0, 20.0], eqn), 2.0) + @test isapprox(energy_internal([1.0, 2.0, 20.0], eqn), 18.0) + end + end + @trixi_testset "Nonconservative terms in 1D (linear advection)" begin + # Same setup as docs/src/adding_new_equations/nonconservative_advection.md - # The conservative part of the flux is zero - Trixi.flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) + # Define new physics + using Trixi + using Trixi: AbstractEquations, get_node_vars - # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation - function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) - _, advection_velocity_ll = u_ll - _, advection_velocity_rr = u_rr + # Since there is no native support for variable coefficients, we use two + # variables: one for the basic unknown `u` and another one for the coefficient `a` + struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# + 2} #= two variables (u,a) =# + end - return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) - end + function Trixi.varnames(::typeof(cons2cons), + ::NonconservativeLinearAdvectionEquation) + ("scalar", "advection_velocity") + end + Trixi.default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () - # We use nonconservative terms - Trixi.have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() + # The conservative part of the flux is zero + function Trixi.flux(u, orientation, + equation::NonconservativeLinearAdvectionEquation) + zero(u) + end - function flux_nonconservative(u_mine, u_other, orientation, - equations::NonconservativeLinearAdvectionEquation) - _, advection_velocity = u_mine - scalar, _ = u_other + # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation + function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, + ::NonconservativeLinearAdvectionEquation) + _, advection_velocity_ll = u_ll + _, advection_velocity_rr = u_rr - return SVector(advection_velocity * scalar, zero(scalar)) - end + return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) + end + # We use nonconservative terms + function Trixi.have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) + Trixi.True() + end - # Create a simulation setup - using Trixi - using OrdinaryDiffEq + function flux_nonconservative(u_mine, u_other, orientation, + equations::NonconservativeLinearAdvectionEquation) + _, advection_velocity = u_mine + scalar, _ = u_other - equation = NonconservativeLinearAdvectionEquation() + return SVector(advection_velocity * scalar, zero(scalar)) + end - # You can derive the exact solution for this setup using the method of - # characteristics - function initial_condition_sine(x, t, equation::NonconservativeLinearAdvectionEquation) - x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) - scalar = sin(x0) - advection_velocity = 2 + cos(x[1]) - SVector(scalar, advection_velocity) - end + # Create a simulation setup + using Trixi + using OrdinaryDiffEq - # Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries - mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level=4, n_cells_max=10^4) + equation = NonconservativeLinearAdvectionEquation() - # Create a DGSEM solver with polynomials of degree `polydeg` - volume_flux = (flux_central, flux_nonconservative) - surface_flux = (flux_lax_friedrichs, flux_nonconservative) - solver = DGSEM(polydeg=3, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + # You can derive the exact solution for this setup using the method of + # characteristics + function initial_condition_sine(x, t, + equation::NonconservativeLinearAdvectionEquation) + x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) + scalar = sin(x0) + advection_velocity = 2 + cos(x[1]) + SVector(scalar, advection_velocity) + end - # Setup the spatial semidiscretization containing all ingredients - semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) + # Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries + mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates + initial_refinement_level = 4, n_cells_max = 10^4) - # Create an ODE problem with given time span - tspan = (0.0, 1.0) - ode = semidiscretize(semi, tspan); + # Create a DGSEM solver with polynomials of degree `polydeg` + volume_flux = (flux_central, flux_nonconservative) + surface_flux = (flux_lax_friedrichs, flux_nonconservative) + solver = DGSEM(polydeg = 3, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) - summary_callback = SummaryCallback() - analysis_callback = AnalysisCallback(semi, interval=50) - callbacks = CallbackSet(summary_callback, analysis_callback); + # Setup the spatial semidiscretization containing all ingredients + semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) - # OrdinaryDiffEq's `solve` method evolves the solution in time and executes - # the passed callbacks - sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, - save_everystep=false, callback=callbacks); + # Create an ODE problem with given time span + tspan = (0.0, 1.0) + ode = semidiscretize(semi, tspan) - @test analysis_callback(sol).l2 ≈ [0.00029609575838969394, 5.5681704039507985e-6] -end + summary_callback = SummaryCallback() + analysis_callback = AnalysisCallback(semi, interval = 50) + callbacks = CallbackSet(summary_callback, analysis_callback) + # OrdinaryDiffEq's `solve` method evolves the solution in time and executes + # the passed callbacks + sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, + save_everystep = false, callback = callbacks) -# Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) + @test analysis_callback(sol).l2 ≈ [0.00029609575838969394, 5.5681704039507985e-6] + end + # Clean up afterwards: delete Trixi.jl output directory + @test_nowarn rm(outdir, recursive = true) end # TreeMesh1D end # module diff --git a/test/test_tree_1d_advection.jl b/test/test_tree_1d_advection.jl index 0cf0f2c1170..63c9e777ce1 100644 --- a/test/test_tree_1d_advection.jl +++ b/test/test_tree_1d_advection.jl @@ -8,31 +8,31 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - l2 = [6.0388296447998465e-6], - linf = [3.217887726258972e-5]) - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - l2 = [0.3540206249507417], - linf = [0.9999896603382347], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - l2 = [4.283508859843524e-6], - linf = [3.235356127918171e-5], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_finite_volume.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"), - l2 = [0.011662300515980219], - linf = [0.01647256923710194]) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + l2=[6.0388296447998465e-6], + linf=[3.217887726258972e-5]) + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + l2=[0.3540206249507417], + linf=[0.9999896603382347], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), + l2=[4.283508859843524e-6], + linf=[3.235356127918171e-5], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_finite_volume.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"), + l2=[0.011662300515980219], + linf=[0.01647256923710194]) + end end end # module diff --git a/test/test_tree_1d_burgers.jl b/test/test_tree_1d_burgers.jl index 8c4cfaa406d..c8144e3a4fa 100644 --- a/test/test_tree_1d_burgers.jl +++ b/test/test_tree_1d_burgers.jl @@ -8,29 +8,29 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Inviscid Burgers" begin - @trixi_testset "elixir_burgers_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2 = [2.967470209082194e-5], - linf = [0.00016152468882624227]) - end - - @trixi_testset "elixir_burgers_linear_stability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), - l2 = [0.5660569881106876], - linf = [1.9352238038313998]) - end - - @trixi_testset "elixir_burgers_shock.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_shock.jl"), - l2 = [0.4422505602587537], - linf = [1.0000000000000009]) - end - - @trixi_testset "elixir_burgers_rarefaction.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_rarefaction.jl"), - l2 = [0.4038224690923722], - linf = [1.0049201454652736]) - end + @trixi_testset "elixir_burgers_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2=[2.967470209082194e-5], + linf=[0.00016152468882624227]) + end + + @trixi_testset "elixir_burgers_linear_stability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), + l2=[0.5660569881106876], + linf=[1.9352238038313998]) + end + + @trixi_testset "elixir_burgers_shock.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_shock.jl"), + l2=[0.4422505602587537], + linf=[1.0000000000000009]) + end + + @trixi_testset "elixir_burgers_rarefaction.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_rarefaction.jl"), + l2=[0.4038224690923722], + linf=[1.0049201454652736]) + end end end # module diff --git a/test/test_tree_1d_euler.jl b/test/test_tree_1d_euler.jl index 1eda4649f65..7fa9432b1fd 100644 --- a/test/test_tree_1d_euler.jl +++ b/test/test_tree_1d_euler.jl @@ -8,145 +8,257 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [2.2527950196212703e-8, 1.8187357193835156e-8, 7.705669939973104e-8], - linf = [1.6205433861493646e-7, 1.465427772462391e-7, 5.372255111879554e-7]) - end - - @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2 = [0.019355699748523896, 0.022326984561234497, 0.02523665947241734], - linf = [0.02895961127645519, 0.03293442484199227, 0.04246098278632804]) - end - - @trixi_testset "elixir_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [0.0011482554820217855, 0.00011482554830323462, 5.741277429325267e-6], - linf = [0.004090978306812376, 0.0004090978313582294, 2.045489210189544e-5]) - end - - @trixi_testset "elixir_euler_density_wave.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [7.71293052584723e-16, 1.9712947511091717e-14, 7.50672833504266e-15], - linf = [3.774758283725532e-15, 6.733502644351574e-14, 2.4868995751603507e-14], - initial_condition = initial_condition_constant) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [3.8099996914101204e-6, 1.6745575717106341e-6, 7.732189531480852e-6], - linf = [1.2971473393186272e-5, 9.270328934274374e-6, 3.092514399671842e-5]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.11821957357197649, 0.15330089521538678, 0.4417674632047301], - linf = [0.24280567569982958, 0.29130548795961936, 0.8847009003152442]) - end - - @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07803455838661963, 0.10032577312032283, 0.29228156303827935], - linf = [0.2549869853794955, 0.3376472164661263, 0.9650477546553962], - maxiters = 10, - surface_flux = flux_kennedy_gruber, - volume_flux = flux_kennedy_gruber) - end - - @trixi_testset "elixir_euler_ec.jl with flux_shima_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07800654460172655, 0.10030365573277883, 0.2921481199111959], - linf = [0.25408579350400395, 0.3388657679031271, 0.9776486386921928], - maxiters = 10, - surface_flux = flux_shima_etal, - volume_flux = flux_shima_etal) - end - - @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07801923089205756, 0.10039557434912669, 0.2922210399923278], - linf = [0.2576521982607225, 0.3409717926625057, 0.9772961936567048], - maxiters = 10, - surface_flux = flux_chandrashekar, - volume_flux = flux_chandrashekar) - end - - @trixi_testset "elixir_euler_ec.jl with flux_hll" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07852272782240548, 0.10209790867523805, 0.293873048809011], - linf = [0.19244768908604093, 0.2515941686151897, 0.7258000837553769], - maxiters = 10, - surface_flux = FluxHLL(min_max_speed_naive), - volume_flux = flux_ranocha) - end - - @trixi_testset "elixir_euler_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2 = [0.11606096465319675, 0.15028768943458806, 0.4328230323046703], - linf = [0.18031710091067965, 0.2351582421501841, 0.6776805692092567]) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [1.250005061244617, 0.06878411345533507, 0.9264328311018613], - linf = [2.9766770877037168, 0.16838100902295852, 2.6655773445485798], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave_pure_fv.jl"), - l2 = [1.0735456065491455, 0.07131078703089379, 0.9205739468590453], - linf = [3.4296365168219216, 0.17635583964559245, 2.6574584326179505], - # Let this test run longer to cover some lines in flux_hllc - coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl with pressure" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [1.297525985166995, 0.07964929522694145, 0.9269991156246368], - linf = [3.1773015255764427, 0.21331831536493773, 2.6650170188241047], - shock_indicator_variable = pressure, - cfl = 0.2, - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl with density" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [1.2798798835860528, 0.07103461242058921, 0.9273792517187003], - linf = [3.1087017048015824, 0.17734706962928956, 2.666689753470263], - shock_indicator_variable = density, - cfl = 0.2, - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_positivity.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), - l2 = [1.6493820253458906, 0.19793887460986834, 0.9783506076125921], - linf = [4.71751203912051, 0.5272411022735763, 2.7426163947635844], - coverage_override = (maxiters=3,)) - end - - @trixi_testset "elixir_euler_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), - l2 = [0.21934822867340323, 0.28131919126002686, 0.554361702716662], - linf = [1.5180897390290355, 1.3967085956620369, 2.0663825294019595], - maxiters = 30) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), - l2 = [0.21814833203212694, 0.2818328665444332, 0.5528379124720818], - linf = [1.5548653877320868, 1.4474018998129738, 2.071919577393772], - maxiters = 30) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2 = [0.22054468879127423, 0.2828269190680846, 0.5542369885642424], - linf = [1.5623359741479623, 1.4290121654488288, 2.1040405133123072], - maxiters = 30) - end + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2=[ + 2.2527950196212703e-8, + 1.8187357193835156e-8, + 7.705669939973104e-8, + ], + linf=[ + 1.6205433861493646e-7, + 1.465427772462391e-7, + 5.372255111879554e-7, + ]) + end + + @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), + l2=[ + 0.019355699748523896, + 0.022326984561234497, + 0.02523665947241734, + ], + linf=[ + 0.02895961127645519, + 0.03293442484199227, + 0.04246098278632804, + ]) + end + + @trixi_testset "elixir_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2=[ + 0.0011482554820217855, + 0.00011482554830323462, + 5.741277429325267e-6, + ], + linf=[ + 0.004090978306812376, + 0.0004090978313582294, + 2.045489210189544e-5, + ]) + end + + @trixi_testset "elixir_euler_density_wave.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2=[ + 7.71293052584723e-16, + 1.9712947511091717e-14, + 7.50672833504266e-15, + ], + linf=[ + 3.774758283725532e-15, + 6.733502644351574e-14, + 2.4868995751603507e-14, + ], + initial_condition=initial_condition_constant) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 3.8099996914101204e-6, + 1.6745575717106341e-6, + 7.732189531480852e-6, + ], + linf=[ + 1.2971473393186272e-5, + 9.270328934274374e-6, + 3.092514399671842e-5, + ]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.11821957357197649, + 0.15330089521538678, + 0.4417674632047301, + ], + linf=[ + 0.24280567569982958, + 0.29130548795961936, + 0.8847009003152442, + ]) + end + + @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.07803455838661963, + 0.10032577312032283, + 0.29228156303827935, + ], + linf=[ + 0.2549869853794955, + 0.3376472164661263, + 0.9650477546553962, + ], + maxiters=10, + surface_flux=flux_kennedy_gruber, + volume_flux=flux_kennedy_gruber) + end + + @trixi_testset "elixir_euler_ec.jl with flux_shima_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.07800654460172655, + 0.10030365573277883, + 0.2921481199111959, + ], + linf=[ + 0.25408579350400395, + 0.3388657679031271, + 0.9776486386921928, + ], + maxiters=10, + surface_flux=flux_shima_etal, + volume_flux=flux_shima_etal) + end + + @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.07801923089205756, + 0.10039557434912669, + 0.2922210399923278, + ], + linf=[ + 0.2576521982607225, + 0.3409717926625057, + 0.9772961936567048, + ], + maxiters=10, + surface_flux=flux_chandrashekar, + volume_flux=flux_chandrashekar) + end + + @trixi_testset "elixir_euler_ec.jl with flux_hll" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[0.07852272782240548, 0.10209790867523805, 0.293873048809011], + linf=[ + 0.19244768908604093, + 0.2515941686151897, + 0.7258000837553769, + ], + maxiters=10, + surface_flux=FluxHLL(min_max_speed_naive), + volume_flux=flux_ranocha) + end + + @trixi_testset "elixir_euler_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), + l2=[ + 0.11606096465319675, + 0.15028768943458806, + 0.4328230323046703, + ], + linf=[ + 0.18031710091067965, + 0.2351582421501841, + 0.6776805692092567, + ]) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2=[1.250005061244617, 0.06878411345533507, 0.9264328311018613], + linf=[ + 2.9766770877037168, + 0.16838100902295852, + 2.6655773445485798, + ], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_sedov_blast_wave_pure_fv.jl"), + l2=[1.0735456065491455, 0.07131078703089379, 0.9205739468590453], + linf=[ + 3.4296365168219216, + 0.17635583964559245, + 2.6574584326179505, + ], + # Let this test run longer to cover some lines in flux_hllc + coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl with pressure" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2=[1.297525985166995, 0.07964929522694145, 0.9269991156246368], + linf=[ + 3.1773015255764427, + 0.21331831536493773, + 2.6650170188241047, + ], + shock_indicator_variable=pressure, + cfl=0.2, + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl with density" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2=[1.2798798835860528, 0.07103461242058921, 0.9273792517187003], + linf=[ + 3.1087017048015824, + 0.17734706962928956, + 2.666689753470263, + ], + shock_indicator_variable=density, + cfl=0.2, + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_positivity.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), + l2=[1.6493820253458906, 0.19793887460986834, 0.9783506076125921], + linf=[4.71751203912051, 0.5272411022735763, 2.7426163947635844], + coverage_override=(maxiters = 3,)) + end + + @trixi_testset "elixir_euler_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), + l2=[0.21934822867340323, 0.28131919126002686, 0.554361702716662], + linf=[ + 1.5180897390290355, + 1.3967085956620369, + 2.0663825294019595, + ], + maxiters=30) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), + l2=[0.21814833203212694, 0.2818328665444332, 0.5528379124720818], + linf=[1.5548653877320868, 1.4474018998129738, 2.071919577393772], + maxiters=30) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2=[0.22054468879127423, 0.2828269190680846, 0.5542369885642424], + linf=[ + 1.5623359741479623, + 1.4290121654488288, + 2.1040405133123072, + ], + maxiters=30) + end end end # module diff --git a/test/test_tree_1d_eulergravity.jl b/test/test_tree_1d_eulergravity.jl index 966add0cdf3..05af290ba5a 100644 --- a/test/test_tree_1d_eulergravity.jl +++ b/test/test_tree_1d_eulergravity.jl @@ -8,11 +8,19 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler with self-gravity" begin - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.0002170799126638106, 0.0002913792848717502, 0.0006112320856262327], - linf = [0.0004977401033188222, 0.0013594223337776157, 0.002041891084400227]) - end + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2=[ + 0.0002170799126638106, + 0.0002913792848717502, + 0.0006112320856262327, + ], + linf=[ + 0.0004977401033188222, + 0.0013594223337776157, + 0.002041891084400227, + ]) + end end end # module diff --git a/test/test_tree_1d_eulermulti.jl b/test/test_tree_1d_eulermulti.jl index e880f98e2d0..daaeb0ace56 100644 --- a/test/test_tree_1d_eulermulti.jl +++ b/test/test_tree_1d_eulermulti.jl @@ -8,56 +8,80 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler Multicomponent" begin + @trixi_testset "elixir_eulermulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), + l2=[0.15330089521538684, 0.4417674632047301, + 0.016888510510282385, 0.03377702102056477, + 0.06755404204112954], + linf=[0.29130548795961864, 0.8847009003152357, + 0.034686525099975274, 0.06937305019995055, + 0.1387461003999011]) + end - @trixi_testset "elixir_eulermulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), - l2 = [0.15330089521538684, 0.4417674632047301, 0.016888510510282385, 0.03377702102056477, - 0.06755404204112954], - linf = [0.29130548795961864, 0.8847009003152357, 0.034686525099975274, 0.06937305019995055, - 0.1387461003999011]) - end - - @trixi_testset "elixir_eulermulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), - l2 = [0.1522380497572071, 0.43830846465313206, 0.03907262116499431, 0.07814524232998862], - linf = [0.24939193075537294, 0.7139395740052739, 0.06324208768391237, 0.12648417536782475]) - end - - @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), - l2 = [8.575236038539227e-5, 0.00016387804318585358, 1.9412699303977585e-5, 3.882539860795517e-5], - linf = [0.00030593277277124464, 0.0006244803933350696, 7.253121435135679e-5, 0.00014506242870271358]) - end - - @trixi_testset "elixir_eulermulti_convergence_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [1.8983933794407234e-5, 6.207744299844731e-5, 1.5466205761868047e-6, 3.0932411523736094e-6, - 6.186482304747219e-6, 1.2372964609494437e-5], - linf = [0.00012014372605895218, 0.0003313207215800418, 6.50836791016296e-6, 1.301673582032592e-5, - 2.603347164065184e-5, 5.206694328130368e-5]) - end - - @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [1.888450477353845e-5, 5.4910600482795386e-5, 9.426737161533622e-7, 1.8853474323067245e-6, - 3.770694864613449e-6, 7.541389729226898e-6], - linf = [0.00011622351152063004, 0.0003079221967086099, 3.2177423254231563e-6, 6.435484650846313e-6, - 1.2870969301692625e-5, 2.574193860338525e-5], - volume_flux = flux_chandrashekar) - end - - @trixi_testset "elixir_eulermulti_two_interacting_blast_waves.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_two_interacting_blast_waves.jl"), - l2 = [1.288867611915533, 82.71335258388848, 0.00350680272313187, 0.013698784353152794, - 0.019179518517518084], - linf = [29.6413044707026, 1322.5844802186496, 0.09191919374782143, 0.31092970966717925, - 0.4417989757182038], - tspan = (0.0, 0.0001)) - end + @trixi_testset "elixir_eulermulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), + l2=[ + 0.1522380497572071, + 0.43830846465313206, + 0.03907262116499431, + 0.07814524232998862, + ], + linf=[ + 0.24939193075537294, + 0.7139395740052739, + 0.06324208768391237, + 0.12648417536782475, + ]) + end + @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), + l2=[ + 8.575236038539227e-5, + 0.00016387804318585358, + 1.9412699303977585e-5, + 3.882539860795517e-5, + ], + linf=[ + 0.00030593277277124464, + 0.0006244803933350696, + 7.253121435135679e-5, + 0.00014506242870271358, + ]) + end -end + @trixi_testset "elixir_eulermulti_convergence_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2=[1.8983933794407234e-5, 6.207744299844731e-5, + 1.5466205761868047e-6, 3.0932411523736094e-6, + 6.186482304747219e-6, 1.2372964609494437e-5], + linf=[0.00012014372605895218, 0.0003313207215800418, + 6.50836791016296e-6, 1.301673582032592e-5, + 2.603347164065184e-5, 5.206694328130368e-5]) + end + @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2=[1.888450477353845e-5, 5.4910600482795386e-5, + 9.426737161533622e-7, 1.8853474323067245e-6, + 3.770694864613449e-6, 7.541389729226898e-6], + linf=[0.00011622351152063004, 0.0003079221967086099, + 3.2177423254231563e-6, 6.435484650846313e-6, + 1.2870969301692625e-5, 2.574193860338525e-5], + volume_flux=flux_chandrashekar) + end + @trixi_testset "elixir_eulermulti_two_interacting_blast_waves.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulermulti_two_interacting_blast_waves.jl"), + l2=[1.288867611915533, 82.71335258388848, 0.00350680272313187, + 0.013698784353152794, + 0.019179518517518084], + linf=[29.6413044707026, 1322.5844802186496, 0.09191919374782143, + 0.31092970966717925, + 0.4417989757182038], + tspan=(0.0, 0.0001)) + end +end end # module diff --git a/test/test_tree_1d_fdsbp.jl b/test/test_tree_1d_fdsbp.jl index a966b3836f3..847608add5e 100644 --- a/test/test_tree_1d_fdsbp.jl +++ b/test/test_tree_1d_fdsbp.jl @@ -8,79 +8,114 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_fdsbp") @testset "Inviscid Burgers" begin - @trixi_testset "elixir_burgers_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2 = [8.316190308678742e-7], - linf = [7.1087263324720595e-6], - tspan = (0.0, 0.5)) + @trixi_testset "elixir_burgers_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2=[8.316190308678742e-7], + linf=[7.1087263324720595e-6], + tspan=(0.0, 0.5)) - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end - end - # same tolerances as above since the methods should be identical (up to - # machine precision) - @trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2 = [8.316190308678742e-7], - linf = [7.1087263324720595e-6], - tspan = (0.0, 0.5), - solver = DG(D_upw, nothing, SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)), VolumeIntegralUpwind(flux_splitting))) - end + # same tolerances as above since the methods should be identical (up to + # machine precision) + @trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2=[8.316190308678742e-7], + linf=[7.1087263324720595e-6], + tspan=(0.0, 0.5), + solver=DG(D_upw, nothing, + SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)), + VolumeIntegralUpwind(flux_splitting))) + end - @trixi_testset "elixir_burgers_linear_stability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), - l2 = [0.9999995642691271], - linf = [1.824702804788453], - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_burgers_linear_stability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), + l2=[0.9999995642691271], + linf=[1.824702804788453], + tspan=(0.0, 0.25)) + end end @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [4.1370344463620254e-6, 4.297052451817826e-6, 9.857382045003056e-6], - linf = [1.675305070092392e-5, 1.3448113863834266e-5, 3.8185336878271414e-5], - tspan = (0.0, 0.5)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 4.1370344463620254e-6, + 4.297052451817826e-6, + 9.857382045003056e-6, + ], + linf=[ + 1.675305070092392e-5, + 1.3448113863834266e-5, + 3.8185336878271414e-5, + ], + tspan=(0.0, 0.5)) - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end - end - @trixi_testset "elixir_euler_convergence.jl with splitting_vanleer_haenel" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [3.413790589105506e-6, 4.243957977156001e-6, 8.667369423676437e-6], - linf = [1.4228079689537765e-5, 1.3249887941046978e-5, 3.201552933251861e-5], - tspan = (0.0, 0.5), - flux_splitting = splitting_vanleer_haenel) - end + @trixi_testset "elixir_euler_convergence.jl with splitting_vanleer_haenel" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 3.413790589105506e-6, + 4.243957977156001e-6, + 8.667369423676437e-6, + ], + linf=[ + 1.4228079689537765e-5, + 1.3249887941046978e-5, + 3.201552933251861e-5, + ], + tspan=(0.0, 0.5), + flux_splitting=splitting_vanleer_haenel) + end - @trixi_testset "elixir_euler_convergence.jl with VolumeIntegralStrongForm" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [8.6126767518378e-6, 7.670897071480729e-6, 1.4972772284191368e-5], - linf = [6.707982777909294e-5, 3.487256699541419e-5, 0.00010170331350556339], - tspan = (0.0, 0.5), - solver = DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), VolumeIntegralStrongForm())) - end + @trixi_testset "elixir_euler_convergence.jl with VolumeIntegralStrongForm" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 8.6126767518378e-6, + 7.670897071480729e-6, + 1.4972772284191368e-5, + ], + linf=[ + 6.707982777909294e-5, + 3.487256699541419e-5, + 0.00010170331350556339, + ], + tspan=(0.0, 0.5), + solver=DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), + VolumeIntegralStrongForm())) + end - @trixi_testset "elixir_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [1.5894925236031034e-5, 9.428412101106044e-6, 0.0008986477358789918], - linf = [4.969438024382544e-5, 2.393091812063694e-5, 0.003271817388146303], - tspan = (0.0, 0.005), abstol = 1.0e-9, reltol = 1.0e-9) - end + @trixi_testset "elixir_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2=[ + 1.5894925236031034e-5, + 9.428412101106044e-6, + 0.0008986477358789918, + ], + linf=[ + 4.969438024382544e-5, + 2.393091812063694e-5, + 0.003271817388146303, + ], + tspan=(0.0, 0.005), abstol=1.0e-9, reltol=1.0e-9) + end end end # module diff --git a/test/test_tree_1d_hypdiff.jl b/test/test_tree_1d_hypdiff.jl index 560f77b2a13..a9332943a6b 100644 --- a/test/test_tree_1d_hypdiff.jl +++ b/test/test_tree_1d_hypdiff.jl @@ -8,20 +8,20 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Hyperbolic diffusion" begin + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2=[1.3655114954641076e-7, 1.0200345025539218e-6], + linf=[7.173286515893551e-7, 4.507116363683394e-6], + atol=2.5e-13) + end - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [1.3655114954641076e-7, 1.0200345025539218e-6], - linf = [7.173286515893551e-7, 4.507116363683394e-6], - atol = 2.5e-13) - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [3.0130941075207524e-12, 2.6240829677090014e-12], - linf = [4.054534485931072e-12, 3.8826719617190975e-12], - atol = 2.5e-13) - end + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[3.0130941075207524e-12, 2.6240829677090014e-12], + linf=[4.054534485931072e-12, 3.8826719617190975e-12], + atol=2.5e-13) + end end end # module diff --git a/test/test_tree_1d_mhd.jl b/test/test_tree_1d_mhd.jl index e3a0cda3250..0ab19b7c487 100644 --- a/test/test_tree_1d_mhd.jl +++ b/test/test_tree_1d_mhd.jl @@ -8,73 +8,235 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "MHD" begin + @trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[ + 1.440611823425164e-15, + 1.1373567770134494e-14, + 3.024482376149653e-15, + 2.0553143516814395e-15, + 3.9938347410210535e-14, + 3.984545392098788e-16, + 2.4782402104201577e-15, + 1.551737464879987e-15, + ], + linf=[ + 1.9984014443252818e-15, + 1.3405943022348765e-14, + 3.3584246494910985e-15, + 3.164135620181696e-15, + 7.815970093361102e-14, + 8.881784197001252e-16, + 2.886579864025407e-15, + 2.942091015256665e-15, + ], + initial_condition=initial_condition_constant, + tspan=(0.0, 1.0)) + end - @trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.440611823425164e-15, 1.1373567770134494e-14, 3.024482376149653e-15, 2.0553143516814395e-15, 3.9938347410210535e-14, 3.984545392098788e-16, 2.4782402104201577e-15, 1.551737464879987e-15], - linf = [1.9984014443252818e-15, 1.3405943022348765e-14, 3.3584246494910985e-15, 3.164135620181696e-15, 7.815970093361102e-14, 8.881784197001252e-16, 2.886579864025407e-15, 2.942091015256665e-15], - initial_condition = initial_condition_constant, - tspan = (0.0,1.0)) - end + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[ + 1.0375628983659061e-5, + 6.571144191446236e-7, + 3.5833569836289104e-5, + 3.583356983615859e-5, + 5.084863194951084e-6, + 1.1963224165731992e-16, + 3.598916927583752e-5, + 3.598916927594727e-5, + ], + linf=[ + 2.614095879338585e-5, + 9.577266731216823e-7, + 0.00012406198007461344, + 0.00012406198007509917, + 1.5066209528846741e-5, + 2.220446049250313e-16, + 0.00012658678753942054, + 0.00012658678753908748, + ]) + end - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.0375628983659061e-5, 6.571144191446236e-7, 3.5833569836289104e-5, 3.583356983615859e-5, 5.084863194951084e-6, 1.1963224165731992e-16, 3.598916927583752e-5, 3.598916927594727e-5], - linf = [2.614095879338585e-5, 9.577266731216823e-7, 0.00012406198007461344, 0.00012406198007509917, 1.5066209528846741e-5, 2.220446049250313e-16, 0.00012658678753942054, 0.00012658678753908748]) - end + @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[ + 1.4396053943470756e-5, + 1.1211016739165248e-5, + 3.577870687983967e-5, + 3.577870687982181e-5, + 1.967962220860377e-6, + 1.1963224165731992e-16, + 3.583562899483433e-5, + 3.583562899486565e-5, + ], + linf=[ + 5.830577969345718e-5, + 3.280495696370357e-5, + 0.00012279619948236953, + 0.00012279619948227238, + 6.978806516122482e-6, + 2.220446049250313e-16, + 0.00012564003648959932, + 0.00012564003648994626, + ], + volume_flux=flux_derigs_etal) + end - @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.4396053943470756e-5, 1.1211016739165248e-5, 3.577870687983967e-5, 3.577870687982181e-5, 1.967962220860377e-6, 1.1963224165731992e-16, 3.583562899483433e-5, 3.583562899486565e-5], - linf = [5.830577969345718e-5, 3.280495696370357e-5, 0.00012279619948236953, 0.00012279619948227238, 6.978806516122482e-6, 2.220446049250313e-16, 0.00012564003648959932, 0.00012564003648994626], - volume_flux = flux_derigs_etal) - end + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2=[ + 0.05815183849746399, + 0.08166807325621023, + 0.054659228513541165, + 0.054659228513541165, + 0.15578125987042743, + 4.130462730494e-17, + 0.05465258887150046, + 0.05465258887150046, + ], + linf=[ + 0.12165312668363826, + 0.1901920742264952, + 0.10059813883022554, + 0.10059813883022554, + 0.44079257431070706, + 1.1102230246251565e-16, + 0.10528911365809579, + 0.10528911365809579, + ]) + end - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.05815183849746399, 0.08166807325621023, 0.054659228513541165, 0.054659228513541165, 0.15578125987042743, 4.130462730494e-17, 0.05465258887150046, 0.05465258887150046], - linf = [0.12165312668363826, 0.1901920742264952, 0.10059813883022554, 0.10059813883022554, 0.44079257431070706, 1.1102230246251565e-16, 0.10528911365809579, 0.10528911365809579]) - end + @trixi_testset "elixir_mhd_briowu_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_briowu_shock_tube.jl"), + l2=[ + 0.17477712356961989, + 0.19489623595086944, + 0.3596546157640463, + 0.0, + 0.3723215736814466, + 1.2060075775846403e-15, + 0.36276754492568164, + 0.0, + ], + linf=[ + 0.5797109945880677, + 0.4372991899547103, + 1.0906536287185835, + 0.0, + 1.0526758874956808, + 5.995204332975845e-15, + 1.5122922036932964, + 0.0, + ], + coverage_override=(maxiters = 6,)) + end - @trixi_testset "elixir_mhd_briowu_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_briowu_shock_tube.jl"), - l2 = [0.17477712356961989, 0.19489623595086944, 0.3596546157640463, 0.0, 0.3723215736814466, 1.2060075775846403e-15, 0.36276754492568164, 0.0], - linf = [0.5797109945880677, 0.4372991899547103, 1.0906536287185835, 0.0, 1.0526758874956808, 5.995204332975845e-15, 1.5122922036932964, 0.0], - coverage_override = (maxiters=6,)) - end + @trixi_testset "elixir_mhd_torrilhon_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"), + l2=[ + 0.45700904847931145, + 0.4792535936512035, + 0.340651203521865, + 0.4478034694296928, + 0.9204708961093411, + 1.3216517820475193e-16, + 0.28897419402047725, + 0.25521206483145126, + ], + linf=[ + 1.2185238171352286, + 0.8913202384963431, + 0.8488793580488431, + 0.973083603686, + 1.660723397705417, + 2.220446049250313e-16, + 0.6874726847741993, + 0.65536978110274, + ]) + end - @trixi_testset "elixir_mhd_torrilhon_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"), - l2 = [0.45700904847931145, 0.4792535936512035, 0.340651203521865, 0.4478034694296928, 0.9204708961093411, 1.3216517820475193e-16, 0.28897419402047725, 0.25521206483145126], - linf = [1.2185238171352286, 0.8913202384963431, 0.8488793580488431, 0.973083603686, 1.660723397705417, 2.220446049250313e-16, 0.6874726847741993, 0.65536978110274]) - end + @trixi_testset "elixir_mhd_ryujones_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ryujones_shock_tube.jl"), + l2=[ + 0.23469781891518154, + 0.3916675299696121, + 0.08245195301016353, + 0.1745346945706147, + 0.9606363432904367, + 6.608258910237605e-17, + 0.21542929107153735, + 0.10705457908737925, + ], + linf=[ + 0.6447951791685409, + 0.9461857095377463, + 0.35074627554617605, + 0.8515177411529542, + 2.0770652030507053, + 1.1102230246251565e-16, + 0.49670855513788204, + 0.24830199967863564, + ], + tspan=(0.0, 0.1)) + end - @trixi_testset "elixir_mhd_ryujones_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ryujones_shock_tube.jl"), - l2 = [0.23469781891518154, 0.3916675299696121, 0.08245195301016353, 0.1745346945706147, 0.9606363432904367, 6.608258910237605e-17, 0.21542929107153735, 0.10705457908737925], - linf = [0.6447951791685409, 0.9461857095377463, 0.35074627554617605, 0.8515177411529542, 2.0770652030507053, 1.1102230246251565e-16, 0.49670855513788204, 0.24830199967863564], - tspan = (0.0, 0.1)) - end + @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), + l2=[ + 1.01126210e+00, + 8.27157902e+00, + 1.30882545e+00, + 0.00000000e+00, + 5.21930435e+01, + 6.56538824e-16, + 1.01022340e+00, + 0.00000000e+00, + ], + linf=[ + 2.87172004e+00, + 2.26438057e+01, + 4.16672442e+00, + 0.00000000e+00, + 1.35152372e+02, + 3.44169138e-15, + 2.83556069e+00, + 0.00000000e+00, + ], + tspan=(0.0, 0.2), + coverage_override=(maxiters = 6,)) + end - @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - l2 = [1.01126210e+00, 8.27157902e+00, 1.30882545e+00, 0.00000000e+00, 5.21930435e+01, 6.56538824e-16, 1.01022340e+00, 0.00000000e+00], - linf = [2.87172004e+00, 2.26438057e+01, 4.16672442e+00, 0.00000000e+00, 1.35152372e+02, 3.44169138e-15, 2.83556069e+00, 0.00000000e+00], - tspan = (0.0, 0.2), - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin - # Include this elixir to make `initial_condition_shu_osher_shock_tube_flipped` available, which is used below - trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), tspan=(0.0, 0.0)) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - l2 = [1.01539817e+00, 8.29625810e+00, 1.29548008e+00, 0.00000000e+00, 5.23565514e+01, 3.18641825e-16, 1.00485291e+00, 0.00000000e+00], - linf = [2.92876280e+00, 2.28341581e+01, 4.11643561e+00, 0.00000000e+00, 1.36966213e+02, 1.55431223e-15, 2.80548864e+00, 0.00000000e+00], - initial_condition = initial_condition_shu_osher_shock_tube_flipped, - boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped), - tspan = (0.0, 0.2), - coverage_override = (maxiters=6,)) - end + @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin + # Include this elixir to make `initial_condition_shu_osher_shock_tube_flipped` available, which is used below + trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), + tspan = (0.0, 0.0)) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), + l2=[ + 1.01539817e+00, + 8.29625810e+00, + 1.29548008e+00, + 0.00000000e+00, + 5.23565514e+01, + 3.18641825e-16, + 1.00485291e+00, + 0.00000000e+00, + ], + linf=[ + 2.92876280e+00, + 2.28341581e+01, + 4.11643561e+00, + 0.00000000e+00, + 1.36966213e+02, + 1.55431223e-15, + 2.80548864e+00, + 0.00000000e+00, + ], + initial_condition=initial_condition_shu_osher_shock_tube_flipped, + boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped), + tspan=(0.0, 0.2), + coverage_override=(maxiters = 6,)) + end end end # module diff --git a/test/test_tree_1d_mhdmulti.jl b/test/test_tree_1d_mhdmulti.jl index 5214ed26d38..61d85b58f7e 100644 --- a/test/test_tree_1d_mhdmulti.jl +++ b/test/test_tree_1d_mhdmulti.jl @@ -8,59 +8,77 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "MHD Multicomponent" begin + @trixi_testset "elixir_mhdmulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2=[0.08166807325620999, 0.054659228513541616, + 0.054659228513541616, 0.15578125987042812, + 4.130462730494e-17, 0.054652588871500665, + 0.054652588871500665, 0.008307405499637766, + 0.01661481099927553, 0.03322962199855106], + linf=[0.19019207422649645, 0.10059813883022888, + 0.10059813883022888, 0.4407925743107146, + 1.1102230246251565e-16, 0.10528911365809623, + 0.10528911365809623, 0.01737901809766182, + 0.03475803619532364, 0.06951607239064728]) + end - @trixi_testset "elixir_mhdmulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.08166807325620999, 0.054659228513541616, 0.054659228513541616, 0.15578125987042812, - 4.130462730494e-17, 0.054652588871500665, 0.054652588871500665, 0.008307405499637766, - 0.01661481099927553, 0.03322962199855106], - linf = [0.19019207422649645, 0.10059813883022888, 0.10059813883022888, 0.4407925743107146, - 1.1102230246251565e-16, 0.10528911365809623, 0.10528911365809623, 0.01737901809766182, - 0.03475803619532364, 0.06951607239064728]) - end - - @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.08151404166186461, 0.054640238302693274, 0.054640238302693274, 0.15536125426328573, - 4.130462730494e-17, 0.054665489963920275, 0.054665489963920275, 0.008308349501359825, - 0.01661669900271965, 0.0332333980054393], - linf = [0.1824424257860952, 0.09734687137001484, 0.09734687137001484, 0.4243089502087325, - 1.1102230246251565e-16, 0.09558639591092555, 0.09558639591092555, 0.017364773041550624, - 0.03472954608310125, 0.0694590921662025], - volume_flux = flux_derigs_etal) - end - - @trixi_testset "elixir_mhdmulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), - l2 = [0.07994082660130175, 0.053940174914031976, 0.053940174914031976, 0.15165513559250643, - 4.130462730494e-17, 0.05363207135290325, 0.05363207135290325, 0.008258265884659555, - 0.01651653176931911, 0.03303306353863822], - linf = [0.14101014428198477, 0.07762441749521025, 0.07762441749521025, 0.3381334453289866, - 1.1102230246251565e-16, 0.07003646400675223, 0.07003646400675223, 0.014962483760600165, - 0.02992496752120033, 0.05984993504240066]) - end + @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2=[0.08151404166186461, 0.054640238302693274, + 0.054640238302693274, 0.15536125426328573, + 4.130462730494e-17, 0.054665489963920275, + 0.054665489963920275, 0.008308349501359825, + 0.01661669900271965, 0.0332333980054393], + linf=[0.1824424257860952, 0.09734687137001484, + 0.09734687137001484, 0.4243089502087325, + 1.1102230246251565e-16, 0.09558639591092555, + 0.09558639591092555, 0.017364773041550624, + 0.03472954608310125, 0.0694590921662025], + volume_flux=flux_derigs_etal) + end - @trixi_testset "elixir_mhdmulti_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), - l2 = [1.7337265267786785e-5, 0.00032976971029271364, 0.0003297697102926479, 6.194071694759044e-5, - 4.130462730494001e-17, 0.00032596825025664136, 0.0003259682502567132, 2.5467510126885455e-5, - 5.093502025377091e-5, 0.00010187004050754182], - linf = [3.877554303711845e-5, 0.0012437848638874956, 0.0012437848638876898, 0.00016431262020277781, - 1.1102230246251565e-16, 0.0012443734922607112, 0.001244373492260704, 5.691007974162332e-5, - 0.00011382015948324664, 0.00022764031896649328]) + @trixi_testset "elixir_mhdmulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), + l2=[0.07994082660130175, 0.053940174914031976, + 0.053940174914031976, 0.15165513559250643, + 4.130462730494e-17, 0.05363207135290325, + 0.05363207135290325, 0.008258265884659555, + 0.01651653176931911, 0.03303306353863822], + linf=[0.14101014428198477, 0.07762441749521025, + 0.07762441749521025, 0.3381334453289866, + 1.1102230246251565e-16, 0.07003646400675223, + 0.07003646400675223, 0.014962483760600165, + 0.02992496752120033, 0.05984993504240066]) end - @trixi_testset "elixir_mhdmulti_briowu_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_briowu_shock_tube.jl"), - l2 = [0.1877830835572639, 0.3455841730726793, 0.0, 0.35413123388836687, - 8.745556626531982e-16, 0.3629920109231055, 0.0, 0.05329005553971236, - 0.10658011107942472], - linf = [0.4288187627971754, 1.0386547815614993, 0.0, 0.9541678878162702, - 5.773159728050814e-15, 1.4595119339458051, 0.0, 0.18201910908829552, - 0.36403821817659104], - coverage_override = (maxiters=6,)) + @trixi_testset "elixir_mhdmulti_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), + l2=[1.7337265267786785e-5, 0.00032976971029271364, + 0.0003297697102926479, 6.194071694759044e-5, + 4.130462730494001e-17, 0.00032596825025664136, + 0.0003259682502567132, 2.5467510126885455e-5, + 5.093502025377091e-5, 0.00010187004050754182], + linf=[3.877554303711845e-5, 0.0012437848638874956, + 0.0012437848638876898, 0.00016431262020277781, + 1.1102230246251565e-16, 0.0012443734922607112, + 0.001244373492260704, 5.691007974162332e-5, + 0.00011382015948324664, 0.00022764031896649328]) end + @trixi_testset "elixir_mhdmulti_briowu_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_briowu_shock_tube.jl"), + l2=[0.1877830835572639, 0.3455841730726793, 0.0, + 0.35413123388836687, + 8.745556626531982e-16, 0.3629920109231055, 0.0, + 0.05329005553971236, + 0.10658011107942472], + linf=[0.4288187627971754, 1.0386547815614993, 0.0, + 0.9541678878162702, + 5.773159728050814e-15, 1.4595119339458051, 0.0, + 0.18201910908829552, + 0.36403821817659104], + coverage_override=(maxiters = 6,)) + end end end # module diff --git a/test/test_tree_1d_shallowwater.jl b/test/test_tree_1d_shallowwater.jl index c66260c0018..b972def59dc 100644 --- a/test/test_tree_1d_shallowwater.jl +++ b/test/test_tree_1d_shallowwater.jl @@ -8,86 +8,169 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Shallow Water" begin - @trixi_testset "elixir_shallowwater_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2 = [0.244729018751225, 0.8583565222389505, 0.07330427577586297], - linf = [2.1635021283528504, 3.8717508164234453, 1.7711213427919539], - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), + l2=[0.244729018751225, 0.8583565222389505, 0.07330427577586297], + linf=[ + 2.1635021283528504, + 3.8717508164234453, + 1.7711213427919539, + ], + tspan=(0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_ec.jl with initial_condition_weak_blast_wave" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2 = [0.39464782107209717, 2.03880864210846, 4.1623084150546725e-10], - linf = [0.778905801278281, 3.2409883402608273, 7.419800190922032e-10], - initial_condition=initial_condition_weak_blast_wave, - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_ec.jl with initial_condition_weak_blast_wave" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), + l2=[ + 0.39464782107209717, + 2.03880864210846, + 4.1623084150546725e-10, + ], + linf=[ + 0.778905801278281, + 3.2409883402608273, + 7.419800190922032e-10, + ], + initial_condition=initial_condition_weak_blast_wave, + tspan=(0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.10416666834254829, 1.4352935256803184e-14, 0.10416666834254838], - linf = [1.9999999999999996, 3.248036646353028e-14, 2.0], - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), + l2=[ + 0.10416666834254829, + 1.4352935256803184e-14, + 0.10416666834254838, + ], + linf=[1.9999999999999996, 3.248036646353028e-14, 2.0], + tspan=(0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.10416666834254835, 1.1891029971551825e-14, 0.10416666834254838], - linf = [2.0000000000000018, 2.4019608337954543e-14, 2.0], - surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), + l2=[ + 0.10416666834254835, + 1.1891029971551825e-14, + 0.10416666834254838, + ], + linf=[2.0000000000000018, 2.4019608337954543e-14, 2.0], + surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0022363707373868713, 0.01576799981934617, 4.436491725585346e-5], - linf = [0.00893601803417754, 0.05939797350246456, 9.098379777405796e-5], - tspan = (0.0, 0.025)) - end + @trixi_testset "elixir_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2=[ + 0.0022363707373868713, + 0.01576799981934617, + 4.436491725585346e-5, + ], + linf=[ + 0.00893601803417754, + 0.05939797350246456, + 9.098379777405796e-5, + ], + tspan=(0.0, 0.025)) + end - @trixi_testset "elixir_shallowwater_source_terms.jl with flux_hll" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0022758146627220154, 0.015864082886204556, 4.436491725585346e-5], - linf = [0.008457195427364006, 0.057201667446161064, 9.098379777405796e-5], - tspan = (0.0, 0.025), surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal)) - end + @trixi_testset "elixir_shallowwater_source_terms.jl with flux_hll" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2=[ + 0.0022758146627220154, + 0.015864082886204556, + 4.436491725585346e-5, + ], + linf=[ + 0.008457195427364006, + 0.057201667446161064, + 9.098379777405796e-5, + ], + tspan=(0.0, 0.025), + surface_flux=(FluxHLL(min_max_speed_naive), + flux_nonconservative_fjordholm_etal)) + end - @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), - l2 = [0.0022851099219788917, 0.01560453773635554, 4.43649172558535e-5], - linf = [0.008934615705174398, 0.059403169140869405, 9.098379777405796e-5], - tspan = (0.0, 0.025)) - end + @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_source_terms_dirichlet.jl"), + l2=[ + 0.0022851099219788917, + 0.01560453773635554, + 4.43649172558535e-5, + ], + linf=[ + 0.008934615705174398, + 0.059403169140869405, + 9.098379777405796e-5, + ], + tspan=(0.0, 0.025)) + end - @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), - l2 = [0.0022956052733432287, 0.015540053559855601, 4.43649172558535e-5], - linf = [0.008460440313118323, 0.05720939349382359, 9.098379777405796e-5], - surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.025)) - end + @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_source_terms_dirichlet.jl"), + l2=[ + 0.0022956052733432287, + 0.015540053559855601, + 4.43649172558535e-5, + ], + linf=[ + 0.008460440313118323, + 0.05720939349382359, + 9.098379777405796e-5, + ], + surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.025)) + end - @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with Dirichlet boundary" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_nonperiodic.jl"), - l2 = [1.725964362045055e-8, 5.0427180314307505e-16, 1.7259643530442137e-8], - linf = [3.844551077492042e-8, 3.469453422316143e-15, 3.844551077492042e-8], - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with Dirichlet boundary" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_nonperiodic.jl"), + l2=[ + 1.725964362045055e-8, + 5.0427180314307505e-16, + 1.7259643530442137e-8, + ], + linf=[ + 3.844551077492042e-8, + 3.469453422316143e-15, + 3.844551077492042e-8, + ], + tspan=(0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_nonperiodic.jl"), - l2 = [1.7259643614361866e-8, 3.5519018243195145e-16, 1.7259643530442137e-8], - linf = [3.844551010878661e-8, 9.846474508971374e-16, 3.844551077492042e-8], - tspan = (0.0, 0.25), - boundary_condition = boundary_condition_slip_wall) - end + @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_nonperiodic.jl"), + l2=[ + 1.7259643614361866e-8, + 3.5519018243195145e-16, + 1.7259643530442137e-8, + ], + linf=[ + 3.844551010878661e-8, + 9.846474508971374e-16, + 3.844551077492042e-8, + ], + tspan=(0.0, 0.25), + boundary_condition=boundary_condition_slip_wall) + end - @trixi_testset "elixir_shallowwater_shock_capturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_shock_capturing.jl"), - l2 = [0.07424140641160326, 0.2148642632748155, 0.0372579849000542], - linf = [1.1209754279344226, 1.3230788645853582, 0.8646939843534251], - tspan = (0.0, 0.05)) - end + @trixi_testset "elixir_shallowwater_shock_capturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_shock_capturing.jl"), + l2=[0.07424140641160326, 0.2148642632748155, 0.0372579849000542], + linf=[ + 1.1209754279344226, + 1.3230788645853582, + 0.8646939843534251, + ], + tspan=(0.0, 0.05)) + end end end # module diff --git a/test/test_tree_1d_shallowwater_twolayer.jl b/test/test_tree_1d_shallowwater_twolayer.jl index 0d8a83806f9..ac5ae500afc 100644 --- a/test/test_tree_1d_shallowwater_twolayer.jl +++ b/test/test_tree_1d_shallowwater_twolayer.jl @@ -8,43 +8,61 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Shallow Water Two layer" begin - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.0050681532925156945, 0.002089013899370176, 0.005105544300292713, 0.002526442122643306, - 0.0004744186597732706], - linf = [0.022256679217306008, 0.005421833004652266, 0.02233993939574197, 0.008765261497422516, - 0.0008992474511784199], - tspan = (0.0, 0.25)) - end - - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.0027681377074701345, 0.0018007543202559165, 0.0028036917433720576, - 0.0013980358596935737, 0.0004744186597732706], - linf = [0.005699303919826093, 0.006432952918256296, 0.0058507082844360125, 0.002717615543961216, - 0.0008992474511784199], - surface_flux=(flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - end - - @trixi_testset "elixir_shallowwater_twolayer_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_well_balanced.jl"), - l2 = [8.949288784402005e-16, 4.0636427176237915e-17, 0.001002881985401548, - 2.133351105037203e-16, 0.0010028819854016578], - linf = [2.6229018956769323e-15, 1.878451903240623e-16, 0.005119880996670156, - 8.003199803957679e-16, 0.005119880996670666], - tspan = (0.0, 0.25)) - end - - @trixi_testset "elixir_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_dam_break.jl"), - l2 = [0.10010269243463918, 0.5668733957648654, 0.08759617327649398, - 0.4538443183566172, 0.013638618139749523], - linf = [0.5854202777756559, 2.1278930820498934, 0.5193686074348809, 1.8071213168086229, 0.5], - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.0050681532925156945, 0.002089013899370176, + 0.005105544300292713, 0.002526442122643306, + 0.0004744186597732706], + linf=[0.022256679217306008, 0.005421833004652266, + 0.02233993939574197, 0.008765261497422516, + 0.0008992474511784199], + tspan=(0.0, 0.25)) + end + @trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.0027681377074701345, 0.0018007543202559165, + 0.0028036917433720576, + 0.0013980358596935737, 0.0004744186597732706], + linf=[0.005699303919826093, 0.006432952918256296, + 0.0058507082844360125, 0.002717615543961216, + 0.0008992474511784199], + surface_flux=(flux_es_fjordholm_etal, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + end + + @trixi_testset "elixir_shallowwater_twolayer_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_well_balanced.jl"), + l2=[8.949288784402005e-16, 4.0636427176237915e-17, + 0.001002881985401548, + 2.133351105037203e-16, 0.0010028819854016578], + linf=[2.6229018956769323e-15, 1.878451903240623e-16, + 0.005119880996670156, + 8.003199803957679e-16, 0.005119880996670666], + tspan=(0.0, 0.25)) + end + + @trixi_testset "elixir_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_dam_break.jl"), + l2=[0.10010269243463918, 0.5668733957648654, + 0.08759617327649398, + 0.4538443183566172, 0.013638618139749523], + linf=[ + 0.5854202777756559, + 2.1278930820498934, + 0.5193686074348809, + 1.8071213168086229, + 0.5, + ], + surface_flux=(flux_lax_friedrichs, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + end end end # module diff --git a/test/test_tree_2d_acoustics.jl b/test/test_tree_2d_acoustics.jl index b443573e3ac..1bb3521569b 100644 --- a/test/test_tree_2d_acoustics.jl +++ b/test/test_tree_2d_acoustics.jl @@ -8,40 +8,95 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Acoustic Perturbation" begin - @trixi_testset "elixir_acoustics_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_convergence.jl"), - l2 = [0.0019921138796370834, 0.002090394698052287, 0.0006091925854593805, 0.0, 0.0, 0.0, 0.0], - linf = [0.00769282588065634, 0.008276649669227254, 0.004196479023954813, 0.0, 0.0, 0.0, 0.0]) - end - - @trixi_testset "elixir_acoustics_gauss.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss.jl"), - l2 = [0.08005276517890283, 0.08005276517890268, 0.4187202920734123, 0.0, 0.0, 0.0, 0.0], - linf = [0.17261097190220992, 0.17261097190220973, 1.13601894068238, 0.0, 0.0, 0.0, 0.0]) - end - - @trixi_testset "elixir_acoustics_gaussian_source.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gaussian_source.jl"), - l2 = [0.004296394903650806, 0.004241280404758938, 0.006269684906035964, 0.0, 0.0, 0.0, 0.0], - linf = [0.03970270697049378, 0.04151096349298151, 0.0640019829058819, 0.0, 0.0, 0.0, 0.0]) - end - - @trixi_testset "elixir_acoustics_gauss_wall.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss_wall.jl"), - l2 = [0.019419398248465843, 0.019510701017551826, 0.04818246051887614, - 7.382060834820337e-17, 0.0, 1.4764121669640674e-16, 1.4764121669640674e-16], - linf = [0.18193631937316496, 0.1877464607867628, 1.0355388011792845, - 2.220446049250313e-16, 0.0, 4.440892098500626e-16, 4.440892098500626e-16]) - end - - @trixi_testset "elixir_acoustics_monopole.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_monopole.jl"), - l2 = [0.006816790293009947, 0.0065068948357351625, 0.008724512056168938, - 0.0009894398191644543, 0.0, 7.144325530679576e-17, 7.144325530679576e-17], - linf = [1.000633375007386, 0.5599788929862504, 0.5738432957070382, - 0.015590137026938428, 0.0, 2.220446049250313e-16, 2.220446049250313e-16], - maxiters=50) - end + @trixi_testset "elixir_acoustics_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_convergence.jl"), + l2=[ + 0.0019921138796370834, + 0.002090394698052287, + 0.0006091925854593805, + 0.0, + 0.0, + 0.0, + 0.0, + ], + linf=[ + 0.00769282588065634, + 0.008276649669227254, + 0.004196479023954813, + 0.0, + 0.0, + 0.0, + 0.0, + ]) + end + + @trixi_testset "elixir_acoustics_gauss.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss.jl"), + l2=[ + 0.08005276517890283, + 0.08005276517890268, + 0.4187202920734123, + 0.0, + 0.0, + 0.0, + 0.0, + ], + linf=[ + 0.17261097190220992, + 0.17261097190220973, + 1.13601894068238, + 0.0, + 0.0, + 0.0, + 0.0, + ]) + end + + @trixi_testset "elixir_acoustics_gaussian_source.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gaussian_source.jl"), + l2=[ + 0.004296394903650806, + 0.004241280404758938, + 0.006269684906035964, + 0.0, + 0.0, + 0.0, + 0.0, + ], + linf=[ + 0.03970270697049378, + 0.04151096349298151, + 0.0640019829058819, + 0.0, + 0.0, + 0.0, + 0.0, + ]) + end + + @trixi_testset "elixir_acoustics_gauss_wall.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss_wall.jl"), + l2=[0.019419398248465843, 0.019510701017551826, + 0.04818246051887614, + 7.382060834820337e-17, 0.0, 1.4764121669640674e-16, + 1.4764121669640674e-16], + linf=[0.18193631937316496, 0.1877464607867628, + 1.0355388011792845, + 2.220446049250313e-16, 0.0, 4.440892098500626e-16, + 4.440892098500626e-16]) + end + + @trixi_testset "elixir_acoustics_monopole.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_monopole.jl"), + l2=[0.006816790293009947, 0.0065068948357351625, + 0.008724512056168938, + 0.0009894398191644543, 0.0, 7.144325530679576e-17, + 7.144325530679576e-17], + linf=[1.000633375007386, 0.5599788929862504, 0.5738432957070382, + 0.015590137026938428, 0.0, 2.220446049250313e-16, + 2.220446049250313e-16], + maxiters=50) + end end -end # module \ No newline at end of file +end # module diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index 973d0caf88b..3fae6efaa42 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -8,198 +8,199 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5], - # Let the small basic test run to the end - coverage_override = (maxiters=10^5,)) - end - - @trixi_testset "elixir_advection_extended.jl with polydeg=1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.02134571266411136], - linf = [0.04347734797775926], - polydeg=1) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [7.81674284320524e-6], - linf = [6.314906965243505e-5]) - end - - @trixi_testset "elixir_advection_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [0.0015188466707237375], - linf = [0.008446655719187679]) - - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [4.913300828257469e-5], - linf = [0.00045263895394385967], - # Let this test run to the end to cover some AMR code - coverage_override = (maxiters=10^5,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [3.2207388565869075e-5], - linf = [0.0007508059772436404], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), - l2 = [4.949660644033807e-5], - linf = [0.0004867846262313763], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_visualization.jl" begin - # To make CI tests work, disable showing a plot window with the GR backend of the Plots package - # Xref: https://github.com/jheinen/GR.jl/issues/278 - # Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103 - if !isinteractive() - restore = get(ENV, "GKSwstype", nothing) - ENV["GKSwstype"] = "100" - end - - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_visualization.jl"), - l2 = [0.0007225529919720868], - linf = [0.005954447875428925], - coverage_override = (maxiters=6,)) - - # Restore GKSwstype to previous value (if it was set) - if !isinteractive() - if isnothing(restore) - delete!(ENV, "GKSwstype") - else - ENV["GKSwstype"] = restore - end - end - end - - @trixi_testset "elixir_advection_timeintegration.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [2.4976030518356626e-5], - linf = [0.0005531580316338533], - # Let this test terminate by time instead of maxiters to cover some lines - # in time_integration/methods_2N.jl - coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) - end - - @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [2.5314747030031457e-5], - linf = [0.0005437136621948904], - ode_algorithm=Trixi.CarpenterKennedy2N43(), - cfl = 1.0) - end - - @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [1.2135350502911197e-5], - linf = [9.999985420537649e-5], - ode_algorithm=Trixi.CarpenterKennedy2N43(), - cfl = 1.0, - maxiters = 1) - end - - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [2.4976673477385313e-5], - linf = [0.0005534166916640881], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94()) - end - - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [3.667894656471403e-5], - linf = [0.0005799465470165757], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), - cfl = 1.0) - end - - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [1.2198725469737875e-5], - linf = [9.977247740793407e-5], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), - cfl = 1.0, - maxiters = 1) - end - - @trixi_testset "elixir_advection_callbacks.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_callbacks.jl"), - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5], + # Let the small basic test run to the end + coverage_override=(maxiters = 10^5,)) + end + + @trixi_testset "elixir_advection_extended.jl with polydeg=1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[0.02134571266411136], + linf=[0.04347734797775926], + polydeg=1) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[7.81674284320524e-6], + linf=[6.314906965243505e-5]) + end + + @trixi_testset "elixir_advection_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[0.0015188466707237375], + linf=[0.008446655719187679]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[4.913300828257469e-5], + linf=[0.00045263895394385967], + # Let this test run to the end to cover some AMR code + coverage_override=(maxiters = 10^5,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[3.2207388565869075e-5], + linf=[0.0007508059772436404], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_visualization.jl" begin + # To make CI tests work, disable showing a plot window with the GR backend of the Plots package + # Xref: https://github.com/jheinen/GR.jl/issues/278 + # Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103 + if !isinteractive() + restore = get(ENV, "GKSwstype", nothing) + ENV["GKSwstype"] = "100" + end + + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_visualization.jl"), + l2=[0.0007225529919720868], + linf=[0.005954447875428925], + coverage_override=(maxiters = 6,)) + + # Restore GKSwstype to previous value (if it was set) + if !isinteractive() + if isnothing(restore) + delete!(ENV, "GKSwstype") + else + ENV["GKSwstype"] = restore + end + end + end + + @trixi_testset "elixir_advection_timeintegration.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2=[2.4976030518356626e-5], + linf=[0.0005531580316338533], + # Let this test terminate by time instead of maxiters to cover some lines + # in time_integration/methods_2N.jl + coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) + end + + @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2=[2.5314747030031457e-5], + linf=[0.0005437136621948904], + ode_algorithm=Trixi.CarpenterKennedy2N43(), + cfl=1.0) + end + + @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2=[1.2135350502911197e-5], + linf=[9.999985420537649e-5], + ode_algorithm=Trixi.CarpenterKennedy2N43(), + cfl=1.0, + maxiters=1) + end + + @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2=[2.4976673477385313e-5], + linf=[0.0005534166916640881], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94()) + end + + @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2=[3.667894656471403e-5], + linf=[0.0005799465470165757], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), + cfl=1.0) + end + + @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2=[1.2198725469737875e-5], + linf=[9.977247740793407e-5], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), + cfl=1.0, + maxiters=1) + end + + @trixi_testset "elixir_advection_callbacks.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_callbacks.jl"), + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + end end # Coverage test for all initial conditions @testset "Linear scalar advection: Tests for initial conditions" begin - # Linear scalar advection - @trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.0001420618061089383], - linf = [0.0007140570281718439], - maxiters = 1, - initial_condition = Trixi.initial_condition_sin_sin) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [3.8302867746057483e-16], - linf = [1.3322676295501878e-15], - maxiters = 1, - initial_condition = initial_condition_constant) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x_y" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [2.7276160570381226e-16], - linf = [5.10702591327572e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_x_y, - boundary_conditions = Trixi.boundary_condition_linear_x_y, - periodicity=false) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.5121648229368207e-16], - linf = [1.3322676295501878e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_x, - boundary_conditions = Trixi.boundary_condition_linear_x, - periodicity=false) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_y" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.714292614252588e-16], - linf = [2.220446049250313e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_y, - boundary_conditions = Trixi.boundary_condition_linear_y, - periodicity=false) - end + # Linear scalar advection + @trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[0.0001420618061089383], + linf=[0.0007140570281718439], + maxiters=1, + initial_condition=Trixi.initial_condition_sin_sin) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[3.8302867746057483e-16], + linf=[1.3322676295501878e-15], + maxiters=1, + initial_condition=initial_condition_constant) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x_y" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[2.7276160570381226e-16], + linf=[5.10702591327572e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_x_y, + boundary_conditions=Trixi.boundary_condition_linear_x_y, + periodicity=false) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[1.5121648229368207e-16], + linf=[1.3322676295501878e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_x, + boundary_conditions=Trixi.boundary_condition_linear_x, + periodicity=false) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_y" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[1.714292614252588e-16], + linf=[2.220446049250313e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_y, + boundary_conditions=Trixi.boundary_condition_linear_y, + periodicity=false) + end end end # module diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 6de380288db..443fe8d818d 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -8,282 +8,647 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5]) - end - - @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2 = [0.026440292358506527, 0.013245905852168414, 0.013245905852168479, 0.03912520302609374], - linf = [0.042130817806361964, 0.022685499230187034, 0.022685499230187922, 0.06999771202145322]) - end - - @trixi_testset "elixir_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [0.0010600778457964775, 0.00010600778457634275, 0.00021201556915872665, 2.650194614399671e-5], - linf = [0.006614198043413566, 0.0006614198043973507, 0.001322839608837334, 0.000165354951256802], - tspan = (0.0, 0.5)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], - linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], - linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) - end - - @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03481471610306124, 0.027694280613944234, 0.027697905866996532, 0.12932052501462554], - linf = [0.31052098400669004, 0.3481295959664616, 0.34807152194137336, 1.1044947556170719], - maxiters = 10, - surface_flux = flux_kennedy_gruber, - volume_flux = flux_kennedy_gruber) - end - - @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03481122603050542, 0.027662840593087695, 0.027665658732350273, 0.12927455860656786], - linf = [0.3110089578739834, 0.34888111987218107, 0.3488278669826813, 1.1056349046774305], - maxiters = 10, - surface_flux = flux_chandrashekar, - volume_flux = flux_chandrashekar) - end - - @trixi_testset "elixir_euler_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2 = [0.05380629130119074, 0.04696798008325309, 0.04697067787841479, 0.19687382235494968], - linf = [0.18527440131928286, 0.2404798030563736, 0.23269573860381076, 0.6874012187446894]) - end - - @trixi_testset "elixir_euler_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), - l2 = [0.14170569763947993, 0.11647068900798814, 0.11647072556898294, 0.3391989213659599], - linf = [1.6544204510794196, 1.35194638484646, 1.3519463848472744, 1.831228461662809], - maxiters = 30) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), - l2 = [0.4758794741390833, 0.21045415565179362, 0.21045325630191866, 0.7022517958549878], - linf = [1.710832148442441, 0.9711663578827681, 0.9703787873632452, 2.9619758810532653], - initial_refinement_level = 4, - maxiters = 50) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2 = [0.472445774440313, 0.2090782039442978, 0.20885558673697927, 0.700569533591275], - linf = [1.7066492792835155, 0.9856122336679919, 0.9784316656930644, 2.9372978989672873], - initial_refinement_level = 4, - maxiters = 50) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl with mortars" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2 = [0.016486406327766923, 0.03097329879894433, 0.03101012918167401, 0.15157175775429868], - linf = [0.27688647744873407, 0.5653724536715139, 0.565695523611447, 2.513047611639946], - refinement_patches=( - (type="box", coordinates_min=(-0.25, -0.25), coordinates_max=(0.25, 0.25)), - (type="box", coordinates_min=(-0.125, -0.125), coordinates_max=(0.125, 0.125)),), - initial_refinement_level = 4, - maxiters = 5) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_cnn.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_cnn.jl"), - l2 = [0.4795795496408325, 0.2125148972465021, 0.21311260934645868, 0.7033388737692883], - linf = [1.8295385992182336, 0.9687795218482794, 0.9616033072376108, 2.9513245978047133], - initial_refinement_level = 4, - maxiters = 50, - rtol = 1.0e-7) - end - - @trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_pure_fv.jl"), - l2 = [0.39957047631960346, 0.21006912294983154, 0.21006903549932, 0.6280328163981136], - linf = [2.20417889887697, 1.5487238480003327, 1.5486788679247812, 2.4656795949035857], - tspan = (0.0, 0.5), - # Let this test run longer to cover some lines in flux_hllc - coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) - end - - @trixi_testset "elixir_euler_blast_wave_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), - l2 = [0.6835576416907511, 0.2839963955262972, 0.28399565983676, 0.7229447806293277], - linf = [3.0969614882801393, 1.7967947300740248, 1.7967508302506658, 3.040149575567518], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [0.4866953770742574, 0.1673477470091984, 0.16734774700934, 0.6184367248923149], - linf = [2.6724832723962053, 1.2916089288910635, 1.2916089289001427, 6.474699399394252], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl"), - l2 = [0.0845430093623868, 0.09271459184623232, 0.09271459184623232, 0.4377291875101709], - linf = [1.3608553480069898, 1.6822884847136004, 1.6822884847135997, 4.220147414536653], - maxiters = 30, - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_positivity.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), - l2 = [0.48862067511841695, 0.16787541578869494, 0.16787541578869422, 0.6184319933114926], - linf = [2.6766520821013002, 1.2910938760258996, 1.2910938760258899, 6.473385481404865], - tspan = (0.0, 1.0), - coverage_override = (maxiters=3,)) - end - - @trixi_testset "elixir_euler_blob_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_mortar.jl"), - l2 = [0.22271619518391986, 0.6284824759323494, 0.24864213447943648, 2.9591811489995474], - linf = [9.15245400430106, 24.96562810334389, 10.388109127032374, 101.20581544156934], - tspan = (0.0, 0.5)) - end - - @trixi_testset "elixir_euler_blob_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_amr.jl"), - l2 = [0.2086261501910662, 1.2118352377894666, 0.10255333189606497, 5.296238138639236], - linf = [14.829071984498198, 74.12967742435727, 6.863554388300223, 303.58813147491134], - tspan = (0.0, 0.12), - # Let this test run longer to cover the ControllerThreeLevelCombined lines - coverage_override = (maxiters=10^5,)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl"), - l2 = [0.1057230211245312, 0.10621112311257341, 0.07260957505339989, 0.11178239111065721], - linf = [2.998719417992662, 2.1400285015556166, 1.1569648700415078, 1.8922492268110913], - tspan = (0.0, 0.1)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - l2 = [0.055691508271624536, 0.032986009333751655, 0.05224390923711999, 0.08009536362771563], - linf = [0.24043622527087494, 0.1660878796929941, 0.12355946691711608, 0.2694290787257758], - tspan = (0.0, 0.2)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_amr.jl"), - l2 = [0.05569452733654995, 0.033107109983417926, 0.05223609622852158, 0.08007777597488817], - linf = [0.2535807803900303, 0.17397028249895308, 0.12321616095649354, 0.269046666668995], - tspan = (0.0, 0.2), - coverage_override = (maxiters=2,)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl"), - # This stuff is experimental and annoying to test. In the future, we plan - # to move it to another repository. Thus, we save developer time right now - # and do not run these tests anymore. - # l2 = [0.0009823702998067061, 0.004943231496200673, 0.0048604522073091815, 0.00496983530893294], - # linf = [0.00855717053383187, 0.02087422420794427, 0.017121993783086185, 0.02720703869972585], - maxiters = 30, - coverage_override = (maxiters=2,)) - end - - @trixi_testset "elixir_euler_colliding_flow.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow.jl"), - l2 = [0.007237139090503349, 0.044887582765386916, 1.0453570959003603e-6, 0.6627307840935432], - linf = [0.19437260992446315, 0.5554343646648533, 5.943891455255412e-5, 15.188919846360125], - tspan = (0.0, 0.1)) - end - - @trixi_testset "elixir_euler_colliding_flow_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow_amr.jl"), - l2 = [0.006768801432802192, 0.032184992228603666, 6.923887797276484e-7, 0.6784222932398366], - linf = [0.2508663007713608, 0.4097017076529792, 0.0003528986458217968, 22.435474993016918], - tspan = (0.0, 0.1), - coverage_override = (maxiters=2,)) - end - - @trixi_testset "elixir_euler_astro_jet_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_astro_jet_amr.jl"), - l2 = [0.011338365293662804, 10.09743543555765, 0.00392429463200361, 4031.7811487690506], - linf = [3.3178633141984193, 2993.6445033486402, 8.031723414357423, 1.1918867260293828e6], - tspan = (0.0, 1.0e-7), - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [0.00013492249515826863, 0.006615696236378061, 0.006782108219800376, 0.016393831451740604], - linf = [0.0020782600954247776, 0.08150078921935999, 0.08663621974991986, 0.2829930622010579]) - end - - @trixi_testset "elixir_euler_vortex_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [0.0017208369388227673, 0.09628684992237334, 0.09620157717330868, 0.1758809552387432], - linf = [0.021869936355319086, 0.9956698009442038, 1.0002507727219028, 2.223249697515648]) - end - - @trixi_testset "elixir_euler_vortex_mortar_split.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_split.jl"), - l2 = [0.0017203323613648241, 0.09628962878682261, 0.09621241164155782, 0.17585995600340926], - linf = [0.021740570456931674, 0.9938841665880938, 1.004140123355135, 2.224108857746245]) - end - - @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), - l2 = [0.0017158367642679273, 0.09619888722871434, 0.09616432767924141, 0.17553381166255197], - linf = [0.021853862449723982, 0.9878047229255944, 0.9880191167111795, 2.2154030488035588]) - end - - @trixi_testset "elixir_euler_vortex_mortar_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_shockcapturing.jl"), - l2 = [0.0017203324051381415, 0.09628962899999398, 0.0962124115572114, 0.1758599596626405], - linf = [0.021740568112562086, 0.9938841624655501, 1.0041401179009877, 2.2241087041100798]) - end - - @trixi_testset "elixir_euler_vortex_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [5.051719943432265e-5, 0.0022574259317084747, 0.0021755998463189713, 0.004346492398617521], - linf = [0.0012880114865917447, 0.03857193149447702, 0.031090457959835893, 0.12125130332971423], - # Let this test run longer to cover some lines in the AMR indicator - coverage_override = (maxiters=10^5, tspan=(0.0, 10.5))) - end - - @trixi_testset "elixir_euler_ec.jl with boundary_condition_slip_wall" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03341239373099515, 0.026673245711492915, 0.026678871434568822, 0.12397486476145089], - linf = [0.3290981764688339, 0.3812055782309788, 0.3812041851225023, 1.168251216556933], - periodicity = false, boundary_conditions = boundary_condition_slip_wall, - cfl = 0.3, tspan = (0.0, 0.1)) # this test is sensitive to the CFL factor - end + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ]) + end + + @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), + l2=[ + 0.026440292358506527, + 0.013245905852168414, + 0.013245905852168479, + 0.03912520302609374, + ], + linf=[ + 0.042130817806361964, + 0.022685499230187034, + 0.022685499230187922, + 0.06999771202145322, + ]) + end + + @trixi_testset "elixir_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2=[ + 0.0010600778457964775, + 0.00010600778457634275, + 0.00021201556915872665, + 2.650194614399671e-5, + ], + linf=[ + 0.006614198043413566, + 0.0006614198043973507, + 0.001322839608837334, + 0.000165354951256802, + ], + tspan=(0.0, 0.5)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511766445e-6, + 2.318888155713922e-6, + 2.3188881557894307e-6, + 6.3327863238858925e-6, + ], + linf=[ + 1.498738264560373e-5, + 1.9182011928187137e-5, + 1.918201192685487e-5, + 6.0526717141407005e-5, + ]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.061751715597716854, + 0.05018223615408711, + 0.05018989446443463, + 0.225871559730513, + ], + linf=[ + 0.29347582879608825, + 0.31081249232844693, + 0.3107380389947736, + 1.0540358049885143, + ]) + end + + @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.03481471610306124, + 0.027694280613944234, + 0.027697905866996532, + 0.12932052501462554, + ], + linf=[ + 0.31052098400669004, + 0.3481295959664616, + 0.34807152194137336, + 1.1044947556170719, + ], + maxiters=10, + surface_flux=flux_kennedy_gruber, + volume_flux=flux_kennedy_gruber) + end + + @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.03481122603050542, + 0.027662840593087695, + 0.027665658732350273, + 0.12927455860656786, + ], + linf=[ + 0.3110089578739834, + 0.34888111987218107, + 0.3488278669826813, + 1.1056349046774305, + ], + maxiters=10, + surface_flux=flux_chandrashekar, + volume_flux=flux_chandrashekar) + end + + @trixi_testset "elixir_euler_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), + l2=[ + 0.05380629130119074, + 0.04696798008325309, + 0.04697067787841479, + 0.19687382235494968, + ], + linf=[ + 0.18527440131928286, + 0.2404798030563736, + 0.23269573860381076, + 0.6874012187446894, + ]) + end + + @trixi_testset "elixir_euler_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), + l2=[ + 0.14170569763947993, + 0.11647068900798814, + 0.11647072556898294, + 0.3391989213659599, + ], + linf=[ + 1.6544204510794196, + 1.35194638484646, + 1.3519463848472744, + 1.831228461662809, + ], + maxiters=30) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), + l2=[ + 0.4758794741390833, + 0.21045415565179362, + 0.21045325630191866, + 0.7022517958549878, + ], + linf=[ + 1.710832148442441, + 0.9711663578827681, + 0.9703787873632452, + 2.9619758810532653, + ], + initial_refinement_level=4, + maxiters=50) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2=[ + 0.472445774440313, + 0.2090782039442978, + 0.20885558673697927, + 0.700569533591275, + ], + linf=[ + 1.7066492792835155, + 0.9856122336679919, + 0.9784316656930644, + 2.9372978989672873, + ], + initial_refinement_level=4, + maxiters=50) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl with mortars" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2=[ + 0.016486406327766923, + 0.03097329879894433, + 0.03101012918167401, + 0.15157175775429868, + ], + linf=[ + 0.27688647744873407, + 0.5653724536715139, + 0.565695523611447, + 2.513047611639946, + ], + refinement_patches=((type = "box", + coordinates_min = (-0.25, -0.25), + coordinates_max = (0.25, 0.25)), + (type = "box", + coordinates_min = (-0.125, -0.125), + coordinates_max = (0.125, 0.125))), + initial_refinement_level=4, + maxiters=5) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_cnn.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_cnn.jl"), + l2=[ + 0.4795795496408325, + 0.2125148972465021, + 0.21311260934645868, + 0.7033388737692883, + ], + linf=[ + 1.8295385992182336, + 0.9687795218482794, + 0.9616033072376108, + 2.9513245978047133, + ], + initial_refinement_level=4, + maxiters=50, + rtol=1.0e-7) + end + + @trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_pure_fv.jl"), + l2=[ + 0.39957047631960346, + 0.21006912294983154, + 0.21006903549932, + 0.6280328163981136, + ], + linf=[ + 2.20417889887697, + 1.5487238480003327, + 1.5486788679247812, + 2.4656795949035857, + ], + tspan=(0.0, 0.5), + # Let this test run longer to cover some lines in flux_hllc + coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) + end + + @trixi_testset "elixir_euler_blast_wave_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), + l2=[ + 0.6835576416907511, + 0.2839963955262972, + 0.28399565983676, + 0.7229447806293277, + ], + linf=[ + 3.0969614882801393, + 1.7967947300740248, + 1.7967508302506658, + 3.040149575567518, + ], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2=[ + 0.4866953770742574, + 0.1673477470091984, + 0.16734774700934, + 0.6184367248923149, + ], + linf=[ + 2.6724832723962053, + 1.2916089288910635, + 1.2916089289001427, + 6.474699399394252, + ], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl"), + l2=[ + 0.0845430093623868, + 0.09271459184623232, + 0.09271459184623232, + 0.4377291875101709, + ], + linf=[ + 1.3608553480069898, + 1.6822884847136004, + 1.6822884847135997, + 4.220147414536653, + ], + maxiters=30, + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_positivity.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), + l2=[ + 0.48862067511841695, + 0.16787541578869494, + 0.16787541578869422, + 0.6184319933114926, + ], + linf=[ + 2.6766520821013002, + 1.2910938760258996, + 1.2910938760258899, + 6.473385481404865, + ], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 3,)) + end + + @trixi_testset "elixir_euler_blob_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_mortar.jl"), + l2=[ + 0.22271619518391986, + 0.6284824759323494, + 0.24864213447943648, + 2.9591811489995474, + ], + linf=[ + 9.15245400430106, + 24.96562810334389, + 10.388109127032374, + 101.20581544156934, + ], + tspan=(0.0, 0.5)) + end + + @trixi_testset "elixir_euler_blob_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_amr.jl"), + l2=[ + 0.2086261501910662, + 1.2118352377894666, + 0.10255333189606497, + 5.296238138639236, + ], + linf=[ + 14.829071984498198, + 74.12967742435727, + 6.863554388300223, + 303.58813147491134, + ], + tspan=(0.0, 0.12), + # Let this test run longer to cover the ControllerThreeLevelCombined lines + coverage_override=(maxiters = 10^5,)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl"), + l2=[ + 0.1057230211245312, + 0.10621112311257341, + 0.07260957505339989, + 0.11178239111065721, + ], + linf=[ + 2.998719417992662, + 2.1400285015556166, + 1.1569648700415078, + 1.8922492268110913, + ], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + l2=[ + 0.055691508271624536, + 0.032986009333751655, + 0.05224390923711999, + 0.08009536362771563, + ], + linf=[ + 0.24043622527087494, + 0.1660878796929941, + 0.12355946691711608, + 0.2694290787257758, + ], + tspan=(0.0, 0.2)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability_amr.jl"), + l2=[ + 0.05569452733654995, + 0.033107109983417926, + 0.05223609622852158, + 0.08007777597488817, + ], + linf=[ + 0.2535807803900303, + 0.17397028249895308, + 0.12321616095649354, + 0.269046666668995, + ], + tspan=(0.0, 0.2), + coverage_override=(maxiters = 2,)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl"), + # This stuff is experimental and annoying to test. In the future, we plan + # to move it to another repository. Thus, we save developer time right now + # and do not run these tests anymore. + # l2 = [0.0009823702998067061, 0.004943231496200673, 0.0048604522073091815, 0.00496983530893294], + # linf = [0.00855717053383187, 0.02087422420794427, 0.017121993783086185, 0.02720703869972585], + maxiters=30, + coverage_override=(maxiters = 2,)) + end + + @trixi_testset "elixir_euler_colliding_flow.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow.jl"), + l2=[ + 0.007237139090503349, + 0.044887582765386916, + 1.0453570959003603e-6, + 0.6627307840935432, + ], + linf=[ + 0.19437260992446315, + 0.5554343646648533, + 5.943891455255412e-5, + 15.188919846360125, + ], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_euler_colliding_flow_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow_amr.jl"), + l2=[ + 0.006768801432802192, + 0.032184992228603666, + 6.923887797276484e-7, + 0.6784222932398366, + ], + linf=[ + 0.2508663007713608, + 0.4097017076529792, + 0.0003528986458217968, + 22.435474993016918, + ], + tspan=(0.0, 0.1), + coverage_override=(maxiters = 2,)) + end + + @trixi_testset "elixir_euler_astro_jet_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_astro_jet_amr.jl"), + l2=[ + 0.011338365293662804, + 10.09743543555765, + 0.00392429463200361, + 4031.7811487690506, + ], + linf=[ + 3.3178633141984193, + 2993.6445033486402, + 8.031723414357423, + 1.1918867260293828e6, + ], + tspan=(0.0, 1.0e-7), + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 0.00013492249515826863, + 0.006615696236378061, + 0.006782108219800376, + 0.016393831451740604, + ], + linf=[ + 0.0020782600954247776, + 0.08150078921935999, + 0.08663621974991986, + 0.2829930622010579, + ]) + end + + @trixi_testset "elixir_euler_vortex_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[ + 0.0017208369388227673, + 0.09628684992237334, + 0.09620157717330868, + 0.1758809552387432, + ], + linf=[ + 0.021869936355319086, + 0.9956698009442038, + 1.0002507727219028, + 2.223249697515648, + ]) + end + + @trixi_testset "elixir_euler_vortex_mortar_split.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_split.jl"), + l2=[ + 0.0017203323613648241, + 0.09628962878682261, + 0.09621241164155782, + 0.17585995600340926, + ], + linf=[ + 0.021740570456931674, + 0.9938841665880938, + 1.004140123355135, + 2.224108857746245, + ]) + end + + @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), + l2=[ + 0.0017158367642679273, + 0.09619888722871434, + 0.09616432767924141, + 0.17553381166255197, + ], + linf=[ + 0.021853862449723982, + 0.9878047229255944, + 0.9880191167111795, + 2.2154030488035588, + ]) + end + + @trixi_testset "elixir_euler_vortex_mortar_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_vortex_mortar_shockcapturing.jl"), + l2=[ + 0.0017203324051381415, + 0.09628962899999398, + 0.0962124115572114, + 0.1758599596626405, + ], + linf=[ + 0.021740568112562086, + 0.9938841624655501, + 1.0041401179009877, + 2.2241087041100798, + ]) + end + + @trixi_testset "elixir_euler_vortex_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), + # Expected errors are exactly the same as in the parallel test! + l2=[ + 5.051719943432265e-5, + 0.0022574259317084747, + 0.0021755998463189713, + 0.004346492398617521, + ], + linf=[ + 0.0012880114865917447, + 0.03857193149447702, + 0.031090457959835893, + 0.12125130332971423, + ], + # Let this test run longer to cover some lines in the AMR indicator + coverage_override=(maxiters = 10^5, tspan = (0.0, 10.5))) + end + + @trixi_testset "elixir_euler_ec.jl with boundary_condition_slip_wall" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.03341239373099515, + 0.026673245711492915, + 0.026678871434568822, + 0.12397486476145089, + ], + linf=[ + 0.3290981764688339, + 0.3812055782309788, + 0.3812041851225023, + 1.168251216556933, + ], + periodicity=false, + boundary_conditions=boundary_condition_slip_wall, + cfl=0.3, tspan=(0.0, 0.1)) # this test is sensitive to the CFL factor + end end # Coverage test for all initial conditions @testset "Compressible Euler: Tests for initial conditions" begin - @trixi_testset "elixir_euler_vortex.jl one step with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [1.1790213022362371e-16, 8.580657423476384e-17, 1.3082387431804115e-16, 1.6182739965672862e-15], - linf = [3.3306690738754696e-16, 2.220446049250313e-16, 5.273559366969494e-16, 3.552713678800501e-15], - maxiters = 1, - initial_condition = initial_condition_constant) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl one step" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [0.0021196114178949396, 0.010703549234544042, 0.01070354923454404, 0.10719124037195142], - linf = [0.11987270645890724, 0.7468615461136827, 0.7468615461136827, 3.910689155287799], - maxiters=1) - end + @trixi_testset "elixir_euler_vortex.jl one step with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 1.1790213022362371e-16, + 8.580657423476384e-17, + 1.3082387431804115e-16, + 1.6182739965672862e-15, + ], + linf=[ + 3.3306690738754696e-16, + 2.220446049250313e-16, + 5.273559366969494e-16, + 3.552713678800501e-15, + ], + maxiters=1, + initial_condition=initial_condition_constant) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl one step" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2=[ + 0.0021196114178949396, + 0.010703549234544042, + 0.01070354923454404, + 0.10719124037195142, + ], + linf=[ + 0.11987270645890724, + 0.7468615461136827, + 0.7468615461136827, + 3.910689155287799, + ], + maxiters=1) + end end end # module diff --git a/test/test_tree_2d_euleracoustics.jl b/test/test_tree_2d_euleracoustics.jl index 01ac939f8aa..c217ccbbd06 100644 --- a/test/test_tree_2d_euleracoustics.jl +++ b/test/test_tree_2d_euleracoustics.jl @@ -8,14 +8,30 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "Acoustic perturbation coupled with compressible Euler" begin - @trixi_testset "elixir_euleracoustics_co-rotating_vortex_pair.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euleracoustics_co-rotating_vortex_pair.jl"), - initial_refinement_level=5, - tspan1=(0.0, 1.0), tspan_averaging=(0.0, 1.0), tspan=(0.0, 1.0), - l2 = [0.00013268029905807722, 0.0001335062197031223, 0.00021776333678401362, 13.000001753042364, 26.00000080243847, 38.00000884725549, 51.000000003859995], - linf = [0.22312716933051027, 0.1579924424942319, 0.25194831158255576, 13.468872744263273, 26.54666679978679, 38.139032147739684, 51.378134660241294] - ) - end + @trixi_testset "elixir_euleracoustics_co-rotating_vortex_pair.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euleracoustics_co-rotating_vortex_pair.jl"), + initial_refinement_level=5, + tspan1=(0.0, 1.0), tspan_averaging=(0.0, 1.0), tspan=(0.0, 1.0), + l2=[ + 0.00013268029905807722, + 0.0001335062197031223, + 0.00021776333678401362, + 13.000001753042364, + 26.00000080243847, + 38.00000884725549, + 51.000000003859995, + ], + linf=[ + 0.22312716933051027, + 0.1579924424942319, + 0.25194831158255576, + 13.468872744263273, + 26.54666679978679, + 38.139032147739684, + 51.378134660241294, + ]) + end end -end # module \ No newline at end of file +end # module diff --git a/test/test_tree_2d_eulermulti.jl b/test/test_tree_2d_eulermulti.jl index 800dc31f84f..1184e09488e 100644 --- a/test/test_tree_2d_eulermulti.jl +++ b/test/test_tree_2d_eulermulti.jl @@ -8,47 +8,121 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Compressible Euler Multicomponent" begin - # NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the - # simulations are set up with dimensional states. For example, the reference pressure in SI - # units is 101325 Pa, i.e., pressure has values of O(10^5) - - @trixi_testset "elixir_eulermulti_shock_bubble.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble.jl"), - l2 = [73.78467629094177, 0.9174752929795251, 57942.83587826468, 0.1828847253029943, 0.011127037850925347], - linf = [196.81051991521073, 7.8456811648529605, 158891.88930113698, 0.811379581519794, 0.08011973559187913], - tspan = (0.0, 0.001)) - end - - @trixi_testset "elixir_eulermulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), - l2 = [0.050182236154087095, 0.050189894464434635, 0.2258715597305131, 0.06175171559771687], - linf = [0.3108124923284472, 0.3107380389947733, 1.054035804988521, 0.29347582879608936]) - end - - @trixi_testset "elixir_eulermulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), - l2 = [0.0496546258404055, 0.04965550099933263, 0.22425206549856372, 0.004087155041747821, 0.008174310083495642, 0.016348620166991283, 0.032697240333982566], - linf = [0.2488251110766228, 0.24832493304479406, 0.9310354690058298, 0.017452870465607374, 0.03490574093121475, 0.0698114818624295, 0.139622963724859]) - end - - @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), - l2 = [0.00012290225488326508, 0.00012290225488321876, 0.00018867397906337653, 4.8542321753649044e-5, 9.708464350729809e-5], - linf = [0.0006722819239133315, 0.0006722819239128874, 0.0012662292789555885, 0.0002843844182700561, 0.0005687688365401122]) - end - - @trixi_testset "elixir_eulermulti_convergence_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [2.2661773867001696e-6, 2.266177386666318e-6, 6.593514692980009e-6, 8.836308667348217e-7, 1.7672617334696433e-6], - linf = [1.4713170997993075e-5, 1.4713170997104896e-5, 5.115618808515521e-5, 5.3639516094383666e-6, 1.0727903218876733e-5]) - end - - @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [1.8621737639352465e-6, 1.862173764098385e-6, 5.942585713809631e-6, 6.216263279534722e-7, 1.2432526559069443e-6], - linf = [1.6235495582606063e-5, 1.6235495576388814e-5, 5.854523678827661e-5, 5.790274858807898e-6, 1.1580549717615796e-5], - volume_flux = flux_chandrashekar) - end + # NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the + # simulations are set up with dimensional states. For example, the reference pressure in SI + # units is 101325 Pa, i.e., pressure has values of O(10^5) + + @trixi_testset "elixir_eulermulti_shock_bubble.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble.jl"), + l2=[ + 73.78467629094177, + 0.9174752929795251, + 57942.83587826468, + 0.1828847253029943, + 0.011127037850925347, + ], + linf=[ + 196.81051991521073, + 7.8456811648529605, + 158891.88930113698, + 0.811379581519794, + 0.08011973559187913, + ], + tspan=(0.0, 0.001)) + end + + @trixi_testset "elixir_eulermulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), + l2=[ + 0.050182236154087095, + 0.050189894464434635, + 0.2258715597305131, + 0.06175171559771687, + ], + linf=[ + 0.3108124923284472, + 0.3107380389947733, + 1.054035804988521, + 0.29347582879608936, + ]) + end + + @trixi_testset "elixir_eulermulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), + l2=[ + 0.0496546258404055, + 0.04965550099933263, + 0.22425206549856372, + 0.004087155041747821, + 0.008174310083495642, + 0.016348620166991283, + 0.032697240333982566, + ], + linf=[ + 0.2488251110766228, + 0.24832493304479406, + 0.9310354690058298, + 0.017452870465607374, + 0.03490574093121475, + 0.0698114818624295, + 0.139622963724859, + ]) + end + + @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), + l2=[ + 0.00012290225488326508, + 0.00012290225488321876, + 0.00018867397906337653, + 4.8542321753649044e-5, + 9.708464350729809e-5, + ], + linf=[ + 0.0006722819239133315, + 0.0006722819239128874, + 0.0012662292789555885, + 0.0002843844182700561, + 0.0005687688365401122, + ]) + end + + @trixi_testset "elixir_eulermulti_convergence_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2=[ + 2.2661773867001696e-6, + 2.266177386666318e-6, + 6.593514692980009e-6, + 8.836308667348217e-7, + 1.7672617334696433e-6, + ], + linf=[ + 1.4713170997993075e-5, + 1.4713170997104896e-5, + 5.115618808515521e-5, + 5.3639516094383666e-6, + 1.0727903218876733e-5, + ]) + end + + @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2=[ + 1.8621737639352465e-6, + 1.862173764098385e-6, + 5.942585713809631e-6, + 6.216263279534722e-7, + 1.2432526559069443e-6, + ], + linf=[ + 1.6235495582606063e-5, + 1.6235495576388814e-5, + 5.854523678827661e-5, + 5.790274858807898e-6, + 1.1580549717615796e-5, + ], + volume_flux=flux_chandrashekar) + end end end # module diff --git a/test/test_tree_2d_fdsbp.jl b/test/test_tree_2d_fdsbp.jl index 7c58ef89a6c..094092106f9 100644 --- a/test/test_tree_2d_fdsbp.jl +++ b/test/test_tree_2d_fdsbp.jl @@ -8,60 +8,101 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_fdsbp") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_extended.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [2.898644263922225e-6], - linf = [8.491517930142578e-6], - rtol = 1.0e-7) # These results change a little bit and depend on the CI system + @trixi_testset "elixir_advection_extended.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[2.898644263922225e-6], + linf=[8.491517930142578e-6], + rtol=1.0e-7) # These results change a little bit and depend on the CI system - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end - end end @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [1.7088389997042244e-6, 1.7437997855125774e-6, 1.7437997855350776e-6, 5.457223460127621e-6], - linf = [9.796504903736292e-6, 9.614745892783105e-6, 9.614745892783105e-6, 4.026107182575345e-5], - tspan = (0.0, 0.1)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 1.7088389997042244e-6, + 1.7437997855125774e-6, + 1.7437997855350776e-6, + 5.457223460127621e-6, + ], + linf=[ + 9.796504903736292e-6, + 9.614745892783105e-6, + 9.614745892783105e-6, + 4.026107182575345e-5, + ], + tspan=(0.0, 0.1)) - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end - end - @trixi_testset "elixir_euler_convergence.jl with Lax-Friedrichs splitting" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [2.1149087345799973e-6, 1.9391438806845798e-6, 1.9391438806759794e-6, 5.842833764682604e-6], - linf = [1.3679037540903494e-5, 1.1770587849069258e-5, 1.1770587848403125e-5, 4.68952678644996e-5], - tspan = (0.0, 0.1), flux_splitting = splitting_lax_friedrichs) - end + @trixi_testset "elixir_euler_convergence.jl with Lax-Friedrichs splitting" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 2.1149087345799973e-6, + 1.9391438806845798e-6, + 1.9391438806759794e-6, + 5.842833764682604e-6, + ], + linf=[ + 1.3679037540903494e-5, + 1.1770587849069258e-5, + 1.1770587848403125e-5, + 4.68952678644996e-5, + ], + tspan=(0.0, 0.1), flux_splitting=splitting_lax_friedrichs) + end - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - l2 = [0.02607850081951497, 0.020357717558016252, 0.028510191844948945, 0.02951535039734857], - linf = [0.12185328623662173, 0.1065055387595834, 0.06257122956937419, 0.11992349951978643], - tspan = (0.0, 0.1)) - end + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + l2=[ + 0.02607850081951497, + 0.020357717558016252, + 0.028510191844948945, + 0.02951535039734857, + ], + linf=[ + 0.12185328623662173, + 0.1065055387595834, + 0.06257122956937419, + 0.11992349951978643, + ], + tspan=(0.0, 0.1)) + end - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [0.0005330228930711585, 0.028475888529345014, 0.02847513865894387, 0.056259951995581196], - linf = [0.007206088611304784, 0.31690373882847234, 0.31685665067192326, 0.7938167296134893], - tspan = (0.0, 0.25)) - end + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 0.0005330228930711585, + 0.028475888529345014, + 0.02847513865894387, + 0.056259951995581196, + ], + linf=[ + 0.007206088611304784, + 0.31690373882847234, + 0.31685665067192326, + 0.7938167296134893, + ], + tspan=(0.0, 0.25)) + end end end # module diff --git a/test/test_tree_2d_hypdiff.jl b/test/test_tree_2d_hypdiff.jl index eb8f8b297b6..0b50f2d27f4 100644 --- a/test/test_tree_2d_hypdiff.jl +++ b/test/test_tree_2d_hypdiff.jl @@ -8,30 +8,63 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Hyperbolic diffusion" begin - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2 = [0.00015687751817403066, 0.001025986772216324, 0.0010259867722164071], - linf = [0.001198695637957381, 0.006423873515531753, 0.006423873515533529]) - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [8.618132355121019e-8, 5.619399844384306e-7, 5.619399844844044e-7], - linf = [1.1248618588430072e-6, 8.622436487026874e-6, 8.622436487915053e-6]) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [8.523077653954864e-6, 2.8779323653020624e-5, 5.454942769125663e-5], - linf = [5.522740952468297e-5, 0.00014544895978971679, 0.00032396328684924924]) - end - - @trixi_testset "elixir_hypdiff_godunov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), - l2 = [5.868147556427088e-6, 3.80517927324465e-5, 3.805179273249344e-5], - linf = [3.701965498725812e-5, 0.0002122422943138247, 0.00021224229431116015], - atol = 2.0e-12 #= required for CI on macOS =#) - end + @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), + l2=[ + 0.00015687751817403066, + 0.001025986772216324, + 0.0010259867722164071, + ], + linf=[ + 0.001198695637957381, + 0.006423873515531753, + 0.006423873515533529, + ]) + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[ + 8.618132355121019e-8, + 5.619399844384306e-7, + 5.619399844844044e-7, + ], + linf=[ + 1.1248618588430072e-6, + 8.622436487026874e-6, + 8.622436487915053e-6, + ]) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2=[ + 8.523077653954864e-6, + 2.8779323653020624e-5, + 5.454942769125663e-5, + ], + linf=[ + 5.522740952468297e-5, + 0.00014544895978971679, + 0.00032396328684924924, + ]) + end + + @trixi_testset "elixir_hypdiff_godunov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), + l2=[ + 5.868147556427088e-6, + 3.80517927324465e-5, + 3.805179273249344e-5, + ], + linf=[ + 3.701965498725812e-5, + 0.0002122422943138247, + 0.00021224229431116015, + ], + atol=2.0e-12) #= required for CI on macOS =# + end end end # module diff --git a/test/test_tree_2d_kpp.jl b/test/test_tree_2d_kpp.jl index 26074ea487f..17a8927cb92 100644 --- a/test/test_tree_2d_kpp.jl +++ b/test/test_tree_2d_kpp.jl @@ -8,16 +8,16 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "KPP" begin - @trixi_testset "elixir_kpp.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_kpp.jl"), - l2 = [0.36563290910786106], - linf = [9.116732052340398], - max_refinement_level = 6, - tspan = (0.0, 0.01), - atol = 1e-6, - rtol = 1e-6, - skip_coverage = true) - end + @trixi_testset "elixir_kpp.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_kpp.jl"), + l2=[0.36563290910786106], + linf=[9.116732052340398], + max_refinement_level=6, + tspan=(0.0, 0.01), + atol=1e-6, + rtol=1e-6, + skip_coverage=true) + end end end # module diff --git a/test/test_tree_2d_lbm.jl b/test/test_tree_2d_lbm.jl index b516708e6cd..cba5e2aa558 100644 --- a/test/test_tree_2d_lbm.jl +++ b/test/test_tree_2d_lbm.jl @@ -8,71 +8,102 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Lattice-Boltzmann" begin - @trixi_testset "elixir_lbm_constant.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_constant.jl"), - l2 = [4.888991832247047e-15, 4.8856380534982224e-15, 5.140829677785587e-16, - 7.340293204570167e-16, 2.0559494114924474e-15, 6.125746684189216e-16, - 1.6545443003155128e-16, 6.001333022242579e-16, 9.450994018139234e-15], - linf = [5.551115123125783e-15, 5.662137425588298e-15, 1.2212453270876722e-15, - 1.27675647831893e-15, 2.4980018054066022e-15, 7.494005416219807e-16, - 4.3021142204224816e-16, 8.881784197001252e-16, 1.0436096431476471e-14]) - end + @trixi_testset "elixir_lbm_constant.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_constant.jl"), + l2=[4.888991832247047e-15, 4.8856380534982224e-15, + 5.140829677785587e-16, + 7.340293204570167e-16, 2.0559494114924474e-15, + 6.125746684189216e-16, + 1.6545443003155128e-16, 6.001333022242579e-16, + 9.450994018139234e-15], + linf=[5.551115123125783e-15, 5.662137425588298e-15, + 1.2212453270876722e-15, + 1.27675647831893e-15, 2.4980018054066022e-15, + 7.494005416219807e-16, + 4.3021142204224816e-16, 8.881784197001252e-16, + 1.0436096431476471e-14]) + end - @trixi_testset "elixir_lbm_couette.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), - l2 = [0.0007899749117603378, 7.0995283148275575e-6, 0.0007454191223764233, - 1.6482025869100257e-5, 0.00012684365365448903, 0.0001198942846383015, - 0.00028436349827736705, 0.0003005161103138576, 4.496683876631818e-5], - linf = [0.005596384769998769, 4.771160474496827e-5, 0.005270322068908595, - 0.00011747787108790098, 0.00084326349695725, 0.000795551892211168, - 0.001956482118303543, 0.0020739599893902436, 0.00032606270109525326], - tspan = (0.0, 1.0)) - end + @trixi_testset "elixir_lbm_couette.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), + l2=[0.0007899749117603378, 7.0995283148275575e-6, + 0.0007454191223764233, + 1.6482025869100257e-5, 0.00012684365365448903, + 0.0001198942846383015, + 0.00028436349827736705, 0.0003005161103138576, + 4.496683876631818e-5], + linf=[0.005596384769998769, 4.771160474496827e-5, + 0.005270322068908595, + 0.00011747787108790098, 0.00084326349695725, + 0.000795551892211168, + 0.001956482118303543, 0.0020739599893902436, + 0.00032606270109525326], + tspan=(0.0, 1.0)) + end - @trixi_testset "elixir_lbm_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), - l2 = [0.0013628495945172754, 0.00021475256243322154, 0.0012579141312268184, - 0.00036542734715110765, 0.00024127756258120715, 0.00022899415795341014, - 0.0004225564518328741, 0.0004593854895507851, 0.00044244398903669927], - linf = [0.025886626070758242, 0.00573859077176217, 0.027568805277855102, 0.00946724671122974, - 0.004031686575556803, 0.0038728927083346437, 0.020038695575169005, - 0.02061789496737146, 0.05568236920459335], - tspan = (0.0, 1.0)) - end + @trixi_testset "elixir_lbm_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), + l2=[0.0013628495945172754, 0.00021475256243322154, + 0.0012579141312268184, + 0.00036542734715110765, 0.00024127756258120715, + 0.00022899415795341014, + 0.0004225564518328741, 0.0004593854895507851, + 0.00044244398903669927], + linf=[0.025886626070758242, 0.00573859077176217, + 0.027568805277855102, 0.00946724671122974, + 0.004031686575556803, 0.0038728927083346437, + 0.020038695575169005, + 0.02061789496737146, 0.05568236920459335], + tspan=(0.0, 1.0)) + end - @trixi_testset "elixir_lbm_couette.jl with initial_condition_couette_steady" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), - l2 = [9.321369073400123e-16, 1.6498793963435488e-6, 5.211495843124065e-16, - 1.6520893954826173e-6, 1.0406056181388841e-5, 8.801606429417205e-6, - 8.801710065560555e-6, 1.040614383799995e-5, 2.6135657178357052e-15], - linf = [1.4432899320127035e-15, 2.1821189867266e-6, 8.881784197001252e-16, - 2.2481261510165496e-6, 1.0692966335143494e-5, 9.606391697600247e-6, - 9.62138334279633e-6, 1.0725969916147021e-5, 3.3861802251067274e-15], - initial_condition=function initial_condition_couette_steady(x, t, equations::LatticeBoltzmannEquations2D) - # Initial state for a *steady* Couette flow setup. To be used in combination with - # [`boundary_condition_couette`](@ref) and [`boundary_condition_noslip_wall`](@ref). - @unpack L, u0, rho0 = equations + @trixi_testset "elixir_lbm_couette.jl with initial_condition_couette_steady" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), + l2=[9.321369073400123e-16, 1.6498793963435488e-6, + 5.211495843124065e-16, + 1.6520893954826173e-6, 1.0406056181388841e-5, + 8.801606429417205e-6, + 8.801710065560555e-6, 1.040614383799995e-5, + 2.6135657178357052e-15], + linf=[1.4432899320127035e-15, 2.1821189867266e-6, + 8.881784197001252e-16, + 2.2481261510165496e-6, 1.0692966335143494e-5, + 9.606391697600247e-6, + 9.62138334279633e-6, 1.0725969916147021e-5, + 3.3861802251067274e-15], + initial_condition=function initial_condition_couette_steady(x, + t, + equations::LatticeBoltzmannEquations2D) + # Initial state for a *steady* Couette flow setup. To be used in combination with + # [`boundary_condition_couette`](@ref) and [`boundary_condition_noslip_wall`](@ref). + @unpack L, u0, rho0 = equations - rho = rho0 - v1 = u0 * x[2] / L - v2 = 0 + rho = rho0 + v1 = u0 * x[2] / L + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) - end, - tspan = (0.0, 1.0)) - end + return equilibrium_distribution(rho, v1, v2, equations) + end, + tspan=(0.0, 1.0)) + end - @trixi_testset "elixir_lbm_lid_driven_cavity.jl with stationary walls" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), - l2 = [1.7198203373689985e-16, 1.685644347036533e-16, 2.1604974801394525e-16, - 2.1527076266915764e-16, 4.2170298143732604e-17, 5.160156233016299e-17, - 6.167794865198169e-17, 5.24166554417795e-17, 6.694740573885739e-16], - linf = [5.967448757360216e-16, 6.522560269672795e-16, 6.522560269672795e-16, - 6.245004513516506e-16, 2.1163626406917047e-16, 2.185751579730777e-16, - 2.185751579730777e-16, 2.393918396847994e-16, 1.887379141862766e-15], - boundary_conditions=boundary_condition_noslip_wall, - tspan = (0, 0.1)) - end + @trixi_testset "elixir_lbm_lid_driven_cavity.jl with stationary walls" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), + l2=[1.7198203373689985e-16, 1.685644347036533e-16, + 2.1604974801394525e-16, + 2.1527076266915764e-16, 4.2170298143732604e-17, + 5.160156233016299e-17, + 6.167794865198169e-17, 5.24166554417795e-17, + 6.694740573885739e-16], + linf=[5.967448757360216e-16, 6.522560269672795e-16, + 6.522560269672795e-16, + 6.245004513516506e-16, 2.1163626406917047e-16, + 2.185751579730777e-16, + 2.185751579730777e-16, 2.393918396847994e-16, + 1.887379141862766e-15], + boundary_conditions=boundary_condition_noslip_wall, + tspan=(0, 0.1)) + end end end # module diff --git a/test/test_tree_2d_linearizedeuler.jl b/test/test_tree_2d_linearizedeuler.jl index 540b3951212..3f150448c55 100644 --- a/test/test_tree_2d_linearizedeuler.jl +++ b/test/test_tree_2d_linearizedeuler.jl @@ -7,10 +7,19 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Linearized Euler Equations 2D" begin - @trixi_testset "elixir_linearizedeuler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_convergence.jl"), - l2 = [0.00020601485381444888, 0.00013380483421751216, 0.0001338048342174503, 0.00020601485381444888], - linf = [0.0011006084408365924, 0.0005788678074691855, 0.0005788678074701847, 0.0011006084408365924] - ) - end + @trixi_testset "elixir_linearizedeuler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_convergence.jl"), + l2=[ + 0.00020601485381444888, + 0.00013380483421751216, + 0.0001338048342174503, + 0.00020601485381444888, + ], + linf=[ + 0.0011006084408365924, + 0.0005788678074691855, + 0.0005788678074701847, + 0.0011006084408365924, + ]) + end end diff --git a/test/test_tree_2d_mhd.jl b/test/test_tree_2d_mhd.jl index ad9e913eab9..1c64b01ba66 100644 --- a/test/test_tree_2d_mhd.jl +++ b/test/test_tree_2d_mhd.jl @@ -8,71 +8,253 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "MHD" begin - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.00011149543672225127, 5.888242524520296e-6, 5.888242524510072e-6, 8.476931432519067e-6, 1.3160738644036652e-6, 1.2542675002588144e-6, 1.2542675002747718e-6, 1.8705223407238346e-6, 4.651717010670585e-7], - linf = [0.00026806333988971254, 1.6278838272418272e-5, 1.627883827305665e-5, 2.7551183488072617e-5, 5.457878055614707e-6, 8.130129322880819e-6, 8.130129322769797e-6, 1.2406302192291552e-5, 2.373765544951732e-6]) - end + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[ + 0.00011149543672225127, + 5.888242524520296e-6, + 5.888242524510072e-6, + 8.476931432519067e-6, + 1.3160738644036652e-6, + 1.2542675002588144e-6, + 1.2542675002747718e-6, + 1.8705223407238346e-6, + 4.651717010670585e-7, + ], + linf=[ + 0.00026806333988971254, + 1.6278838272418272e-5, + 1.627883827305665e-5, + 2.7551183488072617e-5, + 5.457878055614707e-6, + 8.130129322880819e-6, + 8.130129322769797e-6, + 1.2406302192291552e-5, + 2.373765544951732e-6, + ]) + end - @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.7201098719531215e-6, 8.692057393373005e-7, 8.69205739320643e-7, 1.2726508184718958e-6, 1.040607127595208e-6, 1.07029565814218e-6, 1.0702956581404748e-6, 1.3291748105236525e-6, 4.6172239295786824e-7], - linf = [9.865325754310206e-6, 7.352074675170961e-6, 7.352074674185638e-6, 1.0675656902672803e-5, 5.112498347226158e-6, 7.789533065905019e-6, 7.789533065905019e-6, 1.0933531593274037e-5, 2.340244047768378e-6], - volume_flux = (flux_derigs_etal, flux_nonconservative_powell)) - end + @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[ + 1.7201098719531215e-6, + 8.692057393373005e-7, + 8.69205739320643e-7, + 1.2726508184718958e-6, + 1.040607127595208e-6, + 1.07029565814218e-6, + 1.0702956581404748e-6, + 1.3291748105236525e-6, + 4.6172239295786824e-7, + ], + linf=[ + 9.865325754310206e-6, + 7.352074675170961e-6, + 7.352074674185638e-6, + 1.0675656902672803e-5, + 5.112498347226158e-6, + 7.789533065905019e-6, + 7.789533065905019e-6, + 1.0933531593274037e-5, + 2.340244047768378e-6, + ], + volume_flux=(flux_derigs_etal, flux_nonconservative_powell)) + end - @trixi_testset "elixir_mhd_alfven_wave_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_mortar.jl"), - l2 = [3.7762324533854616e-6, 1.5534623833573546e-6, 1.4577234868196855e-6, 1.7647724628707057e-6, 1.4831911814574333e-6, 1.456369119716533e-6, 1.4115666913995062e-6, 1.804758237422838e-6, 8.320469738087189e-7], - linf = [3.670661330201774e-5, 1.530289442645827e-5, 1.3592183785327006e-5, 1.5173897443654383e-5, 9.43771379136038e-6, 1.0906323046233624e-5, 1.0603954940346938e-5, 1.5900499596113726e-5, 5.978772247650426e-6], - tspan = (0.0, 1.0)) - end + @trixi_testset "elixir_mhd_alfven_wave_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_mortar.jl"), + l2=[ + 3.7762324533854616e-6, + 1.5534623833573546e-6, + 1.4577234868196855e-6, + 1.7647724628707057e-6, + 1.4831911814574333e-6, + 1.456369119716533e-6, + 1.4115666913995062e-6, + 1.804758237422838e-6, + 8.320469738087189e-7, + ], + linf=[ + 3.670661330201774e-5, + 1.530289442645827e-5, + 1.3592183785327006e-5, + 1.5173897443654383e-5, + 9.43771379136038e-6, + 1.0906323046233624e-5, + 1.0603954940346938e-5, + 1.5900499596113726e-5, + 5.978772247650426e-6, + ], + tspan=(0.0, 1.0)) + end - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.03637302248881514, 0.043002991956758996, 0.042987505670836056, 0.02574718055258975, 0.1621856170457943, 0.01745369341302589, 0.017454552320664566, 0.026873190440613117, 5.336243933079389e-16], - linf = [0.23623816236321427, 0.3137152204179957, 0.30378397831730597, 0.21500228807094865, 0.9042495730546518, 0.09398098096581875, 0.09470282020962917, 0.15277253978297378, 4.307694418935709e-15]) - end + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2=[ + 0.03637302248881514, + 0.043002991956758996, + 0.042987505670836056, + 0.02574718055258975, + 0.1621856170457943, + 0.01745369341302589, + 0.017454552320664566, + 0.026873190440613117, + 5.336243933079389e-16, + ], + linf=[ + 0.23623816236321427, + 0.3137152204179957, + 0.30378397831730597, + 0.21500228807094865, + 0.9042495730546518, + 0.09398098096581875, + 0.09470282020962917, + 0.15277253978297378, + 4.307694418935709e-15, + ]) + end - @trixi_testset "elixir_mhd_orszag_tang.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), - l2 = [0.21967600768935716, 0.2643126515795721, 0.31488287201980875, 0.0, 0.5160141621186931, 0.23028914748088603, 0.34413527376463915, 0.0, 0.003178793090381426], - linf = [1.2749969218080568, 0.6737013368774057, 0.8604154399895696, 0.0, 2.799342099887639, 0.6473347557712643, 0.9691773375490476, 0.0, 0.05729832038724348], - tspan = (0.0, 0.09)) - end + @trixi_testset "elixir_mhd_orszag_tang.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), + l2=[ + 0.21967600768935716, + 0.2643126515795721, + 0.31488287201980875, + 0.0, + 0.5160141621186931, + 0.23028914748088603, + 0.34413527376463915, + 0.0, + 0.003178793090381426, + ], + linf=[ + 1.2749969218080568, + 0.6737013368774057, + 0.8604154399895696, + 0.0, + 2.799342099887639, + 0.6473347557712643, + 0.9691773375490476, + 0.0, + 0.05729832038724348, + ], + tspan=(0.0, 0.09)) + end - @trixi_testset "elixir_mhd_orszag_tang.jl with flux_hll" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), - l2 = [0.10806619664693064, 0.20199136742199922, 0.22984589847526207, 0.0, 0.29950152196422647, 0.15688413207147794, 0.24293641543490646, 0.0, 0.003246181006326598], - linf = [0.560316034595759, 0.5095520363866776, 0.6536748458764621, 0.0, 0.9627447086204038, 0.3981375420906146, 0.673472146198816, 0.0, 0.04879208429337193], - tspan = (0.0, 0.06), surface_flux = (FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell)) - end + @trixi_testset "elixir_mhd_orszag_tang.jl with flux_hll" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), + l2=[ + 0.10806619664693064, + 0.20199136742199922, + 0.22984589847526207, + 0.0, + 0.29950152196422647, + 0.15688413207147794, + 0.24293641543490646, + 0.0, + 0.003246181006326598, + ], + linf=[ + 0.560316034595759, + 0.5095520363866776, + 0.6536748458764621, + 0.0, + 0.9627447086204038, + 0.3981375420906146, + 0.673472146198816, + 0.0, + 0.04879208429337193, + ], + tspan=(0.0, 0.06), + surface_flux=(FluxHLL(min_max_speed_einfeldt), + flux_nonconservative_powell)) + end - @trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [7.144325530681224e-17, 2.123397983547417e-16, 5.061138912500049e-16, 3.6588423152083e-17, 8.449816179702522e-15, 3.9171737639099993e-16, 2.445565690318772e-16, 3.6588423152083e-17, 9.971153407737885e-17], - linf = [2.220446049250313e-16, 8.465450562766819e-16, 1.8318679906315083e-15, 1.1102230246251565e-16, 1.4210854715202004e-14, 8.881784197001252e-16, 4.440892098500626e-16, 1.1102230246251565e-16, 4.779017148551244e-16], - maxiters = 1, - initial_condition = initial_condition_constant, - atol = 2.0e-13) - end + @trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[ + 7.144325530681224e-17, + 2.123397983547417e-16, + 5.061138912500049e-16, + 3.6588423152083e-17, + 8.449816179702522e-15, + 3.9171737639099993e-16, + 2.445565690318772e-16, + 3.6588423152083e-17, + 9.971153407737885e-17, + ], + linf=[ + 2.220446049250313e-16, + 8.465450562766819e-16, + 1.8318679906315083e-15, + 1.1102230246251565e-16, + 1.4210854715202004e-14, + 8.881784197001252e-16, + 4.440892098500626e-16, + 1.1102230246251565e-16, + 4.779017148551244e-16, + ], + maxiters=1, + initial_condition=initial_condition_constant, + atol=2.0e-13) + end - @trixi_testset "elixir_mhd_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2 = [1.2623319195262743, 1.8273050553090515, 1.7004151198284634, 0.0, 2.2978570581460818, 0.2147235065899803, 0.23558337696054493, 0.0, 0.0032515115395693483], - linf = [11.003677581472843, 14.70614192714736, 15.687648666952708, 0.0, 17.098104835553823, 1.3283750501377847, 1.4365828094434892, 0.0, 0.07886241196068537], - tspan = (0.0, 0.05)) - end + @trixi_testset "elixir_mhd_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), + l2=[ + 1.2623319195262743, + 1.8273050553090515, + 1.7004151198284634, + 0.0, + 2.2978570581460818, + 0.2147235065899803, + 0.23558337696054493, + 0.0, + 0.0032515115395693483, + ], + linf=[ + 11.003677581472843, + 14.70614192714736, + 15.687648666952708, + 0.0, + 17.098104835553823, + 1.3283750501377847, + 1.4365828094434892, + 0.0, + 0.07886241196068537, + ], + tspan=(0.0, 0.05)) + end - @trixi_testset "elixir_mhd_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_blast_wave.jl"), - l2 = [0.17646728395490927, 3.866230215339417, 2.4867304651291255, 0.0, 355.4562971958441, 2.359493623565687, 1.4030741420730297, 0.0, 0.029613599942667133], - linf = [1.581630420824181, 44.15725488910748, 13.056964982196554, 0.0, 2244.875490238186, 13.07679044647926, 9.14612176426092, 0.0, 0.5154756722488522], - tspan = (0.0, 0.003), - # Calling the AnalysisCallback before iteration 9 causes the interpolation - # of this IC to have negative density/pressure values, crashing the simulation. - coverage_override = (maxiters=9,)) - end + @trixi_testset "elixir_mhd_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_blast_wave.jl"), + l2=[ + 0.17646728395490927, + 3.866230215339417, + 2.4867304651291255, + 0.0, + 355.4562971958441, + 2.359493623565687, + 1.4030741420730297, + 0.0, + 0.029613599942667133, + ], + linf=[ + 1.581630420824181, + 44.15725488910748, + 13.056964982196554, + 0.0, + 2244.875490238186, + 13.07679044647926, + 9.14612176426092, + 0.0, + 0.5154756722488522, + ], + tspan=(0.0, 0.003), + # Calling the AnalysisCallback before iteration 9 causes the interpolation + # of this IC to have negative density/pressure values, crashing the simulation. + coverage_override=(maxiters = 9,)) + end end end # module diff --git a/test/test_tree_2d_mhdmulti.jl b/test/test_tree_2d_mhdmulti.jl index 09c26569d46..2f1bb15eaf0 100644 --- a/test/test_tree_2d_mhdmulti.jl +++ b/test/test_tree_2d_mhdmulti.jl @@ -8,62 +8,84 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "MHD Multicomponent" begin + @trixi_testset "elixir_mhdmulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2=[0.04300299195675897, 0.042987505670835945, + 0.025747180552589767, 0.1621856170457937, + 0.017453693413025828, 0.0174545523206645, + 0.026873190440613162, 1.364647699274761e-15, + 0.012124340829605002, 0.024248681659210004], + linf=[0.31371522041799105, 0.3037839783173047, + 0.21500228807094351, 0.904249573054642, + 0.0939809809658183, 0.09470282020962761, 0.1527725397829759, + 8.245701827530042e-15, + 0.0787460541210726, 0.1574921082421452]) + end - @trixi_testset "elixir_mhdmulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.04300299195675897, 0.042987505670835945, 0.025747180552589767, 0.1621856170457937, - 0.017453693413025828, 0.0174545523206645, 0.026873190440613162, 1.364647699274761e-15, - 0.012124340829605002, 0.024248681659210004], - linf = [0.31371522041799105, 0.3037839783173047, 0.21500228807094351, 0.904249573054642, - 0.0939809809658183, 0.09470282020962761, 0.1527725397829759, 8.245701827530042e-15, - 0.0787460541210726, 0.1574921082421452]) - end + @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2=[0.04301155595653799, 0.04299735787276207, + 0.025745530869947714, + 0.16206102676791553, 0.017454384272339165, + 0.01745523378100091, + 0.026879482381500154, 0.0002038008756963954, + 0.012094208262809778, + 0.024188416525619556], + linf=[0.3156206778985397, 0.30941696929809526, + 0.21167563519254176, + 0.9688251298546122, 0.09076254289155083, + 0.09160589769498295, + 0.15698032974768705, 0.006131914796912965, + 0.07839287555951036, + 0.1567857511190207], + volume_flux=(flux_derigs_etal, flux_nonconservative_powell), + surface_flux=(flux_derigs_etal, flux_nonconservative_powell)) + end - @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.04301155595653799, 0.04299735787276207, 0.025745530869947714, - 0.16206102676791553, 0.017454384272339165, 0.01745523378100091, - 0.026879482381500154, 0.0002038008756963954, 0.012094208262809778, - 0.024188416525619556], - linf = [0.3156206778985397, 0.30941696929809526, 0.21167563519254176, - 0.9688251298546122, 0.09076254289155083, 0.09160589769498295, - 0.15698032974768705, 0.006131914796912965, 0.07839287555951036, - 0.1567857511190207], - volume_flux = (flux_derigs_etal, flux_nonconservative_powell), - surface_flux = (flux_derigs_etal, flux_nonconservative_powell)) - end + @trixi_testset "elixir_mhdmulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), + l2=[0.042511527162267, 0.04250603277530184, 0.02385422747993974, + 0.11555081362726903, + 0.016366641053738043, 0.01636681584592762, + 0.02581748418797907, 0.00023394429554818215, + 0.010834603551662698, 0.021669207103325396], + linf=[0.23454607703107877, 0.23464789247380322, + 0.11898832084115452, 0.5331209602648022, + 0.061744814466827336, 0.061767127585091286, + 0.09595041452184983, 0.004421037168524759, + 0.06186597801911198, 0.12373195603822396]) + end - @trixi_testset "elixir_mhdmulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), - l2 = [0.042511527162267, 0.04250603277530184, 0.02385422747993974, 0.11555081362726903, - 0.016366641053738043, 0.01636681584592762, 0.02581748418797907, 0.00023394429554818215, - 0.010834603551662698, 0.021669207103325396], - linf = [0.23454607703107877, 0.23464789247380322, 0.11898832084115452, 0.5331209602648022, - 0.061744814466827336, 0.061767127585091286, 0.09595041452184983, 0.004421037168524759, - 0.06186597801911198, 0.12373195603822396]) - end - - @trixi_testset "elixir_mhdmulti_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), - l2 = [0.0003808877028249613, 0.0003808877028249593, 0.0005155994511260122, 0.000570394227652563, - 0.000439568811048544, 0.0004395688110485541, 0.0005074093477702055, 0.0003859005258180428, - 7.4611207452221e-5, 0.000149222414904442, 0.000298444829808884], - linf = [0.0013324014301672943, 0.0013324014301669181, 0.002684449324758791, 0.0016236816790307085, - 0.0019172373117153363, 0.0019172373117148922, 0.002664932274107224, 0.0011872396664042962, - 0.0002855492944235094, 0.0005710985888470188, 0.0011421971776940376]) - end - - @trixi_testset "elixir_mhdmulti_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_rotor.jl"), - l2 = [0.6574605535168556, 0.6623234319361953, 0.0, 0.689806698245354, - 0.04883686128677976, 0.08382459729494686, 0.0, 0.0021114516459281177, - 0.15909290019096098, 0.07954645009548049], - linf = [9.362339085941425, 9.169838118652539, 0.0, 10.600957847359556, - 0.6628317732399827, 1.4185626901435056, 0.0, 0.06914316292003836, - 3.328770801731456, 1.664385400865728], - tspan = (0.0, 0.01)) -end + @trixi_testset "elixir_mhdmulti_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), + l2=[0.0003808877028249613, 0.0003808877028249593, + 0.0005155994511260122, 0.000570394227652563, + 0.000439568811048544, 0.0004395688110485541, + 0.0005074093477702055, 0.0003859005258180428, + 7.4611207452221e-5, 0.000149222414904442, + 0.000298444829808884], + linf=[0.0013324014301672943, 0.0013324014301669181, + 0.002684449324758791, 0.0016236816790307085, + 0.0019172373117153363, 0.0019172373117148922, + 0.002664932274107224, 0.0011872396664042962, + 0.0002855492944235094, 0.0005710985888470188, + 0.0011421971776940376]) + end + @trixi_testset "elixir_mhdmulti_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_rotor.jl"), + l2=[0.6574605535168556, 0.6623234319361953, 0.0, + 0.689806698245354, + 0.04883686128677976, 0.08382459729494686, 0.0, + 0.0021114516459281177, + 0.15909290019096098, 0.07954645009548049], + linf=[9.362339085941425, 9.169838118652539, 0.0, + 10.600957847359556, + 0.6628317732399827, 1.4185626901435056, 0.0, + 0.06914316292003836, + 3.328770801731456, 1.664385400865728], + tspan=(0.0, 0.01)) + end end end # module From 3e5c402b0261c0da7b520636991be74daa6383ca Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 23 Jun 2023 13:06:35 +0200 Subject: [PATCH 15/22] Revert "format" This reverts commit 047a5e75b4a5ee4a0f58a7979d58b26f15f24334. --- docs/literate/make.jl | 44 +- docs/literate/src/files/DGMulti_1.jl | 67 +- docs/literate/src/files/DGMulti_2.jl | 12 +- docs/literate/src/files/DGSEM_FluxDiff.jl | 46 +- .../src/files/adaptive_mesh_refinement.jl | 35 +- .../src/files/adding_new_parabolic_terms.jl | 79 +- .../src/files/adding_new_scalar_equations.jl | 68 +- .../files/adding_nonconservative_equation.jl | 78 +- .../src/files/differentiable_programming.jl | 140 +-- docs/literate/src/files/hohqmesh_tutorial.jl | 337 +++--- .../src/files/non_periodic_boundaries.jl | 38 +- docs/literate/src/files/parabolic_terms.jl | 41 +- .../src/files/scalar_linear_advection_1d.jl | 102 +- docs/literate/src/files/shock_capturing.jl | 79 +- .../src/files/structured_mesh_mapping.jl | 77 +- docs/literate/src/files/upwind_fdsbp.jl | 8 +- docs/make.jl | 150 +-- .../dgmulti_1d/elixir_advection_gauss_sbp.jl | 13 +- .../dgmulti_1d/elixir_euler_fdsbp_periodic.jl | 23 +- examples/dgmulti_1d/elixir_euler_flux_diff.jl | 12 +- .../dgmulti_2d/elixir_advection_diffusion.jl | 38 +- .../elixir_advection_diffusion_nonperiodic.jl | 54 +- .../elixir_advection_diffusion_periodic.jl | 12 +- examples/dgmulti_2d/elixir_euler_bilinear.jl | 29 +- .../elixir_euler_brown_minion_vortex.jl | 32 +- examples/dgmulti_2d/elixir_euler_curved.jl | 22 +- .../dgmulti_2d/elixir_euler_fdsbp_periodic.jl | 23 +- examples/dgmulti_2d/elixir_euler_hohqmesh.jl | 27 +- ...ixir_euler_kelvin_helmholtz_instability.jl | 35 +- ...lixir_euler_rayleigh_taylor_instability.jl | 58 +- .../dgmulti_2d/elixir_euler_shockcapturing.jl | 27 +- .../elixir_euler_shockcapturing_curved.jl | 31 +- .../elixir_euler_triangulate_pkg_mesh.jl | 12 +- examples/dgmulti_2d/elixir_euler_weakform.jl | 21 +- .../elixir_euler_weakform_periodic.jl | 10 +- .../dgmulti_2d/elixir_mhd_reflective_wall.jl | 94 +- .../dgmulti_2d/elixir_mhd_weak_blast_wave.jl | 20 +- .../elixir_mhd_weak_blast_wave_SBP.jl | 17 +- .../elixir_navierstokes_convergence.jl | 334 +++--- .../elixir_navierstokes_convergence_curved.jl | 341 +++--- .../elixir_navierstokes_lid_driven_cavity.jl | 38 +- .../elixir_shallowwater_source_terms.jl | 19 +- .../elixir_advection_tensor_wedge.jl | 22 +- examples/dgmulti_3d/elixir_euler_curved.jl | 26 +- .../dgmulti_3d/elixir_euler_fdsbp_periodic.jl | 21 +- .../elixir_euler_taylor_green_vortex.jl | 45 +- examples/dgmulti_3d/elixir_euler_weakform.jl | 16 +- .../elixir_euler_weakform_periodic.jl | 10 +- .../elixir_navierstokes_convergence.jl | 410 ++++--- .../elixir_navierstokes_convergence_curved.jl | 418 ++++--- ...elixir_navierstokes_taylor_green_vortex.jl | 50 +- ...ixir_advection_amr_solution_independent.jl | 149 +-- .../elixir_advection_amr_unstructured_flag.jl | 66 +- .../p4est_2d_dgsem/elixir_advection_basic.jl | 32 +- .../elixir_advection_diffusion_periodic.jl | 30 +- ...xir_advection_diffusion_periodic_curved.jl | 34 +- .../elixir_advection_extended.jl | 50 +- .../elixir_advection_nonconforming_flag.jl | 55 +- .../elixir_advection_restart.jl | 10 +- .../elixir_advection_unstructured_flag.jl | 44 +- .../elixir_euler_blast_wave_amr.jl | 96 +- .../elixir_euler_double_mach_amr.jl | 140 ++- .../elixir_euler_forward_step_amr.jl | 152 ++- .../elixir_euler_free_stream.jl | 70 +- examples/p4est_2d_dgsem/elixir_euler_sedov.jl | 79 +- .../elixir_euler_shockcapturing_ec.jl | 44 +- ...e_terms_nonconforming_unstructured_flag.jl | 70 +- .../elixir_euler_supersonic_cylinder.jl | 103 +- .../elixir_euler_wall_bc_amr.jl | 82 +- .../elixir_eulergravity_convergence.jl | 60 +- .../p4est_2d_dgsem/elixir_mhd_alfven_wave.jl | 31 +- examples/p4est_2d_dgsem/elixir_mhd_rotor.jl | 126 +- .../elixir_shallowwater_source_terms.jl | 31 +- .../p4est_3d_dgsem/elixir_advection_amr.jl | 48 +- ...lixir_advection_amr_unstructured_curved.jl | 103 +- .../p4est_3d_dgsem/elixir_advection_basic.jl | 35 +- .../elixir_advection_cubed_sphere.jl | 31 +- .../elixir_advection_nonconforming.jl | 54 +- .../elixir_advection_restart.jl | 13 +- .../elixir_advection_unstructured_curved.jl | 83 +- .../elixir_euler_baroclinic_instability.jl | 370 +++--- ...lixir_euler_circular_wind_nonconforming.jl | 126 +- examples/p4est_3d_dgsem/elixir_euler_ec.jl | 81 +- .../elixir_euler_free_stream.jl | 104 +- .../elixir_euler_free_stream_extruded.jl | 86 +- examples/p4est_3d_dgsem/elixir_euler_sedov.jl | 86 +- ..._euler_source_terms_nonconforming_earth.jl | 108 +- ...terms_nonconforming_unstructured_curved.jl | 107 +- .../elixir_euler_source_terms_nonperiodic.jl | 52 +- ...euler_source_terms_nonperiodic_hohqmesh.jl | 45 +- .../elixir_mhd_alfven_wave_nonconforming.jl | 60 +- .../elixir_mhd_shockcapturing_amr.jl | 124 +- .../elixir_euler_convergence.jl | 31 +- .../elixir_eulergravity_convergence.jl | 54 +- .../elixir_eulergravity_jeans_instability.jl | 164 ++- .../elixir_eulergravity_sedov_blast_wave.jl | 219 ++-- .../elixir_hypdiff_convergence.jl | 45 +- examples/special_elixirs/elixir_euler_ad.jl | 78 +- .../elixir_advection_basic.jl | 24 +- .../elixir_advection_nonperiodic.jl | 35 +- .../elixir_advection_shockcapturing.jl | 81 +- .../structured_1d_dgsem/elixir_euler_sedov.jl | 81 +- .../elixir_euler_sedov_hll.jl | 83 +- .../elixir_euler_source_terms.jl | 31 +- .../elixir_euler_source_terms_nonperiodic.jl | 39 +- .../elixir_advection_basic.jl | 26 +- .../elixir_advection_coupled.jl | 74 +- .../elixir_advection_extended.jl | 34 +- .../elixir_advection_free_stream.jl | 41 +- .../elixir_advection_nonperiodic.jl | 32 +- .../elixir_advection_parallelogram.jl | 57 +- .../elixir_advection_restart.jl | 8 +- .../elixir_advection_rotated.jl | 69 +- .../elixir_advection_waving_flag.jl | 29 +- .../structured_2d_dgsem/elixir_euler_ec.jl | 38 +- .../elixir_euler_free_stream.jl | 39 +- ...lixir_euler_rayleigh_taylor_instability.jl | 72 +- .../structured_2d_dgsem/elixir_euler_sedov.jl | 85 +- .../elixir_euler_source_terms.jl | 26 +- .../elixir_euler_source_terms_nonperiodic.jl | 41 +- ...elixir_euler_source_terms_parallelogram.jl | 26 +- .../elixir_euler_source_terms_rotated.jl | 105 +- .../elixir_euler_source_terms_waving_flag.jl | 30 +- .../elixir_hypdiff_harmonic_nonperiodic.jl | 72 +- .../elixir_hypdiff_nonperiodic.jl | 57 +- .../elixir_mhd_alfven_wave.jl | 62 +- examples/structured_2d_dgsem/elixir_mhd_ec.jl | 88 +- .../elixir_mhd_ec_shockcapturing.jl | 35 +- .../elixir_shallowwater_source_terms.jl | 31 +- .../elixir_shallowwater_well_balanced.jl | 89 +- .../elixir_advection_basic.jl | 30 +- .../elixir_advection_free_stream.jl | 58 +- .../elixir_advection_nonperiodic_curved.jl | 72 +- .../elixir_advection_restart.jl | 13 +- .../structured_3d_dgsem/elixir_euler_ec.jl | 63 +- .../elixir_euler_free_stream.jl | 69 +- .../structured_3d_dgsem/elixir_euler_sedov.jl | 90 +- .../elixir_euler_source_terms.jl | 28 +- ...r_euler_source_terms_nonperiodic_curved.jl | 85 +- .../elixir_mhd_alfven_wave.jl | 39 +- examples/structured_3d_dgsem/elixir_mhd_ec.jl | 67 +- .../elixir_mhd_ec_shockcapturing.jl | 71 +- .../tree_1d_dgsem/elixir_advection_amr.jl | 47 +- .../elixir_advection_amr_nonperiodic.jl | 53 +- .../tree_1d_dgsem/elixir_advection_basic.jl | 30 +- .../elixir_advection_diffusion.jl | 68 +- .../elixir_advection_extended.jl | 40 +- .../elixir_advection_finite_volume.jl | 21 +- .../tree_1d_dgsem/elixir_burgers_basic.jl | 35 +- .../elixir_burgers_linear_stability.jl | 36 +- .../elixir_burgers_rarefaction.jl | 61 +- .../tree_1d_dgsem/elixir_burgers_shock.jl | 57 +- .../tree_1d_dgsem/elixir_euler_blast_wave.jl | 77 +- ...blast_wave_neuralnetwork_perssonperaire.jl | 89 +- ...r_blast_wave_neuralnetwork_rayhesthaven.jl | 89 +- .../elixir_euler_convergence_pure_fv.jl | 37 +- .../elixir_euler_density_wave.jl | 30 +- examples/tree_1d_dgsem/elixir_euler_ec.jl | 33 +- .../tree_1d_dgsem/elixir_euler_positivity.jl | 101 +- .../elixir_euler_sedov_blast_wave.jl | 100 +- .../elixir_euler_sedov_blast_wave_pure_fv.jl | 86 +- .../elixir_euler_shockcapturing.jl | 43 +- .../elixir_euler_source_terms.jl | 35 +- .../elixir_euler_source_terms_nonperiodic.jl | 43 +- .../elixir_eulergravity_convergence.jl | 54 +- .../elixir_eulermulti_convergence_ec.jl | 37 +- .../elixir_eulermulti_convergence_es.jl | 37 +- .../tree_1d_dgsem/elixir_eulermulti_ec.jl | 38 +- .../tree_1d_dgsem/elixir_eulermulti_es.jl | 42 +- ..._eulermulti_two_interacting_blast_waves.jl | 97 +- .../elixir_hypdiff_harmonic_nonperiodic.jl | 63 +- .../elixir_hypdiff_nonperiodic.jl | 38 +- .../tree_1d_dgsem/elixir_mhd_alfven_wave.jl | 45 +- .../elixir_mhd_briowu_shock_tube.jl | 91 +- examples/tree_1d_dgsem/elixir_mhd_ec.jl | 35 +- .../elixir_mhd_ryujones_shock_tube.jl | 71 +- .../elixir_mhd_shu_osher_shock_tube.jl | 128 +-- .../elixir_mhd_torrilhon_shock_tube.jl | 73 +- .../elixir_mhdmulti_briowu_shock_tube.jl | 122 +- .../elixir_mhdmulti_convergence.jl | 36 +- examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl | 33 +- examples/tree_1d_dgsem/elixir_mhdmulti_es.jl | 37 +- .../tree_1d_dgsem/elixir_shallowwater_ec.jl | 63 +- .../elixir_shallowwater_shock_capturing.jl | 84 +- .../elixir_shallowwater_source_terms.jl | 30 +- ...xir_shallowwater_source_terms_dirichlet.jl | 28 +- ...lixir_shallowwater_twolayer_convergence.jl | 32 +- .../elixir_shallowwater_twolayer_dam_break.jl | 71 +- ...xir_shallowwater_twolayer_well_balanced.jl | 42 +- .../elixir_shallowwater_well_balanced.jl | 57 +- ..._shallowwater_well_balanced_nonperiodic.jl | 50 +- .../tree_1d_fdsbp/elixir_burgers_basic.jl | 40 +- .../elixir_burgers_linear_stability.jl | 39 +- .../tree_1d_fdsbp/elixir_euler_convergence.jl | 40 +- .../elixir_euler_density_wave.jl | 36 +- .../elixir_acoustics_convergence.jl | 31 +- .../tree_2d_dgsem/elixir_acoustics_gauss.jl | 27 +- .../elixir_acoustics_gauss_wall.jl | 40 +- .../elixir_acoustics_gaussian_source.jl | 53 +- .../elixir_acoustics_monopole.jl | 134 ++- .../tree_2d_dgsem/elixir_advection_amr.jl | 47 +- .../elixir_advection_amr_coarsen_twice.jl | 69 +- .../elixir_advection_amr_nonperiodic.jl | 50 +- .../elixir_advection_amr_refine_twice.jl | 69 +- ...ixir_advection_amr_solution_independent.jl | 141 +-- .../elixir_advection_amr_visualization.jl | 60 +- .../tree_2d_dgsem/elixir_advection_basic.jl | 30 +- .../elixir_advection_callbacks.jl | 132 +-- .../elixir_advection_diffusion.jl | 49 +- .../elixir_advection_diffusion_nonperiodic.jl | 48 +- .../elixir_advection_extended.jl | 40 +- .../tree_2d_dgsem/elixir_advection_mortar.jl | 40 +- .../tree_2d_dgsem/elixir_advection_restart.jl | 8 +- .../elixir_advection_timeintegration.jl | 45 +- .../elixir_euler_astro_jet_amr.jl | 119 +- .../tree_2d_dgsem/elixir_euler_blast_wave.jl | 75 +- .../elixir_euler_blast_wave_amr.jl | 93 +- ...ixir_euler_blast_wave_neuralnetwork_cnn.jl | 86 +- ...blast_wave_neuralnetwork_perssonperaire.jl | 86 +- ...r_blast_wave_neuralnetwork_rayhesthaven.jl | 88 +- .../elixir_euler_blast_wave_pure_fv.jl | 63 +- .../tree_2d_dgsem/elixir_euler_blob_amr.jl | 131 +-- .../tree_2d_dgsem/elixir_euler_blob_mortar.jl | 119 +- .../elixir_euler_colliding_flow.jl | 116 +- .../elixir_euler_colliding_flow_amr.jl | 119 +- .../elixir_euler_convergence_pure_fv.jl | 28 +- .../elixir_euler_density_wave.jl | 31 +- examples/tree_2d_dgsem/elixir_euler_ec.jl | 37 +- ...ixir_euler_kelvin_helmholtz_instability.jl | 66 +- ..._euler_kelvin_helmholtz_instability_amr.jl | 88 +- ...bility_amr_neuralnetwork_perssonperaire.jl | 124 +- ...in_helmholtz_instability_fjordholm_etal.jl | 128 +-- .../tree_2d_dgsem/elixir_euler_positivity.jl | 104 +- .../elixir_euler_sedov_blast_wave.jl | 102 +- ...blast_wave_neuralnetwork_perssonperaire.jl | 121 +- .../elixir_euler_shockcapturing.jl | 43 +- .../elixir_euler_source_terms.jl | 30 +- ...r_euler_source_terms_amr_refine_coarsen.jl | 86 +- .../elixir_euler_source_terms_nonperiodic.jl | 47 +- examples/tree_2d_dgsem/elixir_euler_vortex.jl | 98 +- .../tree_2d_dgsem/elixir_euler_vortex_amr.jl | 191 ++-- .../elixir_euler_vortex_mortar.jl | 104 +- ...ixir_euler_vortex_mortar_shockcapturing.jl | 114 +- .../elixir_euler_vortex_mortar_split.jl | 106 +- .../elixir_euler_vortex_shockcapturing.jl | 110 +- ..._euleracoustics_co-rotating_vortex_pair.jl | 377 +++--- .../elixir_eulermulti_convergence_ec.jl | 37 +- .../elixir_eulermulti_convergence_es.jl | 37 +- .../tree_2d_dgsem/elixir_eulermulti_ec.jl | 38 +- .../tree_2d_dgsem/elixir_eulermulti_es.jl | 39 +- .../elixir_eulermulti_shock_bubble.jl | 214 ++-- .../tree_2d_dgsem/elixir_hypdiff_godunov.jl | 88 +- .../elixir_hypdiff_harmonic_nonperiodic.jl | 76 +- .../elixir_hypdiff_lax_friedrichs.jl | 86 +- .../elixir_hypdiff_nonperiodic.jl | 45 +- examples/tree_2d_dgsem/elixir_kpp.jl | 81 +- examples/tree_2d_dgsem/elixir_lbm_constant.jl | 37 +- examples/tree_2d_dgsem/elixir_lbm_couette.jl | 113 +- .../elixir_lbm_lid_driven_cavity.jl | 89 +- .../elixir_linearizedeuler_convergence.jl | 31 +- .../tree_2d_dgsem/elixir_mhd_alfven_wave.jl | 45 +- .../elixir_mhd_alfven_wave_mortar.jl | 51 +- .../tree_2d_dgsem/elixir_mhd_blast_wave.jl | 102 +- examples/tree_2d_dgsem/elixir_mhd_ec.jl | 36 +- .../tree_2d_dgsem/elixir_mhd_orszag_tang.jl | 86 +- examples/tree_2d_dgsem/elixir_mhd_rotor.jl | 113 +- .../elixir_mhdmulti_convergence.jl | 39 +- examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl | 40 +- examples/tree_2d_dgsem/elixir_mhdmulti_es.jl | 40 +- .../tree_2d_dgsem/elixir_mhdmulti_rotor.jl | 121 +- .../elixir_navierstokes_convergence.jl | 354 +++--- .../elixir_navierstokes_lid_driven_cavity.jl | 45 +- .../tree_2d_dgsem/elixir_shallowwater_ec.jl | 100 +- .../elixir_shallowwater_source_terms.jl | 30 +- ...xir_shallowwater_source_terms_dirichlet.jl | 29 +- ...lixir_shallowwater_twolayer_convergence.jl | 31 +- ...xir_shallowwater_twolayer_well_balanced.jl | 55 +- .../elixir_shallowwater_well_balanced.jl | 90 +- .../elixir_shallowwater_well_balanced_wall.jl | 90 +- .../elixir_advection_extended.jl | 28 +- .../tree_2d_fdsbp/elixir_euler_convergence.jl | 41 +- ...ixir_euler_kelvin_helmholtz_instability.jl | 69 +- examples/tree_2d_fdsbp/elixir_euler_vortex.jl | 102 +- .../tree_3d_dgsem/elixir_advection_amr.jl | 46 +- .../tree_3d_dgsem/elixir_advection_basic.jl | 30 +- .../elixir_advection_extended.jl | 40 +- .../tree_3d_dgsem/elixir_advection_mortar.jl | 43 +- .../tree_3d_dgsem/elixir_advection_restart.jl | 8 +- examples/tree_3d_dgsem/elixir_euler_amr.jl | 71 +- .../tree_3d_dgsem/elixir_euler_blob_amr.jl | 137 ++- .../tree_3d_dgsem/elixir_euler_convergence.jl | 33 +- .../elixir_euler_convergence_pure_fv.jl | 33 +- .../elixir_euler_density_pulse.jl | 57 +- examples/tree_3d_dgsem/elixir_euler_ec.jl | 33 +- examples/tree_3d_dgsem/elixir_euler_mortar.jl | 37 +- .../elixir_euler_sedov_blast_wave.jl | 159 +-- .../elixir_euler_shockcapturing.jl | 43 +- .../elixir_euler_shockcapturing_amr.jl | 58 +- .../elixir_euler_source_terms.jl | 33 +- .../elixir_euler_taylor_green_vortex.jl | 61 +- .../elixir_eulergravity_convergence.jl | 56 +- .../elixir_hypdiff_lax_friedrichs.jl | 93 +- .../elixir_hypdiff_nonperiodic.jl | 49 +- examples/tree_3d_dgsem/elixir_lbm_constant.jl | 37 +- .../elixir_lbm_taylor_green_vortex.jl | 60 +- .../tree_3d_dgsem/elixir_mhd_alfven_wave.jl | 38 +- .../elixir_mhd_alfven_wave_mortar.jl | 45 +- examples/tree_3d_dgsem/elixir_mhd_ec.jl | 36 +- .../elixir_mhd_ec_shockcapturing.jl | 38 +- .../elixir_navierstokes_convergence.jl | 439 ++++--- ...elixir_navierstokes_taylor_green_vortex.jl | 58 +- .../elixir_advection_extended.jl | 28 +- .../tree_3d_fdsbp/elixir_euler_convergence.jl | 40 +- .../elixir_euler_taylor_green_vortex.jl | 72 +- .../elixir_acoustics_gauss_wall.jl | 45 +- .../elixir_advection_basic.jl | 29 +- .../elixir_euler_basic.jl | 43 +- .../unstructured_2d_dgsem/elixir_euler_ec.jl | 31 +- .../elixir_euler_free_stream.jl | 41 +- .../elixir_euler_periodic.jl | 19 +- .../elixir_euler_restart.jl | 13 +- .../elixir_euler_sedov.jl | 78 +- .../elixir_euler_wall_bc.jl | 64 +- .../elixir_mhd_alfven_wave.jl | 51 +- .../unstructured_2d_dgsem/elixir_mhd_ec.jl | 79 +- .../elixir_shallowwater_dirichlet.jl | 54 +- .../elixir_shallowwater_ec.jl | 101 +- .../elixir_shallowwater_ec_shockcapturing.jl | 104 +- .../elixir_shallowwater_source_terms.jl | 33 +- ...lixir_shallowwater_twolayer_convergence.jl | 34 +- .../elixir_shallowwater_twolayer_dam_break.jl | 139 ++- ...xir_shallowwater_twolayer_well_balanced.jl | 58 +- ...xir_shallowwater_wall_bc_shockcapturing.jl | 83 +- .../elixir_shallowwater_well_balanced.jl | 93 +- src/equations/linearized_euler_2d.jl | 4 +- src/equations/shallow_water_1d.jl | 6 +- src/equations/shallow_water_2d.jl | 16 +- test/coverage/coverage.jl | 48 +- test/runtests.jl | 216 ++-- test/test_dgmulti_1d.jl | 157 +-- test/test_dgmulti_2d.jl | 1010 ++++++----------- test/test_dgmulti_3d.jl | 405 +++---- test/test_mpi.jl | 45 +- test/test_mpi_p4est_2d.jl | 126 +- test/test_mpi_p4est_3d.jl | 223 ++-- test/test_mpi_tree.jl | 474 +++----- test/test_p4est_2d.jl | 421 +++---- test/test_p4est_3d.jl | 456 +++----- ...est_paper_self_gravitating_gas_dynamics.jl | 347 ++---- test/test_parabolic_1d.jl | 21 +- test/test_parabolic_2d.jl | 478 ++++---- test/test_parabolic_3d.jl | 270 ++--- test/test_performance_specializations_2d.jl | 310 ++--- test/test_performance_specializations_3d.jl | 310 ++--- test/test_special_elixirs.jl | 517 ++++----- test/test_structured_1d.jl | 99 +- test/test_structured_2d.jl | 691 +++++------ test/test_structured_3d.jl | 325 ++---- test/test_threaded.jl | 294 ++--- test/test_tree_1d.jl | 490 ++++---- test/test_tree_1d_advection.jl | 50 +- test/test_tree_1d_burgers.jl | 46 +- test/test_tree_1d_euler.jl | 390 +++---- test/test_tree_1d_eulergravity.jl | 18 +- test/test_tree_1d_eulermulti.jl | 116 +- test/test_tree_1d_fdsbp.jl | 157 +-- test/test_tree_1d_hypdiff.jl | 26 +- test/test_tree_1d_mhd.jl | 280 +---- test/test_tree_1d_mhdmulti.jl | 112 +- test/test_tree_1d_shallowwater.jl | 223 ++-- test/test_tree_1d_shallowwater_twolayer.jl | 90 +- test/test_tree_2d_acoustics.jl | 125 +- test/test_tree_2d_advection.jl | 377 +++--- test/test_tree_2d_euler.jl | 909 +++++---------- test/test_tree_2d_euleracoustics.jl | 34 +- test/test_tree_2d_eulermulti.jl | 156 +-- test/test_tree_2d_fdsbp.jl | 129 +-- test/test_tree_2d_hypdiff.jl | 81 +- test/test_tree_2d_kpp.jl | 20 +- test/test_tree_2d_lbm.jl | 149 +-- test/test_tree_2d_linearizedeuler.jl | 21 +- test/test_tree_2d_mhd.jl | 296 +---- test/test_tree_2d_mhdmulti.jl | 126 +- 383 files changed, 15875 insertions(+), 18956 deletions(-) diff --git a/docs/literate/make.jl b/docs/literate/make.jl index 45240a36d78..b620f85c975 100644 --- a/docs/literate/make.jl +++ b/docs/literate/make.jl @@ -3,22 +3,22 @@ using Test: @testset import Pkg # Create markdown and notebook files for `file` -function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder = "") +function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder="") notebook_filename = first(splitext(file)) * ".ipynb" if !isempty(folder) notebook_filename = joinpath(folder, notebook_filename) end - binder_logo = "https://mybinder.org/badge_logo.svg" + binder_logo = "https://mybinder.org/badge_logo.svg" nbviewer_logo = "https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg" download_logo = "https://camo.githubusercontent.com/aea75103f6d9f690a19cb0e17c06f984ab0f472d9e6fe4eadaa0cc438ba88ada/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f776e6c6f61642d6e6f7465626f6f6b2d627269676874677265656e" notebook_path = "tutorials/notebooks/$notebook_filename" - binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path" + binder_url = "https://mybinder.org/v2/gh/trixi-framework/Trixi.jl/tutorial_notebooks?filepath=$notebook_path" nbviewer_url = "https://nbviewer.jupyter.org/github/trixi-framework/Trixi.jl/blob/tutorial_notebooks/$notebook_path" download_url = "https://raw.githubusercontent.com/trixi-framework/Trixi.jl/tutorial_notebooks/$notebook_path" - binder_badge = "# [![]($binder_logo)]($binder_url)" + binder_badge = "# [![]($binder_logo)]($binder_url)" nbviewer_badge = "# [![]($nbviewer_logo)]($nbviewer_url)" download_badge = "# [![]($download_logo)]($download_url)" @@ -28,50 +28,43 @@ function create_files(title, file, repo_src, pages_dir, notebooks_dir; folder = # available for the latest stable release of Trixi.jl at the time of caching.\n\n" return string("# # $title\n\n", warning, content) end - Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder); - execute = false, preprocess = preprocess_notebook, credit = false) + Literate.notebook(joinpath(repo_src, folder, file), joinpath(notebooks_dir, folder); execute=false, preprocess=preprocess_notebook, credit=false) # Generate markdown file function preprocess_docs(content) - return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $download_badge\n\n", - content) + return string("# # [$title](@id $(splitext(file)[1]))\n $binder_badge\n $nbviewer_badge\n $download_badge\n\n", content) end - Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder); - preprocess = preprocess_docs) + Literate.markdown(joinpath(repo_src, folder, file), joinpath(pages_dir, folder); preprocess=preprocess_docs,) end # Create tutorials with Literate.jl function create_tutorials(files) - repo_src = joinpath(@__DIR__, "src", "files") + repo_src = joinpath(@__DIR__, "src", "files") - pages_dir = joinpath(@__DIR__, "..", "src", "tutorials") - notebooks_dir = joinpath(pages_dir, "notebooks") + pages_dir = joinpath(@__DIR__, "..", "src", "tutorials") + notebooks_dir = joinpath(pages_dir, "notebooks") - Sys.rm(pages_dir; recursive = true, force = true) + Sys.rm(pages_dir; recursive=true, force=true) - Sys.rm("out"; recursive = true, force = true) + Sys.rm("out"; recursive=true, force=true) # Run tests on all tutorial files @testset "TrixiTutorials" begin for (i, (title, filename)) in enumerate(files) if filename isa Vector # Several files of one topic for j in eachindex(filename) - @testset "$(filename[j][2][2])" begin - include(joinpath(repo_src, filename[j][2][1], filename[j][2][2])) - end + @testset "$(filename[j][2][2])" begin include(joinpath(repo_src, filename[j][2][1], filename[j][2][2])) end end else # Single files - @testset "$title" begin - include(joinpath(repo_src, filename)) - end + @testset "$title" begin include(joinpath(repo_src, filename)) end end end end # Generate markdown file for introduction page - Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name = "introduction") + Literate.markdown(joinpath(repo_src, "index.jl"), pages_dir; name="introduction") # Navigation system for makedocs - pages = Any["Introduction" => "tutorials/introduction.md"] + pages = Any["Introduction" => "tutorials/introduction.md",] # Create markdown and notebook files for tutorials for (i, (title, filename)) in enumerate(files) @@ -79,9 +72,8 @@ function create_tutorials(files) if filename isa Vector vector = [] for j in eachindex(filename) - create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2], - repo_src, - pages_dir, notebooks_dir; folder = filename[j][2][1]) + create_files("$i.$j: $title: $(filename[j][1])", filename[j][2][2], repo_src, + pages_dir, notebooks_dir; folder=filename[j][2][1]) path = "$(filename[j][2][1])/$(splitext(filename[j][2][2])[1]).md" push!(vector, "$i.$j $(filename[j][1])" => "tutorials/$path") diff --git a/docs/literate/src/files/DGMulti_1.jl b/docs/literate/src/files/DGMulti_1.jl index b50f76225bb..0d78e79907c 100644 --- a/docs/literate/src/files/DGMulti_1.jl +++ b/docs/literate/src/files/DGMulti_1.jl @@ -30,22 +30,22 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (32, 32) mesh = DGMultiMesh(dg, cells_per_dimension, # initial_refinement_level = 5 - coordinates_min = (-2.0, -2.0), - coordinates_max = (2.0, 2.0), - periodicity = true) + coordinates_min=(-2.0, -2.0), + coordinates_max=( 2.0, 2.0), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval = 10) -analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) +alive_callback = AliveCallback(alive_interval=10) +analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) callbacks = CallbackSet(analysis_callback, alive_callback); # Run the simulation with the same time integration algorithm as before. -sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-6, reltol = 1.0e-6, - callback = callbacks, save_everystep = false); +sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-6, reltol=1.0e-6, + callback=callbacks, save_everystep=false); #- using Plots pd = PlotData2D(sol) @@ -60,6 +60,7 @@ plot!(getmesh(pd)) # (2021) provides a nice runtime comparison between the different mesh types. On the other hand, # the functions are more general and thus we have more option we can choose from. + # ## Simulation with Gauss nodes # For instance, we can change the approximation type of our simulation. using Trixi, OrdinaryDiffEq @@ -77,27 +78,28 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (32, 32) mesh = DGMultiMesh(dg, - cells_per_dimension, # initial_refinement_level = 5 - coordinates_min = (-2.0, -2.0), - coordinates_max = (2.0, 2.0), - periodicity = true) + cells_per_dimension, # initial_refinement_level = 5 + coordinates_min=(-2.0, -2.0), + coordinates_max=( 2.0, 2.0), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval = 10) -analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) +alive_callback = AliveCallback(alive_interval=10) +analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) callbacks = CallbackSet(analysis_callback, alive_callback); -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); #- using Plots pd = PlotData2D(sol) plot(pd) + # ## Simulation with triangular elements # Also, we can set another element type. We want to use triangles now. using Trixi, OrdinaryDiffEq @@ -117,21 +119,21 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (32, 32) mesh = DGMultiMesh(dg, cells_per_dimension, # initial_refinement_level = 5 - coordinates_min = (-2.0, -2.0), - coordinates_max = (2.0, 2.0), - periodicity = true) + coordinates_min=(-2.0, -2.0), + coordinates_max=( 2.0, 2.0), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval = 10) -analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) +alive_callback = AliveCallback(alive_interval=10) +analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) callbacks = CallbackSet(analysis_callback, alive_callback); -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); #- using Plots pd = PlotData2D(sol) @@ -140,6 +142,7 @@ plot(pd) plot(pd["rho"]) plot!(getmesh(pd)) + # ## Triangular meshes on non-Cartesian domains # To use triangular meshes on a non-Cartesian domain, Trixi.jl uses the package [StartUpDG.jl](https://github.com/jlchan/StartUpDG.jl). # The following example is based on [`elixir_euler_triangulate_pkg_mesh.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl) @@ -154,7 +157,7 @@ source_terms = source_terms_convergence_test # We create the solver `DGMulti` with triangular elements (`Tri()`) as before. dg = DGMulti(polydeg = 3, element_type = Tri(), - approximation_type = Polynomial(), + approximation_type=Polynomial(), surface_flux = flux_lax_friedrichs, volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) @@ -165,11 +168,11 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole()); # The pre-defined Triangulate geometry in StartUpDG has integer boundary tags. With [`DGMultiMesh`](@ref) # we assign boundary faces based on these integer boundary tags and create a mesh compatible with Trixi.jl. -mesh = DGMultiMesh(meshIO, dg, Dict(:outer_boundary => 1, :inner_boundary => 2)) +mesh = DGMultiMesh(meshIO, dg, Dict(:outer_boundary=>1, :inner_boundary=>2)) #- boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test, - :inner_boundary => boundary_condition_convergence_test) + :inner_boundary => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -178,12 +181,12 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, tspan = (0.0, 0.2) ode = semidiscretize(semi, tspan) -alive_callback = AliveCallback(alive_interval = 20) -analysis_callback = AnalysisCallback(semi, interval = 200, uEltype = real(dg)) +alive_callback = AliveCallback(alive_interval=20) +analysis_callback = AnalysisCallback(semi, interval=200, uEltype=real(dg)) callbacks = CallbackSet(alive_callback, analysis_callback); -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); #- using Plots pd = PlotData2D(sol) diff --git a/docs/literate/src/files/DGMulti_2.jl b/docs/literate/src/files/DGMulti_2.jl index 2944f83b309..92dce43cdab 100644 --- a/docs/literate/src/files/DGMulti_2.jl +++ b/docs/literate/src/files/DGMulti_2.jl @@ -8,8 +8,8 @@ # to the `DGMulti` constructor. For example, the classical second-order FD SBP operator # can be created as using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly -D = derivative_operator(MattssonNordström2004(), derivative_order = 1, accuracy_order = 2, - xmin = 0.0, xmax = 1.0, N = 11) +D = derivative_operator(MattssonNordström2004(), derivative_order=1, accuracy_order=2, + xmin=0.0, xmax=1.0, N=11) # Here, the arguments `xmin` and `xmax` do not matter beyond setting the real type # used for the operator - they just set a reference element and are rescaled on the # physical elements. The parameter `N` determines the number of finite difference nodes. @@ -20,8 +20,8 @@ D = derivative_operator(MattssonNordström2004(), derivative_order = 1, accuracy # # You can also use fully periodic single-block FD methods by creating a periodic SBP # operator. For example, a fully periodic FD operator can be constructed as -D = periodic_derivative_operator(derivative_order = 1, accuracy_order = 2, - xmin = 0.0, xmax = 1.0, N = 11) +D = periodic_derivative_operator(derivative_order=1, accuracy_order=2, + xmin=0.0, xmax=1.0, N=11) # An example using such an FD method is implemented in # [`elixir_euler_fdsbp_periodic.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl). # For all parameters and other calling options, please have a look in the @@ -31,8 +31,8 @@ D = periodic_derivative_operator(derivative_order = 1, accuracy_order = 2, # method with polynomial degree of `3` (`N=4` Legendre Lobatto nodes on `[0, 1]`) coupled continuously # on a uniform mesh with `Nx=10` elements by setting `approximation_type` to using Trixi.SummationByPartsOperators # or add SummationByPartsOperators to your project and use it directly -D = couple_continuously(legendre_derivative_operator(xmin = 0.0, xmax = 1.0, N = 4), - UniformPeriodicMesh1D(xmin = -1.0, xmax = 1.0, Nx = 10)) +D = couple_continuously(legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4), + UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10)) # To choose a discontinuous coupling (DGSEM), use `couple_discontinuously()` instead of `couple_continuously()`. diff --git a/docs/literate/src/files/DGSEM_FluxDiff.jl b/docs/literate/src/files/DGSEM_FluxDiff.jl index 49463fafa54..cf3b0a1dbd4 100644 --- a/docs/literate/src/files/DGSEM_FluxDiff.jl +++ b/docs/literate/src/files/DGSEM_FluxDiff.jl @@ -20,6 +20,7 @@ # J u_t + f(u)_{\xi} = 0, \qquad t\in \mathbb{R}^+, \xi\in [-1,1] # ``` + # ## The weak form of the DGSEM # We consider the so-called discontinuous Galerkin spectral element method (DGSEM) with collocation. # It results from choosing a nodal DG ansatz using $N+1$ Gauss-Lobatto nodes $\xi_i$ in $[-1,1]$ @@ -76,6 +77,7 @@ # ``` # More information about the equivalence you can find in [Kopriva, Gassner (2010)](https://doi.org/10.1007/s10915-010-9372-3). + # ## DGSEM with flux differencing # When using the diagonal SBP property it is possible to rewrite the application of the derivative # operator $D$ in the calculation of the volume integral into a subcell based finite volume type @@ -103,6 +105,7 @@ # flux $f=f_{sur}$ used for the numerical flux $f_{sur}^*$ and the already mentioned volume # flux $f_{vol}$ especially for this formulation. + # This formulation creates a more stable version of DGSEM, because it fulfils entropy stability. # Moreover it allows the construction of entropy conserving discretizations without relying on # exact integration. This is achieved when using a two-point entropy conserving flux function as @@ -110,6 +113,8 @@ # Then, the numerical surface flux can be used to control the dissipation of the discretization and to # guarantee decreasing entropy, i.e. entropy stability. + + # ## [Implementation in Trixi.jl](@id fluxDiffExample) # Now, we have a look at the implementation of DGSEM with flux differencing with [Trixi.jl](https://github.com/trixi-framework/Trixi.jl). using OrdinaryDiffEq, Trixi @@ -153,21 +158,21 @@ initial_condition = initial_condition_weak_blast_wave # We will confirm the entropy conservation property numerically. volume_flux = flux_ranocha # = f_vol -solver = DGSEM(polydeg = 3, surface_flux = volume_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=volume_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Now, we implement Trixi.jl's `mesh`, `semi` and `ode` in a simple framework. For more information please # have a look at the documentation, the basic tutorial [introduction to DG methods](@ref scalar_linear_advection_1d) # or some basic elixirs. coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=5, + n_cells_max=10_000, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) ## ODE solvers tspan = (0.0, 0.4) @@ -175,11 +180,11 @@ ode = semidiscretize(semi, tspan); # To analyse the entropy conservation of the approximation, we will use the analysis calllback # implemented in Trixi. It provides some information about the approximation including the entropy change. -analysis_callback = AnalysisCallback(semi, interval = 100); +analysis_callback = AnalysisCallback(semi, interval=100); # We now run the simulation using `flux_ranocha` for both surface and volume flux. -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = analysis_callback); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=analysis_callback); # A look at the change in entropy $\sum \partial S/\partial U \cdot U_t$ in the analysis callback # confirms that the flux is entropy conserving since the change is about machine precision. @@ -197,33 +202,34 @@ equations = CompressibleEulerEquations2D(gamma) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha # = f_vol -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=5, + n_cells_max=10_000, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) ## ODE solvers tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan); -analysis_callback = AnalysisCallback(semi, interval = 100); +analysis_callback = AnalysisCallback(semi, interval=100); # We now run the simulation using the volume flux `flux_ranocha` and surface flux `flux_lax_friedrichs`. -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = analysis_callback); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=analysis_callback); # The change in entropy confirms the expected entropy stability. using Plots plot(sol) + # Of course, you can use more than these two fluxes in Trixi. Here, we will give a short list # of possible fluxes for the compressible Euler equations. # For the volume flux Trixi.jl provides for example [`flux_ranocha`](@ref), [`flux_shima_etal`](@ref), diff --git a/docs/literate/src/files/adaptive_mesh_refinement.jl b/docs/literate/src/files/adaptive_mesh_refinement.jl index c96040350e9..d6150e887a8 100644 --- a/docs/literate/src/files/adaptive_mesh_refinement.jl +++ b/docs/literate/src/files/adaptive_mesh_refinement.jl @@ -50,6 +50,7 @@ # amr_indicator = IndicatorMax(semi, variable=variable) # ```` + # ### Controllers # The spatial discretization into elements is tree-based for both AMR supporting mesh types `TreeMesh` # and `P4estMesh`. Thus, the higher the level in the tree the higher the level of refinement. @@ -86,6 +87,7 @@ # This controller is for instance used in # [`elixir_euler_astro_jet_amr.jl`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl). + # ### Callback # The AMR indicator and controller are added to the simulation through the callback [`AMRCallback`](@ref). # It contains a semidiscretization `semi`, the controller `amr_controller` and the parameters `interval`, @@ -101,6 +103,7 @@ # adapt_initial_condition_only_refine=true) # ```` + # # Exemplary simulation # Here, we want to implement a simple AMR simulation of the 2D linear advection equation for a Gaussian pulse. @@ -111,16 +114,17 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan); @@ -128,29 +132,29 @@ ode = semidiscretize(semi, tspan); # `IndicatorMax`. As described before, it returns the maximal value of the specified variable # (here the only conserved variable). Therefore, regions with a high maximum are refined. # This is not really useful numerical application, but a nice demonstration example. -amr_indicator = IndicatorMax(semi, variable = first) +amr_indicator = IndicatorMax(semi, variable=first) # These values are transferred to a refinement level with the `ControllerThreeLevel`, such that # every element with maximal value greater than `0.1` is refined once and elements with maximum # above `0.6` are refined twice. amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) callbacks = CallbackSet(amr_callback, stepsize_callback); # Running 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); +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); # We plot the solution and add the refined mesh at the end of the simulation. using Plots @@ -158,6 +162,7 @@ pd = PlotData2D(sol) plot(pd) plot!(getmesh(pd)) + # # More examples # Trixi.jl provides many elixirs using AMR. We want to give some examples for different mesh types: # - `elixir_euler_blast_wave_amr.jl` for [`TreeMesh`](https://github.com/trixi-framework/Trixi.jl/blob/main/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl) diff --git a/docs/literate/src/files/adding_new_parabolic_terms.jl b/docs/literate/src/files/adding_new_parabolic_terms.jl index 7da7ba78520..882f73f66ff 100644 --- a/docs/literate/src/files/adding_new_parabolic_terms.jl +++ b/docs/literate/src/files/adding_new_parabolic_terms.jl @@ -7,6 +7,7 @@ using OrdinaryDiffEq using Trixi + advection_velocity = (1.0, 1.0) equations_hyperbolic = LinearScalarAdvectionEquation2D(advection_velocity); @@ -19,13 +20,12 @@ equations_hyperbolic = LinearScalarAdvectionEquation2D(advection_velocity); # functions defined for hyperbolic equations (such as `varnames`). struct ConstantAnisotropicDiffusion2D{E, T} <: Trixi.AbstractEquationsParabolic{2, 1} - diffusivity::T - equations_hyperbolic::E + diffusivity::T + equations_hyperbolic::E end -function varnames(variable_mapping, equations_parabolic::ConstantAnisotropicDiffusion2D) - varnames(variable_mapping, equations_parabolic.equations_hyperbolic) -end +varnames(variable_mapping, equations_parabolic::ConstantAnisotropicDiffusion2D) = + varnames(variable_mapping, equations_parabolic.equations_hyperbolic) # Next, we define the viscous flux function. We assume that the mixed hyperbolic-parabolic system # is of the form @@ -39,15 +39,14 @@ end # # Here, we specialize the flux to our new parabolic equation type `ConstantAnisotropicDiffusion2D`. -function Trixi.flux(u, gradients, orientation::Integer, - equations_parabolic::ConstantAnisotropicDiffusion2D) - @unpack diffusivity = equations_parabolic - dudx, dudy = gradients - if orientation == 1 - return SVector(diffusivity[1, 1] * dudx + diffusivity[1, 2] * dudy) - else # if orientation == 2 - return SVector(diffusivity[2, 1] * dudx + diffusivity[2, 2] * dudy) - end +function Trixi.flux(u, gradients, orientation::Integer, equations_parabolic::ConstantAnisotropicDiffusion2D) + @unpack diffusivity = equations_parabolic + dudx, dudy = gradients + if orientation == 1 + return SVector(diffusivity[1, 1] * dudx + diffusivity[1, 2] * dudy) + else # if orientation == 2 + return SVector(diffusivity[2, 1] * dudx + diffusivity[2, 2] * dudy) + end end # ## Defining boundary conditions @@ -70,7 +69,7 @@ end # As an example, let us introduce a Dirichlet boundary condition with constant boundary data. struct BoundaryConditionConstantDirichlet{T <: Real} - boundary_value::T + boundary_value::T end # This boundary condition contains only the field `boundary_value`, which we assume to be some @@ -81,13 +80,10 @@ end # the `Gradient` and `Divergence`. Since the gradient is operating on the solution `u`, the boundary # data should be the value of `u`, and we can directly impose Dirichlet data. -@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, - u_inner, - normal::AbstractVector, - x, t, - operator_type::Trixi.Gradient, +@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, u_inner, normal::AbstractVector, + x, t, operator_type::Trixi.Gradient, equations_parabolic::ConstantAnisotropicDiffusion2D) - return boundary_condition.boundary_value + return boundary_condition.boundary_value end # While the gradient acts on the solution `u`, the divergence acts on the viscous flux ``\bm{\sigma}``. @@ -99,13 +95,10 @@ end # `flux_inner`, which is boundary data for ``\bm{\sigma}`` computed using the "inner" or interior solution. # This way, we supply boundary data for the divergence operation without imposing any additional conditions. -@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, - u_inner, - normal::AbstractVector, - x, t, - operator_type::Trixi.Divergence, +@inline function (boundary_condition::BoundaryConditionConstantDirichlet)(flux_inner, u_inner, normal::AbstractVector, + x, t, operator_type::Trixi.Divergence, equations_parabolic::ConstantAnisotropicDiffusion2D) - return flux_inner + return flux_inner end # ### A note on the choice of gradient variables @@ -130,38 +123,38 @@ using Trixi: SMatrix diffusivity = 5.0e-2 * SMatrix{2, 2}([2 -1; -1 2]) equations_parabolic = ConstantAnisotropicDiffusion2D(diffusivity, equations_hyperbolic); -boundary_conditions_hyperbolic = (; - x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1.0)), - y_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(2.0)), - y_pos = boundary_condition_do_nothing, - x_pos = boundary_condition_do_nothing) +boundary_conditions_hyperbolic = (; x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1.0)), + y_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(2.0)), + y_pos = boundary_condition_do_nothing, + x_pos = boundary_condition_do_nothing) boundary_conditions_parabolic = (; x_neg = BoundaryConditionConstantDirichlet(1.0), - y_neg = BoundaryConditionConstantDirichlet(2.0), - y_pos = BoundaryConditionConstantDirichlet(0.0), - x_pos = BoundaryConditionConstantDirichlet(0.0)); + y_neg = BoundaryConditionConstantDirichlet(2.0), + y_pos = BoundaryConditionConstantDirichlet(0.0), + x_pos = BoundaryConditionConstantDirichlet(0.0)); -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = false, n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=4, + periodicity=false, n_cells_max=30_000) # set maximum capacity of tree data structure initial_condition = (x, t, equations) -> SVector(0.0) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations_hyperbolic, equations_parabolic), initial_condition, solver; - boundary_conditions = (boundary_conditions_hyperbolic, - boundary_conditions_parabolic)) + boundary_conditions=(boundary_conditions_hyperbolic, + boundary_conditions_parabolic)) tspan = (0.0, 2.0) ode = semidiscretize(semi, tspan) callbacks = CallbackSet(SummaryCallback()) time_int_tol = 1.0e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks); using Plots plot(sol) + diff --git a/docs/literate/src/files/adding_new_scalar_equations.jl b/docs/literate/src/files/adding_new_scalar_equations.jl index c66ad37f2ae..fec7bcf667a 100644 --- a/docs/literate/src/files/adding_new_scalar_equations.jl +++ b/docs/literate/src/files/adding_new_scalar_equations.jl @@ -12,8 +12,8 @@ # ## Basic setup using Trixi -struct CubicEquation <: Trixi.AbstractEquations{1, #= number of spatial dimensions =# - 1} #= number of primary variables, i.e. scalar =# +struct CubicEquation <: Trixi.AbstractEquations{1 #= number of spatial dimensions =#, + 1 #= number of primary variables, i.e. scalar =#}; end # We create `CubicEquation` as an empty `struct` since we do not use any parameters @@ -23,7 +23,7 @@ end # Next, we define the physical flux `f(u) = u^3` using the calling structure # used in Trixi.jl. -Trixi.flux(u, orientation, equation::CubicEquation) = u .^ 3 +Trixi.flux(u, orientation, equation::CubicEquation) = u.^3 Trixi.varnames(_, ::CubicEquation) = ("scalar",) # In Trixi.jl, the conserved variables `u` are usually passed as `SVector`s of variables @@ -41,10 +41,10 @@ equation = CubicEquation() initial_condition_sine(x, t, equation::CubicEquation) = SVector(sinpi(x[1])) mesh = TreeMesh(-1.0, 1.0, # min/max coordinates - initial_refinement_level = 4, - n_cells_max = 10^4) + initial_refinement_level=4, + n_cells_max=10^4) -solver = DGSEM(3, flux_central) #= polynomial degree =# +solver = DGSEM(3 #= polynomial degree =#, flux_central) semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -67,7 +67,7 @@ callbacks = CallbackSet(summary_callback) ## OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks sol = solve(ode, SSPRK43(); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); # That's it, you ran your first simulation using your new equation with Trixi.jl! Now, we can plot # the solution at the final time using Plots.jl. @@ -79,21 +79,20 @@ plot(sol) # To avoid these issues, we need to use dissipative numerical fluxes (approximate # Riemann solvers) at interfaces. + # ## Advanced setup # Thus, we add a Godunov's flux for our cubic equation. That is easy for this equation # since the wave speed `f'(u) = 3u^2` is always non-negative. -@inline function Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) - flux(u_ll, orientation, equation) -end +@inline Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) = flux(u_ll, orientation, equation) # Let's run the example again but with a dissipative numerical flux at interfaces. # `remake` will recreate the semidiscretization we used before and only change # selected parameters, in this case the `solver`. ## A new setup with dissipation -semi = remake(semi, solver = DGSEM(3, flux_godunov)) +semi = remake(semi, solver=DGSEM(3, flux_godunov)) ode = semidiscretize(semi, tspan) sol = solve(ode, SSPRK43(); ode_default_options()...) plot!(sol) @@ -102,9 +101,8 @@ plot!(sol) # Now let's increase the final time (and also the spatial resolution). ## A larger final time: Nonclassical shocks develop (you can even increase the refinement to 12) -semi = remake(semi, - mesh = TreeMesh(-1.0, 1.0, initial_refinement_level = 8, n_cells_max = 10^5)) -ode = semidiscretize(semi, (0.0, 0.5)) #= tspan =# +semi = remake(semi, mesh=TreeMesh(-1.0, 1.0, initial_refinement_level=8, n_cells_max=10^5)) +ode = semidiscretize(semi, (0.0, 0.5) #= tspan =#) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) @@ -114,16 +112,14 @@ plot(sol) # to define an entropy-conservative numerical flux @inline function Trixi.flux_ec(u_ll, u_rr, orientation, equation::CubicEquation) - return SVector(0.25 * - (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) + return SVector(0.25 * (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) end # and use a [`VolumeIntegralFluxDifferencing`](@ref) instead of the standard # [`VolumeIntegralWeakForm`](@ref) in the DGSEM. ## Let's use a provably entropy-dissipative semidiscretization -semi = remake(semi, - solver = DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) +semi = remake(semi, solver=DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) ode = semidiscretize(semi, (0.0, 0.5)) sol = solve(ode, SSPRK43(); ode_default_options()...); plot(sol) @@ -141,6 +137,7 @@ plot(sol) # the 2D scalar "KPP equation" from [Kurganov, Petrova, Popov (2007)](https://doi.org/10.1137/040614189) is # implemented. + # ## Summary of the code # To sum up, here is the complete code that we used (without the callbacks since these create a @@ -153,23 +150,21 @@ module CubicConservationLaw using Trixi -struct CubicEquation <: Trixi.AbstractEquations{1, #= number of spatial dimensions =# - 1} #= number of primary variables, i.e. scalar =# +struct CubicEquation <: Trixi.AbstractEquations{1 #= number of spatial dimensions =#, + 1 #= number of primary variables, i.e. scalar =#} end -@inline Trixi.flux(u, orientation, equation::CubicEquation) = u .^ 3 +@inline Trixi.flux(u, orientation, equation::CubicEquation) = u.^3 Trixi.varnames(_, ::CubicEquation) = ("scalar",) -@inline function Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) - flux(u_ll, orientation, equation) -end +@inline Trixi.flux_godunov(u_ll, u_rr, orientation, equation::CubicEquation) = flux(u_ll, orientation, equation) @inline function Trixi.flux_ec(u_ll, u_rr, orientation, equation::CubicEquation) - return SVector(0.25 * - (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) + return SVector(0.25 * (u_ll[1]^3 + u_ll[1]^2 * u_rr[1] + u_ll[1] * u_rr[1]^2 + u_rr[1]^3)) end end # module + ## Create a simulation setup import .CubicConservationLaw using Trixi @@ -178,15 +173,13 @@ using Plots equation = CubicConservationLaw.CubicEquation() -function initial_condition_sine(x, t, equation::CubicConservationLaw.CubicEquation) - SVector(sinpi(x[1])) -end +initial_condition_sine(x, t, equation::CubicConservationLaw.CubicEquation) = SVector(sinpi(x[1])) mesh = TreeMesh(-1.0, 1.0, # min/max coordinates - initial_refinement_level = 4, - n_cells_max = 10^4) + initial_refinement_level=4, + n_cells_max=10^4) -solver = DGSEM(3, flux_central) #= polynomial degree =# +solver = DGSEM(3 #= polynomial degree =#, flux_central) semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -198,22 +191,23 @@ ode = semidiscretize(semi, tspan) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) + ## A new setup with dissipation -semi = remake(semi, solver = DGSEM(3, flux_godunov)) +semi = remake(semi, solver=DGSEM(3, flux_godunov)) ode = semidiscretize(semi, tspan) sol = solve(ode, SSPRK43(); ode_default_options()...) plot!(sol) + ## A larger final time: Nonclassical shocks develop (you can even increase the refinement to 12) -semi = remake(semi, - mesh = TreeMesh(-1.0, 1.0, initial_refinement_level = 8, n_cells_max = 10^5)) +semi = remake(semi, mesh=TreeMesh(-1.0, 1.0, initial_refinement_level=8, n_cells_max=10^5)) ode = semidiscretize(semi, (0.0, 0.5)) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) + ## Let's use a provably entropy-dissipative semidiscretization -semi = remake(semi, - solver = DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) +semi = remake(semi, solver=DGSEM(3, flux_godunov, VolumeIntegralFluxDifferencing(flux_ec))) ode = semidiscretize(semi, (0.0, 0.5)) sol = solve(ode, SSPRK43(); ode_default_options()...) plot(sol) diff --git a/docs/literate/src/files/adding_nonconservative_equation.jl b/docs/literate/src/files/adding_nonconservative_equation.jl index ddd6d8d5207..110fa486070 100644 --- a/docs/literate/src/files/adding_nonconservative_equation.jl +++ b/docs/literate/src/files/adding_nonconservative_equation.jl @@ -40,28 +40,27 @@ import Trixi: varnames, default_analysis_integrals, flux, max_abs_speed_naive, ## Since there is no native support for variable coefficients, we use two ## variables: one for the basic unknown `u` and another one for the coefficient `a` -struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# - 2} #= two variables (u,a) =# +struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, + 2 #= two variables (u,a) =#} end -function varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) - ("scalar", "advection_velocity") -end +varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () + ## The conservative part of the flux is zero flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) ## Calculate maximum wave speed for local Lax-Friedrichs-type dissipation -function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, - ::NonconservativeLinearAdvectionEquation) +function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) _, advection_velocity_ll = u_ll _, advection_velocity_rr = u_rr return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) end + ## We use nonconservative terms have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() @@ -74,7 +73,7 @@ have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.Tru function flux_nonconservative(u_mine, u_other, orientation, equations::NonconservativeLinearAdvectionEquation) _, advection_velocity = u_mine - scalar, _ = u_other + scalar, _ = u_other return SVector(advection_velocity * scalar, zero(scalar)) end @@ -106,15 +105,15 @@ end ## Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level = 4, n_cells_max = 10^4) + initial_refinement_level=4, n_cells_max=10^4) ## Create a DGSEM solver with polynomials of degree `polydeg` ## Remember to pass a tuple of the form `(conservative_flux, nonconservative_flux)` ## as `surface_flux` and `volume_flux` when working with nonconservative terms -volume_flux = (flux_central, flux_nonconservative) +volume_flux = (flux_central, flux_nonconservative) surface_flux = (flux_lax_friedrichs, flux_nonconservative) -solver = DGSEM(polydeg = 3, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ## Setup the spatial semidiscretization containing all ingredients semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -126,13 +125,13 @@ ode = semidiscretize(semi, tspan) ## Set up some standard callbacks summarizing the simulation setup and computing ## errors of the numerical solution summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval = 50) +analysis_callback = AnalysisCallback(semi, interval=50) callbacks = CallbackSet(summary_callback, analysis_callback) ## OrdinaryDiffEq's `solve` method evolves the solution in time and executes ## the passed callbacks -sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, - save_everystep = false, callback = callbacks) +sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, + save_everystep=false, callback=callbacks) ## Print the timer summary summary_callback() @@ -153,7 +152,7 @@ error_1 = analysis_callback(sol).l2 |> first # simulation again. mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level = 5, n_cells_max = 10^4) + initial_refinement_level=5, n_cells_max=10^4) semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -161,22 +160,24 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval = 50) +analysis_callback = AnalysisCallback(semi, interval=50) callbacks = CallbackSet(summary_callback, analysis_callback); -sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, - save_everystep = false, callback = callbacks); +sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, + save_everystep=false, callback=callbacks); summary_callback() #nb #- error_2 = analysis_callback(sol).l2 |> first -@test isapprox(error_2, 1.860295931682964e-5, rtol = 0.05) #src +@test isapprox(error_2, 1.860295931682964e-5, rtol=0.05) #src #- error_1 / error_2 -@test isapprox(error_1 / error_2, 15.916970234784808, rtol = 0.05) #src +@test isapprox(error_1 / error_2, 15.916970234784808, rtol=0.05) #src # As expected, the new error is roughly reduced by a factor of 16, corresponding # to an experimental order of convergence of 4 (for polynomials of degree 3). + + # ## Summary of the code # Here is the complete code that we used (without the callbacks since these @@ -185,6 +186,7 @@ error_1 / error_2 # That ensures that we can re-create `struct`s defined therein without having to # restart Julia. + # Define new physics module NonconservativeLinearAdvection @@ -195,28 +197,27 @@ import Trixi: varnames, default_analysis_integrals, flux, max_abs_speed_naive, ## Since there is not yet native support for variable coefficients, we use two ## variables: one for the basic unknown `u` and another one for the coefficient `a` -struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# - 2} #= two variables (u,a) =# +struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, + 2 #= two variables (u,a) =#} end -function varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) - ("scalar", "advection_velocity") -end +varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () + ## The conservative part of the flux is zero flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) ## Calculate maximum wave speed for local Lax-Friedrichs-type dissipation -function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, - ::NonconservativeLinearAdvectionEquation) +function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) _, advection_velocity_ll = u_ll _, advection_velocity_rr = u_rr return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) end + ## We use nonconservative terms have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() @@ -229,13 +230,15 @@ have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.Tru function flux_nonconservative(u_mine, u_other, orientation, equations::NonconservativeLinearAdvectionEquation) _, advection_velocity = u_mine - scalar, _ = u_other + scalar, _ = u_other return SVector(advection_velocity * scalar, zero(scalar)) end end # module + + ## Create a simulation setup import .NonconservativeLinearAdvection using Trixi @@ -245,8 +248,7 @@ equation = NonconservativeLinearAdvection.NonconservativeLinearAdvectionEquation ## You can derive the exact solution for this setup using the method of ## characteristics -function initial_condition_sine(x, t, - equation::NonconservativeLinearAdvection.NonconservativeLinearAdvectionEquation) +function initial_condition_sine(x, t, equation::NonconservativeLinearAdvection.NonconservativeLinearAdvectionEquation) x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) scalar = sin(x0) advection_velocity = 2 + cos(x[1]) @@ -255,15 +257,15 @@ end ## Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level = 4, n_cells_max = 10^4) + initial_refinement_level=4, n_cells_max=10^4) ## Create a DGSEM solver with polynomials of degree `polydeg` ## Remember to pass a tuple of the form `(conservative_flux, nonconservative_flux)` ## as `surface_flux` and `volume_flux` when working with nonconservative terms -volume_flux = (flux_central, NonconservativeLinearAdvection.flux_nonconservative) +volume_flux = (flux_central, NonconservativeLinearAdvection.flux_nonconservative) surface_flux = (flux_lax_friedrichs, NonconservativeLinearAdvection.flux_nonconservative) -solver = DGSEM(polydeg = 3, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ## Setup the spatial semidiscretization containing all ingredients semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) @@ -275,13 +277,13 @@ ode = semidiscretize(semi, tspan); ## Set up some standard callbacks summarizing the simulation setup and computing ## errors of the numerical solution summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval = 50) +analysis_callback = AnalysisCallback(semi, interval=50) callbacks = CallbackSet(summary_callback, analysis_callback); ## OrdinaryDiffEq's `solve` method evolves the solution in time and executes ## the passed callbacks -sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, - save_everystep = false); +sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, + save_everystep=false); ## Plot the numerical solution at the final time using Plots: plot diff --git a/docs/literate/src/files/differentiable_programming.jl b/docs/literate/src/files/differentiable_programming.jl index 5b6b21525bb..ecc09d05dcf 100644 --- a/docs/literate/src/files/differentiable_programming.jl +++ b/docs/literate/src/files/differentiable_programming.jl @@ -10,11 +10,13 @@ using Test: @test #src # In the following, we will walk through some examples demonstrating how to differentiate through # Trixi.jl. + # ## Forward mode automatic differentiation # Trixi.jl integrates well with [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) # for forward mode AD. + # ### Computing the Jacobian # The high-level interface to compute the Jacobian this way is [`jacobian_ad_forward`](@ref). # First, we load the required packages and compute the Jacobian of a semidiscretization @@ -25,7 +27,7 @@ using Trixi, LinearAlgebra, Plots equations = CompressibleEulerEquations2D(1.4) solver = DGSEM(3, flux_central) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_wave, solver) @@ -36,7 +38,7 @@ size(J) # Next, we compute the eigenvalues of the Jacobian. λ = eigvals(J) -scatter(real.(λ), imag.(λ), label = "central flux") +scatter(real.(λ), imag.(λ), label="central flux") # As you can see here, the maximal real part is close to zero. @@ -52,7 +54,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_w J = jacobian_ad_forward(semi) λ = eigvals(J) -scatter!(real.(λ), imag.(λ), label = "Lax-Friedrichs flux") +scatter!(real.(λ), imag.(λ), label="Lax-Friedrichs flux") # Although the maximal real part is still somewhat small, it's larger than for # the purely central discretization. @@ -72,7 +74,7 @@ condition_number = cond(V) equations = CompressibleEulerEquations1D(1.4) solver = DGSEM(3, flux_central) -mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level = 6, n_cells_max = 10^5) +mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=6, n_cells_max=10^5) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_wave, solver) @@ -80,7 +82,7 @@ J = jacobian_ad_forward(semi) λ = eigvals(J) -scatter(real.(λ), imag.(λ), label = "central flux") +scatter(real.(λ), imag.(λ), label="central flux") # Here, the maximal real part is basically zero to machine accuracy. @@ -101,7 +103,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_w J = jacobian_ad_forward(semi) λ = eigvals(J) -scatter!(real.(λ), imag.(λ), label = "Lax-Friedrichs flux") +scatter!(real.(λ), imag.(λ), label="Lax-Friedrichs flux") # As you can see from the plot generated above, the maximal real part is still # basically zero to machine precision. @@ -119,6 +121,7 @@ condition_number = cond(V) # Note that the condition number of the eigenvector matrix increases but is # still smaller than for the example in 2D. + # ### Computing other derivatives # It is also possible to compute derivatives of other dependencies using AD in Trixi.jl. For example, @@ -143,41 +146,40 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - inicenter = SVector(0.0, 0.0) # initial center of the vortex - iniamplitude = 5.0 # size and strength of the vortex + inicenter = SVector(0.0, 0.0) # initial center of the vortex + iniamplitude = 5.0 # size and strength of the vortex - rho = 1.0 # base flow - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 + rho = 1.0 # base flow + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 - cent = inicenter + vel * t_loc # shift advection of center to handle periodic BC, but only for v1 = v2 = 1.0 - cent = x - cent # distance to center point - cent = SVector(-cent[2], cent[1]) + cent = inicenter + vel*t_loc # shift advection of center to handle periodic BC, but only for v1 = v2 = 1.0 + cent = x - cent # distance to center point + cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) solver = DGSEM(3, flux_lax_friedrichs, VolumeIntegralFluxDifferencing(flux_ranocha)) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, solver) u0_ode = Trixi.compute_coefficients(0.0, semi) size(u0_ode) @@ -186,14 +188,13 @@ size(u0_ode) # Next, we compute the Jacobian using `ForwardDiff.jacobian`. J = ForwardDiff.jacobian((du_ode, γ) -> begin - equations_inner = CompressibleEulerEquations2D(first(γ)) - semi_inner = Trixi.remake(semi, equations = equations_inner, - uEltype = eltype(γ)) - Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) - end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` + equations_inner = CompressibleEulerEquations2D(first(γ)) + semi_inner = Trixi.remake(semi, equations=equations_inner, uEltype=eltype(γ)) + Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) +end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` -round.(extrema(J), sigdigits = 2) -@test round.(extrema(J), sigdigits = 2) == (-220.0, 220.0) #src +round.(extrema(J), sigdigits=2) +@test round.(extrema(J), sigdigits=2) == (-220.0, 220.0) #src # Note that we create a semidiscretization `semi` at first to determine the state `u0_ode` around # which we want to perform the linearization. Next, we wrap the RHS evaluation inside a closure @@ -210,6 +211,7 @@ norm(J[1:4:end]) # Here, we used some knowledge about the internal memory layout of Trixi.jl, an array of structs # with the conserved variables as fastest-varying index in memory. + # ## Differentiating through a complete simulation # It is also possible to differentiate through a complete simulation. As an example, let's differentiate @@ -220,23 +222,22 @@ using Trixi, OrdinaryDiffEq, ForwardDiff, Plots function energy_at_final_time(k) # k is the wave number of the initial condition equations = LinearScalarAdvectionEquation2D(1.0, -0.3) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, - n_cells_max = 10^4) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) solver = DGSEM(3, flux_lax_friedrichs) initial_condition = (x, t, equation) -> begin - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) - return SVector(sinpi(k * sum(x_trans))) + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) + return SVector(sinpi(k * sum(x_trans))) end semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype = typeof(k)) + uEltype=typeof(k)) ode = semidiscretize(semi, (0.0, 1.0)) - sol = solve(ode, BS3(), save_everystep = false) + sol = solve(ode, BS3(), save_everystep=false) Trixi.integrate(energy_total, sol.u[end], semi) end -k_values = range(0.9, 1.1, length = 101) +k_values = range(0.9, 1.1, length=101) -plot(k_values, energy_at_final_time.(k_values), label = "Energy") +plot(k_values, energy_at_final_time.(k_values), label="Energy") # You see a plot of a curve that resembles a parabola with local maximum around `k = 1.0`. # Why's that? Well, the domain is fixed but the wave number changes. Thus, if the wave number is @@ -248,45 +249,44 @@ plot(k_values, energy_at_final_time.(k_values), label = "Energy") # We can compute the discrete derivative of the energy at the final time with respect to the wave # number `k` as follows. -round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits = 2) -@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits = 2) == 1.4e-5 #src +round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits=2) +@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits=2) == 1.4e-5 #src # This is rather small and we can treat it as zero in comparison to the value of this derivative at # other wave numbers `k`. dk_values = ForwardDiff.derivative.((energy_at_final_time,), k_values); -plot(k_values, dk_values, label = "Derivative") +plot(k_values, dk_values, label="Derivative") # If you remember basic calculus, a sufficient condition for a local maximum is that the first derivative # vanishes and the second derivative is negative. We can also check this discretely. -second_derivative = round(ForwardDiff.derivative(k -> Trixi.ForwardDiff.derivative(energy_at_final_time, - k), 1.0), - sigdigits = 2) +second_derivative = round(ForwardDiff.derivative( + k -> Trixi.ForwardDiff.derivative(energy_at_final_time, k), 1.0), + sigdigits=2) @test second_derivative ≈ -0.9 #src # Having seen this application, let's break down what happens step by step. function energy_at_final_time(k) # k is the wave number of the initial condition equations = LinearScalarAdvectionEquation2D(1.0, -0.3) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, - n_cells_max = 10^4) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) solver = DGSEM(3, flux_lax_friedrichs) initial_condition = (x, t, equation) -> begin x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) return SVector(sinpi(k * sum(x_trans))) end semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype = typeof(k)) + uEltype=typeof(k)) ode = semidiscretize(semi, (0.0, 1.0)) - sol = solve(ode, BS3(), save_everystep = false) + sol = solve(ode, BS3(), save_everystep=false) Trixi.integrate(energy_total, sol.u[end], semi) end k = 1.0 -round(ForwardDiff.derivative(energy_at_final_time, k), sigdigits = 2) -@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits = 2) == 1.4e-5 #src +round(ForwardDiff.derivative(energy_at_final_time, k), sigdigits=2) +@test round(ForwardDiff.derivative(energy_at_final_time, 1.0), sigdigits=2) == 1.4e-5 #src # When calling `ForwardDiff.derivative(energy_at_final_time, k)` with `k=1.0`, ForwardDiff.jl # will basically use the chain rule and known derivatives of existing basic functions @@ -300,7 +300,7 @@ round(ForwardDiff.derivative(energy_at_final_time, k), sigdigits = 2) # The first step in this example creates some basic ingredients of our simulation. equations = LinearScalarAdvectionEquation2D(1.0, -0.3) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, n_cells_max = 10^4) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) solver = DGSEM(3, flux_lax_friedrichs); # These do not have internal caches storing intermediate values of the numerical @@ -325,18 +325,19 @@ end; # need to tell Trixi.jl to allow `ForwardDiff.Dual` numbers in these caches. That's what # the keyword argument `uEltype=typeof(k)` in semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype = typeof(k)); + uEltype=typeof(k)); # does. This is basically the only part where you need to modify your standard Trixi.jl # code to enable automatic differentiation. From there on, the remaining steps ode = semidiscretize(semi, (0.0, 1.0)) -sol = solve(ode, BS3(), save_everystep = false) -round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits = 5) -@test round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits = 5) == 0.24986 #src +sol = solve(ode, BS3(), save_everystep=false) +round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits=5) +@test round(Trixi.integrate(energy_total, sol.u[end], semi), sigdigits=5) == 0.24986 #src # do not need any modifications since they are sufficiently generic (and enough effort # has been spend to allow general types inside these calls). + # ## Propagating errors using Measurements.jl # [![Error bars by Randall Munroe](https://imgs.xkcd.com/comics/error_bars.png)](https://xkcd.com/2110/) @@ -353,16 +354,16 @@ using Trixi, OrdinaryDiffEq, Measurements, Plots, LaTeXStrings equations = LinearScalarAdvectionEquation1D(1.0 ± 0.1) -mesh = TreeMesh((-1.0,), (1.0,), n_cells_max = 10^5, initial_refinement_level = 5) +mesh = TreeMesh((-1.0,), (1.0,), n_cells_max=10^5, initial_refinement_level=5) solver = DGSEM(3) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver, uEltype = Measurement{Float64}) + solver, uEltype=Measurement{Float64}) ode = semidiscretize(semi, (0.0, 1.5)) -sol = solve(ode, BS3(), save_everystep = false); +sol = solve(ode, BS3(), save_everystep=false); plot(sol) @@ -377,6 +378,7 @@ plot(sol) # All this is possible due to allowing generic types and having good abstractions # in Julia that allow packages to work together seamlessly. + # ## Finite difference approximations # Trixi.jl provides the convenience function [`jacobian_fd`](@ref) to approximate the Jacobian @@ -388,7 +390,7 @@ equations = CompressibleEulerEquations2D(1.4) solver = DGSEM(3, flux_central) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_density_wave, solver) @@ -401,6 +403,7 @@ relative_difference = norm(J_fd - J_ad) / size(J_fd, 1) # This discrepancy is of the expected order of magnitude for central finite difference approximations. + # ## Linear systems # When a linear PDE is discretized using a linear scheme such as a standard DG method, @@ -423,10 +426,9 @@ equations = LinearScalarAdvectionEquation2D(1.0, -0.3) solver = DGSEM(3, flux_lax_friedrichs) -mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 2, n_cells_max = 10^5) +mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=2, n_cells_max=10^5) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) A, b = linear_structure(semi) diff --git a/docs/literate/src/files/hohqmesh_tutorial.jl b/docs/literate/src/files/hohqmesh_tutorial.jl index b0e6402aa74..87076108d91 100644 --- a/docs/literate/src/files/hohqmesh_tutorial.jl +++ b/docs/literate/src/files/hohqmesh_tutorial.jl @@ -35,8 +35,8 @@ # There is a default example for this mesh type that can be executed by using Trixi -redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md - trixi_include(default_example_unstructured()) +redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md +trixi_include(default_example_unstructured()) end #hide #md # This will compute a smooth, manufactured solution test case for the 2D compressible Euler equations @@ -52,8 +52,8 @@ end #hide #md # To convert the HDF5-formatted `.h5` output file(s) from Trixi.jl into VTK format execute the following using Trixi2Vtk -redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md - trixi2vtk("out/solution_000180.h5", output_directory = "out") +redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md +trixi2vtk("out/solution_000180.h5", output_directory="out") end #hide #md # Note this step takes about 15-30 seconds as the package `Trixi2Vtk` must be precompiled and executed for the first time @@ -62,8 +62,8 @@ end #hide #md # where the new files will be saved; it defaults to the current directory. (2) Specifying a higher number of # visualization nodes. For instance, if we want to use 12 uniformly spaced nodes for visualization we can execute -redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md - trixi2vtk("out/solution_000180.h5", output_directory = "out", nvisnodes = 12) +redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md +trixi2vtk("out/solution_000180.h5", output_directory="out", nvisnodes=12) end #hide #md # By default `trixi2vtk` sets `nvisnodes` to be the same as the number of nodes specified in @@ -71,8 +71,8 @@ end #hide #md # Finally, if you want to convert all the solution files to VTK execute -redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md - trixi2vtk("out/solution_000*.h5", output_directory = "out", nvisnodes = 12) +redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md +trixi2vtk("out/solution_000*.h5", output_directory="out", nvisnodes=12) end #hide #md # then it is possible to open the `.pvd` file with ParaView and create a video of the simulation. @@ -94,64 +94,64 @@ end #hide #md # The associated `ice_cream_straight_sides.control` file is created below. open("out/ice_cream_straight_sides.control", "w") do io - println(io, raw""" - \begin{CONTROL_INPUT} - \begin{RUN_PARAMETERS} - mesh file name = ice_cream_straight_sides.mesh - plot file name = ice_cream_straight_sides.tec - stats file name = none - mesh file format = ISM-v2 - polynomial order = 4 - plot file format = skeleton - \end{RUN_PARAMETERS} - - \begin{BACKGROUND_GRID} - x0 = [-8.0, -8.0, 0.0] - dx = [1.0, 1.0, 0.0] - N = [16,16,1] - \end{BACKGROUND_GRID} - - \begin{SPRING_SMOOTHER} - smoothing = ON - smoothing type = LinearAndCrossBarSpring - number of iterations = 25 - \end{SPRING_SMOOTHER} - - \end{CONTROL_INPUT} - - \begin{MODEL} - - \begin{INNER_BOUNDARIES} - - \begin{CHAIN} - name = IceCreamCone - \begin{END_POINTS_LINE} - name = LeftSlant - xStart = [-2.0, 1.0, 0.0] - xEnd = [ 0.0, -3.0, 0.0] - \end{END_POINTS_LINE} - - \begin{END_POINTS_LINE} - name = RightSlant - xStart = [ 0.0, -3.0, 0.0] - xEnd = [ 2.0, 1.0, 0.0] - \end{END_POINTS_LINE} - - \begin{CIRCULAR_ARC} - name = IceCream - units = degrees - center = [ 0.0, 1.0, 0.0] - radius = 2.0 - start angle = 0.0 - end angle = 180.0 - \end{CIRCULAR_ARC} - \end{CHAIN} - - \end{INNER_BOUNDARIES} - - \end{MODEL} - \end{FILE} - """) + println(io, raw""" +\begin{CONTROL_INPUT} + \begin{RUN_PARAMETERS} + mesh file name = ice_cream_straight_sides.mesh + plot file name = ice_cream_straight_sides.tec + stats file name = none + mesh file format = ISM-v2 + polynomial order = 4 + plot file format = skeleton + \end{RUN_PARAMETERS} + + \begin{BACKGROUND_GRID} + x0 = [-8.0, -8.0, 0.0] + dx = [1.0, 1.0, 0.0] + N = [16,16,1] + \end{BACKGROUND_GRID} + + \begin{SPRING_SMOOTHER} + smoothing = ON + smoothing type = LinearAndCrossBarSpring + number of iterations = 25 + \end{SPRING_SMOOTHER} + +\end{CONTROL_INPUT} + +\begin{MODEL} + + \begin{INNER_BOUNDARIES} + + \begin{CHAIN} + name = IceCreamCone + \begin{END_POINTS_LINE} + name = LeftSlant + xStart = [-2.0, 1.0, 0.0] + xEnd = [ 0.0, -3.0, 0.0] + \end{END_POINTS_LINE} + + \begin{END_POINTS_LINE} + name = RightSlant + xStart = [ 0.0, -3.0, 0.0] + xEnd = [ 2.0, 1.0, 0.0] + \end{END_POINTS_LINE} + + \begin{CIRCULAR_ARC} + name = IceCream + units = degrees + center = [ 0.0, 1.0, 0.0] + radius = 2.0 + start angle = 0.0 + end angle = 180.0 + \end{CIRCULAR_ARC} + \end{CHAIN} + + \end{INNER_BOUNDARIES} + +\end{MODEL} +\end{FILE} +""") end # The first three blocks of information are wrapped within a `CONTROL_INPUT` environment block as they define the @@ -304,18 +304,18 @@ equations = CompressibleEulerEquations2D(1.4) # set gas gamma = 1.4 ## freestream flow state with Ma_inf = 0.3 @inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D) - ## set the freestream flow parameters - rho_freestream = 1.0 - u_freestream = 0.3 - p_freestream = inv(equations.gamma) + ## set the freestream flow parameters + rho_freestream = 1.0 + u_freestream = 0.3 + p_freestream = inv(equations.gamma) - theta = 0.0 # zero angle of attack - si, co = sincos(theta) - v1 = u_freestream * co - v2 = u_freestream * si + theta = 0.0 # zero angle of attack + si, co = sincos(theta) + v1 = u_freestream * co + v2 = u_freestream * si - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end ## initial condition @@ -325,13 +325,13 @@ initial_condition = uniform_flow_state boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state) ## boundary condition dictionary -boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow, - :Top => boundary_condition_uniform_flow, - :Right => boundary_condition_uniform_flow, - :Left => boundary_condition_uniform_flow, - :LeftSlant => boundary_condition_slip_wall, - :RightSlant => boundary_condition_slip_wall, - :IceCream => boundary_condition_slip_wall); +boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, + :Top => boundary_condition_uniform_flow, + :Right => boundary_condition_uniform_flow, + :Left => boundary_condition_uniform_flow, + :LeftSlant => boundary_condition_slip_wall, + :RightSlant => boundary_condition_slip_wall, + :IceCream => boundary_condition_slip_wall ); ## DGSEM solver. ## 1) polydeg must be >= the polynomial order set in the HOHQMesh control file to guarantee @@ -339,8 +339,8 @@ boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow, ## 2) VolumeIntegralFluxDifferencing with central volume flux is activated ## for dealiasing volume_flux = flux_ranocha -solver = DGSEM(polydeg = 4, surface_flux = flux_hll, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=flux_hll, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ## create the unstructured mesh from your mesh file mesh_file = joinpath("out", "ice_cream_straight_sides.mesh") @@ -348,28 +348,29 @@ mesh = UnstructuredMesh2D(mesh_file) ## Create semidiscretization with all spatial discretization-related components semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ## Create ODE problem from semidiscretization with time span from 0.0 to 2.0 tspan = (0.0, 2.0) ode = semidiscretize(semi, tspan) + ## Create the callbacks to output solution files and adapt the time step summary_callback = SummaryCallback() -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, save_solution, stepsize_callback) -redirect_stdio(stdout = devnull, stderr = devnull) do # code that prints annoying stuff we don't want to see here #hide #md - ## Evolve ODE problem in time using `solve` from OrdinaryDiffEq - 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) - ## print the timer summary - summary_callback() +redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md +## Evolve ODE problem in time using `solve` from OrdinaryDiffEq +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); +## print the timer summary +summary_callback() end #hide #md # Visualization of the solution is carried out in a similar way as above. That is, one converts the `.h5` @@ -387,72 +388,72 @@ end #hide #md # We create the new control file `ice_cream_curved_sides.control` file below and will then highlight the # major differences compared to `ice_cream_straight_sides.control`. open("out/ice_cream_curved_sides.control", "w") do io - println(io, raw""" - \begin{CONTROL_INPUT} - \begin{RUN_PARAMETERS} - mesh file name = ice_cream_curved_sides.mesh - plot file name = ice_cream_curved_sides.tec - stats file name = none - mesh file format = ISM-v2 - polynomial order = 4 - plot file format = skeleton - \end{RUN_PARAMETERS} - - \begin{BACKGROUND_GRID} - background grid size = [1.0, 1.0, 0.0] - \end{BACKGROUND_GRID} - - \begin{SPRING_SMOOTHER} - smoothing = ON - smoothing type = LinearAndCrossBarSpring - number of iterations = 25 - \end{SPRING_SMOOTHER} - - \end{CONTROL_INPUT} - - \begin{MODEL} - - \begin{OUTER_BOUNDARY} - \begin{PARAMETRIC_EQUATION_CURVE} - name = OuterCircle - xEqn = x(t) = 8.0*sin(2.0*pi*t) - yEqn = y(t) = 8.0*cos(2.0*pi*t) - zEqn = z(t) = 0.0 - \end{PARAMETRIC_EQUATION_CURVE} - - \end{OUTER_BOUNDARY} - - \begin{INNER_BOUNDARIES} - - \begin{CHAIN} - name = IceCreamCone - \begin{END_POINTS_LINE} - name = LeftSlant - xStart = [-2.0, 1.0, 0.0] - xEnd = [ 0.0, -3.0, 0.0] - \end{END_POINTS_LINE} - - \begin{END_POINTS_LINE} - name = RightSlant - xStart = [ 0.0, -3.0, 0.0] - xEnd = [ 2.0, 1.0, 0.0] - \end{END_POINTS_LINE} - - \begin{CIRCULAR_ARC} - name = IceCream - units = degrees - center = [ 0.0, 1.0, 0.0] - radius = 2.0 - start angle = 0.0 - end angle = 180.0 - \end{CIRCULAR_ARC} - \end{CHAIN} - - \end{INNER_BOUNDARIES} - - \end{MODEL} - \end{FILE} - """) + println(io, raw""" +\begin{CONTROL_INPUT} + \begin{RUN_PARAMETERS} + mesh file name = ice_cream_curved_sides.mesh + plot file name = ice_cream_curved_sides.tec + stats file name = none + mesh file format = ISM-v2 + polynomial order = 4 + plot file format = skeleton + \end{RUN_PARAMETERS} + + \begin{BACKGROUND_GRID} + background grid size = [1.0, 1.0, 0.0] + \end{BACKGROUND_GRID} + + \begin{SPRING_SMOOTHER} + smoothing = ON + smoothing type = LinearAndCrossBarSpring + number of iterations = 25 + \end{SPRING_SMOOTHER} + +\end{CONTROL_INPUT} + +\begin{MODEL} + + \begin{OUTER_BOUNDARY} + \begin{PARAMETRIC_EQUATION_CURVE} + name = OuterCircle + xEqn = x(t) = 8.0*sin(2.0*pi*t) + yEqn = y(t) = 8.0*cos(2.0*pi*t) + zEqn = z(t) = 0.0 + \end{PARAMETRIC_EQUATION_CURVE} + + \end{OUTER_BOUNDARY} + + \begin{INNER_BOUNDARIES} + + \begin{CHAIN} + name = IceCreamCone + \begin{END_POINTS_LINE} + name = LeftSlant + xStart = [-2.0, 1.0, 0.0] + xEnd = [ 0.0, -3.0, 0.0] + \end{END_POINTS_LINE} + + \begin{END_POINTS_LINE} + name = RightSlant + xStart = [ 0.0, -3.0, 0.0] + xEnd = [ 2.0, 1.0, 0.0] + \end{END_POINTS_LINE} + + \begin{CIRCULAR_ARC} + name = IceCream + units = degrees + center = [ 0.0, 1.0, 0.0] + radius = 2.0 + start angle = 0.0 + end angle = 180.0 + \end{CIRCULAR_ARC} + \end{CHAIN} + + \end{INNER_BOUNDARIES} + +\end{MODEL} +\end{FILE} +""") end # The first alteration is that we have altered the second block of information @@ -499,10 +500,10 @@ output = generate_mesh(control_file); # dictionary because we now have a boundary named `OuterCircle` instead of four edges of a bounding box. ## boundary condition dictionary -boundary_conditions = Dict(:OuterCircle => boundary_condition_uniform_flow, - :LeftSlant => boundary_condition_slip_wall, - :RightSlant => boundary_condition_slip_wall, - :IceCream => boundary_condition_slip_wall); +boundary_conditions = Dict( :OuterCircle => boundary_condition_uniform_flow, + :LeftSlant => boundary_condition_slip_wall, + :RightSlant => boundary_condition_slip_wall, + :IceCream => boundary_condition_slip_wall ); # Also, we must update the construction of the mesh from our new mesh file `ice_cream_curved_sides.mesh` that # is located in the `out` folder. @@ -511,10 +512,12 @@ boundary_conditions = Dict(:OuterCircle => boundary_condition_uniform_flow, mesh_file = joinpath("out", "ice_cream_curved_sides.mesh") mesh = UnstructuredMesh2D(mesh_file); + # We can then post-process the solution file at the final time on the new mesh with `Trixi2Vtk` and visualize with ParaView. # ![simulation_curved_sides](https://user-images.githubusercontent.com/25242486/129733924-778795c1-9119-419a-8b89-bcbe13e33cd7.png) + # ## Setting up a simulation with AMR via `P4estMesh` # The above explained mesh file format of `ISM-V2` only works with `UnstructuredMesh2D` and so does # not support AMR. On the other hand, the mesh type [`P4estMesh`](@ref) allows AMR. The mesh diff --git a/docs/literate/src/files/non_periodic_boundaries.jl b/docs/literate/src/files/non_periodic_boundaries.jl index 5b92afa6a0d..54da88a64aa 100644 --- a/docs/literate/src/files/non_periodic_boundaries.jl +++ b/docs/literate/src/files/non_periodic_boundaries.jl @@ -25,6 +25,7 @@ # where `x` specifies the spatial coordinates, `t` is the current time, and `equations` is the # corresponding system of equations. + # We want to give a short example for a simulation with such a Dirichlet BC. # Consider the one-dimensional linear advection equation with domain $\Omega=[0, 2]$ and a constant @@ -38,8 +39,7 @@ initial_condition_zero(x, t, equation::LinearScalarAdvectionEquation1D) = SVecto initial_condition = initial_condition_zero using Plots -plot(x -> sum(initial_condition(x, 0.0, equations)), label = "initial condition", - ylim = (-1.5, 1.5)) +plot(x -> sum(initial_condition(x, 0.0, equations)), label="initial condition", ylim=(-1.5, 1.5)) # Using an advection velocity of `1.0` and the (local) Lax-Friedrichs/Rusanov flux # [`FluxLaxFriedrichs`](@ref) as a numerical surface flux, we are able to create an inflow boundary @@ -57,10 +57,10 @@ end boundary_condition = boundary_condition_sine_sector # We set the BC in negative and positive x-direction. -boundary_conditions = (x_neg = BoundaryConditionDirichlet(boundary_condition), - x_pos = BoundaryConditionDirichlet(boundary_condition)) +boundary_conditions = (x_neg=BoundaryConditionDirichlet(boundary_condition), + x_pos=BoundaryConditionDirichlet(boundary_condition)) #- -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (2.0,) @@ -68,41 +68,41 @@ coordinates_max = (2.0,) # For the mesh type `TreeMesh` the parameter `periodicity` must be set to `false` in the # corresponding direction. mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) tspan = (0.0, 6.0) ode = semidiscretize(semi, tspan) -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100,) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) callbacks = CallbackSet(analysis_callback, stepsize_callback); # We define some equidistant nodes for the visualization -visnodes = range(tspan[1], tspan[2], length = 300) +visnodes = range(tspan[1], tspan[2], length=300) # and run the simulation. -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 1, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, saveat = visnodes, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=1, # solve needs some value here but it will be overwritten by the stepsize_callback + save_everystep=false, saveat=visnodes, callback=callbacks); using Plots @gif for step in 1:length(sol.u) - plot(sol.u[step], semi, ylim = (-1.5, 1.5), legend = true, label = "approximation", - title = "time t=$(round(sol.t[step], digits=5))") - scatter!([0.0], [sum(boundary_condition(SVector(0.0), sol.t[step], equations))], - label = "boundary condition") + plot(sol.u[step], semi, ylim=(-1.5, 1.5), legend=true, label="approximation", title="time t=$(round(sol.t[step], digits=5))") + scatter!([0.0], [sum(boundary_condition(SVector(0.0), sol.t[step], equations))], label="boundary condition") end + # # Other available example elixirs with non-trivial BC # Moreover, there are other boundary conditions in Trixi.jl. For instance, you can use the slip wall # boundary condition [`boundary_condition_slip_wall`](@ref). diff --git a/docs/literate/src/files/parabolic_terms.jl b/docs/literate/src/files/parabolic_terms.jl index 8c7800a1f1f..bac0098f8e9 100644 --- a/docs/literate/src/files/parabolic_terms.jl +++ b/docs/literate/src/files/parabolic_terms.jl @@ -34,33 +34,27 @@ equations_parabolic = LaplaceDiffusion2D(diffusivity, equations_hyperbolic); boundary_condition_zero_dirichlet = BoundaryConditionDirichlet((x, t, equations) -> SVector(0.0)) -boundary_conditions_hyperbolic = (; - x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + - 0.5 * - x[2])), - y_neg = boundary_condition_zero_dirichlet, - y_pos = boundary_condition_do_nothing, - x_pos = boundary_condition_do_nothing) - -boundary_conditions_parabolic = (; - x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + - 0.5 * - x[2])), - y_neg = boundary_condition_zero_dirichlet, - y_pos = boundary_condition_zero_dirichlet, - x_pos = boundary_condition_zero_dirichlet); +boundary_conditions_hyperbolic = (; x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.5 * x[2])), + y_neg = boundary_condition_zero_dirichlet, + y_pos = boundary_condition_do_nothing, + x_pos = boundary_condition_do_nothing) + +boundary_conditions_parabolic = (; x_neg = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.5 * x[2])), + y_neg = boundary_condition_zero_dirichlet, + y_pos = boundary_condition_zero_dirichlet, + x_pos = boundary_condition_zero_dirichlet); # ## Defining the solver and mesh # The process of creating the DG solver and mesh is the same as for a purely # hyperbolic system of equations. -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = false, n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=4, + periodicity=false, n_cells_max=30_000) # set maximum capacity of tree data structure initial_condition = (x, t, equations) -> SVector(0.0); @@ -74,8 +68,8 @@ initial_condition = (x, t, equations) -> SVector(0.0); semi = SemidiscretizationHyperbolicParabolic(mesh, (equations_hyperbolic, equations_parabolic), initial_condition, solver; - boundary_conditions = (boundary_conditions_hyperbolic, - boundary_conditions_parabolic)) + boundary_conditions=(boundary_conditions_hyperbolic, + boundary_conditions_parabolic)) # The rest of the code is identical to the hyperbolic case. We create a system of ODEs through # `semidiscretize`, defining callbacks, and then passing the system to OrdinaryDiffEq.jl. @@ -84,10 +78,11 @@ tspan = (0.0, 1.5) ode = semidiscretize(semi, tspan) callbacks = CallbackSet(SummaryCallback()) time_int_tol = 1.0e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks); # We can now visualize the solution, which develops a boundary layer at the outflow boundaries. using Plots plot(sol) + diff --git a/docs/literate/src/files/scalar_linear_advection_1d.jl b/docs/literate/src/files/scalar_linear_advection_1d.jl index 1ad62484038..42c831c98ba 100644 --- a/docs/literate/src/files/scalar_linear_advection_1d.jl +++ b/docs/literate/src/files/scalar_linear_advection_1d.jl @@ -50,6 +50,7 @@ dx = (coordinates_max - coordinates_min) / n_elements # length of one element # ``` # Here, $u_t^{Q_l}$ and $u_\xi^{Q_l}$ denote the time and spatial derivatives of the solution on the element $Q_l$. + # ### ii. Polynomial approach # Now, we want to approximate the solution in each element $Q_l$ by a polynomial of degree $N$. Since we transformed # the equation, we can use the same polynomial approach for the reference coordinate $\xi\in[-1, 1]$ in every @@ -103,7 +104,8 @@ weights = basis.weights # \end{align*} # ``` # Let's use our nodes and weights for $N=3$ and plug in -integral = sum(nodes .^ 3 .* weights) +integral = sum(nodes.^3 .* weights) + # Using this polynomial approach leads to the equation # ```math @@ -117,10 +119,10 @@ integral = sum(nodes .^ 3 .* weights) # for every node. x = Matrix{Float64}(undef, length(nodes), n_elements) for element in 1:n_elements - x_l = coordinates_min + (element - 1) * dx + dx / 2 + x_l = coordinates_min + (element - 1) * dx + dx/2 for i in 1:length(nodes) ξ = nodes[i] # nodes in [-1, 1] - x[i, element] = x_l + dx / 2 * ξ + x[i, element] = x_l + dx/2 * ξ end end @@ -128,7 +130,7 @@ u0 = initial_condition_sine_wave.(x) # To have a look at the initial sinus curve, we plot it. using Plots -plot(vec(x), vec(u0), label = "initial condition", legend = :topleft) +plot(vec(x), vec(u0), label="initial condition", legend=:topleft) # ### iii. Variational formulation # After defining the equation and initial condition, we want to implement an algorithm to @@ -241,9 +243,8 @@ D = basis.derivative_matrix # ``` # for $k=0,...,N$ and therefore, $\underline{f}' = D \underline{f}$. basis_N8 = LobattoLegendreBasis(8) -plot(vec(x), x -> 3 * x^2, label = "f'", lw = 2) -scatter!(basis_N8.nodes, basis_N8.derivative_matrix * basis_N8.nodes .^ 3, label = "Df", - lw = 3) +plot(vec(x), x -> 3 * x^2, label="f'", lw=2) +scatter!(basis_N8.nodes, basis_N8.derivative_matrix * basis_N8.nodes.^3, label="Df", lw=3) # Combining the volume term for every $i=0,...,N$ results in # ```math @@ -301,15 +302,13 @@ function rhs!(du, u, x, t) ## Trixi.jl needs the equation we are dealing with and an additional `1`, that indicates the ## first coordinate direction. equations = LinearScalarAdvectionEquation1D(1.0) - for element in 2:(n_elements - 1) + for element in 2:n_elements-1 ## left interface - flux_numerical[1, element] = surface_flux(u[end, element - 1], u[1, element], 1, - equations) - flux_numerical[end, element - 1] = flux_numerical[1, element] + flux_numerical[1, element] = surface_flux(u[end, element-1], u[1, element], 1, equations) + flux_numerical[end, element-1] = flux_numerical[1, element] ## right interface - flux_numerical[end, element] = surface_flux(u[end, element], u[1, element + 1], 1, - equations) - flux_numerical[1, element + 1] = flux_numerical[end, element] + flux_numerical[end, element] = surface_flux(u[end, element], u[1, element+1], 1, equations) + flux_numerical[1, element+1] = flux_numerical[end, element] end ## boundary flux flux_numerical[1, 1] = surface_flux(u[end, end], u[1, 1], 1, equations) @@ -343,12 +342,13 @@ using OrdinaryDiffEq tspan = (0.0, 2.0) ode = ODEProblem(rhs!, u0, tspan, x) -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()...) +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...) @test maximum(abs.(u0 - sol.u[end])) < 5e-5 #src -plot(vec(x), vec(sol.u[end]), label = "solution at t=$(tspan[2])", legend = :topleft, - lw = 3) +plot(vec(x), vec(sol.u[end]), label="solution at t=$(tspan[2])", legend=:topleft, lw=3) + + + # ## Alternative Implementation based on Trixi.jl # Now, we implement the same example. But this time, we directly use the functionality that Trixi.jl @@ -362,7 +362,7 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) # Then, create a DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux. # The implementation of the basis and the numerical flux is now already done. -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # We will now create a mesh with 16 elements for the physical domain `[-1, 1]` with periodic boundaries. # We use Trixi.jl's standard mesh [`TreeMesh`](@ref). Since it's limited to hypercube domains, we @@ -371,30 +371,29 @@ solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate coordinates_max = 1.0 # maximum coordinate mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, # number of elements = 2^4 - n_cells_max = 30_000) # set maximum capacity of tree data structure (only needed for AMR) + initial_refinement_level=4, # number of elements = 2^4 + n_cells_max=30_000) # set maximum capacity of tree data structure (only needed for AMR) # A semidiscretization collects data structures and functions for the spatial discretization. # In Trixi.jl, an initial condition has the following parameter structure and is of the type `SVector`. -function initial_condition_sine_wave(x, t, equations) - SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) -end +initial_condition_sine_wave(x, t, equations) = SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_sine_wave, solver) # Again, combining all definitions and the function that calculates the right-hand side, we define the ODE and # solve it until `t=2` with OrdinaryDiffEq's `solve` function and the Runge-Kutta method `RDPK3SpFSAL49()`. tspan = (0.0, 2.0) -ode_trixi = semidiscretize(semi, tspan) +ode_trixi = semidiscretize(semi, tspan) -sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()...); +sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...); # We add a plot of the new approximated solution to the one calculated before. -plot!(sol_trixi, label = "solution at t=$(tspan[2]) with Trixi.jl", legend = :topleft, - linestyle = :dash, lw = 2) +plot!(sol_trixi, label="solution at t=$(tspan[2]) with Trixi.jl", legend=:topleft, linestyle=:dash, lw=2) @test maximum(abs.(vec(u0) - sol_trixi.u[end])) ≈ maximum(abs.(u0 - sol.u[end])) #src + + + # ## Summary of the code # To sum up, here is the complete code that we used. @@ -411,16 +410,16 @@ B = diagm([-1; zeros(polydeg - 1); 1]) ## mesh coordinates_min = -1.0 # minimum coordinate coordinates_max = 1.0 # maximum coordinate -n_elements = 16 # number of elements +n_elements = 16 # number of elements dx = (coordinates_max - coordinates_min) / n_elements # length of one element x = Matrix{Float64}(undef, length(nodes), n_elements) for element in 1:n_elements - x_l = -1 + (element - 1) * dx + dx / 2 + x_l = -1 + (element - 1) * dx + dx/2 for i in 1:length(nodes) # basis points in [-1, 1] ξ = nodes[i] - x[i, element] = x_l + dx / 2 * ξ + x[i, element] = x_l + dx/2 * ξ end end @@ -428,7 +427,7 @@ end initial_condition_sine_wave(x) = 1.0 + 0.5 * sin(pi * x) u0 = initial_condition_sine_wave.(x) -plot(vec(x), vec(u0), label = "initial condition", legend = :topleft) +plot(vec(x), vec(u0), label="initial condition", legend=:topleft) ## flux Lax-Friedrichs surface_flux = flux_lax_friedrichs @@ -441,15 +440,13 @@ function rhs!(du, u, x, t) ## calculate interface and boundary fluxes equations = LinearScalarAdvectionEquation1D(1.0) - for element in 2:(n_elements - 1) + for element in 2:n_elements-1 ## left interface - flux_numerical[1, element] = surface_flux(u[end, element - 1], u[1, element], 1, - equations) - flux_numerical[end, element - 1] = flux_numerical[1, element] + flux_numerical[1, element] = surface_flux(u[end, element-1], u[1, element], 1, equations) + flux_numerical[end, element-1] = flux_numerical[1, element] ## right interface - flux_numerical[end, element] = surface_flux(u[end, element], u[1, element + 1], 1, - equations) - flux_numerical[1, element + 1] = flux_numerical[end, element] + flux_numerical[end, element] = surface_flux(u[end, element], u[1, element+1], 1, equations) + flux_numerical[1, element+1] = flux_numerical[end, element] end ## boundary flux flux_numerical[1, 1] = surface_flux(u[end, end], u[1, 1], 1, equations) @@ -479,12 +476,11 @@ tspan = (0.0, 2.0) ode = ODEProblem(rhs!, u0, tspan, x) ## solve -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()...) +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...) @test maximum(abs.(vec(u0) - sol_trixi.u[end])) ≈ maximum(abs.(u0 - sol.u[end])) #src -plot(vec(x), vec(sol.u[end]), label = "solution at t=$(tspan[2])", legend = :topleft, - lw = 3) +plot(vec(x), vec(sol.u[end]), label="solution at t=$(tspan[2])", legend=:topleft, lw=3) + # ### Alternative Implementation based on Trixi.jl using Trixi, OrdinaryDiffEq, Plots @@ -494,28 +490,24 @@ advection_velocity = 1.0 equations = LinearScalarAdvectionEquation1D(advection_velocity) ## create DG solver with flux lax friedrichs and LGL basis -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) ## distretize domain with `TreeMesh` coordinates_min = -1.0 # minimum coordinate coordinates_max = 1.0 # maximum coordinate mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, # number of elements = 2^4 - n_cells_max = 30_000) + initial_refinement_level=4, # number of elements = 2^4 + n_cells_max=30_000) ## create initial condition and semidiscretization -function initial_condition_sine_wave(x, t, equations) - SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) -end +initial_condition_sine_wave(x, t, equations) = SVector(1.0 + 0.5 * sin(pi * sum(x - equations.advection_velocity * t))) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_sine_wave, solver) ## solve tspan = (0.0, 2.0) -ode_trixi = semidiscretize(semi, tspan) -sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()...); +ode_trixi = semidiscretize(semi, tspan) +sol_trixi = solve(ode_trixi, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, ode_default_options()...); -plot!(sol_trixi, label = "solution at t=$(tspan[2]) with Trixi.jl", legend = :topleft, - linestyle = :dash, lw = 2) +plot!(sol_trixi, label="solution at t=$(tspan[2]) with Trixi.jl", legend=:topleft, linestyle=:dash, lw=2) @test maximum(abs.(vec(u0) - sol_trixi.u[end])) ≈ maximum(abs.(u0 - sol.u[end])) #src diff --git a/docs/literate/src/files/shock_capturing.jl b/docs/literate/src/files/shock_capturing.jl index 73fd06983bb..b165f7ec8bd 100644 --- a/docs/literate/src/files/shock_capturing.jl +++ b/docs/literate/src/files/shock_capturing.jl @@ -4,6 +4,7 @@ # and its implementation in [Trixi.jl](https://github.com/trixi-framework/Trixi.jl). # In the second part, an implementation of a positivity preserving limiter is added to the simulation. + # # Shock capturing with flux differencing # The following rough explanation is on a very basic level. More information about an entropy stable @@ -35,6 +36,7 @@ # volume_flux_fv=volume_flux_fv) # ```` + # We now focus on a choice of the shock capturing indicator `indicator_sc`. # A possible indicator is $\alpha_{HG}$ presented by Hennemann et al. (p.10), which depends on the # current approximation with modal coefficients $\{m_j\}_{j=0}^N$ of a given `variable`. @@ -82,6 +84,8 @@ # variable=variable) # ```` + + # # Positivity preserving limiter # Some numerical solutions are physically meaningless, for instance negative values of pressure @@ -128,6 +132,7 @@ # SSPRK43(stage_limiter!). # ```` + # # Simulation with shock capturing and positivity preserving # Now, we can run a simulation using the described methods of shock capturing and positivity @@ -138,26 +143,26 @@ equations = CompressibleEulerEquations2D(1.4) # As our initial condition we use the Sedov blast wave setup. 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) - - 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) + ## 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) + + 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 #- @@ -166,7 +171,7 @@ basis = LobattoLegendreBasis(3) # We set the numerical fluxes and divide between the surface flux and the two volume fluxes for the DG # and FV method. Here, we are using [`flux_lax_friedrichs`](@ref) and [`flux_ranocha`](@ref). surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha # Now, we specify the shock capturing indicator $\alpha$. @@ -175,26 +180,26 @@ volume_flux = flux_ranocha # Since density and pressure are the critical variables in this example, we use # `density_pressure = density * pressure = rho * p` as indicator variable. indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) # Now, we can use the defined fluxes and the indicator to implement the volume integral using shock # capturing. volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) # We finalize the discretization by implementing Trixi.jl's `solver`, `mesh`, `semi` and `ode`, # while `solver` now has the extra parameter `volume_integral`. solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -202,20 +207,20 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan); # We add some callbacks to get an solution analysis and use a CFL-based time step size calculation. -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(analysis_callback, stepsize_callback); # We now run the simulation using the positivity preserving limiter of Zhang and Shu for the variables # density and pressure. -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); using Plots plot(sol) diff --git a/docs/literate/src/files/structured_mesh_mapping.jl b/docs/literate/src/files/structured_mesh_mapping.jl index 6cf9588f594..0ae9cf723f8 100644 --- a/docs/literate/src/files/structured_mesh_mapping.jl +++ b/docs/literate/src/files/structured_mesh_mapping.jl @@ -18,16 +18,15 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) # We start with a pressure perturbation at `(xs, 0.0)` as initial condition. -function initial_condition_pressure_perturbation(x, t, - equations::CompressibleEulerEquations2D) - xs = 1.5 # location of the initial disturbance on the x axis - w = 1 / 8 # half width - p = exp(-log(2) * ((x[1] - xs)^2 + x[2]^2) / w^2) + 1.0 - v1 = 0.0 - v2 = 0.0 - rho = 1.0 - - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_pressure_perturbation(x, t, equations::CompressibleEulerEquations2D) + xs = 1.5 # location of the initial disturbance on the x axis + w = 1/8 # half width + p = exp(-log(2) * ((x[1]-xs)^2 + x[2]^2)/w^2) + 1.0 + v1 = 0.0 + v2 = 0.0 + rho = 1.0 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_pressure_perturbation @@ -36,8 +35,8 @@ boundary_conditions = boundary_condition_slip_wall # The approximation setup is an entropy-stable split-form DG method with `polydeg=4`. We are using # the two fluxes [`flux_ranocha`](@ref) and [`flux_lax_friedrichs`](@ref). -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha)) # We want to define a circular cylinder as physical domain. It contains an inner semicircle with # radius `r0` and an outer semicircle of radius `r1`. @@ -69,6 +68,7 @@ solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, #src # \end{tikzpicture} #src # \end{document} + # The domain boundary curves with curve parameter in $[-1,1]$ are sorted as shown in the sketch. # They always are orientated from negative to positive coordinate, such that the corners have to # fit like this $f_1(+1) = f_4(-1)$, $f_3(+1) = f_2(-1)$, etc. @@ -76,37 +76,37 @@ solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, # In our case we can define the domain boundary curves as follows: r0 = 0.5 # inner radius r1 = 5.0 # outer radius -f1(xi) = SVector(r0 + 0.5 * (r1 - r0) * (xi + 1), 0.0) # right line -f2(xi) = SVector(-r0 - 0.5 * (r1 - r0) * (xi + 1), 0.0) # left line +f1(xi) = SVector( r0 + 0.5 * (r1 - r0) * (xi + 1), 0.0) # right line +f2(xi) = SVector(-r0 - 0.5 * (r1 - r0) * (xi + 1), 0.0) # left line f3(eta) = SVector(r0 * cos(0.5 * pi * (eta + 1)), r0 * sin(0.5 * pi * (eta + 1))) # inner circle f4(eta) = SVector(r1 * cos(0.5 * pi * (eta + 1)), r1 * sin(0.5 * pi * (eta + 1))) # outer circle # We create a curved mesh with 16 x 16 elements. The defined domain boundary curves are passed as a tuple. cells_per_dimension = (16, 16) -mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4), periodicity = false) +mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4), periodicity=false) # Then, we define the simulation with endtime `T=3` with `semi`, `ode` and `callbacks`. semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) tspan = (0.0, 3.0) ode = semidiscretize(semi, tspan) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) callbacks = CallbackSet(analysis_callback, alive_callback, stepsize_callback); # Running 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); +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); using Plots plot(sol) @@ -115,6 +115,7 @@ pd = PlotData2D(sol) plot(pd["p"]) plot!(getmesh(pd)) + # ## Mesh directly defined by the transformation mapping # As mentioned before, you can also define the domain for a `StructuredMesh` by directly setting up # a transformation mapping. Here, we want to present a nice mapping, which is often used to test @@ -131,22 +132,22 @@ equations = CompressibleEulerEquations2D(1.4) # initial condition. initial_condition = initial_condition_constant -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # We define the transformation mapping with variables in $[-1, 1]$ as described in # Rueda-Ramírez et al. (2021), p.18 (reduced to 2D): function mapping(xi_, eta_) - ## Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + ## Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end # Instead of a tuple of boundary functions, the `mesh` now has the mapping as its parameter. @@ -158,28 +159,28 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) -analysis_callback = AnalysisCallback(semi, interval = 250) +analysis_callback = AnalysisCallback(semi, interval=250) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(analysis_callback, stepsize_callback) -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); +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); # Now, we want to verify the free-stream preservation property and plot the mesh. For the verification, # we calculate the absolute difference of the first conservation variable density `u[1]` and `1.0`. # To plot this error and the mesh, we are using the visualization feature `ScalarPlotData2D`, # explained in [visualization](@ref visualization). error_density = let u = Trixi.wrap_array(sol.u[end], semi) - abs.(u[1, :, :, :] .- 1.0) # density, x, y, elements + abs.(u[1, :, :, :] .- 1.0) # density, x, y, elements end pd = ScalarPlotData2D(error_density, semi) using Plots -plot(pd, title = "Error in density") +plot(pd, title="Error in density") plot!(getmesh(pd)) # We observe that the errors in the variable `density` are at the level of machine accuracy. diff --git a/docs/literate/src/files/upwind_fdsbp.jl b/docs/literate/src/files/upwind_fdsbp.jl index b15259cebd3..36ca1b57404 100644 --- a/docs/literate/src/files/upwind_fdsbp.jl +++ b/docs/literate/src/files/upwind_fdsbp.jl @@ -9,8 +9,8 @@ # operator can be created as follows. using Trixi D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, accuracy_order = 2, - xmin = 0.0, xmax = 1.0, N = 11) + derivative_order=1, accuracy_order=2, + xmin=0.0, xmax=1.0, N=11) # Instead of prefixing the source of coefficients `MattssonNordström2004()`, # you can also load the package SummationByPartsOperators.jl. Either way, # this yields an object representing the operator efficiently. If you want to @@ -21,8 +21,8 @@ Matrix(D_SBP) # Upwind SBP operators are a concept introduced in 2017 by Ken Mattsson. You can # create them as follows. D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, accuracy_order = 2, - xmin = 0.0, xmax = 1.0, N = 11) + derivative_order=1, accuracy_order=2, + xmin=0.0, xmax=1.0, N=11) # Upwind operators are derivative operators biased towards one direction. # The "minus" variants has a bias towards the left side, i.e., it uses values # from more nodes to the left than from the right to compute the discrete diff --git a/docs/make.jl b/docs/make.jl index 2b3c3df4219..5069e4dc49a 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,8 +2,7 @@ using Documenter import Pkg # Fix for https://github.com/trixi-framework/Trixi.jl/issues/668 -if (get(ENV, "CI", nothing) != "true") && - (get(ENV, "TRIXI_DOC_DEFAULT_ENVIRONMENT", nothing) != "true") +if (get(ENV, "CI", nothing) != "true") && (get(ENV, "TRIXI_DOC_DEFAULT_ENVIRONMENT", nothing) != "true") push!(LOAD_PATH, dirname(@__DIR__)) end @@ -17,31 +16,30 @@ include(joinpath(trixi_root_dir, "docs", "literate", "make.jl")) # Copy list of authors to not need to synchronize it manually authors_text = read(joinpath(trixi_root_dir, "AUTHORS.md"), String) -authors_text = replace(authors_text, - "in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)") +authors_text = replace(authors_text, "in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)") write(joinpath(@__DIR__, "src", "authors.md"), authors_text) # Define module-wide setups such that the respective modules are available in doctests -DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive = true) -DocMeta.setdocmeta!(Trixi2Vtk, :DocTestSetup, :(using Trixi2Vtk); recursive = true) +DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive=true) +DocMeta.setdocmeta!(Trixi2Vtk, :DocTestSetup, :(using Trixi2Vtk); recursive=true) # Copy some files from the repository root directory to the docs and modify them # as necessary # Based on: https://github.com/ranocha/SummationByPartsOperators.jl/blob/0206a74140d5c6eb9921ca5021cb7bf2da1a306d/docs/make.jl#L27-L41 open(joinpath(@__DIR__, "src", "code_of_conduct.md"), "w") do io - # Point to source license file - println(io, """ - ```@meta - EditURL = "https://github.com/trixi-framework/Trixi.jl/blob/main/CODE_OF_CONDUCT.md" - ``` - """) - # Write the modified contents - println(io, "# [Code of Conduct](@id code-of-conduct)") - println(io, "") - for line in eachline(joinpath(dirname(@__DIR__), "CODE_OF_CONDUCT.md")) - line = replace(line, "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)") - println(io, "> ", line) - end + # Point to source license file + println(io, """ + ```@meta + EditURL = "https://github.com/trixi-framework/Trixi.jl/blob/main/CODE_OF_CONDUCT.md" + ``` + """) + # Write the modified contents + println(io, "# [Code of Conduct](@id code-of-conduct)") + println(io, "") + for line in eachline(joinpath(dirname(@__DIR__), "CODE_OF_CONDUCT.md")) + line = replace(line, "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)") + println(io, "> ", line) + end end # Create tutorials for the following files: @@ -70,63 +68,67 @@ files = [ # Topic: other stuff "Explicit time stepping" => "time_stepping.jl", "Differentiable programming" => "differentiable_programming.jl", -] + ] tutorials = create_tutorials(files) # Make documentation makedocs( - # Specify modules for which docstrings should be shown - modules = [Trixi, Trixi2Vtk], - # Set sitename to Trixi.jl - sitename = "Trixi.jl", - # Provide additional formatting options - format = Documenter.HTML( - # Disable pretty URLs during manual testing - prettyurls = get(ENV, "CI", nothing) == "true", - # Explicitly add favicon as asset - assets = ["assets/favicon.ico"], - # Set canonical URL to GitHub pages URL - canonical = "https://trixi-framework.github.io/Trixi.jl/stable"), - # Explicitly specify documentation structure - pages = [ - "Home" => "index.md", - "Getting started" => [ - "Overview" => "overview.md", - "Visualization" => "visualization.md", - ], - "Tutorials" => tutorials, - "Basic building blocks" => [ - "Meshes" => [ - "Tree mesh" => joinpath("meshes", "tree_mesh.md"), - "Structured mesh" => joinpath("meshes", "structured_mesh.md"), - "Unstructured mesh" => joinpath("meshes", "unstructured_quad_mesh.md"), - "P4est-based mesh" => joinpath("meshes", "p4est_mesh.md"), - "DGMulti mesh" => joinpath("meshes", "dgmulti_mesh.md"), - ], - "Time integration" => "time_integration.md", - "Callbacks" => "callbacks.md", - ], - "Advanced topics & developers" => [ - "Conventions" => "conventions.md", - "Development" => "development.md", - "GitHub & Git" => "github-git.md", - "Style guide" => "styleguide.md", - "Testing" => "testing.md", - "Performance" => "performance.md", - "Parallelization" => "parallelization.md", - ], - "Troubleshooting and FAQ" => "troubleshooting.md", - "Reference" => [ - "Trixi.jl" => "reference-trixi.md", - "Trixi2Vtk.jl" => "reference-trixi2vtk.md", - ], - "Authors" => "authors.md", - "Contributing" => "contributing.md", - "Code of Conduct" => "code_of_conduct.md", - "License" => "license.md", - ], - strict = true) + # Specify modules for which docstrings should be shown + modules = [Trixi, Trixi2Vtk], + # Set sitename to Trixi.jl + sitename="Trixi.jl", + # Provide additional formatting options + format = Documenter.HTML( + # Disable pretty URLs during manual testing + prettyurls = get(ENV, "CI", nothing) == "true", + # Explicitly add favicon as asset + assets = ["assets/favicon.ico"], + # Set canonical URL to GitHub pages URL + canonical = "https://trixi-framework.github.io/Trixi.jl/stable" + ), + # Explicitly specify documentation structure + pages = [ + "Home" => "index.md", + "Getting started" => [ + "Overview" => "overview.md", + "Visualization" => "visualization.md", + ], + "Tutorials" => tutorials, + "Basic building blocks" => [ + "Meshes" => [ + "Tree mesh" => joinpath("meshes", "tree_mesh.md"), + "Structured mesh" => joinpath("meshes", "structured_mesh.md"), + "Unstructured mesh" => joinpath("meshes", "unstructured_quad_mesh.md"), + "P4est-based mesh" => joinpath("meshes", "p4est_mesh.md"), + "DGMulti mesh" => joinpath("meshes", "dgmulti_mesh.md"), + ], + "Time integration" => "time_integration.md", + "Callbacks" => "callbacks.md", + ], + "Advanced topics & developers" => [ + "Conventions" =>"conventions.md", + "Development" => "development.md", + "GitHub & Git" => "github-git.md", + "Style guide" => "styleguide.md", + "Testing" => "testing.md", + "Performance" => "performance.md", + "Parallelization" => "parallelization.md", + ], + "Troubleshooting and FAQ" => "troubleshooting.md", + "Reference" => [ + "Trixi.jl" => "reference-trixi.md", + "Trixi2Vtk.jl" => "reference-trixi2vtk.md" + ], + "Authors" => "authors.md", + "Contributing" => "contributing.md", + "Code of Conduct" => "code_of_conduct.md", + "License" => "license.md" + ], + strict = true # to make the GitHub action fail when doctests fail, see https://github.com/neuropsychology/Psycho.jl/issues/34 +) -deploydocs(repo = "github.com/trixi-framework/Trixi.jl", - devbranch = "main", - push_preview = true) +deploydocs( + repo = "github.com/trixi-framework/Trixi.jl", + devbranch = "main", + push_preview = true +) diff --git a/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl b/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl index 09d66fe8aea..d06ed05a621 100644 --- a/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl +++ b/examples/dgmulti_1d/elixir_advection_gauss_sbp.jl @@ -23,8 +23,8 @@ dg = DGMulti(polydeg = 3, cells_per_dimension = (8,) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-1.0,), coordinates_max = (1.0,), - periodicity = true) + coordinates_min=(-1.0,), coordinates_max=(1.0,), + periodicity=true) ############################################################################### # setup the test problem (no source term needed for linear advection) @@ -49,10 +49,10 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=100, uEltype=real(dg)) # handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 0.75) +stepsize_callback = StepsizeCallback(cfl=0.75) # collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback) @@ -60,8 +60,9 @@ callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 1.0, save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=1.0, save_everystep=false, callback=callbacks); # Print the timer summary summary_callback() + diff --git a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl index d31c0dbdba5..f5c2a07bd24 100644 --- a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl @@ -2,10 +2,8 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Line(), - approximation_type = periodic_derivative_operator(derivative_order = 1, - accuracy_order = 4, - xmin = 0.0, xmax = 1.0, - N = 50), + approximation_type = periodic_derivative_operator( + derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), surface_flux = FluxHLL(min_max_speed_naive), volume_integral = VolumeIntegralWeakForm()) @@ -13,8 +11,8 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test -mesh = DGMultiMesh(dg, coordinates_min = (-1.0,), - coordinates_max = (1.0,)) +mesh = DGMultiMesh(dg, coordinates_min=(-1.0,), + coordinates_max=( 1.0,)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -23,16 +21,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -stepsize_callback = StepsizeCallback(cfl = 1.0) -callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, - analysis_callback) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +stepsize_callback = StepsizeCallback(cfl=1.0) +callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_1d/elixir_euler_flux_diff.jl b/examples/dgmulti_1d/elixir_euler_flux_diff.jl index 56a24d25d07..489b23e37b2 100644 --- a/examples/dgmulti_1d/elixir_euler_flux_diff.jl +++ b/examples/dgmulti_1d/elixir_euler_flux_diff.jl @@ -13,17 +13,17 @@ source_terms = source_terms_convergence_test cells_per_dimension = (8,) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-1.0,), coordinates_max = (1.0,), periodicity = true) + coordinates_min=(-1.0,), coordinates_max=(1.0,), periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; - source_terms = source_terms) + source_terms=source_terms) tspan = (0.0, 1.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) @@ -31,7 +31,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_advection_diffusion.jl b/examples/dgmulti_2d/elixir_advection_diffusion.jl index ce7b0e745a4..8a79e9700ac 100644 --- a/examples/dgmulti_2d/elixir_advection_diffusion.jl +++ b/examples/dgmulti_2d/elixir_advection_diffusion.jl @@ -11,52 +11,48 @@ initial_condition_zero(x, t, equations::LinearScalarAdvectionEquation2D) = SVect initial_condition = initial_condition_zero # tag different boundary segments -left(x, tol = 50 * eps()) = abs(x[1] + 1) < tol -right(x, tol = 50 * eps()) = abs(x[1] - 1) < tol -bottom(x, tol = 50 * eps()) = abs(x[2] + 1) < tol -top(x, tol = 50 * eps()) = abs(x[2] - 1) < tol +left(x, tol=50*eps()) = abs(x[1] + 1) < tol +right(x, tol=50*eps()) = abs(x[1] - 1) < tol +bottom(x, tol=50*eps()) = abs(x[2] + 1) < tol +top(x, tol=50*eps()) = abs(x[2] - 1) < tol is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary) # BC types -boundary_condition_left = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + - 0.1 * - x[2])) +boundary_condition_left = BoundaryConditionDirichlet((x, t, equations) -> SVector(1 + 0.1 * x[2])) boundary_condition_zero = BoundaryConditionDirichlet((x, t, equations) -> SVector(0.0)) boundary_condition_neumann_zero = BoundaryConditionNeumann((x, t, equations) -> SVector(0.0)) # define inviscid boundary conditions boundary_conditions = (; :left => boundary_condition_left, - :bottom => boundary_condition_zero, - :top => boundary_condition_do_nothing, - :right => boundary_condition_do_nothing) + :bottom => boundary_condition_zero, + :top => boundary_condition_do_nothing, + :right => boundary_condition_do_nothing) # define viscous boundary conditions boundary_conditions_parabolic = (; :left => boundary_condition_left, - :bottom => boundary_condition_zero, - :top => boundary_condition_zero, - :right => boundary_condition_neumann_zero) + :bottom => boundary_condition_zero, + :top => boundary_condition_zero, + :right => boundary_condition_neumann_zero) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic)) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) tspan = (0.0, 1.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl b/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl index d2f11f18507..7e87d9f097d 100644 --- a/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl +++ b/examples/dgmulti_2d/elixir_advection_diffusion_nonperiodic.jl @@ -16,63 +16,61 @@ equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) # to numerical partial differential equations. # [DOI](https://doi.org/10.1007/978-3-319-41640-3_6). function initial_condition_erikkson_johnson(x, t, equations) - l = 4 - epsilon = diffusivity() # Note: this requires epsilon < 0.6 due to the sqrt - lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + - cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) - return SVector{1}(u) + l = 4 + epsilon = diffusivity() # Note: this requires epsilon < 0.6 due to the sqrt + lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + + cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) + return SVector{1}(u) end initial_condition = initial_condition_erikkson_johnson # tag different boundary segments -left(x, tol = 50 * eps()) = abs(x[1] + 1) < tol -right(x, tol = 50 * eps()) = abs(x[1]) < tol -bottom(x, tol = 50 * eps()) = abs(x[2] + 0.5) < tol -top(x, tol = 50 * eps()) = abs(x[2] - 0.5) < tol -entire_boundary(x, tol = 50 * eps()) = true +left(x, tol=50*eps()) = abs(x[1] + 1) < tol +right(x, tol=50*eps()) = abs(x[1]) < tol +bottom(x, tol=50*eps()) = abs(x[2] + 0.5) < tol +top(x, tol=50*eps()) = abs(x[2] - 0.5) < tol +entire_boundary(x, tol=50*eps()) = true is_on_boundary = Dict(:left => left, :right => right, :top => top, :bottom => bottom, :entire_boundary => entire_boundary) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension; - coordinates_min = (-1.0, -0.5), - coordinates_max = (0.0, 0.5), + coordinates_min=(-1.0, -0.5), + coordinates_max=(0.0, 0.5), is_on_boundary) # BC types boundary_condition = BoundaryConditionDirichlet(initial_condition) # define inviscid boundary conditions, enforce "do nothing" boundary condition at the outflow -boundary_conditions = (; :left => boundary_condition, - :top => boundary_condition, - :bottom => boundary_condition, - :right => boundary_condition_do_nothing) +boundary_conditions = (; :left => boundary_condition, + :top => boundary_condition, + :bottom => boundary_condition, + :right => boundary_condition_do_nothing) # define viscous boundary conditions boundary_conditions_parabolic = (; :entire_boundary => boundary_condition) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic)) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) tspan = (0.0, 1.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl b/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl index c498e5468d3..76512f1e39f 100644 --- a/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl +++ b/examples/dgmulti_2d/elixir_advection_diffusion_periodic.jl @@ -8,12 +8,12 @@ equations = LinearScalarAdvectionEquation2D(0.0, 0.0) equations_parabolic = LaplaceDiffusion2D(5.0e-1, equations) function initial_condition_sharp_gaussian(x, t, equations::LinearScalarAdvectionEquation2D) - return SVector(exp(-100 * (x[1]^2 + x[2]^2))) + return SVector(exp(-100 * (x[1]^2 + x[2]^2))) end initial_condition = initial_condition_sharp_gaussian cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg) @@ -21,16 +21,16 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-6 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - dt = time_int_tol, ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + dt = time_int_tol, ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_bilinear.jl b/examples/dgmulti_2d/elixir_euler_bilinear.jl index b0e575e5200..e9f02863c9b 100644 --- a/examples/dgmulti_2d/elixir_euler_bilinear.jl +++ b/examples/dgmulti_2d/elixir_euler_bilinear.jl @@ -10,28 +10,27 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) +top_boundary(x, tol=50*eps()) = abs(x[2]-1) top_boundary, :rest => rest_of_boundary) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) -vertex_coordinates, EToV = StartUpDG.uniform_mesh(dg.basis.element_type, - cells_per_dimension...) +vertex_coordinates, EToV = StartUpDG.uniform_mesh(dg.basis.element_type, cells_per_dimension...) for i in eachindex(vertex_coordinates[1]) - vx, vy = getindex.(vertex_coordinates, i) - setindex!.(vertex_coordinates, mapping(vx, vy), i) + vx, vy = getindex.(vertex_coordinates, i) + setindex!.(vertex_coordinates, mapping(vx, vy), i) end -mesh = DGMultiMesh(dg, vertex_coordinates, EToV, is_on_boundary = is_on_boundary) +mesh = DGMultiMesh(dg, vertex_coordinates, EToV, is_on_boundary=is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -41,15 +40,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl b/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl index e7830c4736b..4bb05c0b062 100644 --- a/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl +++ b/examples/dgmulti_2d/elixir_euler_brown_minion_vortex.jl @@ -1,6 +1,6 @@ using Trixi, OrdinaryDiffEq -dg = DGMulti(polydeg = 4, element_type = Quad(), approximation_type = Polynomial(), +dg = DGMulti(polydeg=4, element_type = Quad(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(FluxLaxFriedrichs()), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) @@ -16,38 +16,38 @@ incompressible version. [DOI: 10.1006/jcph.1995.1205](https://doi.org/10.1006/jcph.1995.1205) """ function initial_condition_BM_vortex(x, t, equations::CompressibleEulerEquations2D) - pbar = 9.0 / equations.gamma - delta = 0.05 - epsilon = 30 - H = (x[2] < 0) ? tanh(epsilon * (x[2] + 0.25)) : tanh(epsilon * (0.25 - x[2])) - rho = 1.0 - v1 = H - v2 = delta * cos(2.0 * pi * x[1]) - p = pbar - return prim2cons(SVector(rho, v1, v2, p), equations) + pbar = 9.0 / equations.gamma + delta = 0.05 + epsilon = 30 + H = (x[2] < 0) ? tanh(epsilon * (x[2] + 0.25)) : tanh(epsilon * (0.25 - x[2])) + rho = 1.0 + v1 = H + v2 = delta * cos(2.0 * pi * x[1]) + p = pbar + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_BM_vortex cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-0.5, -0.5), coordinates_max = (0.5, 0.5), - periodicity = true) + coordinates_min=(-0.5, -0.5), coordinates_max=(0.5, 0.5), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) ############################################################################### # run the simulation tol = 1.0e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = tol, reltol = tol, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=tol, reltol=tol, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_curved.jl b/examples/dgmulti_2d/elixir_euler_curved.jl index a48252e9ee0..9e773ff7399 100644 --- a/examples/dgmulti_2d/elixir_euler_curved.jl +++ b/examples/dgmulti_2d/elixir_euler_curved.jl @@ -10,21 +10,21 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) +top_boundary(x, tol=50*eps()) = abs(x[2]-1) top_boundary, :rest => rest_of_boundary) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary = is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary=is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -34,15 +34,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl index 2959bd98657..81cd9224d18 100644 --- a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl @@ -2,10 +2,8 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Quad(), - approximation_type = periodic_derivative_operator(derivative_order = 1, - accuracy_order = 4, - xmin = 0.0, xmax = 1.0, - N = 50), + approximation_type = periodic_derivative_operator( + derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), surface_flux = FluxHLL(min_max_speed_naive), volume_integral = VolumeIntegralWeakForm()) @@ -13,8 +11,8 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test -mesh = DGMultiMesh(dg, coordinates_min = (-1.0, -1.0), - coordinates_max = (1.0, 1.0)) +mesh = DGMultiMesh(dg, coordinates_min=(-1.0, -1.0), + coordinates_max=( 1.0, 1.0)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -23,16 +21,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -stepsize_callback = StepsizeCallback(cfl = 1.0) -callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, - analysis_callback) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +stepsize_callback = StepsizeCallback(cfl=1.0) +callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_hohqmesh.jl b/examples/dgmulti_2d/elixir_euler_hohqmesh.jl index f534b5bc8ad..b9a24dc2450 100644 --- a/examples/dgmulti_2d/elixir_euler_hohqmesh.jl +++ b/examples/dgmulti_2d/elixir_euler_hohqmesh.jl @@ -15,11 +15,11 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (; :Slant => boundary_condition_convergence_test, - :Bezier => boundary_condition_convergence_test, - :Right => boundary_condition_convergence_test, - :Bottom => boundary_condition_convergence_test, - :Top => boundary_condition_convergence_test) +boundary_conditions = (; :Slant => boundary_condition_convergence_test, + :Bezier => boundary_condition_convergence_test, + :Right => boundary_condition_convergence_test, + :Bottom => boundary_condition_convergence_test, + :Top => boundary_condition_convergence_test ) ############################################################################### # Get the DG approximation space @@ -32,9 +32,8 @@ dg = DGMulti(polydeg = 8, element_type = Quad(), approximation_type = SBP(), # Get the curved quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_trixi_unstructured_mesh_docs.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = DGMultiMesh(dg, mesh_file) @@ -43,8 +42,8 @@ mesh = DGMultiMesh(dg, mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - source_terms = source_terms, - boundary_conditions = boundary_conditions) + source_terms=source_terms, + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -55,9 +54,9 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -67,7 +66,7 @@ callbacks = CallbackSet(summary_callback, # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - dt = time_int_tol, ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + dt = time_int_tol, ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl b/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl index 14de0bf0e8b..39e98d1a2c5 100644 --- a/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl +++ b/examples/dgmulti_2d/elixir_euler_kelvin_helmholtz_instability.jl @@ -15,24 +15,23 @@ A version of the classical Kelvin-Helmholtz instability based on of the Euler Equations [arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) """ -function initial_condition_kelvin_helmholtz_instability(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability cells_per_dimension = (32, 32) -mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = true) +mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) @@ -40,9 +39,9 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) @@ -50,7 +49,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl index efcb3451388..e3ced751af4 100644 --- a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl @@ -29,34 +29,34 @@ defined below. """ @inline function initial_condition_rayleigh_taylor_instability(x, t, equations::CompressibleEulerEquations2D, - slope = 1000) - tol = 1e2 * eps() - - if x[2] < 0.5 - p = 2 * x[2] + 1 - else - p = x[2] + 3 / 2 - end - - # smooth the discontinuity to avoid ambiguity at element interfaces - smoothed_heaviside(x, left, right) = left + 0.5 * (1 + tanh(slope * x)) * (right - left) - rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) - - c = sqrt(equations.gamma * p / rho) - # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the - # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. - v = -0.025 * c * cos(8 * pi * x[1]) * sin(pi * x[2])^6 - u = 0.0 - - return prim2cons(SVector(rho, u, v, p), equations) + slope=1000) + tol = 1e2*eps() + + if x[2] < 0.5 + p = 2*x[2] + 1 + else + p = x[2] + 3/2 + end + + # smooth the discontinuity to avoid ambiguity at element interfaces + smoothed_heaviside(x, left, right) = left + 0.5*(1 + tanh(slope * x)) * (right-left) + rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) + + c = sqrt(equations.gamma * p / rho) + # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the + # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. + v = -0.025 * c * cos(8*pi*x[1]) * sin(pi*x[2])^6 + u = 0.0 + + return prim2cons(SVector(rho, u, v, p), equations) end @inline function source_terms_rayleigh_taylor_instability(u, x, t, equations::CompressibleEulerEquations2D) - g = 1.0 - rho, rho_v1, rho_v2, rho_e = u + g = 1.0 + rho, rho_v1, rho_v2, rho_e = u - return SVector(0.0, 0.0, g * rho, g * rho_v2) + return SVector(0.0, 0.0, g*rho, g*rho_v2) end # numerical parameters @@ -67,8 +67,8 @@ dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial num_elements = 16 cells_per_dimension = (num_elements, 4 * num_elements) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (0.0, 0.0), coordinates_max = (0.25, 1.0), - periodicity = (true, false)) + coordinates_min=(0.0, 0.0), coordinates_max=(0.25, 1.0), + periodicity=(true, false)) initial_condition = initial_condition_rayleigh_taylor_instability boundary_conditions = (; :entire_boundary => boundary_condition_slip_wall) @@ -86,9 +86,9 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -97,7 +97,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_shockcapturing.jl b/examples/dgmulti_2d/elixir_euler_shockcapturing.jl index 36494b268d6..4b2a408c757 100644 --- a/examples/dgmulti_2d/elixir_euler_shockcapturing.jl +++ b/examples/dgmulti_2d/elixir_euler_shockcapturing.jl @@ -10,25 +10,25 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 -basis = DGMultiBasis(Quad(), polydeg, approximation_type = GaussSBP()) +basis = DGMultiBasis(Quad(), polydeg, approximation_type=GaussSBP()) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) dg = DGMulti(basis, surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = volume_integral) cells_per_dimension = (8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) @@ -36,15 +36,16 @@ tspan = (0.0, 0.15) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary + diff --git a/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl b/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl index 5e8d9e6c8e4..dad898b99b6 100644 --- a/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl +++ b/examples/dgmulti_2d/elixir_euler_shockcapturing_curved.jl @@ -10,27 +10,27 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 -basis = DGMultiBasis(Quad(), polydeg, approximation_type = GaussSBP()) +basis = DGMultiBasis(Quad(), polydeg, approximation_type=GaussSBP()) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) dg = DGMulti(basis, surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = volume_integral) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension, mapping) @@ -41,15 +41,16 @@ tspan = (0.0, 0.15) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary + diff --git a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl index cc150a319f0..150fb769138 100644 --- a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl +++ b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl @@ -13,11 +13,11 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole()) # the pre-defined Triangulate geometry in StartUpDG has integer boundary tags. this routine # assigns boundary faces based on these integer boundary tags. -mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary => 1, :inner_boundary => 2)) +mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary=>1, :inner_boundary=>2)) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test, - :inner_boundary => boundary_condition_convergence_test) + :inner_boundary => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -27,14 +27,14 @@ tspan = (0.0, 0.2) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_weakform.jl b/examples/dgmulti_2d/elixir_euler_weakform.jl index cf08866e178..a43790a4d5f 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform.jl @@ -10,16 +10,16 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) +top_boundary(x, tol=50*eps()) = abs(x[2]-1) top_boundary, :rest => rest_of_boundary) cells_per_dimension = (8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary = is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary=is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -29,16 +29,15 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -stepsize_callback = StepsizeCallback(cfl = 1.5) -callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, - analysis_callback) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +stepsize_callback = StepsizeCallback(cfl=1.5) +callbacks = CallbackSet(summary_callback, alive_callback, stepsize_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl index 6fe578c1527..0bb011bf540 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl @@ -10,7 +10,7 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test cells_per_dimension = (4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -18,14 +18,14 @@ tspan = (0.0, 0.4) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl b/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl index 2b8d36fb94f..a1351cf8244 100644 --- a/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl +++ b/examples/dgmulti_2d/elixir_mhd_reflective_wall.jl @@ -8,73 +8,70 @@ using LinearAlgebra: norm, dot # for use in the MHD boundary condition equations = IdealGlmMhdEquations2D(1.4) function initial_condition_perturbation(x, t, equations::IdealGlmMhdEquations2D) - # pressure perturbation in a vertically magnetized field on the domain [-1, 1]^2 + # pressure perturbation in a vertically magnetized field on the domain [-1, 1]^2 - r2 = (x[1] + 0.25)^2 + (x[2] + 0.25)^2 + r2 = (x[1] + 0.25)^2 + (x[2] + 0.25)^2 - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = 1 + 0.5 * exp(-100 * r2) + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = 1 + 0.5 * exp(-100 * r2) - # the pressure and magnetic field are chosen to be strongly - # magnetized, such that p / ||B||^2 ≈ 0.01. - B1 = 0.0 - B2 = 40.0 / sqrt(4.0 * pi) - B3 = 0.0 + # the pressure and magnetic field are chosen to be strongly + # magnetized, such that p / ||B||^2 ≈ 0.01. + B1 = 0.0 + B2 = 40.0 / sqrt(4.0 * pi) + B3 = 0.0 - psi = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) + psi = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) end initial_condition = initial_condition_perturbation surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = GaussSBP(), +solver = DGMulti(polydeg=3, element_type = Quad(), approximation_type = GaussSBP(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) -x_neg(x, tol = 50 * eps()) = abs(x[1] + 1) < tol -x_pos(x, tol = 50 * eps()) = abs(x[1] - 1) < tol -y_neg(x, tol = 50 * eps()) = abs(x[2] + 1) < tol -y_pos(x, tol = 50 * eps()) = abs(x[2] - 1) < tol +x_neg(x, tol=50*eps()) = abs(x[1] + 1) < tol +x_pos(x, tol=50*eps()) = abs(x[1] - 1) < tol +y_neg(x, tol=50*eps()) = abs(x[2] + 1) < tol +y_pos(x, tol=50*eps()) = abs(x[2] - 1) < tol is_on_boundary = Dict(:x_neg => x_neg, :x_pos => x_pos, :y_neg => y_neg, :y_pos => y_pos) cells_per_dimension = (16, 16) -mesh = DGMultiMesh(solver, cells_per_dimension; periodicity = (false, false), - is_on_boundary) +mesh = DGMultiMesh(solver, cells_per_dimension; periodicity=(false, false), is_on_boundary) # Create a "reflective-like" boundary condition by mirroring the velocity but leaving the magnetic field alone. # Note that this boundary condition is probably not entropy stable. -function boundary_condition_velocity_slip_wall(u_inner, normal_direction::AbstractVector, x, - t, - surface_flux_function, - equations::IdealGlmMhdEquations2D) +function boundary_condition_velocity_slip_wall(u_inner, normal_direction::AbstractVector, x, t, + surface_flux_function, equations::IdealGlmMhdEquations2D) - # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later - norm_ = norm(normal_direction) - normal = normal_direction / norm_ + # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later + norm_ = norm(normal_direction) + normal = normal_direction / norm_ - # compute the primitive variables - rho, v1, v2, v3, p, B1, B2, B3, psi = cons2prim(u_inner, equations) + # compute the primitive variables + rho, v1, v2, v3, p, B1, B2, B3, psi = cons2prim(u_inner, equations) - v_normal = dot(normal, SVector(v1, v2)) - u_mirror = prim2cons(SVector(rho, v1 - 2 * v_normal * normal[1], - v2 - 2 * v_normal * normal[2], - v3, p, B1, B2, B3, psi), equations) + v_normal = dot(normal, SVector(v1, v2)) + u_mirror = prim2cons(SVector(rho, v1 - 2 * v_normal * normal[1], + v2 - 2 * v_normal * normal[2], + v3, p, B1, B2, B3, psi), equations) - return surface_flux_function(u_inner, u_mirror, normal, equations) * norm_ + return surface_flux_function(u_inner, u_mirror, normal, equations) * norm_ end -boundary_conditions = (; x_neg = boundary_condition_velocity_slip_wall, - x_pos = boundary_condition_velocity_slip_wall, - y_neg = boundary_condition_do_nothing, - y_pos = BoundaryConditionDirichlet(initial_condition)) +boundary_conditions = (; x_neg=boundary_condition_velocity_slip_wall, + x_pos=boundary_condition_velocity_slip_wall, + y_neg=boundary_condition_do_nothing, + y_pos=BoundaryConditionDirichlet(initial_condition)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -85,13 +82,12 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - uEltype = real(solver)) -alive_callback = AliveCallback(alive_interval = 10) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(solver)) +alive_callback = AliveCallback(alive_interval=10) cfl = 0.5 -stepsize_callback = StepsizeCallback(cfl = cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -102,8 +98,8 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 1e-5, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=1e-5, # 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 diff --git a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl index 663301e189f..bf5045ce8b0 100644 --- a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl +++ b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave.jl @@ -11,14 +11,14 @@ initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial(), +dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-2.0, -2.0), coordinates_max = (2.0, 2.0), - periodicity = true) + coordinates_min=(-2.0, -2.0), coordinates_max=(2.0, 2.0), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) ############################################################################### @@ -30,13 +30,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +alive_callback = AliveCallback(analysis_interval=analysis_interval) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -47,8 +47,8 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl index 3dc070a7296..9c8dfcb3801 100644 --- a/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl +++ b/examples/dgmulti_2d/elixir_mhd_weak_blast_wave_SBP.jl @@ -15,13 +15,13 @@ initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), +dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = SBP(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-2.0, -2.0), coordinates_max = (2.0, 2.0), - periodicity = true) + coordinates_min=(-2.0, -2.0), coordinates_max=(2.0, 2.0), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg) ############################################################################### @@ -33,8 +33,8 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # See comment above and https://github.com/trixi-framework/Trixi.jl/issues/881 # DGMulti uses a conservative timestep estimate, so we can use a large CFL here. @@ -46,7 +46,8 @@ alive_callback = AliveCallback(analysis_interval = analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, #stepsize_callback, - alive_callback) #=glm_speed_callback=# + alive_callback, + #=glm_speed_callback=#) ############################################################################### # run the simulation @@ -55,7 +56,7 @@ callbacks = CallbackSet(summary_callback, # 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); -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_navierstokes_convergence.jl b/examples/dgmulti_2d/elixir_navierstokes_convergence.jl index cd3c015b5fa..23c9c2e8ed4 100644 --- a/examples/dgmulti_2d/elixir_navierstokes_convergence.jl +++ b/examples/dgmulti_2d/elixir_navierstokes_convergence.jl @@ -10,214 +10,169 @@ mu() = 0.01 equations = CompressibleEulerEquations2D(1.4) # Note: If you change the Navier-Stokes parameters here, also change them in the initial condition # I really do not like this structure but it should work for now -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), - Prandtl = prandtl_number(), - gradient_variables = GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), Prandtl=prandtl_number(), + gradient_variables=GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = (true, false), is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=(true, false), is_on_boundary) # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion2D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion2D`) # and by the initial condition (which passes in `CompressibleEulerEquations2D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Amplitude and shift - A = 0.5 - c = 2.0 + # Amplitude and shift + A = 0.5 + c = 2.0 - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0))) * cos(pi_t) - v2 = v1 - p = rho^2 + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0)) ) * cos(pi_t) + v2 = v1 + p = rho^2 - return prim2cons(SVector(rho, v1, v2, p), equations) + return prim2cons(SVector(rho, v1, v2, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - y = x[2] - - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Same settings as in `initial_condition` - # Amplitude and shift - A = 0.5 - c = 2.0 - - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t - - # compute the manufactured solution and all necessary derivatives - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) - rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) - rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) - rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - - v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) - v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_y = sin(pi_x) * - (A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_xy = pi * cos(pi_x) * - (A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_yy = (sin(pi_x) * - (2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) - - - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) - - - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_xx = v1_xx - v2_xy = v1_xy - v2_yy = v1_yy - - p = rho * rho - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x - p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y - - # Note this simplifies slightly because the ansatz assumes that v1 = v2 - E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) - E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y - - # Some convenience constants - T_const = equations.gamma * inv_gamma_minus_one / Pr - inv_rho_cubed = 1.0 / (rho^3) - - # compute the source terms - # density equation - du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y - - # x-momentum equation - du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - # stress tensor from x-direction - - - 4.0 / 3.0 * v1_xx * mu_ - + - 2.0 / 3.0 * v2_xy * mu_ - - - v1_yy * mu_ - - - v2_xy * mu_) - # y-momentum equation - du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - # stress tensor from y-direction - - - v1_xy * mu_ - - - v2_xx * mu_ - - - 4.0 / 3.0 * v2_yy * mu_ - + - 2.0 / 3.0 * v1_xy * mu_) - # total energy equation - du4 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - # stress tensor and temperature gradient terms from x-direction - - - 4.0 / 3.0 * v1_xx * v1 * mu_ - + - 2.0 / 3.0 * v2_xy * v1 * mu_ - - - 4.0 / 3.0 * v1_x * v1_x * mu_ - + - 2.0 / 3.0 * v2_y * v1_x * mu_ - - - v1_xy * v2 * mu_ - - - v2_xx * v2 * mu_ - - - v1_y * v2_x * mu_ - - - v2_x * v2_x * mu_ - - - T_const * inv_rho_cubed * - (p_xx * rho * rho - - - 2.0 * p_x * rho * rho_x - + - 2.0 * p * rho_x * rho_x - - - p * rho * rho_xx) * mu_ - # stress tensor and temperature gradient terms from y-direction - - - v1_yy * v1 * mu_ - - - v2_xy * v1 * mu_ - - - v1_y * v1_y * mu_ - - - v2_x * v1_y * mu_ - - - 4.0 / 3.0 * v2_yy * v2 * mu_ - + - 2.0 / 3.0 * v1_xy * v2 * mu_ - - - 4.0 / 3.0 * v2_y * v2_y * mu_ - + - 2.0 / 3.0 * v1_x * v2_y * mu_ - - - T_const * inv_rho_cubed * - (p_yy * rho * rho - - - 2.0 * p_y * rho * rho_y - + - 2.0 * p * rho_y * rho_y - - - p * rho * rho_yy) * mu_) - - return SVector(du1, du2, du3, du4) + y = x[2] + + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Same settings as in `initial_condition` + # Amplitude and shift + A = 0.5 + c = 2.0 + + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t + + # compute the manufactured solution and all necessary derivatives + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) + rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) + rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) + rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + + v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) + v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_y = sin(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_xy = pi * cos(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_yy = (sin(pi_x) * ( 2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) + - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_xx = v1_xx + v2_xy = v1_xy + v2_yy = v1_yy + + p = rho * rho + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x + p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y + + # Note this simplifies slightly because the ansatz assumes that v1 = v2 + E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) + E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y + + # Some convenience constants + T_const = equations.gamma * inv_gamma_minus_one / Pr + inv_rho_cubed = 1.0 / (rho^3) + + # compute the source terms + # density equation + du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y + + # x-momentum equation + du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + # stress tensor from x-direction + - 4.0 / 3.0 * v1_xx * mu_ + + 2.0 / 3.0 * v2_xy * mu_ + - v1_yy * mu_ + - v2_xy * mu_ ) + # y-momentum equation + du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + # stress tensor from y-direction + - v1_xy * mu_ + - v2_xx * mu_ + - 4.0 / 3.0 * v2_yy * mu_ + + 2.0 / 3.0 * v1_xy * mu_ ) + # total energy equation + du4 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + # stress tensor and temperature gradient terms from x-direction + - 4.0 / 3.0 * v1_xx * v1 * mu_ + + 2.0 / 3.0 * v2_xy * v1 * mu_ + - 4.0 / 3.0 * v1_x * v1_x * mu_ + + 2.0 / 3.0 * v2_y * v1_x * mu_ + - v1_xy * v2 * mu_ + - v2_xx * v2 * mu_ + - v1_y * v2_x * mu_ + - v2_x * v2_x * mu_ + - T_const * inv_rho_cubed * ( p_xx * rho * rho + - 2.0 * p_x * rho * rho_x + + 2.0 * p * rho_x * rho_x + - p * rho * rho_xx ) * mu_ + # stress tensor and temperature gradient terms from y-direction + - v1_yy * v1 * mu_ + - v2_xy * v1 * mu_ + - v1_y * v1_y * mu_ + - v2_x * v1_y * mu_ + - 4.0 / 3.0 * v2_yy * v2 * mu_ + + 2.0 / 3.0 * v1_xy * v2 * mu_ + - 4.0 / 3.0 * v2_y * v2_y * mu_ + + 2.0 / 3.0 * v1_x * v2_y * mu_ + - T_const * inv_rho_cubed * ( p_yy * rho * rho + - 2.0 * p_y * rho * rho_y + + 2.0 * p * rho_y * rho_y + - p * rho * rho_yy ) * mu_ ) + + return SVector(du1, du2, du3, du4) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, - t, - equations)[2:3]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, - heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -225,11 +180,10 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic), - source_terms = source_terms_navier_stokes_convergence_test) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), + source_terms=source_terms_navier_stokes_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -239,15 +193,15 @@ tspan = (0.0, 0.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl b/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl index 996446d1db7..86b5ae64348 100644 --- a/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl +++ b/examples/dgmulti_2d/elixir_navierstokes_convergence_curved.jl @@ -10,26 +10,24 @@ mu() = 0.01 equations = CompressibleEulerEquations2D(1.4) # Note: If you change the Navier-Stokes parameters here, also change them in the initial condition # I really do not like this structure but it should work for now -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), - Prandtl = prandtl_number(), - gradient_variables = GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), Prandtl=prandtl_number(), + gradient_variables=GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y) end cells_per_dimension = (16, 16) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity = (true, false), - is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity=(true, false), is_on_boundary) # This initial condition is taken from `examples/dgmulti_2d/elixir_navierstokes_convergence.jl` @@ -38,194 +36,150 @@ mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity = (true, false) # and by the initial condition (which passes in `CompressibleEulerEquations2D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Amplitude and shift - A = 0.5 - c = 2.0 + # Amplitude and shift + A = 0.5 + c = 2.0 - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0))) * cos(pi_t) - v2 = v1 - p = rho^2 + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0)) ) * cos(pi_t) + v2 = v1 + p = rho^2 - return prim2cons(SVector(rho, v1, v2, p), equations) + return prim2cons(SVector(rho, v1, v2, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - y = x[2] - - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Same settings as in `initial_condition` - # Amplitude and shift - A = 0.5 - c = 2.0 - - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t - - # compute the manufactured solution and all necessary derivatives - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) - rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) - rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) - rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - - v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) - v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_y = sin(pi_x) * - (A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_xy = pi * cos(pi_x) * - (A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_yy = (sin(pi_x) * - (2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) - - - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) - - - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_xx = v1_xx - v2_xy = v1_xy - v2_yy = v1_yy - - p = rho * rho - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x - p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y - - # Note this simplifies slightly because the ansatz assumes that v1 = v2 - E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) - E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y - - # Some convenience constants - T_const = equations.gamma * inv_gamma_minus_one / Pr - inv_rho_cubed = 1.0 / (rho^3) - - # compute the source terms - # density equation - du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y - - # x-momentum equation - du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - # stress tensor from x-direction - - - 4.0 / 3.0 * v1_xx * mu_ - + - 2.0 / 3.0 * v2_xy * mu_ - - - v1_yy * mu_ - - - v2_xy * mu_) - # y-momentum equation - du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - # stress tensor from y-direction - - - v1_xy * mu_ - - - v2_xx * mu_ - - - 4.0 / 3.0 * v2_yy * mu_ - + - 2.0 / 3.0 * v1_xy * mu_) - # total energy equation - du4 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - # stress tensor and temperature gradient terms from x-direction - - - 4.0 / 3.0 * v1_xx * v1 * mu_ - + - 2.0 / 3.0 * v2_xy * v1 * mu_ - - - 4.0 / 3.0 * v1_x * v1_x * mu_ - + - 2.0 / 3.0 * v2_y * v1_x * mu_ - - - v1_xy * v2 * mu_ - - - v2_xx * v2 * mu_ - - - v1_y * v2_x * mu_ - - - v2_x * v2_x * mu_ - - - T_const * inv_rho_cubed * - (p_xx * rho * rho - - - 2.0 * p_x * rho * rho_x - + - 2.0 * p * rho_x * rho_x - - - p * rho * rho_xx) * mu_ - # stress tensor and temperature gradient terms from y-direction - - - v1_yy * v1 * mu_ - - - v2_xy * v1 * mu_ - - - v1_y * v1_y * mu_ - - - v2_x * v1_y * mu_ - - - 4.0 / 3.0 * v2_yy * v2 * mu_ - + - 2.0 / 3.0 * v1_xy * v2 * mu_ - - - 4.0 / 3.0 * v2_y * v2_y * mu_ - + - 2.0 / 3.0 * v1_x * v2_y * mu_ - - - T_const * inv_rho_cubed * - (p_yy * rho * rho - - - 2.0 * p_y * rho * rho_y - + - 2.0 * p * rho_y * rho_y - - - p * rho * rho_yy) * mu_) - - return SVector(du1, du2, du3, du4) + y = x[2] + + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Same settings as in `initial_condition` + # Amplitude and shift + A = 0.5 + c = 2.0 + + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t + + # compute the manufactured solution and all necessary derivatives + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) + rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) + rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) + rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + + v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) + v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_y = sin(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_xy = pi * cos(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_yy = (sin(pi_x) * ( 2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) + - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_xx = v1_xx + v2_xy = v1_xy + v2_yy = v1_yy + + p = rho * rho + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x + p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y + + # Note this simplifies slightly because the ansatz assumes that v1 = v2 + E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) + E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y + + # Some convenience constants + T_const = equations.gamma * inv_gamma_minus_one / Pr + inv_rho_cubed = 1.0 / (rho^3) + + # compute the source terms + # density equation + du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y + + # x-momentum equation + du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + # stress tensor from x-direction + - 4.0 / 3.0 * v1_xx * mu_ + + 2.0 / 3.0 * v2_xy * mu_ + - v1_yy * mu_ + - v2_xy * mu_ ) + # y-momentum equation + du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + # stress tensor from y-direction + - v1_xy * mu_ + - v2_xx * mu_ + - 4.0 / 3.0 * v2_yy * mu_ + + 2.0 / 3.0 * v1_xy * mu_ ) + # total energy equation + du4 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + # stress tensor and temperature gradient terms from x-direction + - 4.0 / 3.0 * v1_xx * v1 * mu_ + + 2.0 / 3.0 * v2_xy * v1 * mu_ + - 4.0 / 3.0 * v1_x * v1_x * mu_ + + 2.0 / 3.0 * v2_y * v1_x * mu_ + - v1_xy * v2 * mu_ + - v2_xx * v2 * mu_ + - v1_y * v2_x * mu_ + - v2_x * v2_x * mu_ + - T_const * inv_rho_cubed * ( p_xx * rho * rho + - 2.0 * p_x * rho * rho_x + + 2.0 * p * rho_x * rho_x + - p * rho * rho_xx ) * mu_ + # stress tensor and temperature gradient terms from y-direction + - v1_yy * v1 * mu_ + - v2_xy * v1 * mu_ + - v1_y * v1_y * mu_ + - v2_x * v1_y * mu_ + - 4.0 / 3.0 * v2_yy * v2 * mu_ + + 2.0 / 3.0 * v1_xy * v2 * mu_ + - 4.0 / 3.0 * v2_y * v2_y * mu_ + + 2.0 / 3.0 * v1_x * v2_y * mu_ + - T_const * inv_rho_cubed * ( p_yy * rho * rho + - 2.0 * p_y * rho * rho_y + + 2.0 * p * rho_y * rho_y + - p * rho * rho_yy ) * mu_ ) + + return SVector(du1, du2, du3, du4) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, - t, - equations)[2:3]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, - heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -233,11 +187,10 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic), - source_terms = source_terms_navier_stokes_convergence_test) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), + source_terms=source_terms_navier_stokes_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -247,15 +200,15 @@ tspan = (0.0, 0.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl b/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl index 7c55cbf0ccf..97b779ebaf9 100644 --- a/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl +++ b/examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl @@ -9,27 +9,28 @@ prandtl_number() = 0.72 mu() = 0.001 equations = CompressibleEulerEquations2D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), - Prandtl = prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), + Prandtl=prandtl_number()) + # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = GaussSBP(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) -top(x, tol = 50 * eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol = 50 * eps()) = !top(x, tol) +top(x, tol=50*eps()) = abs(x[2] - 1) < tol +rest_of_boundary(x, tol=50*eps()) = !top(x, tol) is_on_boundary = Dict(:top => top, :rest_of_boundary => rest_of_boundary) cells_per_dimension = (16, 16) mesh = DGMultiMesh(dg, cells_per_dimension; is_on_boundary) function initial_condition_cavity(x, t, equations::CompressibleEulerEquations2D) - Ma = 0.1 - rho = 1.0 - u, v = 0.0, 0.0 - p = 1.0 / (Ma^2 * equations.gamma) - return prim2cons(SVector(rho, u, v, p), equations) + Ma = 0.1 + rho = 1.0 + u, v = 0.0, 0.0 + p = 1.0 / (Ma^2 * equations.gamma) + return prim2cons(SVector(rho, u, v, p), equations) end initial_condition = initial_condition_cavity @@ -42,16 +43,15 @@ boundary_condition_cavity = BoundaryConditionNavierStokesWall(velocity_bc_cavity # define inviscid boundary conditions boundary_conditions = (; :top => boundary_condition_slip_wall, - :rest_of_boundary => boundary_condition_slip_wall) + :rest_of_boundary => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top => boundary_condition_lid, - :rest_of_boundary => boundary_condition_cavity) + :rest_of_boundary => boundary_condition_cavity) + +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -61,15 +61,15 @@ tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl b/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl index f7120d8091b..3551c863ff2 100644 --- a/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl +++ b/examples/dgmulti_2d/elixir_shallowwater_source_terms.jl @@ -4,23 +4,24 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal) -dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), +dg = DGMulti(polydeg=3, element_type = Quad(), approximation_type = SBP(), surface_integral = SurfaceIntegralWeakForm(surface_flux), volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) cells_per_dimension = (8, 8) mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (0.0, 0.0), coordinates_max = (sqrt(2), sqrt(2)), - periodicity = true) + coordinates_min=(0.0, 0.0), coordinates_max=(sqrt(2), sqrt(2)), + periodicity=true) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg; - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -31,8 +32,8 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -41,7 +42,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-7, reltol=1.0e-7, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl b/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl index e877e602547..4f43f2571a3 100644 --- a/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl +++ b/examples/dgmulti_3d/elixir_advection_tensor_wedge.jl @@ -16,15 +16,17 @@ dg = DGMulti(element_type = Wedge(), surface_flux = flux_lax_friedrichs, polydeg = tensor_polydeg) + cells_per_dimension = (8, 8, 8) -mesh = DGMultiMesh(dg, +mesh = DGMultiMesh(dg, cells_per_dimension, - coordinates_min = (-1.0, -1.0, -1.0), + coordinates_min = (-1.0, -1.0, -1.0), coordinates_max = (1.0, 1.0, 1.0), periodicity = true) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) ############################################################################### # ODE solvers, callbacks etc. @@ -35,20 +37,20 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback) -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, - stepsize_callback) ############################################################################### # run the simulation sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), dt = 1.0, - save_everystep = false, callback = callbacks); + save_everystep=false, callback=callbacks); -summary_callback() # print the timer summary +summary_callback() # print the timer summary \ No newline at end of file diff --git a/examples/dgmulti_3d/elixir_euler_curved.jl b/examples/dgmulti_3d/elixir_euler_curved.jl index 5f2a03f780b..56d870f6bf6 100644 --- a/examples/dgmulti_3d/elixir_euler_curved.jl +++ b/examples/dgmulti_3d/elixir_euler_curved.jl @@ -1,7 +1,7 @@ using Trixi, OrdinaryDiffEq -dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = SBP(), +dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type=SBP(), surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) @@ -10,22 +10,22 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) +top_boundary(x, tol=50*eps()) = abs(x[2] - 1) < tol +rest_of_boundary(x, tol=50*eps()) = !top_boundary(x, tol) is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary) function mapping(xi, eta, zeta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y, z) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary = is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping, is_on_boundary=is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -35,14 +35,14 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl index 0eb38674689..35f7aee8795 100644 --- a/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_3d/elixir_euler_fdsbp_periodic.jl @@ -10,20 +10,19 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test -volume_flux = flux_ranocha +volume_flux = flux_ranocha solver = DGMulti(element_type = Hex(), - approximation_type = periodic_derivative_operator(derivative_order = 1, - accuracy_order = 4, - xmin = 0.0, xmax = 1.0, - N = 20), + approximation_type = periodic_derivative_operator( + derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=20), surface_flux = flux_lax_friedrichs, volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) -mesh = DGMultiMesh(solver, coordinates_min = (-1.0, -1.0, -1.0), - coordinates_max = (1.0, 1.0, 1.0)) +mesh = DGMultiMesh(solver, coordinates_min=(-1.0, -1.0, -1.0), + coordinates_max=( 1.0, 1.0, 1.0)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; - source_terms = source_terms) + source_terms=source_terms) + ############################################################################### # ODE solvers, callbacks etc. @@ -34,14 +33,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - uEltype = real(solver)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(solver)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation diff --git a/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl b/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl index fea43ad4d26..253d2486468 100644 --- a/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl +++ b/examples/dgmulti_3d/elixir_euler_taylor_green_vortex.jl @@ -12,38 +12,35 @@ equations = CompressibleEulerEquations3D(1.4) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, - equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + - 1.0 / 16.0 * A^2 * rho * - (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + - cos(2 * x[2]) * cos(2 * x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex -volume_flux = flux_ranocha +volume_flux = flux_ranocha surface_flux = flux_lax_friedrichs solver = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(surface_flux), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + surface_integral= SurfaceIntegralWeakForm(surface_flux), + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) cells_per_dimension = (8, 8, 8) mesh = DGMultiMesh(solver, cells_per_dimension, - coordinates_min = (-pi, -pi, -pi), coordinates_max = (pi, pi, pi), - periodicity = true) + coordinates_min=(-pi, -pi, -pi), coordinates_max=(pi, pi, pi), + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -53,14 +50,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - uEltype = real(solver)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(solver)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation diff --git a/examples/dgmulti_3d/elixir_euler_weakform.jl b/examples/dgmulti_3d/elixir_euler_weakform.jl index 5e54f016579..2a44a7b6c7b 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform.jl @@ -10,16 +10,16 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test # example where we tag two separate boundary segments of the mesh -top_boundary(x, tol = 50 * eps()) = abs(x[2] - 1) < tol -rest_of_boundary(x, tol = 50 * eps()) = !top_boundary(x, tol) +top_boundary(x, tol=50*eps()) = abs(x[2] - 1) < tol +rest_of_boundary(x, tol=50*eps()) = !top_boundary(x, tol) is_on_boundary = Dict(:top => top_boundary, :rest => rest_of_boundary) cells_per_dimension = (4, 4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary = is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, is_on_boundary=is_on_boundary) boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) boundary_conditions = (; :top => boundary_condition_convergence_test, - :rest => boundary_condition_convergence_test) + :rest => boundary_condition_convergence_test) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms, @@ -29,14 +29,14 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl index 8ffbf54bd18..fd4a83a386f 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl @@ -10,7 +10,7 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test cells_per_dimension = (4, 4, 4) -mesh = DGMultiMesh(dg, cells_per_dimension, periodicity = true) +mesh = DGMultiMesh(dg, cells_per_dimension, periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg, source_terms = source_terms) @@ -19,14 +19,14 @@ tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 0.5 * estimate_dt(mesh, dg), save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt = 0.5 * estimate_dt(mesh, dg), save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_navierstokes_convergence.jl b/examples/dgmulti_3d/elixir_navierstokes_convergence.jl index b5e6c6f80a8..9a237b2d2fc 100644 --- a/examples/dgmulti_3d/elixir_navierstokes_convergence.jl +++ b/examples/dgmulti_3d/elixir_navierstokes_convergence.jl @@ -8,234 +8,219 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), - Prandtl = prandtl_number(), - gradient_variables = GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), Prandtl=prandtl_number(), + gradient_variables=GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) cells_per_dimension = (8, 8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension; periodicity = (true, false, true), - is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension; periodicity=(true, false, true), is_on_boundary) # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion3D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion3D`) # and by the initial condition (which passes in `CompressibleEulerEquations3D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * - cos(pi_t) - v2 = v1 - v3 = v1 - p = rho^2 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * cos(pi_t) + v2 = v1 + v3 = v1 + p = rho^2 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - # Define auxiliary functions for the strange function of the y variable - # to make expressions easier to read - g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) - g_y = (A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) - + - (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0)) - g_yy = (2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) - - - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) - - - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0))) - - # Density and its derivatives - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) - rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) - rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) - rho_xx = -pi^2 * (rho - c) - rho_yy = -pi^2 * (rho - c) - rho_zz = -pi^2 * (rho - c) - - # Velocities and their derivatives - # v1 terms - v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) - v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_xx = -pi^2 * v1 - v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) - v1_zz = -pi^2 * v1 - v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) - # v2 terms (simplifies from ansatz) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_z = v1_z - v2_xx = v1_xx - v2_yy = v1_yy - v2_zz = v1_zz - v2_xy = v1_xy - v2_yz = v1_yz - # v3 terms (simplifies from ansatz) - v3 = v1 - v3_t = v1_t - v3_x = v1_x - v3_y = v1_y - v3_z = v1_z - v3_xx = v1_xx - v3_yy = v1_yy - v3_zz = v1_zz - v3_xz = v1_xz - v3_yz = v1_yz - - # Pressure and its derivatives - p = rho^2 - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_z = 2.0 * rho * rho_z - - # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 - E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 - E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y - E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z - - # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho - kappa = equations.gamma * inv_gamma_minus_one / Pr - q_xx = kappa * rho_xx # kappa T_xx - q_yy = kappa * rho_yy # kappa T_yy - q_zz = kappa * rho_zz # kappa T_zz - - # Stress tensor and its derivatives (exploit symmetry) - tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) - tau12 = v1_y + v2_x - tau13 = v1_z + v3_x - tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) - tau23 = v2_z + v3_y - tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) - - tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) - tau12_x = v1_xy + v2_xx - tau13_x = v1_xz + v3_xx - - tau12_y = v1_yy + v2_xy - tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) - tau23_y = v2_yz + v3_yy - - tau13_z = v1_zz + v3_xz - tau23_z = v2_zz + v3_yz - tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) - - # Compute the source terms - # Density equation - du1 = (rho_t + rho_x * v1 + rho * v1_x - + rho_y * v2 + rho * v2_y - + rho_z * v3 + rho * v3_z) - # x-momentum equation - du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - + rho_z * v1 * v3 - + rho * v1_z * v3 - + rho * v1 * v3_z - - - mu_ * (tau11_x + tau12_y + tau13_z)) - # y-momentum equation - du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - + rho_z * v2 * v3 - + rho * v2_z * v3 - + rho * v2 * v3_z - - - mu_ * (tau12_x + tau22_y + tau23_z)) - # z-momentum equation - du4 = (rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 - + rho * v1_x * v3 - + rho * v1 * v3_x - + rho_y * v2 * v3 - + rho * v2_y * v3 - + rho * v2 * v3_y - + rho_z * v3^2 - + 2.0 * rho * v3 * v3_z - - - mu_ * (tau13_x + tau23_y + tau33_z)) - # Total energy equation - du5 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - + v3_z * (E + p) + v3 * (E_z + p_z) - # stress tensor and temperature gradient from x-direction - - - mu_ * (q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 - + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) - # stress tensor and temperature gradient terms from y-direction - - - mu_ * (q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 - + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) - # stress tensor and temperature gradient terms from z-direction - - - mu_ * (q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 - + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z)) - - return SVector(du1, du2, du3, du4, du5) + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + # Define auxiliary functions for the strange function of the y variable + # to make expressions easier to read + g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) + g_y = ( A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) + + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0) ) + g_yy = ( 2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) + - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) + - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) ) + + # Density and its derivatives + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) + rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) + rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) + rho_xx = -pi^2 * (rho - c) + rho_yy = -pi^2 * (rho - c) + rho_zz = -pi^2 * (rho - c) + + # Velocities and their derivatives + # v1 terms + v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) + v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_xx = -pi^2 * v1 + v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) + v1_zz = -pi^2 * v1 + v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) + # v2 terms (simplifies from ansatz) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_z = v1_z + v2_xx = v1_xx + v2_yy = v1_yy + v2_zz = v1_zz + v2_xy = v1_xy + v2_yz = v1_yz + # v3 terms (simplifies from ansatz) + v3 = v1 + v3_t = v1_t + v3_x = v1_x + v3_y = v1_y + v3_z = v1_z + v3_xx = v1_xx + v3_yy = v1_yy + v3_zz = v1_zz + v3_xz = v1_xz + v3_yz = v1_yz + + # Pressure and its derivatives + p = rho^2 + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_z = 2.0 * rho * rho_z + + # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 + E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 + E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y + E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z + + # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho + kappa = equations.gamma * inv_gamma_minus_one / Pr + q_xx = kappa * rho_xx # kappa T_xx + q_yy = kappa * rho_yy # kappa T_yy + q_zz = kappa * rho_zz # kappa T_zz + + # Stress tensor and its derivatives (exploit symmetry) + tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) + tau12 = v1_y + v2_x + tau13 = v1_z + v3_x + tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) + tau23 = v2_z + v3_y + tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) + + tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) + tau12_x = v1_xy + v2_xx + tau13_x = v1_xz + v3_xx + + tau12_y = v1_yy + v2_xy + tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) + tau23_y = v2_yz + v3_yy + + tau13_z = v1_zz + v3_xz + tau23_z = v2_zz + v3_yz + tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) + + # Compute the source terms + # Density equation + du1 = ( rho_t + rho_x * v1 + rho * v1_x + + rho_y * v2 + rho * v2_y + + rho_z * v3 + rho * v3_z ) + # x-momentum equation + du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + + rho_z * v1 * v3 + + rho * v1_z * v3 + + rho * v1 * v3_z + - mu_ * (tau11_x + tau12_y + tau13_z) ) + # y-momentum equation + du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + + rho_z * v2 * v3 + + rho * v2_z * v3 + + rho * v2 * v3_z + - mu_ * (tau12_x + tau22_y + tau23_z) ) + # z-momentum equation + du4 = ( rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 + + rho * v1_x * v3 + + rho * v1 * v3_x + + rho_y * v2 * v3 + + rho * v2_y * v3 + + rho * v2 * v3_y + + rho_z * v3^2 + + 2.0 * rho * v3 * v3_z + - mu_ * (tau13_x + tau23_y + tau33_z) ) + # Total energy equation + du5 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + + v3_z * (E + p) + v3 * (E_z + p_z) + # stress tensor and temperature gradient from x-direction + - mu_ * ( q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 + + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) + # stress tensor and temperature gradient terms from y-direction + - mu_ * ( q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 + + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) + # stress tensor and temperature gradient terms from z-direction + - mu_ * ( q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 + + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z) ) + + return SVector(du1, du2, du3, du4, du5) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, - t, - equations)[2:4]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, - heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -243,11 +228,10 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic), - source_terms = source_terms_navier_stokes_convergence_test) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), + source_terms=source_terms_navier_stokes_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -257,15 +241,15 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl b/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl index 87c19dbd509..c14d6620803 100644 --- a/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl +++ b/examples/dgmulti_3d/elixir_navierstokes_convergence_curved.jl @@ -8,27 +8,25 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), - Prandtl = prandtl_number(), - gradient_variables = GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), Prandtl=prandtl_number(), + gradient_variables=GradientVariablesPrimitive()) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_lax_friedrichs), volume_integral = VolumeIntegralWeakForm()) -top_bottom(x, tol = 50 * eps()) = abs(abs(x[2]) - 1) < tol +top_bottom(x, tol=50*eps()) = abs(abs(x[2]) - 1) < tol is_on_boundary = Dict(:top_bottom => top_bottom) function mapping(xi, eta, zeta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) - return SVector(x, y, z) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + z = zeta + 0.1 * sin(pi * xi) * sin(pi * eta) + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) -mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity = (true, false, true), - is_on_boundary) +mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity=(true, false, true), is_on_boundary) # This initial condition is taken from `examples/dgmulti_3d/elixir_navierstokes_convergence.jl` @@ -37,213 +35,200 @@ mesh = DGMultiMesh(dg, cells_per_dimension, mapping; periodicity = (true, false, # and by the initial condition (which passes in `CompressibleEulerEquations3D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * - cos(pi_t) - v2 = v1 - v3 = v1 - p = rho^2 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * cos(pi_t) + v2 = v1 + v3 = v1 + p = rho^2 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - # Define auxiliary functions for the strange function of the y variable - # to make expressions easier to read - g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) - g_y = (A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) - + - (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0)) - g_yy = (2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) - - - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) - - - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0))) - - # Density and its derivatives - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) - rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) - rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) - rho_xx = -pi^2 * (rho - c) - rho_yy = -pi^2 * (rho - c) - rho_zz = -pi^2 * (rho - c) - - # Velocities and their derivatives - # v1 terms - v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) - v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_xx = -pi^2 * v1 - v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) - v1_zz = -pi^2 * v1 - v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) - # v2 terms (simplifies from ansatz) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_z = v1_z - v2_xx = v1_xx - v2_yy = v1_yy - v2_zz = v1_zz - v2_xy = v1_xy - v2_yz = v1_yz - # v3 terms (simplifies from ansatz) - v3 = v1 - v3_t = v1_t - v3_x = v1_x - v3_y = v1_y - v3_z = v1_z - v3_xx = v1_xx - v3_yy = v1_yy - v3_zz = v1_zz - v3_xz = v1_xz - v3_yz = v1_yz - - # Pressure and its derivatives - p = rho^2 - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_z = 2.0 * rho * rho_z - - # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 - E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 - E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y - E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z - - # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho - kappa = equations.gamma * inv_gamma_minus_one / Pr - q_xx = kappa * rho_xx # kappa T_xx - q_yy = kappa * rho_yy # kappa T_yy - q_zz = kappa * rho_zz # kappa T_zz - - # Stress tensor and its derivatives (exploit symmetry) - tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) - tau12 = v1_y + v2_x - tau13 = v1_z + v3_x - tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) - tau23 = v2_z + v3_y - tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) - - tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) - tau12_x = v1_xy + v2_xx - tau13_x = v1_xz + v3_xx - - tau12_y = v1_yy + v2_xy - tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) - tau23_y = v2_yz + v3_yy - - tau13_z = v1_zz + v3_xz - tau23_z = v2_zz + v3_yz - tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) - - # Compute the source terms - # Density equation - du1 = (rho_t + rho_x * v1 + rho * v1_x - + rho_y * v2 + rho * v2_y - + rho_z * v3 + rho * v3_z) - # x-momentum equation - du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - + rho_z * v1 * v3 - + rho * v1_z * v3 - + rho * v1 * v3_z - - - mu_ * (tau11_x + tau12_y + tau13_z)) - # y-momentum equation - du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - + rho_z * v2 * v3 - + rho * v2_z * v3 - + rho * v2 * v3_z - - - mu_ * (tau12_x + tau22_y + tau23_z)) - # z-momentum equation - du4 = (rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 - + rho * v1_x * v3 - + rho * v1 * v3_x - + rho_y * v2 * v3 - + rho * v2_y * v3 - + rho * v2 * v3_y - + rho_z * v3^2 - + 2.0 * rho * v3 * v3_z - - - mu_ * (tau13_x + tau23_y + tau33_z)) - # Total energy equation - du5 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - + v3_z * (E + p) + v3 * (E_z + p_z) - # stress tensor and temperature gradient from x-direction - - - mu_ * (q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 - + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) - # stress tensor and temperature gradient terms from y-direction - - - mu_ * (q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 - + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) - # stress tensor and temperature gradient terms from z-direction - - - mu_ * (q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 - + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z)) - - return SVector(du1, du2, du3, du4, du5) + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + # Define auxiliary functions for the strange function of the y variable + # to make expressions easier to read + g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) + g_y = ( A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) + + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0) ) + g_yy = ( 2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) + - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) + - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) ) + + # Density and its derivatives + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) + rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) + rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) + rho_xx = -pi^2 * (rho - c) + rho_yy = -pi^2 * (rho - c) + rho_zz = -pi^2 * (rho - c) + + # Velocities and their derivatives + # v1 terms + v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) + v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_xx = -pi^2 * v1 + v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) + v1_zz = -pi^2 * v1 + v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) + # v2 terms (simplifies from ansatz) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_z = v1_z + v2_xx = v1_xx + v2_yy = v1_yy + v2_zz = v1_zz + v2_xy = v1_xy + v2_yz = v1_yz + # v3 terms (simplifies from ansatz) + v3 = v1 + v3_t = v1_t + v3_x = v1_x + v3_y = v1_y + v3_z = v1_z + v3_xx = v1_xx + v3_yy = v1_yy + v3_zz = v1_zz + v3_xz = v1_xz + v3_yz = v1_yz + + # Pressure and its derivatives + p = rho^2 + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_z = 2.0 * rho * rho_z + + # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 + E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 + E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y + E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z + + # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho + kappa = equations.gamma * inv_gamma_minus_one / Pr + q_xx = kappa * rho_xx # kappa T_xx + q_yy = kappa * rho_yy # kappa T_yy + q_zz = kappa * rho_zz # kappa T_zz + + # Stress tensor and its derivatives (exploit symmetry) + tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) + tau12 = v1_y + v2_x + tau13 = v1_z + v3_x + tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) + tau23 = v2_z + v3_y + tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) + + tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) + tau12_x = v1_xy + v2_xx + tau13_x = v1_xz + v3_xx + + tau12_y = v1_yy + v2_xy + tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) + tau23_y = v2_yz + v3_yy + + tau13_z = v1_zz + v3_xz + tau23_z = v2_zz + v3_yz + tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) + + # Compute the source terms + # Density equation + du1 = ( rho_t + rho_x * v1 + rho * v1_x + + rho_y * v2 + rho * v2_y + + rho_z * v3 + rho * v3_z ) + # x-momentum equation + du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + + rho_z * v1 * v3 + + rho * v1_z * v3 + + rho * v1 * v3_z + - mu_ * (tau11_x + tau12_y + tau13_z) ) + # y-momentum equation + du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + + rho_z * v2 * v3 + + rho * v2_z * v3 + + rho * v2 * v3_z + - mu_ * (tau12_x + tau22_y + tau23_z) ) + # z-momentum equation + du4 = ( rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 + + rho * v1_x * v3 + + rho * v1 * v3_x + + rho_y * v2 * v3 + + rho * v2_y * v3 + + rho * v2 * v3_y + + rho_z * v3^2 + + 2.0 * rho * v3 * v3_z + - mu_ * (tau13_x + tau23_y + tau33_z) ) + # Total energy equation + du5 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + + v3_z * (E + p) + v3 * (E_z + p_z) + # stress tensor and temperature gradient from x-direction + - mu_ * ( q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 + + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) + # stress tensor and temperature gradient terms from y-direction + - mu_ * ( q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 + + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) + # stress tensor and temperature gradient terms from z-direction + - mu_ * ( q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 + + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z) ) + + return SVector(du1, du2, du3, du4, du5) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, - t, - equations)[2:4]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, - heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) @@ -251,11 +236,10 @@ boundary_conditions = (; :top_bottom => boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; :top_bottom => boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, dg; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic), - source_terms = source_terms_navier_stokes_convergence_test) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), + source_terms=source_terms_navier_stokes_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -265,15 +249,15 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg)) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl b/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl index dedd8267a3b..7953838afeb 100644 --- a/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl +++ b/examples/dgmulti_3d/elixir_navierstokes_taylor_green_vortex.jl @@ -10,30 +10,26 @@ prandtl_number() = 0.72 mu() = 6.25e-4 # equivalent to Re = 1600 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), - Prandtl = prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), + Prandtl=prandtl_number()) """ initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, - equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + - 1.0 / 16.0 * A^2 * rho * - (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + - cos(2 * x[2]) * cos(2 * x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex @@ -43,11 +39,11 @@ dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type = GaussSBP(), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = (1.0, 1.0, 1.0) .* pi +coordinates_max = ( 1.0, 1.0, 1.0) .* pi cells_per_dimension = (8, 8, 8) mesh = DGMultiMesh(dg, cells_per_dimension; coordinates_min, coordinates_max, - periodicity = (true, true, true)) + periodicity=(true, true, true)) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, dg) @@ -59,18 +55,18 @@ tspan = (0.0, 10.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg), - extra_analysis_integrals = (energy_kinetic, - energy_internal, - enstrophy)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, uEltype=real(dg), + extra_analysis_integrals=(energy_kinetic, + energy_internal, + enstrophy)) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl b/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl index 5a2537be4e6..841a080947e 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_amr_solution_independent.jl @@ -7,73 +7,74 @@ module TrixiExtension using Trixi -struct IndicatorSolutionIndependent{Cache <: NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorSolutionIndependent{Cache<:NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorSolutionIndependent(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) - return IndicatorSolutionIndependent{typeof(cache)}(cache) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) + return IndicatorSolutionIndependent{typeof(cache)}(cache) end -function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any, 4}, +function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any,4}, mesh, equations, dg, cache; t, kwargs...) - mesh = indicator.cache.mesh - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) - - #Predict the theoretical center. - advection_velocity = (0.2, -0.7) - center = t .* advection_velocity - - inner_distance = 1 - outer_distance = 1.85 - - #Iterate over all elements - for element in 1:length(alpha) - # Calculate periodic distance between cell and center. - # This requires an uncurved mesh! - coordinates = SVector(0.5 * (cache.elements.node_coordinates[1, 1, 1, element] + - cache.elements.node_coordinates[1, end, 1, element]), - 0.5 * (cache.elements.node_coordinates[2, 1, 1, element] + - cache.elements.node_coordinates[2, 1, end, element])) - - #The geometric shape of the amr should be preserved when the base_level is increased. - #This is done by looking at the original coordinates of each cell. - cell_coordinates = original_coordinates(coordinates, 5 / 8) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) - if cell_distance < (inner_distance + outer_distance) / 2 - cell_coordinates = original_coordinates(coordinates, 5 / 16) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) - end - - #Set alpha according to cells position inside the circles. - target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) - alpha[element] = target_level / 2 + + mesh = indicator.cache.mesh + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) + + #Predict the theoretical center. + advection_velocity = (0.2, -0.7) + center = t.*advection_velocity + + inner_distance = 1 + outer_distance = 1.85 + + #Iterate over all elements + for element in 1:length(alpha) + # Calculate periodic distance between cell and center. + # This requires an uncurved mesh! + coordinates = SVector(0.5 * (cache.elements.node_coordinates[1, 1, 1, element] + + cache.elements.node_coordinates[1, end, 1, element]), + 0.5 * (cache.elements.node_coordinates[2, 1, 1, element] + + cache.elements.node_coordinates[2, 1, end, element])) + + #The geometric shape of the amr should be preserved when the base_level is increased. + #This is done by looking at the original coordinates of each cell. + cell_coordinates = original_coordinates(coordinates, 5/8) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + if cell_distance < (inner_distance+outer_distance)/2 + cell_coordinates = original_coordinates(coordinates, 5/16) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) end - return alpha + + #Set alpha according to cells position inside the circles. + target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) + alpha[element] = target_level/2 + end + return alpha end # For periodic domains, distance between two points must take into account # periodic extensions of the domain function periodic_distance_2d(coordinates, center, domain_length) - dx = coordinates .- center - dx_shifted = abs.(dx .% domain_length) - dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) - return sqrt(sum(dx_periodic .^ 2)) + dx = coordinates .- center + dx_shifted = abs.(dx .% domain_length) + dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) + return sqrt(sum(dx_periodic.^2)) end #This takes a cells coordinates and transforms them into the coordinates of a parent-cell it originally refined from. #It does it so that the parent-cell has given cell_length. function original_coordinates(coordinates, cell_length) - offset = coordinates .% cell_length - offset_sign = sign.(offset) - border = coordinates - offset - center = border + (offset_sign .* cell_length / 2) - return center + offset = coordinates .% cell_length + offset_sign = sign.(offset) + border = coordinates - offset + center = border + (offset_sign .* cell_length/2) + return center end end # module TrixiExtension @@ -87,19 +88,21 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) trees_per_dimension = (1, 1) -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 4) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=4) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -109,38 +112,38 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_controller = ControllerThreeLevel(semi, - TrixiExtension.IndicatorSolutionIndependent(semi), - base_level = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, TrixiExtension.IndicatorSolutionIndependent(semi), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl b/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl index 0a50b3644f0..7e6d99c83b1 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_amr_unstructured_flag.jl @@ -12,16 +12,18 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( + :all => boundary_condition +) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-5.0, 5 * s - 5.0) -f2(s) = SVector(5.0, 5 * s + 5.0) +f2(s) = SVector( 5.0, 5 * s + 5.0) f3(s) = SVector(5 * s, -5.0 + 5 * sin(0.5 * pi * s)) -f4(s) = SVector(5 * s, 5.0 + 5 * sin(0.5 * pi * s)) +f4(s) = SVector(5 * s, 5.0 + 5 * sin(0.5 * pi * s)) faces = (f1, f2, f3, f4) # This creates a mapping that transforms [-1, 1]^2 to the domain with the faces defined above. @@ -32,16 +34,17 @@ mapping_flag = Trixi.transfinite_mapping(faces) # Unstructured mesh with 24 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) + +mesh = P4estMesh{2}(mesh_file, polydeg=3, + mapping=mapping_flag, + initial_refinement_level=1) -mesh = P4estMesh{2}(mesh_file, polydeg = 3, - mapping = mapping_flag, - initial_refinement_level = 1) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -52,40 +55,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +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 = 1, - med_level = 2, med_threshold = 0.1, - max_level = 3, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=1, + med_level=2, med_threshold=0.1, + max_level=3, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.7) +stepsize_callback = StepsizeCallback(cfl=0.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, amr_callback, stepsize_callback); + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 1, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=1, # 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 diff --git a/examples/p4est_2d_dgsem/elixir_advection_basic.jl b/examples/p4est_2d_dgsem/elixir_advection_basic.jl index ed235bf839c..0b2de85da48 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_basic.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_basic.jl @@ -11,21 +11,21 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) trees_per_dimension = (8, 8) # Create P4estMesh with 8 x 8 trees and 16 x 16 elements -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 1) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=1) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -38,26 +38,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl index 0b5129e3c0f..1cd075e84ea 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic.jl @@ -9,21 +9,19 @@ advection_velocity = (1.0, 0.0) equations = LinearScalarAdvectionEquation2D(advection_velocity) equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) -function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0)) +function x_trans_periodic(x, domain_length=SVector(2 * pi), center=SVector(0.0)) x_normalized = x .- center x_shifted = x_normalized .% domain_length - x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* - domain_length + x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* domain_length return center + x_shifted + x_offset end # Define initial condition (copied from "examples/tree_1d_dgsem/elixir_advection_diffusion.jl") -function initial_condition_diffusive_convergence_test(x, t, - equation::LinearScalarAdvectionEquation2D) +function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation2D) # Store translated coordinate for easy use of exact solution # Assumes that advection_velocity[2] = 0 (effectively that we are solving a 1D equation) x_trans = x_trans_periodic(x[1] - equation.advection_velocity[1] * t) - + nu = diffusivity() c = 0.0 A = 1.0 @@ -34,22 +32,23 @@ end initial_condition = initial_condition_diffusive_convergence_test # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-pi, -pi) # minimum coordinates (min(x), min(y)) -coordinates_max = (pi, pi) # maximum coordinates (max(x), max(y)) +coordinates_max = ( pi, pi) # maximum coordinates (max(x), max(y)) trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg = 3, initial_refinement_level = 2, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = true) + polydeg=3, initial_refinement_level=2, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -63,21 +62,22 @@ 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) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl index 130def37997..b438fb8a29c 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_curved.jl @@ -9,21 +9,19 @@ advection_velocity = (1.0, 0.0) equations = LinearScalarAdvectionEquation2D(advection_velocity) equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) -function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0)) +function x_trans_periodic(x, domain_length=SVector(2 * pi), center=SVector(0.0)) x_normalized = x .- center x_shifted = x_normalized .% domain_length - x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* - domain_length + x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* domain_length return center + x_shifted + x_offset end # Define initial condition (copied from "examples/tree_1d_dgsem/elixir_advection_diffusion.jl") -function initial_condition_diffusive_convergence_test(x, t, - equation::LinearScalarAdvectionEquation2D) +function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation2D) # Store translated coordinate for easy use of exact solution # Assumes that advection_velocity[2] = 0 (effectively that we are solving a 1D equation) x_trans = x_trans_periodic(x[1] - equation.advection_velocity[1] * t) - + nu = diffusivity() c = 0.0 A = 1.0 @@ -34,27 +32,28 @@ end initial_condition = initial_condition_diffusive_convergence_test # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # This maps the domain [-1, 1]^2 to [-pi, pi]^2 while also # introducing a curved warping to interior nodes. function mapping(xi, eta) - x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) - y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) - return pi * SVector(x, y) + x = xi + 0.1 * sin(pi * xi) * sin(pi * eta) + y = eta + 0.1 * sin(pi * xi) * sin(pi * eta) + return pi * SVector(x, y) end trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg = 3, initial_refinement_level = 2, - mapping = mapping, - periodicity = true) + polydeg=3, initial_refinement_level=2, + mapping=mapping, + periodicity=true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -68,21 +67,22 @@ 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) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_extended.jl b/examples/p4est_2d_dgsem/elixir_advection_extended.jl index 66a5b7e0f5b..6d8e7030ac0 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_extended.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_extended.jl @@ -12,28 +12,31 @@ initial_condition = initial_condition_convergence_test # BCs must be passed as Dict boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:x_neg => boundary_condition, - :x_pos => boundary_condition, - :y_neg => boundary_condition, - :y_pos => boundary_condition) +boundary_conditions = Dict( + :x_neg => boundary_condition, + :x_pos => boundary_condition, + :y_neg => boundary_condition, + :y_pos => boundary_condition +) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # The initial condition is 2-periodic coordinates_min = (-1.5, 1.3) # minimum coordinates (min(x), min(y)) -coordinates_max = (0.5, 5.3) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 0.5, 5.3) # maximum coordinates (max(x), max(y)) trees_per_dimension = (19, 37) # Create curved mesh with 19 x 37 elements -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = false) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=false) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -48,24 +51,24 @@ 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, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.6) +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, @@ -73,13 +76,14 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl b/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl index b47b0d61192..0e6e314ebd7 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_nonconforming_flag.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the linear advection equation @@ -9,44 +10,42 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) # Create DG solver with polynomial degree = 4 and (local) Lax-Friedrichs/Rusanov flux as surface flux -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector(1.0, s + 1.0) +f2(s) = SVector( 1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) # Create P4estMesh with 3 x 2 trees and 6 x 4 elements, # approximate the geometry with a smaller polydeg for testing. trees_per_dimension = (3, 2) -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - faces = (f1, f2, f3, f4), - initial_refinement_level = 1) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + faces=(f1, f2, f3, f4), + initial_refinement_level=1) # Refine bottom left quadrant of each tree to level 4 function refine_fn(p4est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 4 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 4 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 4 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p4est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -59,26 +58,26 @@ ode = semidiscretize(semi, (0.0, 0.2)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_advection_restart.jl b/examples/p4est_2d_dgsem/elixir_advection_restart.jl index 46eabb4cf38..1906fb2896e 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_restart.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_restart.jl @@ -10,6 +10,7 @@ restart_file = "restart_000021.h5" trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file)) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -20,15 +21,16 @@ restart_filename = joinpath("out", restart_file) mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl b/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl index 37fcc547f60..9f5b813639f 100644 --- a/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_advection_unstructured_flag.jl @@ -3,6 +3,7 @@ using Downloads: download using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the linear advection equation @@ -12,17 +13,19 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( + :all => boundary_condition +) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector(1.0, s + 1.0) +f2(s) = SVector( 1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) faces = (f1, f2, f3, f4) Trixi.validate_faces(faces) @@ -30,17 +33,16 @@ mapping_flag = Trixi.transfinite_mapping(faces) # Unstructured mesh with 24 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{2}(mesh_file, polydeg = 3, - mapping = mapping_flag, - initial_refinement_level = 2) +mesh = P4estMesh{2}(mesh_file, polydeg=3, + mapping=mapping_flag, + initial_refinement_level=2) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -54,26 +56,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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.4) +stepsize_callback = StepsizeCallback(cfl=1.4) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl index 0ca4fdc2eb7..e3f33fb0d28 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_blast_wave_amr.jl @@ -17,48 +17,49 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) # Unstructured mesh with 48 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_1.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", + mesh_file) -mesh = P4estMesh{2}(mesh_file, polydeg = 3, initial_refinement_level = 1) +mesh = P4estMesh{2}(mesh_file, polydeg=3, initial_refinement_level=1) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition))) + boundary_conditions=Dict( + :all => BoundaryConditionDirichlet(initial_condition) + )) ############################################################################### # ODE solvers, callbacks etc. @@ -69,39 +70,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 1, - max_level = 3, max_threshold = 0.01) + base_level=1, + max_level =3, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl index 37de44fd40d..6d00aa91ba3 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl @@ -21,66 +21,64 @@ See Section IV c on the paper below for details. The Numerical Simulation of Two-Dimensional Fluid Flows with Strong Shocks. [DOI: 10.1016/0021-9991(84)90142-6](https://doi.org/10.1016/0021-9991(84)90142-6) """ -@inline function initial_condition_double_mach_reflection(x, t, - equations::CompressibleEulerEquations2D) - if x[1] < 1 / 6 + (x[2] + 20 * t) / sqrt(3) - phi = pi / 6 - sin_phi, cos_phi = sincos(phi) - - rho = 8 - v1 = 8.25 * cos_phi - v2 = -8.25 * sin_phi - p = 116.5 - else - rho = 1.4 - v1 = 0 - v2 = 0 - p = 1 - end - - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) +@inline function initial_condition_double_mach_reflection(x, t, equations::CompressibleEulerEquations2D) + + if x[1] < 1 / 6 + (x[2] + 20 * t) / sqrt(3) + phi = pi / 6 + sin_phi, cos_phi = sincos(phi) + + rho = 8 + v1 = 8.25 * cos_phi + v2 = -8.25 * sin_phi + p = 116.5 + else + rho = 1.4 + v1 = 0 + v2 = 0 + p = 1 + end + + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_double_mach_reflection + boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition_double_mach_reflection) # Supersonic outflow boundary condition. Solution is taken entirely from the internal state. # See `examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl` for complete documentation. @inline function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, - equations::CompressibleEulerEquations2D) - # NOTE: Only for the supersonic outflow is this strategy valid - # Calculate the boundary flux entirely from the internal solution state - return flux(u_inner, normal_direction, equations) + surface_flux_function, equations::CompressibleEulerEquations2D) + # NOTE: Only for the supersonic outflow is this strategy valid + # Calculate the boundary flux entirely from the internal solution state + return flux(u_inner, normal_direction, equations) end # Special mixed boundary condition type for the :Bottom of the domain. # It is Dirichlet when x < 1/6 and a slip wall when x >= 1/6 -@inline function boundary_condition_mixed_dirichlet_wall(u_inner, - normal_direction::AbstractVector, +@inline function boundary_condition_mixed_dirichlet_wall(u_inner, normal_direction::AbstractVector, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) - if x[1] < 1 / 6 - # From the BoundaryConditionDirichlet - # get the external value of the solution - u_boundary = initial_condition_double_mach_reflection(x, t, equations) - # Calculate boundary flux - flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations) - else # x[1] >= 1 / 6 - # Use the free slip wall BC otherwise - flux = boundary_condition_slip_wall(u_inner, normal_direction, x, t, - surface_flux_function, equations) - end - - return flux + if x[1] < 1 / 6 + # From the BoundaryConditionDirichlet + # get the external value of the solution + u_boundary = initial_condition_double_mach_reflection(x, t, equations) + # Calculate boundary flux + flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations) + else # x[1] >= 1 / 6 + # Use the free slip wall BC otherwise + flux = boundary_condition_slip_wall(u_inner, normal_direction, x, t, surface_flux_function, equations) + end + + return flux end -boundary_conditions = Dict(:Bottom => boundary_condition_mixed_dirichlet_wall, - :Top => boundary_condition_inflow, - :Right => boundary_condition_outflow, - :Left => boundary_condition_inflow) +boundary_conditions = Dict( :Bottom => boundary_condition_mixed_dirichlet_wall, + :Top => boundary_condition_inflow, + :Right => boundary_condition_outflow, + :Left => boundary_condition_inflow ) volume_flux = flux_ranocha surface_flux = flux_lax_friedrichs @@ -88,27 +86,25 @@ surface_flux = flux_lax_friedrichs polydeg = 4 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_double_mach.inp") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/a0806ef0d03cf5ea221af523167b6e32/raw/61ed0eb017eb432d996ed119a52fb041fe363e8c/abaqus_double_mach.inp", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/a0806ef0d03cf5ea221af523167b6e32/raw/61ed0eb017eb432d996ed119a52fb041fe363e8c/abaqus_double_mach.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -119,27 +115,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) +amr_indicator = IndicatorLöhner(semi, variable=Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 0, - med_level = 3, med_threshold = 0.05, - max_level = 6, max_threshold = 0.1) + base_level=0, + med_level=3, med_threshold=0.05, + max_level=6, max_threshold=0.1) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -147,11 +143,11 @@ callbacks = CallbackSet(summary_callback, amr_callback) # positivity limiter necessary for this example with strong shocks -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) ############################################################################### # run the simulation sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl index 0ec9fc222f2..667834ea108 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl @@ -20,18 +20,19 @@ See Section IV b on the paper below for details. [DOI: 10.1016/0021-9991(84)90142-6](https://doi.org/10.1016/0021-9991(84)90142-6) """ @inline function initial_condition_mach3_flow(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.4 - v1 = 3.0 - v2 = 0.0 - p_freestream = 1.0 - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.4 + v1 = 3.0 + v2 = 0.0 + p_freestream = 1.0 + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = initial_condition_mach3_flow + boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition_mach3_flow) # Outflow boundary condition. @@ -45,47 +46,46 @@ boundary_condition_inflow = BoundaryConditionDirichlet(initial_condition_mach3_f # Inflow/Outflow Boundary Conditions with Application to FUN3D. # [NASA TM 20110022658](https://ntrs.nasa.gov/citations/20110022658) @inline function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, - equations::CompressibleEulerEquations2D) - # # This would be for the general case where we need to check the magnitude of the local Mach number - # norm_ = norm(normal_direction) - # # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later - # normal = normal_direction / norm_ - - # # Rotate the internal solution state - # u_local = Trixi.rotate_to_x(u_inner, normal, equations) - - # # Compute the primitive variables - # rho_local, v_normal, v_tangent, p_local = cons2prim(u_local, equations) - - # # Compute local Mach number - # a_local = sqrt( equations.gamma * p_local / rho_local ) - # Mach_local = abs( v_normal / a_local ) - # if Mach_local <= 1.0 - # p_local = # Set to the external reference pressure value (somehow? maybe stored in `equations`) - # end - - # # Create the `u_surface` solution state where the local pressure is possibly set from an external value - # prim = SVector(rho_local, v_normal, v_tangent, p_local) - # u_boundary = prim2cons(prim, equations) - # u_surface = Trixi.rotate_from_x(u_boundary, normal, equations) - - # Compute the flux using the appropriate mixture of internal / external solution states - # flux = Trixi.flux(u_surface, normal_direction, equations) - - # NOTE: Only for the supersonic outflow is this strategy valid - # Calculate the boundary flux entirely from the internal solution state - flux = Trixi.flux(u_inner, normal_direction, equations) - - return flux + surface_flux_function, equations::CompressibleEulerEquations2D) + # # This would be for the general case where we need to check the magnitude of the local Mach number + # norm_ = norm(normal_direction) + # # Normalize the vector without using `normalize` since we need to multiply by the `norm_` later + # normal = normal_direction / norm_ + + # # Rotate the internal solution state + # u_local = Trixi.rotate_to_x(u_inner, normal, equations) + + # # Compute the primitive variables + # rho_local, v_normal, v_tangent, p_local = cons2prim(u_local, equations) + + # # Compute local Mach number + # a_local = sqrt( equations.gamma * p_local / rho_local ) + # Mach_local = abs( v_normal / a_local ) + # if Mach_local <= 1.0 + # p_local = # Set to the external reference pressure value (somehow? maybe stored in `equations`) + # end + + # # Create the `u_surface` solution state where the local pressure is possibly set from an external value + # prim = SVector(rho_local, v_normal, v_tangent, p_local) + # u_boundary = prim2cons(prim, equations) + # u_surface = Trixi.rotate_from_x(u_boundary, normal, equations) + + # Compute the flux using the appropriate mixture of internal / external solution states + # flux = Trixi.flux(u_surface, normal_direction, equations) + + # NOTE: Only for the supersonic outflow is this strategy valid + # Calculate the boundary flux entirely from the internal solution state + flux = Trixi.flux(u_inner, normal_direction, equations) + + return flux end -boundary_conditions = Dict(:Bottom => boundary_condition_slip_wall, - :Step_Front => boundary_condition_slip_wall, - :Step_Top => boundary_condition_slip_wall, - :Top => boundary_condition_slip_wall, - :Right => boundary_condition_outflow, - :Left => boundary_condition_inflow) +boundary_conditions = Dict( :Bottom => boundary_condition_slip_wall, + :Step_Front => boundary_condition_slip_wall, + :Step_Top => boundary_condition_slip_wall, + :Top => boundary_condition_slip_wall, + :Right => boundary_condition_outflow, + :Left => boundary_condition_inflow ) volume_flux = flux_ranocha surface_flux = flux_lax_friedrichs @@ -93,27 +93,25 @@ surface_flux = flux_lax_friedrichs polydeg = 4 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_forward_step.inp") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/b346ee6aa5446687f128eab8b37d52a7/raw/cd1e1d43bebd8d2631a07caec45585ec8456ca4c/abaqus_forward_step.inp", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/b346ee6aa5446687f128eab8b37d52a7/raw/cd1e1d43bebd8d2631a07caec45585ec8456ca4c/abaqus_forward_step.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -124,27 +122,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 2000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=2000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) +amr_indicator = IndicatorLöhner(semi, variable=Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 0, - med_level = 2, med_threshold = 0.05, - max_level = 5, max_threshold = 0.1) + base_level=0, + med_level=2, med_threshold=0.05, + max_level=5, max_threshold=0.1) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -152,12 +150,12 @@ callbacks = CallbackSet(summary_callback, amr_callback) # positivity limiter necessary for this example with strong shocks -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) ############################################################################### # run the simulation sol = solve(ode, SSPRK43(stage_limiter!); - maxiters = 999999, ode_default_options()..., - callback = callbacks); + maxiters=999999, ode_default_options()..., + callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl b/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl index 38307a7d781..e88baa2223d 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_free_stream.jl @@ -10,21 +10,21 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_constant -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040 but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end ############################################################################### @@ -32,34 +32,34 @@ end # Unstructured mesh with 48 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_1.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/a075f8ec39a67fa9fad8f6f84342cbca/raw/a7206a02ed3a5d3cadacd8d9694ac154f9151db7/square_unstructured_1.inp", + mesh_file) # Map the unstructured mesh with the mapping above -mesh = P4estMesh{2}(mesh_file, polydeg = 3, mapping = mapping, initial_refinement_level = 1) +mesh = P4estMesh{2}(mesh_file, polydeg=3, mapping=mapping, initial_refinement_level=1) # Refine bottom left quadrant of each tree to level 2 function refine_fn(p4est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 3 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 3 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 2. # The mesh will be rebalanced before the simulation starts. -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p4est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition))) + boundary_conditions=Dict( + :all => BoundaryConditionDirichlet(initial_condition) + )) + ############################################################################### # ODE solvers, callbacks etc. @@ -70,16 +70,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 2.0) +stepsize_callback = StepsizeCallback(cfl=2.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -89,7 +89,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_sedov.jl b/examples/p4est_2d_dgsem/elixir_euler_sedov.jl index 1b78a152d4e..9f5247e8c4d 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_sedov.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_sedov.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) - p0_outer = 1.0e-5 # = true Sedov 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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) + p0_outer = 1.0e-5 # = true Sedov 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 @@ -43,27 +43,26 @@ volume_flux = flux_ranocha polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=1.0, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) ############################################################################### coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg = 4, initial_refinement_level = 2, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = true) + polydeg=4, initial_refinement_level=2, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -76,15 +75,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 300, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=300, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -95,7 +94,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl b/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl index 0cb18526f8d..6ef551c486f 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_shockcapturing_ec.jl @@ -14,30 +14,30 @@ volume_flux = flux_ranocha polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=1.0, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) ############################################################################### coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) trees_per_dimension = (4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg = 4, initial_refinement_level = 2, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = true) + polydeg=4, initial_refinement_level=2, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -47,16 +47,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -66,7 +66,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl b/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl index 09d018309a6..d9a322b065a 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_flag.jl @@ -14,16 +14,18 @@ source_terms = source_terms_convergence_test # BCs must be passed as Dict boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( + :all => boundary_condition +) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector(1.0, s + 1.0) +f2(s) = SVector( 1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) faces = (f1, f2, f3, f4) Trixi.validate_faces(faces) @@ -32,36 +34,34 @@ mapping_flag = Trixi.transfinite_mapping(faces) # Get the uncurved mesh from a file (downloads the file if not available locally) # Unstructured mesh with 24 cells of the square domain [-1, 1]^n mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{2}(mesh_file, polydeg = 3, - mapping = mapping_flag, - initial_refinement_level = 1) +mesh = P4estMesh{2}(mesh_file, polydeg=3, + mapping=mapping_flag, + initial_refinement_level=1) # Refine bottom left quadrant of each tree to level 2 function refine_fn(p4est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 2 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p4est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms, - boundary_conditions = boundary_conditions) + source_terms=source_terms, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -72,19 +72,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -93,7 +93,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl b/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl index aae0b109392..366be700f9f 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl @@ -23,14 +23,14 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) @inline function initial_condition_mach3_flow(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.4 - v1 = 3.0 - v2 = 0.0 - p_freestream = 1.0 - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.4 + v1 = 3.0 + v2 = 0.0 + p_freestream = 1.0 + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = initial_condition_mach3_flow @@ -38,33 +38,30 @@ initial_condition = initial_condition_mach3_flow # Supersonic inflow boundary condition. # Calculate the boundary flux entirely from the external solution state, i.e., set # external solution state values for everything entering the domain. -@inline function boundary_condition_supersonic_inflow(u_inner, - normal_direction::AbstractVector, x, - t, - surface_flux_function, - equations::CompressibleEulerEquations2D) - u_boundary = initial_condition_mach3_flow(x, t, equations) - flux = Trixi.flux(u_boundary, normal_direction, equations) - - return flux +@inline function boundary_condition_supersonic_inflow(u_inner, normal_direction::AbstractVector, x, t, + surface_flux_function, equations::CompressibleEulerEquations2D) + u_boundary = initial_condition_mach3_flow(x, t, equations) + flux = Trixi.flux(u_boundary, normal_direction, equations) + + return flux end + # Supersonic outflow boundary condition. # Calculate the boundary flux entirely from the internal solution state. Analogous to supersonic inflow # except all the solution state values are set from the internal solution as everything leaves the domain @inline function boundary_condition_outflow(u_inner, normal_direction::AbstractVector, x, t, - surface_flux_function, - equations::CompressibleEulerEquations2D) - flux = Trixi.flux(u_inner, normal_direction, equations) + surface_flux_function, equations::CompressibleEulerEquations2D) + flux = Trixi.flux(u_inner, normal_direction, equations) - return flux + return flux end -boundary_conditions = Dict(:Bottom => boundary_condition_slip_wall, - :Circle => boundary_condition_slip_wall, - :Top => boundary_condition_slip_wall, - :Right => boundary_condition_outflow, - :Left => boundary_condition_supersonic_inflow) +boundary_conditions = Dict( :Bottom => boundary_condition_slip_wall, + :Circle => boundary_condition_slip_wall, + :Top => boundary_condition_slip_wall, + :Right => boundary_condition_outflow, + :Left => boundary_condition_supersonic_inflow ) volume_flux = flux_ranocha_turbo surface_flux = flux_lax_friedrichs @@ -72,27 +69,25 @@ surface_flux = flux_lax_friedrichs polydeg = 3 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_cylinder_in_channel.inp") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/a08f78f6b185b63c3baeff911a63f628/raw/addac716ea0541f588b9d2bd3f92f643eb27b88f/abaqus_cylinder_in_channel.inp", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/a08f78f6b185b63c3baeff911a63f628/raw/addac716ea0541f588b9d2bd3f92f643eb27b88f/abaqus_cylinder_in_channel.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers @@ -105,26 +100,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_indicator = IndicatorLöhner(semi, variable = Trixi.density) +amr_indicator = IndicatorLöhner(semi, variable=Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 0, - med_level = 3, med_threshold = 0.05, - max_level = 5, max_threshold = 0.1) + base_level=0, + med_level=3, med_threshold=0.05, + max_level=5, max_threshold=0.1) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -133,11 +128,11 @@ callbacks = CallbackSet(summary_callback, # positivity limiter necessary for this example with strong shocks. Very sensitive # to the order of the limiter variables, pressure must come first. -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-7, 1.0e-6), - variables = (pressure, Trixi.density)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-7, 1.0e-6), + variables=(pressure, Trixi.density)) ############################################################################### # run the simulation sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl b/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl index 8b8d05bade8..7c7896ce372 100644 --- a/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl +++ b/examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl @@ -9,46 +9,45 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) @inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.0 - u_freestream = 0.3 - p_freestream = inv(equations.gamma) - - theta = pi / 90.0 # analogous with a two degree angle of attack - si, co = sincos(theta) - v1 = u_freestream * co - v2 = u_freestream * si - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.0 + u_freestream = 0.3 + p_freestream = inv(equations.gamma) + + theta = pi / 90.0 # analogous with a two degree angle of attack + si, co = sincos(theta) + v1 = u_freestream * co + v2 = u_freestream * si + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = uniform_flow_state boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state) -boundary_conditions = Dict(:Body => boundary_condition_uniform_flow, - :Button1 => boundary_condition_slip_wall, - :Button2 => boundary_condition_slip_wall, - :Eye1 => boundary_condition_slip_wall, - :Eye2 => boundary_condition_slip_wall, - :Smile => boundary_condition_slip_wall, - :Bowtie => boundary_condition_slip_wall) +boundary_conditions = Dict( :Body => boundary_condition_uniform_flow, + :Button1 => boundary_condition_slip_wall, + :Button2 => boundary_condition_slip_wall, + :Eye1 => boundary_condition_slip_wall, + :Eye2 => boundary_condition_slip_wall, + :Smile => boundary_condition_slip_wall, + :Bowtie => boundary_condition_slip_wall ) volume_flux = flux_ranocha -solver = DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=5, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "abaqus_gingerbread_man.inp") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/0e9e990a04b5105d1d2e3096a6e41272/raw/0d924b1d7e7d3cc1070a6cc22fe1d501687aa6dd/abaqus_gingerbread_man.inp", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/0e9e990a04b5105d1d2e3096a6e41272/raw/0d924b1d7e7d3cc1070a6cc22fe1d501687aa6dd/abaqus_gingerbread_man.inp", + default_mesh_file) mesh_file = default_mesh_file mesh = P4estMesh{2}(mesh_file) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -59,35 +58,36 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_indicator = IndicatorLöhner(semi, variable = density) +amr_indicator = IndicatorLöhner(semi, variable=density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 0, - med_level = 1, med_threshold = 0.05, - max_level = 3, max_threshold = 0.1) + base_level=0, + med_level=1, med_threshold=0.05, + max_level=3, max_threshold=0.1) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback) + ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-7, reltol=1.0e-7, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl index 974466e3b3b..a99f9110aa8 100644 --- a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl @@ -2,8 +2,10 @@ using OrdinaryDiffEq using Trixi + initial_condition = initial_condition_eoc_test_coupled_euler_gravity + ############################################################################### # semidiscretization of the compressible Euler equations gamma = 2.0 @@ -16,13 +18,13 @@ coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) trees_per_dimension = (1, 1) -mesh = P4estMesh(trees_per_dimension, polydeg = 1, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 2) +mesh = P4estMesh(trees_per_dimension, polydeg=1, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=2) + +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, + source_terms=source_terms_eoc_test_coupled_euler_gravity) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, - solver_euler, - source_terms = source_terms_eoc_test_coupled_euler_gravity) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -30,23 +32,24 @@ equations_gravity = HyperbolicDiffusionEquations2D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, - solver_gravity, - source_terms = source_terms_harmonic) +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, + source_terms=source_terms_harmonic) + ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 +parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 # rho0 is (ab)used to add a "+8π" term to the source terms # for the manufactured solution - gravitational_constant = 1.0, # aka G - cfl = 1.1, - resid_tol = 1.0e-10, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_erk52_3Sstar!) + gravitational_constant=1.0, # aka G + cfl=1.1, + resid_tol=1.0e-10, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -54,30 +57,31 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, - save_analysis = true) +analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, + save_analysis=true) callbacks = CallbackSet(summary_callback, stepsize_callback, save_restart, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl index 58b02b3b94c..8b4aee5eec6 100644 --- a/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/p4est_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -2,29 +2,28 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg = 4, - surface_flux = (FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) -coordinates_min = (0.0, 0.0) +coordinates_min = (0.0 , 0.0 ) coordinates_max = (sqrt(2.0), sqrt(2.0)) trees_per_dimension = (8, 8) mesh = P4estMesh(trees_per_dimension, - polydeg = 3, initial_refinement_level = 0, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = true) + polydeg=3, initial_refinement_level=0, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -37,14 +36,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) cfl = 0.9 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -55,7 +54,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl b/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl index 380db487356..58915a8f6a7 100644 --- a/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl +++ b/examples/p4est_2d_dgsem/elixir_mhd_rotor.jl @@ -16,74 +16,74 @@ The classical MHD rotor test case. Here, the setup is taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ function initial_condition_rotor(x, t, equations::IdealGlmMhdEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 1.4 - dx = x[1] - 0.5 - dy = x[2] - 0.5 - r = sqrt(dx^2 + dy^2) - f = (0.115 - r) / 0.015 - if r <= 0.1 - rho = 10.0 - v1 = -20.0 * dy - v2 = 20.0 * dx - elseif r >= 0.115 - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - else - rho = 1.0 + 9.0 * f - v1 = -20.0 * f * dy - v2 = 20.0 * f * dx - end - v3 = 0.0 - p = 1.0 - B1 = 5.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) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 1.4 + dx = x[1] - 0.5 + dy = x[2] - 0.5 + r = sqrt(dx^2 + dy^2) + f = (0.115 - r)/0.015 + if r <= 0.1 + rho = 10.0 + v1 = -20.0*dy + v2 = 20.0*dx + elseif r >= 0.115 + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + else + rho = 1.0 + 9.0*f + v1 = -20.0*f*dy + v2 = 20.0*f*dx + end + v3 = 0.0 + p = 1.0 + B1 = 5.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_rotor surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) # Affine type mapping to take the [-1,1]^2 domain from the mesh file # and put it onto the rotor domain [0,1]^2 and then warp it with a mapping # as described in https://arxiv.org/abs/2012.12040 function mapping_twist(xi, eta) - y = 0.5 * (eta + 1.0) + - 0.05 * cos(1.5 * pi * (2.0 * xi - 1.0)) * cos(0.5 * pi * (2.0 * eta - 1.0)) - x = 0.5 * (xi + 1.0) + 0.05 * cos(0.5 * pi * (2.0 * xi - 1.0)) * cos(2.0 * pi * y) - return SVector(x, y) + y = 0.5 * (eta + 1.0) + 0.05 * cos(1.5 * pi * (2.0 * xi - 1.0)) * cos(0.5 * pi * (2.0 * eta - 1.0)) + x = 0.5 * (xi + 1.0) + 0.05 * cos(0.5 * pi * (2.0 * xi - 1.0)) * cos(2.0 * pi * y) + return SVector(x, y) end + mesh_file = joinpath(@__DIR__, "square_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/63ff2ea224409e55ee8423b3a33e316a/raw/7db58af7446d1479753ae718930741c47a3b79b7/square_unstructured_2.inp", + mesh_file) mesh = P4estMesh{2}(mesh_file, - polydeg = 4, - mapping = mapping_twist, - initial_refinement_level = 1) + polydeg=4, + mapping=mapping_twist, + initial_refinement_level=1) boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( :all => boundary_condition ) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -94,31 +94,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorLöhner(semi, - variable = density_pressure) + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 1, - med_level = 3, med_threshold = 0.05, - max_level = 5, max_threshold = 0.1) + base_level=1, + med_level =3, med_threshold=0.05, + max_level =5, max_threshold=0.1) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) cfl = 0.5 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -131,7 +131,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl index c7922fd3b75..b185a8ce39d 100644 --- a/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/p4est_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,17 +5,17 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test # MMS EOC test + ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the P4estMesh and setup a periodic mesh @@ -25,13 +25,14 @@ coordinates_max = (sqrt(2.0), sqrt(2.0)) # maximum coordinates (max(x), max(y)) # Create P4estMesh with 8 x 8 trees and 16 x 16 elements trees_per_dimension = (8, 8) -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 1) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=1) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -43,13 +44,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -57,6 +58,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_advection_amr.jl b/examples/p4est_3d_dgsem/elixir_advection_amr.jl index d56ecc233ff..0473fd2b23a 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_amr.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_amr.jl @@ -11,21 +11,23 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0, -5.0) -coordinates_max = (5.0, 5.0, 5.0) +coordinates_max = ( 5.0, 5.0, 5.0) trees_per_dimension = (1, 1, 1) # Note that it is not necessary to use mesh polydeg lower than the solver polydeg # on a Cartesian mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -mesh = P4estMesh(trees_per_dimension, polydeg = 1, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 4) +mesh = P4estMesh(trees_per_dimension, polydeg=1, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=4) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -35,26 +37,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +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 = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -66,7 +68,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl b/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl index cd280cf5bf6..fb87c361c18 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_amr_unstructured_curved.jl @@ -12,55 +12,54 @@ equations = LinearScalarAdvectionEquation3D(advection_velocity) # Solver with polydeg=4 to ensure free stream preservation (FSP) on non-conforming meshes. # The polydeg of the solver must be at least twice as big as the polydeg of the mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) initial_condition = initial_condition_gauss boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( + :all => boundary_condition +) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. The original mapping applied to this unstructured mesh # causes some Jacobians to be negative, which makes the mesh invalid. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 1 / 4 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 1 / 4 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 1 / 4 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - # Transform the weird deformed cube to be approximately the size of [-5,5]^3 to match IC - return SVector(5 * x, 5 * y, 5 * z) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + 1/4 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 1/4 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 1/4 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + # Transform the weird deformed cube to be approximately the size of [-5,5]^3 to match IC + return SVector(5 * x, 5 * y, 5 * z) end # Unstructured mesh with 48 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", + mesh_file) # Mesh polydeg of 2 (half the solver polydeg) to ensure FSP (see above). -mesh = P4estMesh{3}(mesh_file, polydeg = 2, - mapping = mapping, - initial_refinement_level = 1) +mesh = P4estMesh{3}(mesh_file, polydeg=2, + mapping=mapping, + initial_refinement_level=1) + + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -71,29 +70,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +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 = 1, - med_level = 2, med_threshold = 0.1, - max_level = 3, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=1, + med_level=2, med_threshold=0.1, + max_level=3, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -106,7 +105,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_advection_basic.jl b/examples/p4est_3d_dgsem/elixir_advection_basic.jl index 02ffa5c7aff..a165d1ff132 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_basic.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_basic.jl @@ -11,20 +11,19 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create P4estMesh with 8 x 8 x 8 elements (note `refinement_level=1`) trees_per_dimension = (4, 4, 4) -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 1) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=1) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) ############################################################################### # ODE solvers, callbacks etc. @@ -38,30 +37,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - solution_variables = cons2prim) +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.2) +stepsize_callback = StepsizeCallback(cfl=1.2) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution, - stepsize_callback) +callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl b/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl index cd641ca4af7..07a8b36bb4c 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_cubed_sphere.jl @@ -9,20 +9,21 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:inside => boundary_condition, - :outside => boundary_condition) +boundary_conditions = Dict( + :inside => boundary_condition, + :outside => boundary_condition, +) mesh = Trixi.P4estMeshCubedSphere(5, 3, 0.5, 0.5, - polydeg = 3, initial_refinement_level = 0) + polydeg=3, initial_refinement_level=0) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -36,26 +37,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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.2) +stepsize_callback = StepsizeCallback(cfl=1.2) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl index 34b0e95834d..93ff17c7842 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_nonconforming.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the linear advection equation @@ -9,42 +10,39 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) trees_per_dimension = (1, 1, 1) # Note that it is not necessary to use mesh polydeg lower than the solver polydeg # on a Cartesian mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -mesh = P4estMesh(trees_per_dimension, polydeg = 3, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - initial_refinement_level = 2) +mesh = P4estMesh(trees_per_dimension, polydeg=3, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + initial_refinement_level=2) # Refine bottom left quadrant of each tree to level 3 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && - quadrant_obj.level < 3 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 3 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 3 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -58,26 +56,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_advection_restart.jl b/examples/p4est_3d_dgsem/elixir_advection_restart.jl index 95aa1dd983f..71b37e9f39b 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_restart.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_restart.jl @@ -6,7 +6,8 @@ using Trixi # create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), - trees_per_dimension = (2, 2, 2)) + trees_per_dimension=(2, 2, 2)) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -17,16 +18,16 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), restart_filename = joinpath("out", "restart_000010.h5") mesh = load_mesh(restart_filename) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl b/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl index 6df9ac0b16a..85fd0b9a2cf 100644 --- a/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl +++ b/examples/p4est_3d_dgsem/elixir_advection_unstructured_curved.jl @@ -10,54 +10,51 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( + :all => boundary_condition +) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. The original mapping applied to this unstructured mesh # causes some Jacobians to be negative, which makes the mesh invalid. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end # Unstructured mesh with 68 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_1.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", + mesh_file) -mesh = P4estMesh{3}(mesh_file, polydeg = 3, - mapping = mapping, - initial_refinement_level = 2) +mesh = P4estMesh{3}(mesh_file, polydeg=3, + mapping=mapping, + initial_refinement_level=2) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -71,32 +68,32 @@ 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) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - solution_variables = cons2prim) +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.2) +stepsize_callback = StepsizeCallback(cfl=1.2) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, - save_solution, stepsize_callback) +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl b/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl index 0274a89aec7..27c8ceb130c 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_baroclinic_instability.jl @@ -22,194 +22,190 @@ equations = CompressibleEulerEquations3D(gamma) # Initial condition for an idealized baroclinic instability test # https://doi.org/10.1002/qj.2241, Section 3.2 and Appendix A -function initial_condition_baroclinic_instability(x, t, - equations::CompressibleEulerEquations3D) - lon, lat, r = cartesian_to_sphere(x) - radius_earth = 6.371229e6 - # Make sure that the r is not smaller than radius_earth - z = max(r - radius_earth, 0.0) +function initial_condition_baroclinic_instability(x, t, equations::CompressibleEulerEquations3D) + lon, lat, r = cartesian_to_sphere(x) + radius_earth = 6.371229e6 + # Make sure that the r is not smaller than radius_earth + z = max(r - radius_earth, 0.0) - # Unperturbed basic state - rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) + # Unperturbed basic state + rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) - # Stream function type perturbation - u_perturbation, v_perturbation = perturbation_stream_function(lon, lat, z) + # Stream function type perturbation + u_perturbation, v_perturbation = perturbation_stream_function(lon, lat, z) - u += u_perturbation - v = v_perturbation + u += u_perturbation + v = v_perturbation - # Convert spherical velocity to Cartesian - v1 = -sin(lon) * u - sin(lat) * cos(lon) * v - v2 = cos(lon) * u - sin(lat) * sin(lon) * v - v3 = cos(lat) * v + # Convert spherical velocity to Cartesian + v1 = -sin(lon) * u - sin(lat) * cos(lon) * v + v2 = cos(lon) * u - sin(lat) * sin(lon) * v + v3 = cos(lat) * v - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end # Steady state for RHS correction below function steady_state_baroclinic_instability(x, t, equations::CompressibleEulerEquations3D) - lon, lat, r = cartesian_to_sphere(x) - radius_earth = 6.371229e6 - # Make sure that the r is not smaller than radius_earth - z = max(r - radius_earth, 0.0) + lon, lat, r = cartesian_to_sphere(x) + radius_earth = 6.371229e6 + # Make sure that the r is not smaller than radius_earth + z = max(r - radius_earth, 0.0) - # Unperturbed basic state - rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) + # Unperturbed basic state + rho, u, p = basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) - # Convert spherical velocity to Cartesian - v1 = -sin(lon) * u - v2 = cos(lon) * u - v3 = 0.0 + # Convert spherical velocity to Cartesian + v1 = -sin(lon) * u + v2 = cos(lon) * u + v3 = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end function cartesian_to_sphere(x) - r = norm(x) - lambda = atan(x[2], x[1]) - if lambda < 0 - lambda += 2 * pi - end - phi = asin(x[3] / r) - - return lambda, phi, r + r = norm(x) + lambda = atan(x[2], x[1]) + if lambda < 0 + lambda += 2 * pi + end + phi = asin(x[3] / r) + + return lambda, phi, r end # Unperturbed balanced steady-state. # Returns primitive variables with only the velocity in longitudinal direction (rho, u, p). # The other velocity components are zero. function basic_state_baroclinic_instability_longitudinal_velocity(lon, lat, z) - # Parameters from Table 1 in the paper - # Corresponding names in the paper are commented - radius_earth = 6.371229e6 # a - half_width_parameter = 2 # b - gravitational_acceleration = 9.80616 # g - k = 3 # k - surface_pressure = 1e5 # p₀ - gas_constant = 287 # R - surface_equatorial_temperature = 310.0 # T₀ᴱ - surface_polar_temperature = 240.0 # T₀ᴾ - lapse_rate = 0.005 # Γ - angular_velocity = 7.29212e-5 # Ω - - # Distance to the center of the Earth - r = z + radius_earth - - # In the paper: T₀ - temperature0 = 0.5 * (surface_equatorial_temperature + surface_polar_temperature) - # In the paper: A, B, C, H - const_a = 1 / lapse_rate - const_b = (temperature0 - surface_polar_temperature) / - (temperature0 * surface_polar_temperature) - const_c = 0.5 * (k + 2) * (surface_equatorial_temperature - surface_polar_temperature) / - (surface_equatorial_temperature * surface_polar_temperature) - const_h = gas_constant * temperature0 / gravitational_acceleration - - # In the paper: (r - a) / bH - scaled_z = z / (half_width_parameter * const_h) - - # Temporary variables - temp1 = exp(lapse_rate / temperature0 * z) - temp2 = exp(-scaled_z^2) - - # In the paper: ̃τ₁, ̃τ₂ - tau1 = const_a * lapse_rate / temperature0 * temp1 + - const_b * (1 - 2 * scaled_z^2) * temp2 - tau2 = const_c * (1 - 2 * scaled_z^2) * temp2 - - # In the paper: ∫τ₁(r') dr', ∫τ₂(r') dr' - inttau1 = const_a * (temp1 - 1) + const_b * z * temp2 - inttau2 = const_c * z * temp2 - - # Temporary variables - temp3 = r / radius_earth * cos(lat) - temp4 = temp3^k - k / (k + 2) * temp3^(k + 2) - - # In the paper: T - temperature = 1 / ((r / radius_earth)^2 * (tau1 - tau2 * temp4)) - - # In the paper: U, u (zonal wind, first component of spherical velocity) - big_u = gravitational_acceleration / radius_earth * k * temperature * inttau2 * - (temp3^(k - 1) - temp3^(k + 1)) - temp5 = radius_earth * cos(lat) - u = -angular_velocity * temp5 + sqrt(angular_velocity^2 * temp5^2 + temp5 * big_u) - - # Hydrostatic pressure - p = surface_pressure * - exp(-gravitational_acceleration / gas_constant * (inttau1 - inttau2 * temp4)) - - # Density (via ideal gas law) - rho = p / (gas_constant * temperature) - - return rho, u, p + # Parameters from Table 1 in the paper + # Corresponding names in the paper are commented + radius_earth = 6.371229e6 # a + half_width_parameter = 2 # b + gravitational_acceleration = 9.80616 # g + k = 3 # k + surface_pressure = 1e5 # p₀ + gas_constant = 287 # R + surface_equatorial_temperature = 310.0 # T₀ᴱ + surface_polar_temperature = 240.0 # T₀ᴾ + lapse_rate = 0.005 # Γ + angular_velocity = 7.29212e-5 # Ω + + # Distance to the center of the Earth + r = z + radius_earth + + # In the paper: T₀ + temperature0 = 0.5 * (surface_equatorial_temperature + surface_polar_temperature) + # In the paper: A, B, C, H + const_a = 1 / lapse_rate + const_b = (temperature0 - surface_polar_temperature) / + (temperature0 * surface_polar_temperature) + const_c = 0.5 * (k + 2) * (surface_equatorial_temperature - surface_polar_temperature) / + (surface_equatorial_temperature * surface_polar_temperature) + const_h = gas_constant * temperature0 / gravitational_acceleration + + # In the paper: (r - a) / bH + scaled_z = z / (half_width_parameter * const_h) + + # Temporary variables + temp1 = exp(lapse_rate/temperature0 * z) + temp2 = exp(-scaled_z^2) + + # In the paper: ̃τ₁, ̃τ₂ + tau1 = const_a * lapse_rate / temperature0 * temp1 + const_b * (1 - 2 * scaled_z^2) * temp2 + tau2 = const_c * (1 - 2 * scaled_z^2) * temp2 + + # In the paper: ∫τ₁(r') dr', ∫τ₂(r') dr' + inttau1 = const_a * (temp1 - 1) + const_b * z * temp2 + inttau2 = const_c * z * temp2 + + # Temporary variables + temp3 = r/radius_earth * cos(lat) + temp4 = temp3^k - k/(k + 2) * temp3^(k+2) + + # In the paper: T + temperature = 1 / ((r/radius_earth)^2 * (tau1 - tau2 * temp4)) + + # In the paper: U, u (zonal wind, first component of spherical velocity) + big_u = gravitational_acceleration/radius_earth * k * temperature * inttau2 * (temp3^(k-1) - temp3^(k+1)) + temp5 = radius_earth * cos(lat) + u = -angular_velocity * temp5 + sqrt(angular_velocity^2 * temp5^2 + temp5 * big_u) + + # Hydrostatic pressure + p = surface_pressure * exp(-gravitational_acceleration/gas_constant * (inttau1 - inttau2 * temp4)) + + # Density (via ideal gas law) + rho = p / (gas_constant * temperature) + + return rho, u, p end # Perturbation as in Equations 25 and 26 of the paper (analytical derivative) function perturbation_stream_function(lon, lat, z) - # Parameters from Table 1 in the paper - # Corresponding names in the paper are commented - perturbation_radius = 1 / 6 # d₀ / a - perturbed_wind_amplitude = 1.0 # Vₚ - perturbation_lon = pi / 9 # Longitude of perturbation location - perturbation_lat = 2 * pi / 9 # Latitude of perturbation location - pertz = 15000 # Perturbation height cap - - # Great circle distance (d in the paper) divided by a (radius of the Earth) - # because we never actually need d without dividing by a - great_circle_distance_by_a = acos(sin(perturbation_lat) * sin(lat) + - cos(perturbation_lat) * cos(lat) * - cos(lon - perturbation_lon)) - - # In the first case, the vertical taper function is per definition zero. - # In the second case, the stream function is per definition zero. - if z > pertz || great_circle_distance_by_a > perturbation_radius - return 0.0, 0.0 - end - - # Vertical tapering of stream function - perttaper = 1.0 - 3 * z^2 / pertz^2 + 2 * z^3 / pertz^3 - - # sin/cos(pi * d / (2 * d_0)) in the paper - sin_, cos_ = sincos(0.5 * pi * great_circle_distance_by_a / perturbation_radius) - - # Common factor for both u and v - factor = 16 / (3 * sqrt(3)) * perturbed_wind_amplitude * perttaper * cos_^3 * sin_ - - u_perturbation = -factor * (-sin(perturbation_lat) * cos(lat) + - cos(perturbation_lat) * sin(lat) * cos(lon - perturbation_lon)) / - sin(great_circle_distance_by_a) - - v_perturbation = factor * cos(perturbation_lat) * sin(lon - perturbation_lon) / - sin(great_circle_distance_by_a) - - return u_perturbation, v_perturbation + # Parameters from Table 1 in the paper + # Corresponding names in the paper are commented + perturbation_radius = 1/6 # d₀ / a + perturbed_wind_amplitude = 1.0 # Vₚ + perturbation_lon = pi/9 # Longitude of perturbation location + perturbation_lat = 2 * pi/9 # Latitude of perturbation location + pertz = 15000 # Perturbation height cap + + # Great circle distance (d in the paper) divided by a (radius of the Earth) + # because we never actually need d without dividing by a + great_circle_distance_by_a = acos(sin(perturbation_lat) * sin(lat) + + cos(perturbation_lat) * cos(lat) * + cos(lon - perturbation_lon)) + + # In the first case, the vertical taper function is per definition zero. + # In the second case, the stream function is per definition zero. + if z > pertz || great_circle_distance_by_a > perturbation_radius + return 0.0, 0.0 + end + + # Vertical tapering of stream function + perttaper = 1.0 - 3 * z^2 / pertz^2 + 2 * z^3 / pertz^3 + + # sin/cos(pi * d / (2 * d_0)) in the paper + sin_, cos_ = sincos(0.5 * pi * great_circle_distance_by_a / perturbation_radius) + + # Common factor for both u and v + factor = 16 / (3 * sqrt(3)) * perturbed_wind_amplitude * perttaper * cos_^3 * sin_ + + u_perturbation = -factor * (-sin(perturbation_lat) * cos(lat) + + cos(perturbation_lat) * sin(lat) * cos(lon - perturbation_lon) + ) / sin(great_circle_distance_by_a) + + v_perturbation = factor * cos(perturbation_lat) * sin(lon - perturbation_lon) / + sin(great_circle_distance_by_a) + + return u_perturbation, v_perturbation end -@inline function source_terms_baroclinic_instability(u, x, t, - equations::CompressibleEulerEquations3D) - radius_earth = 6.371229e6 # a - gravitational_acceleration = 9.80616 # g - angular_velocity = 7.29212e-5 # Ω - r = norm(x) - # Make sure that r is not smaller than radius_earth - z = max(r - radius_earth, 0.0) - r = z + radius_earth +@inline function source_terms_baroclinic_instability(u, x, t, equations::CompressibleEulerEquations3D) + radius_earth = 6.371229e6 # a + gravitational_acceleration = 9.80616 # g + angular_velocity = 7.29212e-5 # Ω - du1 = zero(eltype(u)) + r = norm(x) + # Make sure that r is not smaller than radius_earth + z = max(r - radius_earth, 0.0) + r = z + radius_earth - # Gravity term - temp = -gravitational_acceleration * radius_earth^2 / r^3 - du2 = temp * u[1] * x[1] - du3 = temp * u[1] * x[2] - du4 = temp * u[1] * x[3] - du5 = temp * (u[2] * x[1] + u[3] * x[2] + u[4] * x[3]) + du1 = zero(eltype(u)) - # Coriolis term, -2Ω × ρv = -2 * angular_velocity * (0, 0, 1) × u[2:4] - du2 -= -2 * angular_velocity * u[3] - du3 -= 2 * angular_velocity * u[2] + # Gravity term + temp = -gravitational_acceleration * radius_earth^2 / r^3 + du2 = temp * u[1] * x[1] + du3 = temp * u[1] * x[2] + du4 = temp * u[1] * x[3] + du5 = temp * (u[2] * x[1] + u[3] * x[2] + u[4] * x[3]) - return SVector(du1, du2, du3, du4, du5) + # Coriolis term, -2Ω × ρv = -2 * angular_velocity * (0, 0, 1) × u[2:4] + du2 -= -2 * angular_velocity * u[3] + du3 -= 2 * angular_velocity * u[2] + + return SVector(du1, du2, du3, du4, du5) end ############################################################################### @@ -217,24 +213,26 @@ end initial_condition = initial_condition_baroclinic_instability -boundary_conditions = Dict(:inside => boundary_condition_slip_wall, - :outside => boundary_condition_slip_wall) +boundary_conditions = Dict( + :inside => boundary_condition_slip_wall, + :outside => boundary_condition_slip_wall, +) # This is a good estimate for the speed of sound in this example. # Other values between 300 and 400 should work as well. surface_flux = FluxLMARS(340) -volume_flux = flux_kennedy_gruber -solver = DGSEM(polydeg = 5, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +volume_flux = flux_kennedy_gruber +solver = DGSEM(polydeg=5, surface_flux=surface_flux, volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # For optimal results, use (16, 8) here trees_per_cube_face = (8, 4) mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0, - polydeg = 5, initial_refinement_level = 0) + polydeg=5, initial_refinement_level=0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_baroclinic_instability, - boundary_conditions = boundary_conditions) + source_terms=source_terms_baroclinic_instability, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -252,20 +250,20 @@ tspan = (0.0, 10 * 24 * 60 * 60.0) # time in seconds for 10 days u_steady_state = compute_coefficients(steady_state_baroclinic_instability, tspan[1], semi) # Use a `let` block for performance (otherwise du_steady_state will be a global variable) let du_steady_state = similar(u_steady_state) - # Save RHS of the steady state - Trixi.rhs!(du_steady_state, u_steady_state, semi, tspan[1]) - - global function corrected_rhs!(du, u, semi, t) - # Normal RHS evaluation - Trixi.rhs!(du, u, semi, t) - # Correct by subtracting the steady-state RHS - Trixi.@trixi_timeit Trixi.timer() "rhs correction" begin - # Use Trixi.@threaded for threaded performance - Trixi.@threaded for i in eachindex(du) - du[i] -= du_steady_state[i] - end - end + # Save RHS of the steady state + Trixi.rhs!(du_steady_state, u_steady_state, semi, tspan[1]) + + global function corrected_rhs!(du, u, semi, t) + # Normal RHS evaluation + Trixi.rhs!(du, u, semi, t) + # Correct by subtracting the steady-state RHS + Trixi.@trixi_timeit Trixi.timer() "rhs correction" begin + # Use Trixi.@threaded for threaded performance + Trixi.@threaded for i in eachindex(du) + du[i] -= du_steady_state[i] + end end + end end u0 = compute_coefficients(tspan[1], semi) ode = ODEProblem(corrected_rhs!, u0, tspan, semi) @@ -273,27 +271,27 @@ ode = ODEProblem(corrected_rhs!, u0, tspan, semi) summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 5000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=5000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + ############################################################################### # run the simulation # Use a Runge-Kutta method with automatic (error based) time step size control # Enable threading of the RK method for better performance on multiple threads -sol = solve(ode, RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()); abstol = 1.0e-6, - reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(thread=OrdinaryDiffEq.True()); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl index 34a43a5b534..63e937620f0 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_circular_wind_nonconforming.jl @@ -14,77 +14,78 @@ using LinearAlgebra gamma = 1.4 equations = CompressibleEulerEquations3D(gamma) + function initial_condition_circular_wind(x, t, equations::CompressibleEulerEquations3D) - radius_earth = 6.371229e6 - p = 1e5 - rho = 1.0 - v1 = -10 * x[2] / radius_earth - v2 = 10 * x[1] / radius_earth - v3 = 0.0 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + radius_earth = 6.371229e6 + p = 1e5 + rho = 1.0 + v1 = -10 * x[2] / radius_earth + v2 = 10 * x[1] / radius_earth + v3 = 0.0 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end -@inline function source_terms_circular_wind(u, x, t, - equations::CompressibleEulerEquations3D) - radius_earth = 6.371229e6 - rho = 1.0 +@inline function source_terms_circular_wind(u, x, t, equations::CompressibleEulerEquations3D) + radius_earth = 6.371229e6 + rho = 1.0 - du1 = 0.0 - du2 = -rho * (10 / radius_earth) * (10 * x[1] / radius_earth) - du3 = -rho * (10 / radius_earth) * (10 * x[2] / radius_earth) - du4 = 0.0 - du5 = 0.0 + du1 = 0.0 + du2 = -rho * (10 / radius_earth) * (10 * x[1] / radius_earth) + du3 = -rho * (10 / radius_earth) * (10 * x[2] / radius_earth) + du4 = 0.0 + du5 = 0.0 - return SVector(du1, du2, du3, du4, du5) + return SVector(du1, du2, du3, du4, du5) end -function indicator_test(u::AbstractArray{<:Any, 5}, + +function indicator_test(u::AbstractArray{<:Any,5}, mesh, equations, dg::DGSEM, cache; kwargs...) - alpha = zeros(Int, nelements(dg, cache)) - - for element in eachelement(dg, cache) - for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) - x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, - k, element) - lambda, phi, r = cart_to_sphere(x) - if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 - alpha[element] = 1 - end - end + alpha = zeros(Int, nelements(dg, cache)) + + for element in eachelement(dg, cache) + for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) + x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, k, element) + lambda, phi, r = cart_to_sphere(x) + if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 + alpha[element] = 1 + end end + end - return alpha + return alpha end function cart_to_sphere(x) - r = norm(x) - lambda = atan(x[2], x[1]) - if lambda < 0 - lambda += 2 * pi - end - phi = asin(x[3] / r) - - return lambda, phi, r + r = norm(x) + lambda = atan(x[2], x[1]) + if lambda < 0 + lambda += 2 * pi + end + phi = asin(x[3] / r) + + return lambda, phi, r end -function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), - ::AMRCallback) - return nothing +function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), ::AMRCallback) + return nothing end initial_condition = initial_condition_circular_wind -boundary_conditions = Dict(:inside => boundary_condition_slip_wall, - :outside => boundary_condition_slip_wall) +boundary_conditions = Dict( + :inside => boundary_condition_slip_wall, + :outside => boundary_condition_slip_wall +) # The speed of sound in this example is 374 m/s. surface_flux = FluxLMARS(374) # Note that a free stream is not preserved if N < 2 * N_geo, where N is the # polydeg of the solver and N_geo is the polydeg of the mesh. # However, the FSP error is negligible in this example. -solver = DGSEM(polydeg = 4, surface_flux = surface_flux) +solver = DGSEM(polydeg=4, surface_flux=surface_flux) # Other mesh configurations to run this simulation on. # The cylinder allows to use a structured mesh, the face of the cubed sphere @@ -112,11 +113,12 @@ solver = DGSEM(polydeg = 4, surface_flux = surface_flux) trees_per_cube_face = (6, 2) mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0, - polydeg = 4, initial_refinement_level = 0) + polydeg=4, initial_refinement_level=0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_circular_wind, - boundary_conditions = boundary_conditions) + source_terms=source_terms_circular_wind, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -127,22 +129,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 5000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=5000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_controller = ControllerThreeLevel(semi, indicator_test, - base_level = 0, - max_level = 1, max_threshold = 0.6) + base_level=0, + max_level=1, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 0, # Only initial refinement - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=0, # Only initial refinement + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -150,13 +152,13 @@ callbacks = CallbackSet(summary_callback, save_solution, amr_callback) + ############################################################################### # run the simulation # Use a Runge-Kutta method with automatic (error based) time step size control # Enable threading of the RK method for better performance on multiple threads -sol = solve(ode, RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()); abstol = 1.0e-6, - reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(thread=OrdinaryDiffEq.True()); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_euler_ec.jl b/examples/p4est_3d_dgsem/elixir_euler_ec.jl index d9d774a7ffc..463a26fca53 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_ec.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_ec.jl @@ -6,59 +6,56 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerEquations3D(5 / 3) +equations = CompressibleEulerEquations3D(5/3) initial_condition = initial_condition_weak_blast_wave -boundary_conditions = Dict(:all => boundary_condition_slip_wall) +boundary_conditions = Dict( + :all => boundary_condition_slip_wall +) # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg = 5, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=5, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the curved quad mesh from a file # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end # Unstructured mesh with 48 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{3}(mesh_file, polydeg = 5, - mapping = mapping, - initial_refinement_level = 0) +mesh = P4estMesh{3}(mesh_file, polydeg=5, + mapping=mapping, + initial_refinement_level=0) # create the semidiscretization object -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -69,15 +66,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -88,7 +85,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl b/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl index 24a781ca59e..3450adfe861 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_free_stream.jl @@ -10,75 +10,70 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_constant -boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition)) +boundary_conditions = Dict( + :all => BoundaryConditionDirichlet(initial_condition) +) # Solver with polydeg=4 to ensure free stream preservation (FSP) on non-conforming meshes. # The polydeg of the solver must be at least twice as big as the polydeg of the mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. This can yield problematic geometries if the unrefined mesh # is not fine enough. function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end # Unstructured mesh with 68 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_1.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", + mesh_file) # Mesh polydeg of 2 (half the solver polydeg) to ensure FSP (see above). -mesh = P4estMesh{3}(mesh_file, polydeg = 2, - mapping = mapping, - initial_refinement_level = 0) +mesh = P4estMesh{3}(mesh_file, polydeg=2, + mapping=mapping, + initial_refinement_level=0) # Refine bottom left quadrant of each second tree to level 2 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if iseven(convert(Int, which_tree)) && quadrant_obj.x == 0 && quadrant_obj.y == 0 && - quadrant_obj.z == 0 && quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if iseven(convert(Int, which_tree)) && quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of every second tree has level 2. # The mesh will be rebalanced before the simulation starts. -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -89,26 +84,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl b/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl index f56fe3a429d..630a269b4a1 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_free_stream_extruded.jl @@ -10,10 +10,12 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_constant -boundary_conditions = Dict(:all => BoundaryConditionDirichlet(initial_condition)) +boundary_conditions = Dict( + :all => BoundaryConditionDirichlet(initial_condition) +) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but reduced to 2D. # This particular mesh is unstructured in the yz-plane, but extruded in x-direction. @@ -21,52 +23,47 @@ solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, # in x-direction to ensure free stream preservation on a non-conforming mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. function mapping(xi, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 - z = zeta + - 1 / 6 * (cos(1.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) + z = zeta + 1/6 * (cos(1.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) - y = eta + 1 / 6 * (cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(2 * pi * (2 * z - 3) / 3)) + y = eta + 1/6 * (cos(0.5 * pi * (2 * eta - 3)/3) * + cos(2 * pi * (2 * z - 3)/3)) - return SVector(xi, y, z) + return SVector(xi, y, z) end # Unstructured mesh with 48 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_2.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/b8df0033798e4926dec515fc045e8c2c/raw/b9254cde1d1fb64b6acc8416bc5ccdd77a240227/cube_unstructured_2.inp", + mesh_file) -mesh = P4estMesh{3}(mesh_file, polydeg = 3, - mapping = mapping, - initial_refinement_level = 0) +mesh = P4estMesh{3}(mesh_file, polydeg=3, + mapping=mapping, + initial_refinement_level=0) # Refine quadrants in y-direction of each tree at one edge to level 2 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if convert(Int, which_tree) < 4 && quadrant_obj.x == 0 && quadrant_obj.y == 0 && - quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if convert(Int, which_tree) < 4 && quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each desired quadrant has level 2. # The mesh will be rebalanced before the simulation starts. -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -77,29 +74,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, stepsize_callback) + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), #maxiters=1, - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), #maxiters=1, + 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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_sedov.jl b/examples/p4est_3d_dgsem/elixir_euler_sedov.jl index fe0ee77818e..00da4132851 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_sedov.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_sedov.jl @@ -14,29 +14,28 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 with smaller strength of the initial discontinuity. """ -function initial_condition_medium_sedov_blast_wave(x, t, - equations::CompressibleEulerEquations3D) - # Set up polar coordinates - inicenter = SVector(0.0, 0.0, 0.0) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - z_norm = x[3] - inicenter[3] - r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) - p0_outer = 1.0e-3 - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_medium_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D) + # Set up polar coordinates + inicenter = SVector(0.0, 0.0, 0.0) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + z_norm = x[3] - inicenter[3] + r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) + p0_outer = 1.0e-3 + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_medium_sedov_blast_wave @@ -46,25 +45,24 @@ volume_flux = flux_ranocha polydeg = 5 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=1.0, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = (1.0, 1.0, 1.0) +coordinates_max = ( 1.0, 1.0, 1.0) trees_per_dimension = (4, 4, 4) mesh = P4estMesh(trees_per_dimension, - polydeg = 4, initial_refinement_level = 0, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = true) + polydeg=4, initial_refinement_level=0, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -78,15 +76,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -97,7 +95,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl index 28cdec12da5..fc5c7da5234 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl @@ -11,68 +11,68 @@ using LinearAlgebra gamma = 1.4 equations = CompressibleEulerEquations3D(gamma) -function initial_condition_convergence_test_sphere(x, t, - equations::CompressibleEulerEquations3D) - x_scaled = x / 6.371229e6 - t_scaled = t / 6.371229e6 - return initial_condition_convergence_test(x_scaled, t_scaled, equations) +function initial_condition_convergence_test_sphere(x, t, equations::CompressibleEulerEquations3D) + x_scaled = x / 6.371229e6 + t_scaled = t / 6.371229e6 + + return initial_condition_convergence_test(x_scaled, t_scaled, equations) end -@inline function source_terms_convergence_test_sphere(u, x, t, - equations::CompressibleEulerEquations3D) - x_scaled = x / 6.371229e6 - t_scaled = t / 6.371229e6 +@inline function source_terms_convergence_test_sphere(u, x, t, equations::CompressibleEulerEquations3D) + x_scaled = x / 6.371229e6 + t_scaled = t / 6.371229e6 - return source_terms_convergence_test(u, x_scaled, t_scaled, equations) / 6.371229e6 + return source_terms_convergence_test(u, x_scaled, t_scaled, equations) / 6.371229e6 end -function indicator_test(u::AbstractArray{<:Any, 5}, + +function indicator_test(u::AbstractArray{<:Any,5}, mesh, equations, dg::DGSEM, cache; kwargs...) - alpha = zeros(Int, nelements(dg, cache)) - - for element in eachelement(dg, cache) - for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) - x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, - k, element) - lambda, phi, r = cart_to_sphere(x) - if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 - alpha[element] = 1 - end - end + alpha = zeros(Int, nelements(dg, cache)) + + for element in eachelement(dg, cache) + for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg) + x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, i, j, k, element) + lambda, phi, r = cart_to_sphere(x) + if 0.22 < lambda < 3.3 && 0.45 < phi < 1.3 + alpha[element] = 1 + end end + end - return alpha + return alpha end function cart_to_sphere(x) - r = norm(x) - lambda = atan(x[2], x[1]) - if lambda < 0 - lambda += 2 * pi - end - phi = asin(x[3] / r) - - return lambda, phi, r + r = norm(x) + lambda = atan(x[2], x[1]) + if lambda < 0 + lambda += 2 * pi + end + phi = asin(x[3] / r) + + return lambda, phi, r end -function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), - ::AMRCallback) - return nothing +function Trixi.get_element_variables!(element_variables, indicator::typeof(indicator_test), ::AMRCallback) + return nothing end initial_condition = initial_condition_convergence_test_sphere boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:inside => boundary_condition, - :outside => boundary_condition) +boundary_conditions = Dict( + :inside => boundary_condition, + :outside => boundary_condition +) surface_flux = FluxHLL(min_max_speed_naive) # Note that a free stream is not preserved if N < 2 * N_geo, where N is the # polydeg of the solver and N_geo is the polydeg of the mesh. # However, the FSP error is negligible in this example. -solver = DGSEM(polydeg = 4, surface_flux = surface_flux) +solver = DGSEM(polydeg=4, surface_flux=surface_flux) # For performance reasons, only one face of the cubed sphere can be used: @@ -87,11 +87,12 @@ solver = DGSEM(polydeg = 4, surface_flux = surface_flux) trees_per_cube_face = (6, 2) mesh = Trixi.P4estMeshCubedSphere(trees_per_cube_face..., 6.371229e6, 30000.0, - polydeg = 4, initial_refinement_level = 0) + polydeg=4, initial_refinement_level=0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test_sphere, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test_sphere, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -102,22 +103,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_controller = ControllerThreeLevel(semi, indicator_test, - base_level = 0, - max_level = 1, max_threshold = 0.6) + base_level=0, + max_level=1, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 0, # Only initial refinement - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=0, # Only initial refinement + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -125,11 +126,12 @@ callbacks = CallbackSet(summary_callback, save_solution, amr_callback) + ############################################################################### # run the simulation # Use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl index 0de22eaea40..dd394091758 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_unstructured_curved.jl @@ -11,77 +11,73 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:all => boundary_condition) +boundary_conditions = Dict( + :all => boundary_condition +) # Solver with polydeg=4 to ensure free stream preservation (FSP) on non-conforming meshes. # The polydeg of the solver must be at least twice as big as the polydeg of the mesh. # See https://doi.org/10.1007/s10915-018-00897-9, Section 6. -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. The original mapping applied to this unstructured mesh # causes some Jacobians to be negative, which makes the mesh invalid. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - # Transform the weird deformed cube to be approximately the cube [0,2]^3 - return SVector(x + 1, y + 1, z + 1) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + # Transform the weird deformed cube to be approximately the cube [0,2]^3 + return SVector(x + 1, y + 1, z + 1) end # Unstructured mesh with 68 cells of the cube domain [-1, 1]^3 mesh_file = joinpath(@__DIR__, "cube_unstructured_1.inp") -isfile(mesh_file) || - download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", - mesh_file) +isfile(mesh_file) || download("https://gist.githubusercontent.com/efaulhaber/d45c8ac1e248618885fa7cc31a50ab40/raw/37fba24890ab37cfa49c39eae98b44faf4502882/cube_unstructured_1.inp", + mesh_file) # Mesh polydeg of 2 (half the solver polydeg) to ensure FSP (see above). -mesh = P4estMesh{3}(mesh_file, polydeg = 2, - mapping = mapping, - initial_refinement_level = 0) +mesh = P4estMesh{3}(mesh_file, polydeg=2, + mapping=mapping, + initial_refinement_level=0) # Refine bottom left quadrant of each tree to level 2 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && - quadrant_obj.level < 2 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 2 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 2 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -92,26 +88,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl index fc5e4da3ceb..cd796c33e47 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -10,28 +10,31 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:x_neg => boundary_condition, - :x_pos => boundary_condition, - :y_neg => boundary_condition, - :y_pos => boundary_condition, - :z_neg => boundary_condition, - :z_pos => boundary_condition) - -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +boundary_conditions = Dict( + :x_neg => boundary_condition, + :x_pos => boundary_condition, + :y_neg => boundary_condition, + :y_pos => boundary_condition, + :z_neg => boundary_condition, + :z_pos => boundary_condition +) + +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) trees_per_dimension = (2, 2, 2) -mesh = P4estMesh(trees_per_dimension, polydeg = 1, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = false, initial_refinement_level = 1) +mesh = P4estMesh(trees_per_dimension, polydeg=1, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=false, initial_refinement_level=1) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -42,26 +45,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) 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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl index 0fa3a28fe8b..ff101bea8aa 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonperiodic_hohqmesh.jl @@ -11,25 +11,25 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:Bottom => boundary_condition, - :Top => boundary_condition, - :Circle => boundary_condition, - :Cut => boundary_condition) +boundary_conditions = Dict( :Bottom => boundary_condition, + :Top => boundary_condition, + :Circle => boundary_condition, + :Cut => boundary_condition ) -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) # Unstructured 3D half circle mesh from HOHQMesh default_mesh_file = joinpath(@__DIR__, "abaqus_half_circle_3d.inp") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/11461efbfb02c42e06aca338b3d0b645/raw/81deeb1ebc4945952c30af5bb75fe222a18d975c/abaqus_half_circle_3d.inp", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/11461efbfb02c42e06aca338b3d0b645/raw/81deeb1ebc4945952c30af5bb75fe222a18d975c/abaqus_half_circle_3d.inp", + default_mesh_file) mesh_file = default_mesh_file -mesh = P4estMesh{3}(mesh_file, initial_refinement_level = 0) +mesh = P4estMesh{3}(mesh_file, initial_refinement_level=0) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -40,17 +40,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 50, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=50, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -58,11 +58,12 @@ callbacks = CallbackSet(summary_callback, save_solution, stepsize_callback); + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 1, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=1, # 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 diff --git a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl index 9cacfc2e8ac..988e9e09ea3 100644 --- a/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl +++ b/examples/p4est_3d_dgsem/elixir_mhd_alfven_wave_nonconforming.jl @@ -5,45 +5,40 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5 / 3) +equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = (1.0, 1.0, 1.0) +coordinates_max = ( 1.0, 1.0, 1.0) # Create P4estMesh with 2 x 2 x 2 trees trees_per_dimension = (2, 2, 2) mesh = P4estMesh(trees_per_dimension, - polydeg = 3, initial_refinement_level = 2, - coordinates_min = coordinates_min, coordinates_max = coordinates_max, - periodicity = true) + polydeg=3, initial_refinement_level=2, + coordinates_min=coordinates_min, coordinates_max=coordinates_max, + periodicity=true) # OBS! Workaround to add a refinement patch after mesh is constructed # Refine bottom left quadrant of each tree to level 4 function refine_fn(p8est, which_tree, quadrant) - quadrant_obj = unsafe_load(quadrant) - if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && - quadrant_obj.level < 4 - # return true (refine) - return Cint(1) - else - # return false (don't refine) - return Cint(0) - end + quadrant_obj = unsafe_load(quadrant) + if quadrant_obj.x == 0 && quadrant_obj.y == 0 && quadrant_obj.z == 0 && quadrant_obj.level < 4 + # return true (refine) + return Cint(1) + else + # return false (don't refine) + return Cint(0) + end end # Refine recursively until each bottom left quadrant of a tree has level 4 # The mesh will be rebalanced before the simulation starts -refine_fn_c = @cfunction(refine_fn, Cint, - (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p8est_quadrant_t})) +refine_fn_c = @cfunction(refine_fn, Cint, (Ptr{Trixi.p8est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p8est_quadrant_t})) Trixi.refine_p4est!(mesh.p4est, true, refine_fn_c, C_NULL) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -57,18 +52,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -76,10 +71,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl b/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl index 3941a40b2e4..fc95d427abb 100644 --- a/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl +++ b/examples/p4est_3d_dgsem/elixir_mhd_shockcapturing_amr.jl @@ -17,74 +17,71 @@ Weak magnetic blast wave setup taken from Section 6.1 of the paper: [doi: 10.1016/j.jcp.2021.110580](https://doi.org/10.1016/j.jcp.2021.110580) """ function initial_condition_blast_wave(x, t, equations::IdealGlmMhdEquations3D) - # Center of the blast wave is selected for the domain [0, 3]^3 - inicenter = (1.5, 1.5, 1.5) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - z_norm = x[3] - inicenter[3] - r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) - - delta_0 = 0.1 - r_0 = 0.3 - lambda = exp(5.0 / delta_0 * (r - r_0)) - - prim_inner = SVector(1.2, 0.1, 0.0, 0.1, 0.9, 1.0, 1.0, 1.0, 0.0) - prim_outer = SVector(1.2, 0.2, -0.4, 0.2, 0.3, 1.0, 1.0, 1.0, 0.0) - prim_vars = (prim_inner + lambda * prim_outer) / (1.0 + lambda) - - return prim2cons(prim_vars, equations) + # Center of the blast wave is selected for the domain [0, 3]^3 + inicenter = (1.5, 1.5, 1.5) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + z_norm = x[3] - inicenter[3] + r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) + + delta_0 = 0.1 + r_0 = 0.3 + lambda = exp(5.0 / delta_0 * (r - r_0)) + + prim_inner = SVector(1.2, 0.1, 0.0, 0.1, 0.9, 1.0, 1.0, 1.0, 0.0) + prim_outer = SVector(1.2, 0.2, -0.4, 0.2, 0.3, 1.0, 1.0, 1.0, 0.0) + prim_vars = (prim_inner + lambda * prim_outer) / (1.0 + lambda) + + return prim2cons(prim_vars, equations) end initial_condition = initial_condition_blast_wave surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) + +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) # Mapping as described in https://arxiv.org/abs/2012.12040 but with slightly less warping. # The mapping will be interpolated at tree level, and then refined without changing # the geometry interpolant. function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 11 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 11 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 11 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/11 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/11 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/11 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end trees_per_dimension = (2, 2, 2) mesh = P4estMesh(trees_per_dimension, - polydeg = 3, - mapping = mapping, - initial_refinement_level = 2, - periodicity = true) + polydeg=3, + mapping=mapping, + initial_refinement_level=2, + periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -98,24 +95,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) amr_indicator = IndicatorLöhner(semi, - variable = density_pressure) + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 2, - max_level = 4, max_threshold = 0.15) + base_level=2, + max_level =4, max_threshold=0.15) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -124,10 +121,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl index 4f44d7b12ac..f76ca4f2cdf 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl @@ -8,16 +8,18 @@ equations = CompressibleEulerEquations2D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg = 3, surface_flux = FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_eoc_test_euler) + source_terms=source_terms_eoc_test_euler) + ############################################################################### # ODE solvers, callbacks etc. @@ -27,25 +29,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval = analysis_interval) -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) callbacks = CallbackSet(summary_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl index 49b98803577..8277577f5b9 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl @@ -2,8 +2,10 @@ using OrdinaryDiffEq using Trixi + initial_condition = initial_condition_eoc_test_coupled_euler_gravity + ############################################################################### # semidiscretization of the compressible Euler equations gamma = 2.0 @@ -15,12 +17,12 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, + source_terms=source_terms_eoc_test_coupled_euler_gravity) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, - solver_euler, - source_terms = source_terms_eoc_test_coupled_euler_gravity) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -28,23 +30,24 @@ equations_gravity = HyperbolicDiffusionEquations2D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, - solver_gravity, - source_terms = source_terms_harmonic) +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, + source_terms=source_terms_harmonic) + ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 +parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 # rho0 is (ab)used to add a "+8π" term to the source terms # for the manufactured solution - gravitational_constant = 1.0, # aka G - cfl = 1.1, - resid_tol = 1.0e-10, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_erk52_3Sstar!) + gravitational_constant=1.0, # aka G + cfl=1.1, + resid_tol=1.0e-10, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -52,27 +55,28 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, - save_analysis = true) +analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, + save_analysis=true) callbacks = CallbackSet(summary_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl index 2f2cefe198c..a23915745df 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + """ initial_condition_jeans_instability(x, t, equations::Union{CompressibleEulerEquations2D, @@ -18,51 +19,52 @@ The classical Jeans instability taken from in CGS (centimeter, gram, second) units. """ function initial_condition_jeans_instability(x, t, - equations::CompressibleEulerEquations2D) - # Jeans gravitational instability test case - # see Derigs et al. https://arxiv.org/abs/1605.03572; Sec. 4.6 - # OBS! this uses cgs (centimeter, gram, second) units - # periodic boundaries - # domain size [0,L]^2 depends on the wave number chosen for the perturbation - # OBS! Be very careful here L must be chosen such that problem is periodic - # typical final time is T = 5 - # gamma = 5/3 - dens0 = 1.5e7 # g/cm^3 - pres0 = 1.5e7 # dyn/cm^2 - delta0 = 1e-3 - # set wave vector values for perturbation (units 1/cm) - # see FLASH manual: https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf - kx = 2.0 * pi / 0.5 # 2π/λ_x, λ_x = 0.5 - ky = 0.0 # 2π/λ_y, λ_y = 1e10 - k_dot_x = kx * x[1] + ky * x[2] - # perturb density and pressure away from reference states ρ_0 and p_0 - dens = dens0 * (1.0 + delta0 * cos(k_dot_x)) # g/cm^3 - pres = pres0 * (1.0 + equations.gamma * delta0 * cos(k_dot_x)) # dyn/cm^2 - # flow starts as stationary - velx = 0.0 # cm/s - vely = 0.0 # cm/s - return prim2cons((dens, velx, vely, pres), equations) + equations::CompressibleEulerEquations2D) + # Jeans gravitational instability test case + # see Derigs et al. https://arxiv.org/abs/1605.03572; Sec. 4.6 + # OBS! this uses cgs (centimeter, gram, second) units + # periodic boundaries + # domain size [0,L]^2 depends on the wave number chosen for the perturbation + # OBS! Be very careful here L must be chosen such that problem is periodic + # typical final time is T = 5 + # gamma = 5/3 + dens0 = 1.5e7 # g/cm^3 + pres0 = 1.5e7 # dyn/cm^2 + delta0 = 1e-3 + # set wave vector values for perturbation (units 1/cm) + # see FLASH manual: https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf + kx = 2.0*pi/0.5 # 2π/λ_x, λ_x = 0.5 + ky = 0.0 # 2π/λ_y, λ_y = 1e10 + k_dot_x = kx*x[1] + ky*x[2] + # perturb density and pressure away from reference states ρ_0 and p_0 + dens = dens0*(1.0 + delta0*cos(k_dot_x)) # g/cm^3 + pres = pres0*(1.0 + equations.gamma*delta0*cos(k_dot_x)) # dyn/cm^2 + # flow starts as stationary + velx = 0.0 # cm/s + vely = 0.0 # cm/s + return prim2cons((dens, velx, vely, pres), equations) end function initial_condition_jeans_instability(x, t, equations::HyperbolicDiffusionEquations2D) - # gravity equation: -Δϕ = -4πGρ - # Constants taken from the FLASH manual - # https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf - rho0 = 1.5e7 - delta0 = 1e-3 - - phi = rho0 * delta0 # constant background perturbation magnitude - q1 = 0.0 - q2 = 0.0 - return (phi, q1, q2) + # gravity equation: -Δϕ = -4πGρ + # Constants taken from the FLASH manual + # https://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel.pdf + rho0 = 1.5e7 + delta0 = 1e-3 + + phi = rho0*delta0 # constant background perturbation magnitude + q1 = 0.0 + q2 = 0.0 + return (phi, q1, q2) end initial_condition = initial_condition_jeans_instability + ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5 / 3 +gamma = 5/3 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 @@ -71,11 +73,11 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, - solver_euler) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -83,21 +85,22 @@ equations_gravity = HyperbolicDiffusionEquations2D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, - solver_gravity, - source_terms = source_terms_harmonic) +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, + source_terms=source_terms_harmonic) + ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density = 1.5e7, # aka rho0 - gravitational_constant = 6.674e-8, # aka G - cfl = 1.6, - resid_tol = 1.0e-4, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_carpenter_kennedy_erk54_2N!) +parameters = ParametersEulerGravity(background_density=1.5e7, # aka rho0 + gravitational_constant=6.674e-8, # aka G + cfl=1.6, + resid_tol=1.0e-4, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_carpenter_kennedy_erk54_2N!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 5.0) @@ -105,58 +108,51 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) Trixi.pretty_form_utf(::Val{:energy_potential}) = "∑e_potential" Trixi.pretty_form_ascii(::Val{:energy_potential}) = "e_potential" -function Trixi.analyze(::Val{:energy_potential}, du, u_euler, t, - semi::SemidiscretizationEulerGravity) - u_gravity = Trixi.wrap_array(semi.cache.u_ode, semi.semi_gravity) - - mesh, equations_euler, dg, cache = Trixi.mesh_equations_solver_cache(semi.semi_euler) - _, equations_gravity, _, _ = Trixi.mesh_equations_solver_cache(semi.semi_gravity) - - e_potential = Trixi.integrate_via_indices(u_euler, mesh, equations_euler, dg, cache, - equations_gravity, - u_gravity) do u, i, j, element, - equations_euler, dg, - equations_gravity, u_gravity - u_euler_local = Trixi.get_node_vars(u_euler, equations_euler, dg, i, j, element) - u_gravity_local = Trixi.get_node_vars(u_gravity, equations_gravity, dg, i, j, - element) - # OBS! subtraction is specific to Jeans instability test where rho0 = 1.5e7 - return (u_euler_local[1] - 1.5e7) * u_gravity_local[1] - end - return e_potential +function Trixi.analyze(::Val{:energy_potential}, du, u_euler, t, semi::SemidiscretizationEulerGravity) + + u_gravity = Trixi.wrap_array(semi.cache.u_ode, semi.semi_gravity) + + mesh, equations_euler, dg, cache = Trixi.mesh_equations_solver_cache(semi.semi_euler) + _, equations_gravity, _, _ = Trixi.mesh_equations_solver_cache(semi.semi_gravity) + + e_potential = Trixi.integrate_via_indices(u_euler, mesh, equations_euler, dg, cache, equations_gravity, u_gravity) do u, i, j, element, equations_euler, dg, equations_gravity, u_gravity + u_euler_local = Trixi.get_node_vars(u_euler, equations_euler, dg, i, j, element) + u_gravity_local = Trixi.get_node_vars(u_gravity, equations_gravity, dg, i, j, element) + # OBS! subtraction is specific to Jeans instability test where rho0 = 1.5e7 + return (u_euler_local[1] - 1.5e7) * u_gravity_local[1] + end + return e_potential end -analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (energy_total, - energy_kinetic, - energy_internal, - Val(:energy_potential))) +analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal, Val(:energy_potential))) callbacks = CallbackSet(summary_callback, stepsize_callback, save_restart, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl index ba92f77bbaf..de8baf2ecdb 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl @@ -19,33 +19,33 @@ based on Should be used together with [`boundary_condition_sedov_self_gravity`](@ref). """ function initial_condition_sedov_self_gravity(x, t, equations::CompressibleEulerEquations2D) - # Set up polar coordinates - r = sqrt(x[1]^2 + x[2]^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 - r0 = 0.125 # = 4.0 * smallest dx (for domain length=8 and max-ref=8) - E = 1.0 - p_inner = (equations.gamma - 1) * E / (pi * r0^2) - p_ambient = 1e-5 # = true Sedov setup - - # Calculate primitive variables - # use a logistic function to transfer density value smoothly - L = 1.0 # maximum of function - x0 = 1.0 # center point of function - k = -150.0 # sharpness of transfer - logistic_function_rho = L / (1.0 + exp(-k * (r - x0))) - rho_ambient = 1e-5 - rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny - - # velocities are zero - v1 = 0.0 - v2 = 0.0 - - # use a logistic function to transfer pressure value smoothly - logistic_function_p = p_inner / (1.0 + exp(-k * (r - r0))) - p = max(logistic_function_p, p_ambient) - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Set up polar coordinates + r = sqrt(x[1]^2 + x[2]^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 + r0 = 0.125 # = 4.0 * smallest dx (for domain length=8 and max-ref=8) + E = 1.0 + p_inner = (equations.gamma - 1) * E / (pi * r0^2) + p_ambient = 1e-5 # = true Sedov setup + + # Calculate primitive variables + # use a logistic function to transfer density value smoothly + L = 1.0 # maximum of function + x0 = 1.0 # center point of function + k = -150.0 # sharpness of transfer + logistic_function_rho = L/(1.0 + exp(-k*(r - x0))) + rho_ambient = 1e-5 + rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny + + # velocities are zero + v1 = 0.0 + v2 = 0.0 + + # use a logistic function to transfer pressure value smoothly + logistic_function_p = p_inner/(1.0 + exp(-k*(r - r0))) + p = max(logistic_function_p, p_ambient) + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_sedov_self_gravity @@ -65,50 +65,50 @@ Should be used together with [`initial_condition_sedov_self_gravity`](@ref). function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) - # velocities are zero, density/pressure are ambient values according to - # initial_condition_sedov_self_gravity - rho = 1e-5 - v1 = 0.0 - v2 = 0.0 - p = 1e-5 - - u_boundary = prim2cons(SVector(rho, v1, v2, p), equations) - - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end - - return flux + # velocities are zero, density/pressure are ambient values according to + # initial_condition_sedov_self_gravity + rho = 1e-5 + v1 = 0.0 + v2 = 0.0 + p = 1e-5 + + u_boundary = prim2cons(SVector(rho, v1, v2, p), equations) + + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end + + return flux end boundary_conditions = boundary_condition_sedov_self_gravity surface_flux = FluxHLL(min_max_speed_naive) -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations_euler, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver_euler = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-4, -4) -coordinates_max = (4, 4) +coordinates_max = ( 4, 4) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 100_000, - periodicity = false) + initial_refinement_level=2, + n_cells_max=100_000, + periodicity=false) + +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, + boundary_conditions=boundary_conditions) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, - solver_euler, - boundary_conditions = boundary_conditions) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -125,13 +125,12 @@ based on - http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 Should be used together with [`boundary_condition_sedov_self_gravity`](@ref). """ -function initial_condition_sedov_self_gravity(x, t, - equations::HyperbolicDiffusionEquations2D) - # for now just use constant initial condition for sedov blast wave (can likely be improved) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - return SVector(phi, q1, q2) +function initial_condition_sedov_self_gravity(x, t, equations::HyperbolicDiffusionEquations2D) + # for now just use constant initial condition for sedov blast wave (can likely be improved) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + return SVector(phi, q1, q2) end """ @@ -148,38 +147,39 @@ based on Should be used together with [`initial_condition_sedov_self_gravity`](@ref). """ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, x, t, - surface_flux_function, - equations::HyperbolicDiffusionEquations2D) - u_boundary = initial_condition_sedov_self_gravity(x, t, equations) - - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end - - return flux + surface_flux_function, + equations::HyperbolicDiffusionEquations2D) + u_boundary = initial_condition_sedov_self_gravity(x, t, equations) + + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end + + return flux end solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, - solver_gravity, - boundary_conditions = boundary_conditions, - source_terms = source_terms_harmonic) +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, + boundary_conditions=boundary_conditions, + source_terms=source_terms_harmonic) + ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density = 0.0, # aka rho0 - gravitational_constant = 6.674e-8, # aka G - cfl = 2.4, - resid_tol = 1.0e-4, - n_iterations_max = 100, - timestep_gravity = timestep_gravity_erk52_3Sstar!) +parameters = ParametersEulerGravity(background_density=0.0, # aka rho0 + gravitational_constant=6.674e-8, # aka G + cfl=2.4, + resid_tol=1.0e-4, + n_iterations_max=100, + timestep_gravity=timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 1.0) @@ -188,42 +188,41 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0, - alpha_smooth = false, - variable = density_pressure) + alpha_max=1.0, + alpha_min=0.0, + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 2, - max_level = 8, max_threshold = 0.0003) + base_level=2, + max_level =8, max_threshold=0.0003) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) analysis_interval = 100 -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal)) callbacks = CallbackSet(summary_callback, amr_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl index df6e4e6349f..029c19380cf 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_hypdiff_convergence.jl @@ -9,10 +9,10 @@ equations = HyperbolicDiffusionEquations2D() initial_condition = initial_condition_poisson_nonperiodic # 1 => -x, 2 => +x, 3 => -y, 4 => +y as usual for orientations -boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, - x_pos = boundary_condition_poisson_nonperiodic, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) +boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, + x_pos=boundary_condition_poisson_nonperiodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic) polydeg = 3 surface_flux = flux_lax_friedrichs @@ -21,13 +21,15 @@ solver = DGSEM(polydeg, surface_flux) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000, - periodicity = (false, true)) + initial_refinement_level=2, + n_cells_max=30_000, + periodicity=(false, true)) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_poisson_nonperiodic, - boundary_conditions = boundary_conditions) + source_terms=source_terms_poisson_nonperiodic, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -38,28 +40,29 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 1.0e-10 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) analysis_interval = 500 -alive_callback = AliveCallback(analysis_interval = analysis_interval) -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +alive_callback = AliveCallback(analysis_interval=analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) callbacks = CallbackSet(summary_callback, steady_state_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 diff --git a/examples/special_elixirs/elixir_euler_ad.jl b/examples/special_elixirs/elixir_euler_ad.jl index 3aa44f9a773..48fd37cc9d4 100644 --- a/examples/special_elixirs/elixir_euler_ad.jl +++ b/examples/special_elixirs/elixir_euler_ad.jl @@ -6,10 +6,10 @@ using Trixi, LinearAlgebra, ForwardDiff equations = CompressibleEulerEquations2D(1.4) mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), - initial_refinement_level = 2, n_cells_max = 10^5) + initial_refinement_level=2, n_cells_max=10^5) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha)) """ initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) @@ -21,45 +21,43 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_isentropic_vortex, solver) u0_ode = compute_coefficients(0.0, semi) J = ForwardDiff.jacobian((du_ode, γ) -> begin - equations_inner = CompressibleEulerEquations2D(first(γ)) - semi_inner = Trixi.remake(semi, equations = equations_inner, - uEltype = eltype(γ)) - Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) - end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` + equations_inner = CompressibleEulerEquations2D(first(γ)) + semi_inner = Trixi.remake(semi, equations=equations_inner, uEltype=eltype(γ)) + Trixi.rhs!(du_ode, u0_ode, semi_inner, 0.0) + end, similar(u0_ode), [1.4]); # γ needs to be an `AbstractArray` diff --git a/examples/structured_1d_dgsem/elixir_advection_basic.jl b/examples/structured_1d_dgsem/elixir_advection_basic.jl index cdabeb4c61a..82464f23964 100644 --- a/examples/structured_1d_dgsem/elixir_advection_basic.jl +++ b/examples/structured_1d_dgsem/elixir_advection_basic.jl @@ -11,7 +11,7 @@ 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0,) # minimum coordinate coordinates_max = (1.0,) # maximum coordinate @@ -21,8 +21,8 @@ cells_per_dimension = (16,) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -35,26 +35,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl b/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl index 1e0c579ffcf..e87e0b36b0a 100644 --- a/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl +++ b/examples/structured_1d_dgsem/elixir_advection_nonperiodic.jl @@ -11,16 +11,18 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) initial_condition = initial_condition_gauss boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (5.0,) -mesh = StructuredMesh((16,), coordinates_min, coordinates_max, periodicity = false) +mesh = StructuredMesh((16,), coordinates_min, coordinates_max, periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,30 +33,31 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, stepsize_callback); + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl b/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl index 96566bc2373..313812fe08d 100644 --- a/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl +++ b/examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl @@ -17,30 +17,30 @@ Slight simplification from [DOI: 10.1006/jcph.1996.0130](https://doi.org/10.1006/jcph.1996.0130) """ function initial_condition_composite(x, t, equations::LinearScalarAdvectionEquation1D) - xmin, xmax = -1.0, 1.0 # Only works if the domain is [-1.0,1.0] - x_trans = x[1] - t - L = xmax - xmin - if x_trans > xmax - x_ = x_trans - L * floor((x_trans + xmin) / L) - elseif x_trans < xmin - x_ = x_trans + L * floor((xmax - x_trans) / L) - else - x_ = x_trans - end - - if x_ > -0.8 && x_ < -0.6 - value = exp(-log(2.0) * (x_ + 0.7)^2 / 0.0009) - elseif x_ > -0.4 && x_ < -0.2 - value = 1.0 - elseif x_ > 0.0 && x_ < 0.2 - value = 1.0 - abs(10.0 * (x_ - 0.1)) - elseif x_ > 0.4 && x_ < 0.6 - value = sqrt(1.0 - 100.0 * (x_ - 0.5)^2) - else - value = 0.0 - end - - return SVector(value) + xmin, xmax = -1.0, 1.0 # Only works if the domain is [-1.0,1.0] + x_trans = x[1] - t + L = xmax - xmin + if x_trans > xmax + x_ = x_trans - L * floor((x_trans + xmin) / L) + elseif x_trans < xmin + x_ = x_trans + L * floor((xmax - x_trans) / L) + else + x_ = x_trans + end + + if x_ > -0.8 && x_ < -0.6 + value = exp(-log(2.0) * (x_ + 0.7)^2 / 0.0009) + elseif x_ > -0.4 && x_ < -0.2 + value = 1.0 + elseif x_ > 0.0 && x_ < 0.2 + value = 1.0 - abs(10.0 * (x_ - 0.1)) + elseif x_ > 0.4 && x_ < 0.6 + value = sqrt(1.0 - 100.0 * (x_ - 0.5)^2) + else + value = 0.0 + end + + return SVector(value) end initial_condition = initial_condition_composite @@ -52,13 +52,13 @@ volume_flux = flux_central polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = Trixi.first) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=Trixi.first) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) # Create curved mesh @@ -66,11 +66,12 @@ cells_per_dimension = (120,) coordinates_min = (-1.0,) # minimum coordinate coordinates_max = (1.0,) # maximum coordinate mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, - periodicity = true) + periodicity=true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -83,23 +84,23 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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 = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) # 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) +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, # 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 +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 \ No newline at end of file diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov.jl b/examples/structured_1d_dgsem/elixir_euler_sedov.jl index 9293a864058..ee950b3aaaa 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov.jl @@ -14,50 +14,50 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - p0_outer = 1.0e-5 # = true Sedov setup - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + p0_outer = 1.0e-5 # = true Sedov setup + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = shock_indicator_variable) + alpha_max=1.0, + alpha_min=0.001, + alpha_smooth=true, + variable=shock_indicator_variable) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) cells_per_dimension = (64,) coordinates_min = (-2.0,) -coordinates_max = (2.0,) -mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, - periodicity = true) +coordinates_max = ( 2.0,) +mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -67,27 +67,28 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) -callbacks = CallbackSet(summary_callback, - analysis_callback, +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, save_solution, stepsize_callback) + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl index 270da192fe1..230ba92d6b6 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl @@ -14,49 +14,49 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - p0_outer = 1.0e-5 # = true Sedov setup - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + p0_outer = 1.0e-5 # = true Sedov setup + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_hll -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = shock_indicator_variable) + alpha_max=1.0, + alpha_min=0.001, + alpha_smooth=true, + variable=shock_indicator_variable) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) cells_per_dimension = (64,) coordinates_min = (-2.0,) -coordinates_max = (2.0,) -mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, - periodicity = true) +coordinates_max = ( 2.0,) +mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -66,27 +66,28 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) -callbacks = CallbackSet(summary_callback, - analysis_callback, +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, save_solution, stepsize_callback) + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # 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 +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 \ No newline at end of file diff --git a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl index 6cf42df9416..05bf07f59c0 100644 --- a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl @@ -13,7 +13,7 @@ initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. # Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (2.0,) @@ -21,8 +21,10 @@ cells_per_dimension = (16,) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -33,28 +35,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl index d5063838136..9aa5b7f4979 100644 --- a/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/structured_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -15,18 +15,20 @@ source_terms = source_terms_convergence_test # 1*ndims == 2 directions or you can pass a tuple containing BCs for # each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg = boundary_condition, - x_pos = boundary_condition) +boundary_conditions = (x_neg=boundary_condition, + x_pos=boundary_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) f1() = SVector(0.0) f2() = SVector(2.0) -mesh = StructuredMesh((16,), (f1, f2), periodicity = false) +mesh = StructuredMesh((16,), (f1, f2), periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms, - boundary_conditions = boundary_conditions) + source_terms=source_terms, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -37,29 +39,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/structured_2d_dgsem/elixir_advection_basic.jl b/examples/structured_2d_dgsem/elixir_advection_basic.jl index 1d7235fc214..7d2e1f49276 100644 --- a/examples/structured_2d_dgsem/elixir_advection_basic.jl +++ b/examples/structured_2d_dgsem/elixir_advection_basic.jl @@ -11,10 +11,10 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) cells_per_dimension = (16, 16) @@ -22,8 +22,8 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -36,26 +36,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_coupled.jl b/examples/structured_2d_dgsem/elixir_advection_coupled.jl index 2a56d23f4c0..1e54e411db6 100644 --- a/examples/structured_2d_dgsem/elixir_advection_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_advection_coupled.jl @@ -1,6 +1,7 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # Coupled semidiscretization of two linear advection systems, which are connected periodically # @@ -34,11 +35,11 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # First mesh is the left half of a [-1,1]^2 square coordinates_min1 = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max1 = ( 0.0, 1.0) # maximum coordinates (max(x), max(y)) # Define identical resolution as a variable such that it is easier to change from `trixi_include` cells_per_dimension = (8, 16) @@ -48,45 +49,32 @@ cells_per_dimension1 = cells_per_dimension mesh1 = StructuredMesh(cells_per_dimension1, coordinates_min1, coordinates_max1) # A semidiscretization collects data structures and functions for the spatial discretization -semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_convergence_test, - solver, - boundary_conditions = ( - # Connect left boundary with right boundary of right mesh - x_neg = BoundaryConditionCoupled(2, - (:end, - :i_forward), - Float64), - # Connect right boundary with left boundary of right mesh - x_pos = BoundaryConditionCoupled(2, - (:begin, - :i_forward), - Float64), - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic)) +semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_convergence_test, solver, + boundary_conditions=( + # Connect left boundary with right boundary of right mesh + x_neg=BoundaryConditionCoupled(2, (:end, :i_forward), Float64), + # Connect right boundary with left boundary of right mesh + x_pos=BoundaryConditionCoupled(2, (:begin, :i_forward), Float64), + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic)) + # Second mesh is the right half of a [-1,1]^2 square coordinates_min2 = (0.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max2 = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max2 = (1.0, 1.0) # maximum coordinates (max(x), max(y)) cells_per_dimension2 = cells_per_dimension mesh2 = StructuredMesh(cells_per_dimension2, coordinates_min2, coordinates_max2) -semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_convergence_test, - solver, - boundary_conditions = ( - # Connect left boundary with right boundary of left mesh - x_neg = BoundaryConditionCoupled(1, - (:end, - :i_forward), - Float64), - # Connect right boundary with left boundary of left mesh - x_pos = BoundaryConditionCoupled(1, - (:begin, - :i_forward), - Float64), - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic)) +semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_convergence_test, solver, + boundary_conditions=( + # Connect left boundary with right boundary of left mesh + x_neg=BoundaryConditionCoupled(1, (:end, :i_forward), Float64), + # Connect right boundary with left boundary of left mesh + x_pos=BoundaryConditionCoupled(1, (:begin, :i_forward), Float64), + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic)) # Create a semidiscretization that bundles semi1 and semi2 semi = SemidiscretizationCoupled(semi1, semi2) @@ -102,28 +90,28 @@ ode = semidiscretize(semi, (0.0, 2.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback1 = AnalysisCallback(semi1, interval = 100) -analysis_callback2 = AnalysisCallback(semi2, interval = 100) +analysis_callback1 = AnalysisCallback(semi1, interval=100) +analysis_callback2 = AnalysisCallback(semi2, interval=100) analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - solution_variables = cons2prim) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_extended.jl b/examples/structured_2d_dgsem/elixir_advection_extended.jl index df7e1f375a9..fbaa7783d99 100644 --- a/examples/structured_2d_dgsem/elixir_advection_extended.jl +++ b/examples/structured_2d_dgsem/elixir_advection_extended.jl @@ -18,11 +18,11 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # The initial condition is 2-periodic coordinates_min = (-1.5, 1.3) # minimum coordinates (min(x), min(y)) -coordinates_max = (0.5, 5.3) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 0.5, 5.3) # maximum coordinates (max(x), max(y)) cells_per_dimension = (19, 37) @@ -31,7 +31,8 @@ mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -46,24 +47,24 @@ 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, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.6) +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, @@ -71,13 +72,14 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_free_stream.jl b/examples/structured_2d_dgsem/elixir_advection_free_stream.jl index 7785b4f9e18..155a2d19fc9 100644 --- a/examples/structured_2d_dgsem/elixir_advection_free_stream.jl +++ b/examples/structured_2d_dgsem/elixir_advection_free_stream.jl @@ -11,21 +11,21 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_constant # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (16, 16) @@ -36,6 +36,7 @@ mesh = StructuredMesh(cells_per_dimension, mapping) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -47,30 +48,30 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +save_solution = SaveSolutionCallback(interval=100, + solution_variables=cons2prim) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 2.0) +stepsize_callback = StepsizeCallback(cfl=2.0) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution, - stepsize_callback) +callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl index e2e113b168d..2aad3a01566 100644 --- a/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_advection_nonperiodic.jl @@ -13,14 +13,16 @@ initial_condition = initial_condition_gauss # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) -mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity = false) +coordinates_max = ( 5.0, 5.0) +mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,17 +33,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -50,7 +52,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl b/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl index b70deb12318..b9a6d3f91ae 100644 --- a/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl +++ b/examples/structured_2d_dgsem/elixir_advection_parallelogram.jl @@ -7,23 +7,24 @@ using OrdinaryDiffEq using Trixi + # initial_condition_convergence_test transformed to the parallelogram function initial_condition_parallelogram(x, t, equation::LinearScalarAdvectionEquation2D) - # Transform back to unit square - x_transformed = SVector(x[1] - x[2], x[2]) - a = equation.advection_velocity - a_transformed = SVector(a[1] - a[2], a[2]) - - # Store translated coordinate for easy use of exact solution - x_translated = x_transformed - a_transformed * t - - c = 1.0 - A = 0.5 - L = 2 - f = 1 / L - omega = 2 * pi * f - scalar = c + A * sin(omega * sum(x_translated)) - return SVector(scalar) + # Transform back to unit square + x_transformed = SVector(x[1] - x[2], x[2]) + a = equation.advection_velocity + a_transformed = SVector(a[1] - a[2], a[2]) + + # Store translated coordinate for easy use of exact solution + x_translated = x_transformed - a_transformed * t + + c = 1.0 + A = 0.5 + L = 2 + f = 1/L + omega = 2 * pi * f + scalar = c + A * sin(omega * sum(x_translated)) + return SVector(scalar) end ############################################################################### @@ -34,7 +35,7 @@ advection_velocity = (-0.5, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Define faces for a parallelogram that looks like this # @@ -48,11 +49,11 @@ mapping(xi, eta) = SVector(xi + eta, eta) cells_per_dimension = (16, 16) # Create curved mesh with 16 x 16 elements, periodic in both dimensions -mesh = StructuredMesh(cells_per_dimension, mapping; periodicity = (true, true)) +mesh = StructuredMesh(cells_per_dimension, mapping; periodicity=(true, true)) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_parallelogram, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_parallelogram, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -65,26 +66,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_restart.jl b/examples/structured_2d_dgsem/elixir_advection_restart.jl index b4ae56543f8..2c2a0ef8f51 100644 --- a/examples/structured_2d_dgsem/elixir_advection_restart.jl +++ b/examples/structured_2d_dgsem/elixir_advection_restart.jl @@ -10,6 +10,7 @@ restart_file = "restart_000021.h5" trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file)) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -24,10 +25,11 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 diff --git a/examples/structured_2d_dgsem/elixir_advection_rotated.jl b/examples/structured_2d_dgsem/elixir_advection_rotated.jl index 826c7ebaacb..7dfee23a067 100644 --- a/examples/structured_2d_dgsem/elixir_advection_rotated.jl +++ b/examples/structured_2d_dgsem/elixir_advection_rotated.jl @@ -7,6 +7,7 @@ using OrdinaryDiffEq using Trixi + # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -16,41 +17,40 @@ using Trixi # initial_condition_convergence_test transformed to the rotated rectangle struct InitialConditionConvergenceTestRotated - sin_alpha::Float64 - cos_alpha::Float64 + sin_alpha::Float64 + cos_alpha::Float64 end function InitialConditionConvergenceTestRotated(alpha) - sin_alpha, cos_alpha = sincos(alpha) + sin_alpha, cos_alpha = sincos(alpha) - InitialConditionConvergenceTestRotated(sin_alpha, cos_alpha) + InitialConditionConvergenceTestRotated(sin_alpha, cos_alpha) end -function (initial_condition::InitialConditionConvergenceTestRotated)(x, t, - equation::LinearScalarAdvectionEquation2D) - sin_ = initial_condition.sin_alpha - cos_ = initial_condition.cos_alpha +function (initial_condition::InitialConditionConvergenceTestRotated)(x, t, equation::LinearScalarAdvectionEquation2D) + sin_ = initial_condition.sin_alpha + cos_ = initial_condition.cos_alpha - # Rotate back to unit square + # Rotate back to unit square - # Clockwise rotation by α and translation by 1 - # Multiply with [ cos(α) sin(α); - # -sin(α) cos(α)] - x_rot = SVector(cos_ * x[1] + sin_ * x[2], -sin_ * x[1] + cos_ * x[2]) - a = equation.advection_velocity - a_rot = SVector(cos_ * a[1] + sin_ * a[2], -sin_ * a[1] + cos_ * a[2]) + # Clockwise rotation by α and translation by 1 + # Multiply with [ cos(α) sin(α); + # -sin(α) cos(α)] + x_rot = SVector(cos_ * x[1] + sin_ * x[2], -sin_ * x[1] + cos_ * x[2]) + a = equation.advection_velocity + a_rot = SVector(cos_ * a[1] + sin_ * a[2], -sin_ * a[1] + cos_ * a[2]) - # Store translated coordinate for easy use of exact solution - x_trans = x_rot - a_rot * t + # Store translated coordinate for easy use of exact solution + x_trans = x_rot - a_rot * t - c = 1.0 - A = 0.5 - L = 2 - f = 1 / L - omega = 2 * pi * f - scalar = c + A * sin(omega * sum(x_trans)) + c = 1.0 + A = 0.5 + L = 2 + f = 1/L + omega = 2 * pi * f + scalar = c + A * sin(omega * sum(x_trans)) - return SVector(scalar) + return SVector(scalar) end end # module TrixiExtensionAdvectionRotated @@ -70,7 +70,7 @@ advection_velocity = Tuple(T * [0.2, -0.7]) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) mapping(xi, eta) = T * SVector(xi, eta) @@ -82,6 +82,7 @@ mesh = StructuredMesh(cells_per_dimension, mapping) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -93,26 +94,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl b/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl index 50393d50a19..d0db19ea635 100644 --- a/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl +++ b/examples/structured_2d_dgsem/elixir_advection_waving_flag.jl @@ -11,14 +11,14 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector(1.0, s + 1.0) +f2(s) = SVector( 1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) cells_per_dimension = (16, 16) @@ -28,6 +28,7 @@ mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4)) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,30 +40,30 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - solution_variables = cons2prim) +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.4) +stepsize_callback = StepsizeCallback(cfl=1.4) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver -callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, save_solution, - stepsize_callback) +callbacks = CallbackSet(summary_callback, analysis_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_euler_ec.jl b/examples/structured_2d_dgsem/elixir_euler_ec.jl index 29686bd3cb7..2c91349ff98 100644 --- a/examples/structured_2d_dgsem/elixir_euler_ec.jl +++ b/examples/structured_2d_dgsem/elixir_euler_ec.jl @@ -13,25 +13,25 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg = 4, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the curved quad mesh from a mapping function # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (16, 16) @@ -53,15 +53,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -72,7 +72,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_free_stream.jl b/examples/structured_2d_dgsem/elixir_euler_free_stream.jl index 3aab4be979e..c4ddb887e5f 100644 --- a/examples/structured_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/structured_2d_dgsem/elixir_euler_free_stream.jl @@ -9,21 +9,21 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_constant -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (16, 16) @@ -32,6 +32,7 @@ mesh = StructuredMesh(cells_per_dimension, mapping) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -41,16 +42,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 2.0) +stepsize_callback = StepsizeCallback(cfl=2.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -60,7 +61,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl index 744c40213a3..499aea21d9b 100644 --- a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl @@ -29,40 +29,40 @@ defined below. """ @inline function initial_condition_rayleigh_taylor_instability(x, t, equations::CompressibleEulerEquations2D, - slope = 1000) - tol = 1e2 * eps() - - if x[2] < 0.5 - p = 2 * x[2] + 1 - else - p = x[2] + 3 / 2 - end - - # smooth the discontinuity to avoid ambiguity at element interfaces - smoothed_heaviside(x, left, right) = left + 0.5 * (1 + tanh(slope * x)) * (right - left) - rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) - - c = sqrt(equations.gamma * p / rho) - # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the - # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. - v = -0.025 * c * cos(8 * pi * x[1]) * sin(pi * x[2])^6 - u = 0.0 - - return prim2cons(SVector(rho, u, v, p), equations) + slope=1000) + tol = 1e2*eps() + + if x[2] < 0.5 + p = 2*x[2] + 1 + else + p = x[2] + 3/2 + end + + # smooth the discontinuity to avoid ambiguity at element interfaces + smoothed_heaviside(x, left, right) = left + 0.5*(1 + tanh(slope * x)) * (right-left) + rho = smoothed_heaviside(x[2] - 0.5, 2.0, 1.0) + + c = sqrt(equations.gamma * p / rho) + # the velocity is multiplied by sin(pi*y)^6 as in Remacle et al. 2003 to ensure that the + # initial condition satisfies reflective boundary conditions at the top/bottom boundaries. + v = -0.025 * c * cos(8*pi*x[1]) * sin(pi*x[2])^6 + u = 0.0 + + return prim2cons(SVector(rho, u, v, p), equations) end @inline function source_terms_rayleigh_taylor_instability(u, x, t, equations::CompressibleEulerEquations2D) - g = 1.0 - rho, rho_v1, rho_v2, rho_e = u + g = 1.0 + rho, rho_v1, rho_v2, rho_e = u - return SVector(0.0, 0.0, g * rho, g * rho_v2) + return SVector(0.0, 0.0, g*rho, g*rho_v2) end # numerical parameters volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = FluxHLL(min_max_speed_naive), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # The domain is [0, 0.25] x [0, 1] mapping(xi, eta) = SVector(0.25 * 0.5 * (1.0 + xi), 0.5 * (1.0 + eta)) @@ -72,10 +72,12 @@ cells_per_dimension = (num_elements_per_dimension, num_elements_per_dimension * mesh = StructuredMesh(cells_per_dimension, mapping) initial_condition = initial_condition_rayleigh_taylor_instability -boundary_conditions = (x_neg = boundary_condition_slip_wall, - x_pos = boundary_condition_slip_wall, - y_neg = boundary_condition_slip_wall, - y_pos = boundary_condition_slip_wall) +boundary_conditions = ( + x_neg=boundary_condition_slip_wall, + x_pos=boundary_condition_slip_wall, + y_neg=boundary_condition_slip_wall, + y_pos=boundary_condition_slip_wall, + ) # # Alternative setup: left/right periodic BCs and Dirichlet BCs on the top/bottom. # boundary_conditions = ( @@ -86,8 +88,8 @@ boundary_conditions = (x_neg = boundary_condition_slip_wall, # ) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver; - source_terms = source_terms_rayleigh_taylor_instability, - boundary_conditions = boundary_conditions) + source_terms=source_terms_rayleigh_taylor_instability, + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -98,9 +100,9 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -109,7 +111,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/structured_2d_dgsem/elixir_euler_sedov.jl b/examples/structured_2d_dgsem/elixir_euler_sedov.jl index 2f91e6db7a5..ed1bfab3be2 100644 --- a/examples/structured_2d_dgsem/elixir_euler_sedov.jl +++ b/examples/structured_2d_dgsem/elixir_euler_sedov.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) - p0_outer = 1.0e-5 # = true Sedov 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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) + p0_outer = 1.0e-5 # = true Sedov 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 @@ -43,30 +43,29 @@ volume_flux = flux_ranocha polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=1.0, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=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)) + 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) + 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 = true) + +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=true) # create the semidiscretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -80,15 +79,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 300, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=300, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -99,7 +98,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms.jl index 6827848e185..70d3e060dd0 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms.jl @@ -11,7 +11,7 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) @@ -20,8 +20,10 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -32,16 +34,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -51,7 +53,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl index f42d223611a..94537ecef0d 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -12,20 +12,21 @@ initial_condition = initial_condition_convergence_test # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg = boundary_condition, - x_pos = boundary_condition, - y_neg = boundary_condition, - y_pos = boundary_condition) +boundary_conditions = (x_neg=boundary_condition, + x_pos=boundary_condition, + y_neg=boundary_condition, + y_pos=boundary_condition,) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) -mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity = false) +mesh = StructuredMesh((16, 16), coordinates_min, coordinates_max, periodicity=false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -36,19 +37,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -57,7 +58,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl index 5d6b0908389..a9c08049f41 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_parallelogram.jl @@ -9,7 +9,7 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Define faces for a parallelogram that looks like this # @@ -24,8 +24,10 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, mapping) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -36,16 +38,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -55,7 +57,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl index f2e3c448893..fdd189ffb55 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_rotated.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -11,69 +12,68 @@ using Trixi # initial_condition_convergence_test transformed to the rotated rectangle struct InitialConditionSourceTermsRotated - sin_alpha::Float64 - cos_alpha::Float64 + sin_alpha::Float64 + cos_alpha::Float64 end function InitialConditionSourceTermsRotated(alpha) - sin_alpha, cos_alpha = sincos(alpha) + sin_alpha, cos_alpha = sincos(alpha) - InitialConditionSourceTermsRotated(sin_alpha, cos_alpha) + InitialConditionSourceTermsRotated(sin_alpha, cos_alpha) end -function (initial_condition::InitialConditionSourceTermsRotated)(x, t, - equations::CompressibleEulerEquations2D) - sin_ = initial_condition.sin_alpha - cos_ = initial_condition.cos_alpha +function (initial_condition::InitialConditionSourceTermsRotated)(x, t, equations::CompressibleEulerEquations2D) + sin_ = initial_condition.sin_alpha + cos_ = initial_condition.cos_alpha - # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 + # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 - # Clockwise rotation by α and translation by 1 - # Multiply with [ cos(α) sin(α); - # -sin(α) cos(α)] - x1 = cos_ * x[1] + sin_ * x[2] + 1 - x2 = -sin_ * x[1] + cos_ * x[2] + 1 + # Clockwise rotation by α and translation by 1 + # Multiply with [ cos(α) sin(α); + # -sin(α) cos(α)] + x1 = cos_ * x[1] + sin_ * x[2] + 1 + x2 = -sin_ * x[1] + cos_ * x[2] + 1 - rho, rho_v1, rho_v2, rho_e = initial_condition_convergence_test(SVector(x1, x2), t, - equations) + rho, rho_v1, rho_v2, rho_e = initial_condition_convergence_test(SVector(x1, x2), t, equations) - # Rotate velocity vector counterclockwise - # Multiply with [ cos(α) -sin(α); - # sin(α) cos(α)] - rho_v1_rot = cos_ * rho_v1 - sin_ * rho_v2 - rho_v2_rot = sin_ * rho_v1 + cos_ * rho_v2 + # Rotate velocity vector counterclockwise + # Multiply with [ cos(α) -sin(α); + # sin(α) cos(α)] + rho_v1_rot = cos_ * rho_v1 - sin_ * rho_v2 + rho_v2_rot = sin_ * rho_v1 + cos_ * rho_v2 - return SVector(rho, rho_v1_rot, rho_v2_rot, rho_e) + return SVector(rho, rho_v1_rot, rho_v2_rot, rho_e) end -@inline function (source_terms::InitialConditionSourceTermsRotated)(u, x, t, - equations::CompressibleEulerEquations2D) - sin_ = source_terms.sin_alpha - cos_ = source_terms.cos_alpha - # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 +@inline function (source_terms::InitialConditionSourceTermsRotated)(u, x, t, equations::CompressibleEulerEquations2D) + sin_ = source_terms.sin_alpha + cos_ = source_terms.cos_alpha + + # Rotate back to unit square and translate from [-1, 1]^2 to [0, 2]^2 - # Clockwise rotation by α and translation by 1 - # Multiply with [ cos(α) sin(α); - # -sin(α) cos(α)] - x1 = cos_ * x[1] + sin_ * x[2] + 1 - x2 = -sin_ * x[1] + cos_ * x[2] + 1 + # Clockwise rotation by α and translation by 1 + # Multiply with [ cos(α) sin(α); + # -sin(α) cos(α)] + x1 = cos_ * x[1] + sin_ * x[2] + 1 + x2 = -sin_ * x[1] + cos_ * x[2] + 1 - du1, du2, du3, du4 = source_terms_convergence_test(u, SVector(x1, x2), t, equations) + du1, du2, du3, du4 = source_terms_convergence_test(u, SVector(x1, x2), t, equations) - # Rotate velocity vector counterclockwise - # Multiply with [ cos(α) -sin(α); - # sin(α) cos(α)] - du2_rotated = cos_ * du2 - sin_ * du3 - du3_rotated = sin_ * du2 + cos_ * du3 + # Rotate velocity vector counterclockwise + # Multiply with [ cos(α) -sin(α); + # sin(α) cos(α)] + du2_rotated = cos_ * du2 - sin_ * du3 + du3_rotated = sin_ * du2 + cos_ * du3 - return SVector(du1, du2_rotated, du3_rotated, du4) + return SVector(du1, du2_rotated, du3_rotated, du4) end end # module TrixiExtensionEulerRotated import .TrixiExtensionEulerRotated + ############################################################################### # semidiscretization of the compressible Euler equations @@ -85,7 +85,8 @@ sin_ = initial_condition_source_terms.sin_alpha cos_ = initial_condition_source_terms.cos_alpha T = [cos_ -sin_; sin_ cos_] -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) + +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) mapping(xi, eta) = T * SVector(xi, eta) @@ -93,8 +94,10 @@ cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, mapping) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_source_terms, solver, - source_terms = initial_condition_source_terms) + source_terms=initial_condition_source_terms) + ############################################################################### # ODE solvers, callbacks etc. @@ -105,16 +108,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -124,7 +127,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl b/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl index 4a78b65ae0b..505e28ecd8d 100644 --- a/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl +++ b/examples/structured_2d_dgsem/elixir_euler_source_terms_waving_flag.jl @@ -9,21 +9,23 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Deformed rectangle that looks like a waving flag, # lower and upper faces are sinus curves, left and right are vertical lines. f1(s) = SVector(-1.0, s - 1.0) -f2(s) = SVector(1.0, s + 1.0) +f2(s) = SVector( 1.0, s + 1.0) f3(s) = SVector(s, -1.0 + sin(0.5 * pi * s)) -f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) +f4(s) = SVector(s, 1.0 + sin(0.5 * pi * s)) cells_per_dimension = (16, 16) mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4)) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -34,16 +36,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -53,7 +55,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl index ccb74fa4b68..6730b1c4beb 100644 --- a/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl @@ -7,42 +7,43 @@ using Trixi equations = HyperbolicDiffusionEquations2D() -@inline function initial_condition_harmonic_nonperiodic(x, t, - equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω - if t == 0.0 - phi = 1.0 - q1 = 1.0 - q2 = 1.0 - else - C = inv(sinh(pi)) - sinpi_x1, cospi_x1 = sincos(pi * x[1]) - sinpi_x2, cospi_x2 = sincos(pi * x[2]) - sinh_pix1 = sinh(pi * x[1]) - cosh_pix1 = cosh(pi * x[1]) - sinh_pix2 = sinh(pi * x[2]) - cosh_pix2 = cosh(pi * x[2]) - phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) - q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) - q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) - end - return SVector(phi, q1, q2) +@inline function initial_condition_harmonic_nonperiodic(x, t, equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω + if t == 0.0 + phi = 1.0 + q1 = 1.0 + q2 = 1.0 + else + C = inv(sinh(pi)) + sinpi_x1, cospi_x1 = sincos(pi*x[1]) + sinpi_x2, cospi_x2 = sincos(pi*x[2]) + sinh_pix1 = sinh(pi*x[1]) + cosh_pix1 = cosh(pi*x[1]) + sinh_pix2 = sinh(pi*x[2]) + cosh_pix2 = cosh(pi*x[2]) + phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) + q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) + q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_harmonic_nonperiodic boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 4, surface_flux = flux_godunov) +solver = DGSEM(polydeg=4, surface_flux=flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) cells_per_dimension = (8, 8) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max, - periodicity = false) + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions, - source_terms = source_terms_harmonic) + boundary_conditions=boundary_conditions, + source_terms=source_terms_harmonic) + ############################################################################### # ODE solvers, callbacks etc. @@ -53,29 +54,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl index 681b3bd781b..ba77dca9a99 100644 --- a/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/structured_2d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -9,38 +9,40 @@ equations = HyperbolicDiffusionEquations2D() initial_condition = initial_condition_poisson_nonperiodic -solver = DGSEM(polydeg = 6, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=6, surface_flux=flux_lax_friedrichs) -boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, - x_pos = boundary_condition_poisson_nonperiodic, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) +boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, + x_pos=boundary_condition_poisson_nonperiodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic) ############################################################################### # Get the curved quad mesh from a mapping function # # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end # Create curved mesh with 8 x 8 elements cells_per_dimension = (8, 8) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = (false, true)) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=(false, true)) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_poisson_nonperiodic, - boundary_conditions = boundary_conditions) + source_terms=source_terms_poisson_nonperiodic, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -51,30 +53,31 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 4000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 4000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=4000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.9) +stepsize_callback = StepsizeCallback(cfl=1.9) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) + ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = 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 diff --git a/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl index e8f2b2ecc3a..259875050c6 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,34 +5,31 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the curved quad mesh from a mapping function # Mapping as described in https://arxiv.org/abs/1809.01178 function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0, sqrt(2)] - # Note, we use the domain [0, sqrt(2)]^2 for the Alfvén wave convergence test case - xi = 0.5 * sqrt(2) * xi_ + 0.5 * sqrt(2) - eta = 0.5 * sqrt(2) * eta_ + 0.5 * sqrt(2) + # Transform input variables between -1 and 1 onto [0, sqrt(2)] + # Note, we use the domain [0, sqrt(2)]^2 for the Alfvén wave convergence test case + xi = 0.5 * sqrt(2) * xi_ + 0.5 * sqrt(2) + eta = 0.5 * sqrt(2) * eta_ + 0.5 * sqrt(2) - y = eta + - sqrt(2) / 12 * (cos(1.5 * pi * (2 * xi - sqrt(2)) / sqrt(2)) * - cos(0.5 * pi * (2 * eta - sqrt(2)) / sqrt(2))) + y = eta + sqrt(2)/12 * (cos(1.5 * pi * (2 * xi - sqrt(2))/sqrt(2)) * + cos(0.5 * pi * (2 * eta - sqrt(2))/sqrt(2))) - x = xi + - sqrt(2) / 12 * (cos(0.5 * pi * (2 * xi - sqrt(2)) / sqrt(2)) * - cos(2 * pi * (2 * y - sqrt(2)) / sqrt(2))) + x = xi + sqrt(2)/12 * (cos(0.5 * pi * (2 * xi - sqrt(2))/sqrt(2)) * + cos(2 * pi * (2 * y - sqrt(2))/sqrt(2))) - return SVector(x, y) + return SVector(x, y) end cells_per_dimension = (4, 4) @@ -50,24 +47,21 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) - -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 2.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -79,7 +73,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_mhd_ec.jl b/examples/structured_2d_dgsem/elixir_mhd_ec.jl index a6c31744ca5..634738e5c8b 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_ec.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_ec.jl @@ -8,46 +8,45 @@ using Trixi equations = IdealGlmMhdEquations2D(1.4) function initial_condition_shifted_weak_blast_wave(x, t, equations::IdealGlmMhdEquations2D) - # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) - # Same discontinuity in the velocities but with magnetic fields - # Set up polar coordinates - inicenter = (1.5, 1.5) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) - v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) - p = r > 0.5 ? 1.0 : 1.245 - - return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) + # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) + # Same discontinuity in the velocities but with magnetic fields + # Set up polar coordinates + inicenter = (1.5, 1.5) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) + v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) + p = r > 0.5 ? 1.0 : 1.245 + + return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) end initial_condition = initial_condition_shifted_weak_blast_wave # Get the DG approximation space volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 5, - surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=5, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the curved quad mesh from a mapping function # Mapping as described in https://arxiv.org/abs/2012.12040, but reduced to 2D function mapping(xi_, eta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 - y = eta + 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3)) + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3)) - x = xi + 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3)) + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3)) - return SVector(x, y) + return SVector(x, y) end # Create curved mesh with 8 x 8 elements @@ -66,24 +65,21 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) - -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -95,7 +91,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl b/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl index 6668014a0b6..084aeca90b9 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_ec_shockcapturing.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations equations = IdealGlmMhdEquations2D(1.4) @@ -9,17 +10,17 @@ equations = IdealGlmMhdEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + 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 @@ -30,14 +31,16 @@ function mapping(xi, eta) x = 2.0 * xi + 1.0 / 6.0 * (cos(0.5 * pi * xi) * cos(2 * pi * y)) return SVector(x, y) -end + end cells_per_dimension = (16, 16) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=true) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -47,14 +50,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -65,7 +68,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl index 48fe37b9996..18f48080850 100644 --- a/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/structured_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,14 +5,13 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) @@ -21,8 +20,10 @@ cells_per_dimension = (8, 8) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -33,16 +34,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 2.0) +stepsize_callback = StepsizeCallback(cfl=2.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -52,7 +53,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl index c7c14da2ab4..17836fa6b8f 100644 --- a/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/structured_2d_dgsem/elixir_shallowwater_well_balanced.jl @@ -7,22 +7,21 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.0) +equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) + + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -31,17 +30,16 @@ initial_condition = initial_condition_well_balancedness # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, - hydrostatic_reconstruction_audusse_etal), +surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal) -solver = DGSEM(polydeg = 4, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup a structured periodic mesh coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) cells_per_dimension = (4, 4) @@ -66,33 +64,30 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_discontinuous_well_balancedness(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), - element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -101,16 +96,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -118,7 +113,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_advection_basic.jl b/examples/structured_3d_dgsem/elixir_advection_basic.jl index 5b0bb371fe8..47ae6352485 100644 --- a/examples/structured_3d_dgsem/elixir_advection_basic.jl +++ b/examples/structured_3d_dgsem/elixir_advection_basic.jl @@ -11,18 +11,18 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) cells_per_dimension = (8, 8, 8) # Create curved mesh with 8 x 8 x 8 elements mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) # A semidiscretization collects data structures and functions for the spatial discretization -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -35,30 +35,30 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +save_solution = SaveSolutionCallback(interval=100, + solution_variables=cons2prim) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) # 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, save_restart, - stepsize_callback) +callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_3d_dgsem/elixir_advection_free_stream.jl b/examples/structured_3d_dgsem/elixir_advection_free_stream.jl index 12d52f15160..749233b8c68 100644 --- a/examples/structured_3d_dgsem/elixir_advection_free_stream.jl +++ b/examples/structured_3d_dgsem/elixir_advection_free_stream.jl @@ -13,27 +13,24 @@ solver = DGSEM(3, flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) @@ -44,6 +41,7 @@ mesh = StructuredMesh(cells_per_dimension, mapping) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_constant, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -55,26 +53,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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 = 2.0) +stepsize_callback = StepsizeCallback(cfl=2.0) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl b/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl index 1a20a9c8533..fa8ae756566 100644 --- a/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl +++ b/examples/structured_3d_dgsem/elixir_advection_nonperiodic_curved.jl @@ -11,38 +11,36 @@ equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_convergence_test boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = false) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -53,20 +51,20 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -78,7 +76,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_advection_restart.jl b/examples/structured_3d_dgsem/elixir_advection_restart.jl index a4b72ef34c2..39e1a675167 100644 --- a/examples/structured_3d_dgsem/elixir_advection_restart.jl +++ b/examples/structured_3d_dgsem/elixir_advection_restart.jl @@ -6,7 +6,8 @@ using Trixi # create a restart file trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), - cells_per_dimension = (4, 4, 4)) + cells_per_dimension=(4, 4, 4)) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -17,16 +18,16 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.jl"), restart_filename = joinpath("out", "restart_000010.h5") mesh = load_mesh(restart_filename) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_ec.jl b/examples/structured_3d_dgsem/elixir_euler_ec.jl index 1330006760e..0009eb31180 100644 --- a/examples/structured_3d_dgsem/elixir_euler_ec.jl +++ b/examples/structured_3d_dgsem/elixir_euler_ec.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerEquations3D(5 / 3) +equations = CompressibleEulerEquations3D(5/3) initial_condition = initial_condition_weak_blast_wave @@ -13,35 +13,32 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg = 5, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=5, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the curved quad mesh from a file # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -62,15 +59,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -81,7 +78,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_free_stream.jl b/examples/structured_3d_dgsem/elixir_euler_free_stream.jl index 1b01287100e..b0e71435767 100644 --- a/examples/structured_3d_dgsem/elixir_euler_free_stream.jl +++ b/examples/structured_3d_dgsem/elixir_euler_free_stream.jl @@ -9,32 +9,29 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_constant -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -43,6 +40,7 @@ mesh = StructuredMesh(cells_per_dimension, mapping) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -52,29 +50,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.3) +stepsize_callback = StepsizeCallback(cfl=1.3) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_sedov.jl b/examples/structured_3d_dgsem/elixir_euler_sedov.jl index 99e2fd72f96..8f428495b4f 100644 --- a/examples/structured_3d_dgsem/elixir_euler_sedov.jl +++ b/examples/structured_3d_dgsem/elixir_euler_sedov.jl @@ -14,29 +14,28 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 with smaller strength of the initial discontinuity. """ -function initial_condition_medium_sedov_blast_wave(x, t, - equations::CompressibleEulerEquations3D) - # Set up polar coordinates - inicenter = SVector(0.0, 0.0, 0.0) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - z_norm = x[3] - inicenter[3] - r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) - p0_outer = 1.0e-3 - - # Calculate primitive variables - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_medium_sedov_blast_wave(x, t, equations::CompressibleEulerEquations3D) + # Set up polar coordinates + inicenter = SVector(0.0, 0.0, 0.0) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + z_norm = x[3] - inicenter[3] + r = sqrt(x_norm^2 + y_norm^2 + z_norm^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (4 * pi * r0^2) + p0_outer = 1.0e-3 + + # Calculate primitive variables + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_medium_sedov_blast_wave @@ -46,31 +45,30 @@ volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=1.0, + 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(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) + +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi, eta, zeta) - y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) + y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) - x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) + x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) - z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) + z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) - return SVector(x, y, z) + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = true) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -84,15 +82,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -103,7 +101,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_source_terms.jl b/examples/structured_3d_dgsem/elixir_euler_source_terms.jl index ebf1336c12c..d8c6ea4bb83 100644 --- a/examples/structured_3d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_3d_dgsem/elixir_euler_source_terms.jl @@ -11,8 +11,8 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) # coordinates_min = (0.0, 0.0, 0.0) # coordinates_max = (2.0, 2.0, 2.0) @@ -28,7 +28,8 @@ cells_per_dimension = (4, 4, 4) mesh = StructuredMesh(cells_per_dimension, (f1, f2, f3, f4, f5, f6)) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,26 +40,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl b/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl index eb358fa5da1..8ddfd426553 100644 --- a/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl +++ b/examples/structured_3d_dgsem/elixir_euler_source_terms_nonperiodic_curved.jl @@ -12,48 +12,46 @@ initial_condition = initial_condition_convergence_test # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg = boundary_condition, - x_pos = boundary_condition, - y_neg = boundary_condition, - y_pos = boundary_condition, - z_neg = boundary_condition, - z_pos = boundary_condition) +boundary_conditions = (x_neg=boundary_condition, + x_pos=boundary_condition, + y_neg=boundary_condition, + y_pos=boundary_condition, + z_neg=boundary_condition, + z_pos=boundary_condition,) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) # Mapping as described in https://arxiv.org/abs/2012.12040 but with less warping. function mapping(xi, eta, zeta) - # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries - # xi = 1.5 * xi_ + 1.5 - # eta = 1.5 * eta_ + 1.5 - # zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 1 / 6 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 1 / 6 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 1 / 6 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - # Transform the weird deformed cube to be approximately the cube [0,2]^3 - return SVector(x + 1, y + 1, z + 1) + # Don't transform input variables between -1 and 1 onto [0,3] to obtain curved boundaries + # xi = 1.5 * xi_ + 1.5 + # eta = 1.5 * eta_ + 1.5 + # zeta = 1.5 * zeta_ + 1.5 + + y = eta + 1/6 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 1/6 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 1/6 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + # Transform the weird deformed cube to be approximately the cube [0,2]^3 + return SVector(x + 1, y + 1, z + 1) end cells_per_dimension = (4, 4, 4) -mesh = StructuredMesh(cells_per_dimension, mapping, periodicity = false) +mesh = StructuredMesh(cells_per_dimension, mapping, periodicity=false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -64,26 +62,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) 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); +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 diff --git a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl index 52f52c5b490..8d651a2fcf4 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,15 +5,13 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5 / 3) +equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg = 5, - surface_flux = (FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=5, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Create the mesh # Note, we use the domain [-1, 1]^3 for the Alfvén wave convergence test case so the @@ -21,13 +19,13 @@ solver = DGSEM(polydeg = 5, # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi, eta, zeta) - y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) + y = eta + 0.125 * (cos(1.5 * pi * xi) * cos(0.5 * pi * eta) * cos(0.5 * pi * zeta)) - x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) + x = xi + 0.125 * (cos(0.5 * pi * xi) * cos(2 * pi * y) * cos(0.5 * pi * zeta)) - z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) + z = zeta + 0.125 * (cos(0.5 * pi * x) * cos(pi * y) * cos(0.5 * pi * zeta)) - return SVector(x, y, z) + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -45,18 +43,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.2 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -64,10 +62,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_mhd_ec.jl b/examples/structured_3d_dgsem/elixir_mhd_ec.jl index 5b3cd6f3718..a8c2288e811 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_ec.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_ec.jl @@ -10,35 +10,31 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Create a heavily warped curved mesh # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end cells_per_dimension = (4, 4, 4) @@ -56,19 +52,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -76,10 +72,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl b/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl index 084e2ee962a..d669c2350a5 100644 --- a/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl +++ b/examples/structured_3d_dgsem/elixir_mhd_ec_shockcapturing.jl @@ -10,46 +10,42 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) # Create a heavily warped curved mesh # Mapping as described in https://arxiv.org/abs/2012.12040 function mapping(xi_, eta_, zeta_) - # Transform input variables between -1 and 1 onto [0,3] - xi = 1.5 * xi_ + 1.5 - eta = 1.5 * eta_ + 1.5 - zeta = 1.5 * zeta_ + 1.5 - - y = eta + - 3 / 8 * (cos(1.5 * pi * (2 * xi - 3) / 3) * - cos(0.5 * pi * (2 * eta - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - x = xi + - 3 / 8 * (cos(0.5 * pi * (2 * xi - 3) / 3) * - cos(2 * pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - z = zeta + - 3 / 8 * (cos(0.5 * pi * (2 * x - 3) / 3) * - cos(pi * (2 * y - 3) / 3) * - cos(0.5 * pi * (2 * zeta - 3) / 3)) - - return SVector(x, y, z) + # Transform input variables between -1 and 1 onto [0,3] + xi = 1.5 * xi_ + 1.5 + eta = 1.5 * eta_ + 1.5 + zeta = 1.5 * zeta_ + 1.5 + + y = eta + 3/8 * (cos(1.5 * pi * (2 * xi - 3)/3) * + cos(0.5 * pi * (2 * eta - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + x = xi + 3/8 * (cos(0.5 * pi * (2 * xi - 3)/3) * + cos(2 * pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + z = zeta + 3/8 * (cos(0.5 * pi * (2 * x - 3)/3) * + cos(pi * (2 * y - 3)/3) * + cos(0.5 * pi * (2 * zeta - 3)/3)) + + return SVector(x, y, z) end cells_per_dimension = (8, 8, 8) @@ -67,24 +63,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_advection_amr.jl b/examples/tree_1d_dgsem/elixir_advection_amr.jl index 1071c98ab7e..dc371233bc8 100644 --- a/examples/tree_1d_dgsem/elixir_advection_amr.jl +++ b/examples/tree_1d_dgsem/elixir_advection_amr.jl @@ -10,16 +10,18 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0,) -coordinates_max = (5.0,) +coordinates_max = ( 5.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -29,36 +31,37 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +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 = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl index ff62e905429..098deedb9d6 100644 --- a/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_advection_amr_nonperiodic.jl @@ -11,19 +11,21 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) initial_condition = initial_condition_gauss boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (5.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -34,39 +36,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +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 = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, save_solution, amr_callback, stepsize_callback); + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_advection_basic.jl b/examples/tree_1d_dgsem/elixir_advection_basic.jl index cba522f6366..d61062c772e 100644 --- a/examples/tree_1d_dgsem/elixir_advection_basic.jl +++ b/examples/tree_1d_dgsem/elixir_advection_basic.jl @@ -9,19 +9,19 @@ 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate -coordinates_max = 1.0 # maximum 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 + 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) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -34,26 +34,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_1d_dgsem/elixir_advection_diffusion.jl b/examples/tree_1d_dgsem/elixir_advection_diffusion.jl index 72b8b3f1933..0472bd25a71 100644 --- a/examples/tree_1d_dgsem/elixir_advection_diffusion.jl +++ b/examples/tree_1d_dgsem/elixir_advection_diffusion.jl @@ -11,52 +11,49 @@ diffusivity() = 0.1 equations_parabolic = LaplaceDiffusion1D(diffusivity(), equations) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = -pi # minimum coordinate -coordinates_max = pi # maximum coordinate +coordinates_max = pi # 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 - periodicity = true) - -function x_trans_periodic(x, domain_length = SVector(2 * pi), center = SVector(0.0)) - x_normalized = x .- center - x_shifted = x_normalized .% domain_length - x_offset = ((x_shifted .< -0.5 * domain_length) - (x_shifted .> 0.5 * domain_length)) .* - domain_length - return center + x_shifted + x_offset + initial_refinement_level=4, + n_cells_max=30_000, # set maximum capacity of tree data structure + periodicity=true) + +function x_trans_periodic(x, domain_length = SVector(2*pi), center = SVector(0.0)) + x_normalized = x .- center + x_shifted = x_normalized .% domain_length + x_offset = ((x_shifted .< -0.5*domain_length) - (x_shifted .> 0.5*domain_length)) .* domain_length + return center + x_shifted + x_offset end # Define initial condition -function initial_condition_diffusive_convergence_test(x, t, - equation::LinearScalarAdvectionEquation1D) - # Store translated coordinate for easy use of exact solution - x_trans = x_trans_periodic(x - equation.advection_velocity * t) - - nu = diffusivity() - c = 0.0 - A = 1.0 - L = 2 - f = 1 / L - omega = 1.0 - scalar = c + A * sin(omega * sum(x_trans)) * exp(-nu * omega^2 * t) - return SVector(scalar) +function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation1D) + # Store translated coordinate for easy use of exact solution + x_trans = x_trans_periodic(x - equation.advection_velocity * t) + + nu = diffusivity() + c = 0.0 + A = 1.0 + L = 2 + f = 1/L + omega = 1.0 + scalar = c + A * sin(omega * sum(x_trans)) * exp(-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_diffusive_convergence_test, - solver; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic)) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition_diffusive_convergence_test, solver; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic)) + ############################################################################### # ODE solvers, callbacks etc. @@ -70,22 +67,23 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = 100) +alive_callback = AliveCallback(analysis_interval=100) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-10 time_abs_tol = 1.0e-10 -sol = solve(ode, KenCarp4(autodiff = false), abstol = time_abs_tol, reltol = time_int_tol, - save_everystep = false, callback = callbacks) +sol = solve(ode, KenCarp4(autodiff=false), abstol=time_abs_tol, reltol=time_int_tol, + save_everystep=false, callback=callbacks) # Print the timer summary summary_callback() diff --git a/examples/tree_1d_dgsem/elixir_advection_extended.jl b/examples/tree_1d_dgsem/elixir_advection_extended.jl index df185834701..5c87ac7ef5c 100644 --- a/examples/tree_1d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_1d_dgsem/elixir_advection_extended.jl @@ -18,20 +18,21 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate -coordinates_max = 1.0 # maximum 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 - periodicity = true) + initial_refinement_level=4, + n_cells_max=30_000, # set maximum capacity of tree data structure + periodicity=true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -46,24 +47,24 @@ 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, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.6) +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, @@ -71,13 +72,14 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl b/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl index 62701f3ecf5..28518e7276a 100644 --- a/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl +++ b/examples/tree_1d_dgsem/elixir_advection_finite_volume.jl @@ -10,19 +10,19 @@ equations = LinearScalarAdvectionEquation1D(advection_velocity) # Create DG solver with polynomial degree = 0, i.e., a first order finite volume solver, # with (local) Lax-Friedrichs/Rusanov flux as surface flux -solver = DGSEM(polydeg = 0, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=0, surface_flux=flux_lax_friedrichs) coordinates_min = -1.0 # minimum coordinate -coordinates_max = 1.0 # maximum coordinate +coordinates_max = 1.0 # maximum coordinate # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=5, + 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) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -35,21 +35,22 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback) + ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks sol = solve(ode, Euler(), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); + 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() diff --git a/examples/tree_1d_dgsem/elixir_burgers_basic.jl b/examples/tree_1d_dgsem/elixir_burgers_basic.jl index f57b8e730fe..cebd9b11201 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_basic.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_basic.jl @@ -9,16 +9,18 @@ equations = InviscidBurgersEquation1D() initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -29,28 +31,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl b/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl index ae2039edde6..6a25f94ca05 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_linear_stability.jl @@ -8,22 +8,23 @@ using Trixi equations = InviscidBurgersEquation1D() function initial_condition_linear_stability(x, t, equation::InviscidBurgersEquation1D) - k = 1 - 2 + sinpi(k * (x[1] - 0.7)) |> SVector + k = 1 + 2 + sinpi(k * (x[1] - 0.7)) |> SVector end volume_flux = flux_ec -solver = DGSEM(polydeg = 3, surface_flux = flux_ec, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ec, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_linear_stability, solver) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_linear_stability, - solver) ############################################################################### # ODE solvers, callbacks etc. @@ -34,22 +35,23 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl b/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl index d32b9d6f1f4..28ab7b7c768 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_rarefaction.jl @@ -10,18 +10,18 @@ equations = InviscidBurgersEquation1D() basis = LobattoLegendreBasis(3) # Use shock capturing techniques to suppress oscillations at discontinuities indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = first) + alpha_max=1.0, + alpha_min=0.001, + alpha_smooth=true, + variable=first) -volume_flux = flux_ec +volume_flux = flux_ec surface_flux = flux_lax_friedrichs volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) - + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) + solver = DGSEM(basis, surface_flux, volume_integral) coordinate_min = 0.0 @@ -29,41 +29,42 @@ coordinate_max = 1.0 # Make sure to turn periodicity explicitly off as special boundary conditions are specified mesh = TreeMesh(coordinate_min, coordinate_max, - initial_refinement_level = 6, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=6, + n_cells_max=10_000, + periodicity=false) # Discontinuous initial condition (Riemann Problem) leading to a rarefaction fan. function initial_condition_rarefaction(x, t, equation::InviscidBurgersEquation1D) - scalar = x[1] < 0.5 ? 0.5 : 1.5 + scalar = x[1] < 0.5 ? 0.5 : 1.5 - return SVector(scalar) -end + return SVector(scalar) +end ############################################################################### # Specify non-periodic boundary conditions function inflow(x, t, equations::InviscidBurgersEquation1D) - return initial_condition_rarefaction(coordinate_min, t, equations) + return initial_condition_rarefaction(coordinate_min, t, equations) end boundary_condition_inflow = BoundaryConditionDirichlet(inflow) function boundary_condition_outflow(u_inner, orientation, normal_direction, x, t, - surface_flux_function, - equations::InviscidBurgersEquation1D) - # Calculate the boundary flux entirely from the internal solution state - flux = Trixi.flux(u_inner, normal_direction, equations) + surface_flux_function, equations::InviscidBurgersEquation1D) + # Calculate the boundary flux entirely from the internal solution state + flux = Trixi.flux(u_inner, normal_direction, equations) - return flux + return flux end -boundary_conditions = (x_neg = boundary_condition_inflow, - x_pos = boundary_condition_outflow) +boundary_conditions = (x_neg=boundary_condition_inflow, + x_pos=boundary_condition_outflow) + initial_condition = initial_condition_rarefaction semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -74,11 +75,12 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +stepsize_callback = StepsizeCallback(cfl=0.9) -stepsize_callback = StepsizeCallback(cfl = 0.9) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -87,8 +89,9 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 42, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=42, # 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 diff --git a/examples/tree_1d_dgsem/elixir_burgers_shock.jl b/examples/tree_1d_dgsem/elixir_burgers_shock.jl index 1f0b0e7e042..00b5314e19f 100644 --- a/examples/tree_1d_dgsem/elixir_burgers_shock.jl +++ b/examples/tree_1d_dgsem/elixir_burgers_shock.jl @@ -10,17 +10,17 @@ equations = InviscidBurgersEquation1D() basis = LobattoLegendreBasis(3) # Use shock capturing techniques to suppress oscillations at discontinuities indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = first) + alpha_max=1.0, + alpha_min=0.001, + alpha_smooth=true, + variable=first) -volume_flux = flux_ec +volume_flux = flux_ec surface_flux = flux_lax_friedrichs volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = surface_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=surface_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) @@ -29,41 +29,42 @@ coordinate_max = 1.0 # Make sure to turn periodicity explicitly off as special boundary conditions are specified mesh = TreeMesh(coordinate_min, coordinate_max, - initial_refinement_level = 6, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=6, + n_cells_max=10_000, + periodicity=false) # Discontinuous initial condition (Riemann Problem) leading to a shock to test e.g. correct shock speed. function initial_condition_shock(x, t, equation::InviscidBurgersEquation1D) - scalar = x[1] < 0.5 ? 1.5 : 0.5 + scalar = x[1] < 0.5 ? 1.5 : 0.5 - return SVector(scalar) + return SVector(scalar) end ############################################################################### # Specify non-periodic boundary conditions function inflow(x, t, equations::InviscidBurgersEquation1D) - return initial_condition_shock(coordinate_min, t, equations) + return initial_condition_shock(coordinate_min, t, equations) end boundary_condition_inflow = BoundaryConditionDirichlet(inflow) function boundary_condition_outflow(u_inner, orientation, normal_direction, x, t, - surface_flux_function, - equations::InviscidBurgersEquation1D) - # Calculate the boundary flux entirely from the internal solution state - flux = Trixi.flux(u_inner, normal_direction, equations) + surface_flux_function, equations::InviscidBurgersEquation1D) + # Calculate the boundary flux entirely from the internal solution state + flux = Trixi.flux(u_inner, normal_direction, equations) - return flux + return flux end -boundary_conditions = (x_neg = boundary_condition_inflow, - x_pos = boundary_condition_outflow) + +boundary_conditions = (x_neg=boundary_condition_inflow, + x_pos=boundary_condition_outflow) initial_condition = initial_condition_shock semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -74,11 +75,12 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +stepsize_callback = StepsizeCallback(cfl=0.85) -stepsize_callback = StepsizeCallback(cfl = 0.85) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -87,8 +89,9 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 42, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); + +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=42, # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl b/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl index 9cba4936d22..2318063c2be 100644 --- a/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl +++ b/examples/tree_1d_dgsem/elixir_euler_blast_wave.jl @@ -16,47 +16,49 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - # The following code is equivalent to - # phi = atan(0.0, x_norm) - # cos_phi = cos(phi) - # in 1D but faster - cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + # The following code is equivalent to + # phi = atan(0.0, x_norm) + # cos_phi = cos(phi) + # in 1D but faster + cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -67,26 +69,27 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl index 05f392624fd..d35dec6bc73 100644 --- a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl +++ b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl @@ -2,8 +2,7 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.97-0.0001.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.97-0.0001.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.97-0.0001.bson", network) model1d = load(network, @__MODULE__)[:model1d] using OrdinaryDiffEq @@ -15,6 +14,7 @@ using Trixi # University of Cologne, advisors: Gregor Gassner, Michael Schlottke-Lakemper # This motivates the particular choice of fluxes, mesh resolution etc. + ############################################################################### # semidiscretization of the compressible Euler equations @@ -29,51 +29,53 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - # The following code is equivalent to - # phi = atan(0.0, x_norm) - # cos_phi = cos(phi) - # in 1D but faster - cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + # The following code is equivalent to + # phi = atan(0.0, x_norm) + # cos_phi = cos(phi) + # in 1D but faster + cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkPerssonPeraire(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = false, - alpha_amr = false, - variable = density_pressure, - network = model1d) + indicator_type=NeuralNetworkPerssonPeraire(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=false, + alpha_amr=false, + variable=density_pressure, + network=model1d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -84,26 +86,27 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl index de2f5134a49..fb36f8540f8 100644 --- a/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl +++ b/examples/tree_1d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl @@ -2,8 +2,7 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnrh-0.95-0.009.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrh-0.95-0.009.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrh-0.95-0.009.bson", network) model1d = load(network, @__MODULE__)[:model1d] using OrdinaryDiffEq @@ -15,6 +14,7 @@ using Trixi # University of Cologne, advisors: Gregor Gassner, Michael Schlottke-Lakemper # This motivates the particular choice of fluxes, mesh resolution etc. + ############################################################################### # semidiscretization of the compressible Euler equations @@ -29,51 +29,53 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - # The following code is equivalent to - # phi = atan(0.0, x_norm) - # cos_phi = cos(phi) - # in 1D but faster - cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + # The following code is equivalent to + # phi = atan(0.0, x_norm) + # cos_phi = cos(phi) + # in 1D but faster + cos_phi = x_norm > 0 ? one(x_norm) : -one(x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkRayHesthaven(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = false, - alpha_amr = false, - variable = density_pressure, - network = model1d) + indicator_type=NeuralNetworkRayHesthaven(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=false, + alpha_amr=false, + variable=density_pressure, + network=model1d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -84,26 +86,27 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl b/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl index 1fa07d4edda..fe221ea5bd7 100644 --- a/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl +++ b/examples/tree_1d_dgsem/elixir_euler_convergence_pure_fv.jl @@ -9,17 +9,19 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, - volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc)) +solver = DGSEM(polydeg=3, surface_flux=flux_hllc, + volume_integral=VolumeIntegralPureLGLFiniteVolume(flux_hllc)) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,28 +32,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_density_wave.jl b/examples/tree_1d_dgsem/elixir_euler_density_wave.jl index 01ccbb2b517..746989dfe56 100644 --- a/examples/tree_1d_dgsem/elixir_euler_density_wave.jl +++ b/examples/tree_1d_dgsem/elixir_euler_density_wave.jl @@ -8,16 +8,18 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_density_wave -solver = DGSEM(polydeg = 5, surface_flux = flux_central) +solver = DGSEM(polydeg=5, surface_flux=flux_central) coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000) + initial_refinement_level=2, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -27,16 +29,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 2000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -46,7 +48,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_ec.jl b/examples/tree_1d_dgsem/elixir_euler_ec.jl index 0be9c8fbf4c..f20bd4fd69e 100644 --- a/examples/tree_1d_dgsem/elixir_euler_ec.jl +++ b/examples/tree_1d_dgsem/elixir_euler_ec.jl @@ -9,17 +9,19 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -29,26 +31,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_positivity.jl b/examples/tree_1d_dgsem/elixir_euler_positivity.jl index 1a6017eb529..7942937151a 100644 --- a/examples/tree_1d_dgsem/elixir_euler_positivity.jl +++ b/examples/tree_1d_dgsem/elixir_euler_positivity.jl @@ -14,92 +14,97 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - 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 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + 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 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 4.0) ode = semidiscretize(semi, tspan) + summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorLöhner(semi, - variable = density_pressure) + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - med_level = 0, med_threshold = 0.1, # med_level = current level - max_level = 6, max_threshold = 0.3) + base_level=4, + med_level =0, med_threshold=0.1, # med_level = current level + max_level =6, max_threshold=0.3) amr_callback = AMRCallback(semi, amr_controller, - interval = 2, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=2, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) + +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl index f4b817c3a8c..746a7cf1bac 100644 --- a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -14,92 +14,96 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - 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 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + 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 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = shock_indicator_variable) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=shock_indicator_variable) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 12.5) ode = semidiscretize(semi, tspan) + summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level=6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) 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 = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl index 96f68470c85..00b80dbae92 100644 --- a/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl +++ b/examples/tree_1d_dgsem/elixir_euler_sedov_blast_wave_pure_fv.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 """ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEquations1D) - # Set up polar coordinates - inicenter = SVector(0.0) - x_norm = x[1] - inicenter[1] - r = abs(x_norm) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) - 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 - p = r > r0 ? p0_outer : p0_inner - - return prim2cons(SVector(rho, v1, p), equations) + # Set up polar coordinates + inicenter = SVector(0.0) + x_norm = x[1] - inicenter[1] + r = abs(x_norm) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 = 6 * (equations.gamma - 1) * E / (3 * pi * r0) + 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 + p = r > r0 ? p0_outer : p0_inner + + return prim2cons(SVector(rho, v1, p), equations) end initial_condition = initial_condition_sedov_blast_wave @@ -42,55 +42,59 @@ volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 7, - n_cells_max = 10_000) + initial_refinement_level=7, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 12.5) ode = semidiscretize(semi, tspan) + summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 7, max_threshold = 0.01) + base_level=4, + max_level=7, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.25) +stepsize_callback = StepsizeCallback(cfl=0.25) 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 = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl b/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl index 08367505377..90547f8ddc1 100644 --- a/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl +++ b/examples/tree_1d_dgsem/elixir_euler_shockcapturing.jl @@ -10,26 +10,28 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_shima_etal +volume_flux = flux_shima_etal basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -2.0 -coordinates_max = 2.0 +coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,26 +41,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl index 442b61f8158..193c6cedc5b 100644 --- a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl @@ -11,16 +11,18 @@ initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. # Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,28 +33,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl index 922ac3dd97d..3794e0c8d54 100644 --- a/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -13,21 +13,23 @@ initial_condition = initial_condition_convergence_test # 1*ndims == 2 directions or you can pass a tuple containing BCs for # each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg = boundary_condition, - x_pos = boundary_condition) +boundary_conditions = (x_neg=boundary_condition, + x_pos=boundary_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) coordinates_max = (2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -38,29 +40,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl index 6d54c6b86c9..762ab1c90ca 100644 --- a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl @@ -15,11 +15,11 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, - solver_euler) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -27,21 +27,22 @@ equations_gravity = HyperbolicDiffusionEquations1D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, - solver_gravity, - source_terms = source_terms_harmonic) +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, + source_terms=source_terms_harmonic) + ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 - gravitational_constant = 1.0, # aka G - cfl = 1.5, - resid_tol = 1.0e-10, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_erk52_3Sstar!) +parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 + gravitational_constant=1.0, # aka G + cfl=1.5, + resid_tol=1.0e-10, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -50,20 +51,20 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, - save_analysis = true) +analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, + save_analysis=true) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -72,10 +73,11 @@ callbacks = CallbackSet(summary_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl index 6d6316898b7..2444fe8611d 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_ec.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0,) -coordinates_max = (1.0,) +coordinates_max = ( 1.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,26 +33,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl index 1b37a8a2279..86f4a4bad04 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_convergence_es.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4, 1.4), gas_constants = (0.4, 0.4, 0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0,) -coordinates_max = (1.0,) +coordinates_max = ( 1.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,26 +33,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl b/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl index 73f8de15d82..04d937a9a8f 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_ec.jl @@ -4,23 +4,26 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), gas_constants = (0.4, 0.4, 0.4)) + initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,27 +34,28 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (Trixi.density,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(Trixi.density,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_es.jl b/examples/tree_1d_dgsem/elixir_eulermulti_es.jl index 7fbec0c0055..7abb3b0d021 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_es.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_es.jl @@ -4,23 +4,26 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) + initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0,) -coordinates_max = (2.0,) +coordinates_max = ( 2.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,30 +34,31 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (Trixi.density,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(Trixi.density,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl b/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl index 20aeaf9fb48..81966194180 100644 --- a/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl +++ b/examples/tree_1d_dgsem/elixir_eulermulti_two_interacting_blast_waves.jl @@ -5,8 +5,8 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), - gas_constants = (0.4, 0.4, 0.4)) +equations = CompressibleEulerMulticomponentEquations1D(gammas = (1.4, 1.4, 1.4), + gas_constants = (0.4, 0.4, 0.4)) """ initial_condition_two_interacting_blast_waves(x, t, equations::CompressibleEulerMulticomponentEquations1D) @@ -16,68 +16,69 @@ A multicomponent two interacting blast wave test taken from The consistent multi-fluid advection method [arXiv: 9807241](https://arxiv.org/pdf/astro-ph/9807241.pdf) """ -function initial_condition_two_interacting_blast_waves(x, t, - equations::CompressibleEulerMulticomponentEquations1D) - rho1 = 0.5 * x[1]^2 - rho2 = 0.5 * (sin(20 * x[1]))^2 - rho3 = 1 - rho1 - rho2 +function initial_condition_two_interacting_blast_waves(x, t, equations::CompressibleEulerMulticomponentEquations1D) - prim_rho = SVector{3, real(equations)}(rho1, rho2, rho3) + rho1 = 0.5 * x[1]^2 + rho2 = 0.5 * (sin(20 * x[1]))^2 + rho3 = 1 - rho1 - rho2 - v1 = 0.0 + prim_rho = SVector{3, real(equations)}(rho1, rho2, rho3) - if x[1] <= 0.1 - p = 1000 - elseif x[1] < 0.9 - p = 0.01 - else - p = 100 - end + v1 = 0.0 - prim_other = SVector{2, real(equations)}(v1, p) + if x[1] <= 0.1 + p = 1000 + elseif x[1] < 0.9 + p = 0.01 + else + p = 100 + end - return prim2cons(vcat(prim_other, prim_rho), equations) + prim_other = SVector{2, real(equations)}(v1, p) + + return prim2cons(vcat(prim_other, prim_rho), equations) end initial_condition = initial_condition_two_interacting_blast_waves -function boundary_condition_two_interacting_blast_waves(u_inner, orientation, direction, x, - t, +function boundary_condition_two_interacting_blast_waves(u_inner, orientation, direction, x, t, surface_flux_function, equations::CompressibleEulerMulticomponentEquations1D) - u_inner_reflect = SVector(-u_inner[1], u_inner[2], u_inner[3], u_inner[4], u_inner[5]) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_inner_reflect, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_inner_reflect, u_inner, orientation, equations) - end - - return flux + + u_inner_reflect = SVector(-u_inner[1], u_inner[2], u_inner[3], u_inner[4], u_inner[5]) + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_inner_reflect, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_inner_reflect, u_inner, orientation, equations) + end + + return flux end boundary_conditions = boundary_condition_two_interacting_blast_waves surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, alpha_max = 0.8, alpha_min = 0.0, alpha_smooth = true, - variable = pressure) + variable=pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0,) coordinates_max = (1.0,) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 9, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=9, + n_cells_max=10_000, + periodicity=false) + + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -89,16 +90,16 @@ summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.1) +stepsize_callback = StepsizeCallback(cfl=0.1) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -108,7 +109,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl index b9173ec9f49..9a19807ae29 100644 --- a/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the hyperbolic diffusion equations -equations = HyperbolicDiffusionEquations1D(nu = 1.25) +equations = HyperbolicDiffusionEquations1D(nu=1.25) """ initial_condition_poisson_nonperiodic(x, t, equations::HyperbolicDiffusionEquations1D) @@ -16,36 +16,36 @@ A non-priodic harmonic function used in combination with !!! note The only harmonic functions in 1D have the form phi(x) = A + Bx """ -function initial_condition_harmonic_nonperiodic(x, t, - equations::HyperbolicDiffusionEquations1D) - # elliptic equation: -νΔϕ = f - if t == 0.0 - phi = 5.0 - q1 = 0.0 - else - A = 3 - B = exp(1) - phi = A + B * x[1] - q1 = B - end - return SVector(phi, q1) +function initial_condition_harmonic_nonperiodic(x, t, equations::HyperbolicDiffusionEquations1D) + # elliptic equation: -νΔϕ = f + if t == 0.0 + phi = 5.0 + q1 = 0.0 + else + A = 3 + B = exp(1) + phi = A + B * x[1] + q1 = B + end + return SVector(phi, q1) end initial_condition = initial_condition_harmonic_nonperiodic boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = -1.0 -coordinates_max = 2.0 +coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000, - periodicity = false) + initial_refinement_level=2, + n_cells_max=30_000, + periodicity=false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions, - source_terms = source_terms_harmonic) + boundary_conditions=boundary_conditions, + source_terms=source_terms_harmonic) + ############################################################################### # ODE solvers, callbacks etc. @@ -56,29 +56,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.75) +stepsize_callback = StepsizeCallback(cfl=1.75) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) + ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = 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 diff --git a/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl index 4da3b33a466..827d8d25ce7 100644 --- a/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -11,18 +11,19 @@ initial_condition = initial_condition_poisson_nonperiodic boundary_conditions = boundary_condition_poisson_nonperiodic -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000, - periodicity = false) + initial_refinement_level=3, + n_cells_max=30_000, + periodicity=false) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions, - source_terms = source_terms_poisson_nonperiodic) + boundary_conditions=boundary_conditions, + source_terms=source_terms_poisson_nonperiodic) + ############################################################################### # ODE solvers, callbacks etc. @@ -33,30 +34,31 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl b/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl index 1a66ac60b9b..82bca93c707 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_alfven_wave.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations1D(gamma) initial_condition = initial_condition_convergence_test volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,33 +32,32 @@ 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), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl index 7be8492cad1..0e25ac6ac6c 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_briowu_shock_tube.jl @@ -17,44 +17,46 @@ MHD extension of the Sod shock tube. Taken from Section V of the article [DOI: 10.1016/0021-9991(88)90120-9](https://doi.org/10.1016/0021-9991(88)90120-9) """ function initial_condition_briowu_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [0, 1], γ = 2, final time = 0.12 - rho = x[1] < 0.5 ? 1.0 : 0.125 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = x[1] < 0.5 ? 1.0 : 0.1 - B1 = 0.75 - B2 = x[1] < 0.5 ? 1.0 : -1.0 - B3 = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [0, 1], γ = 2, final time = 0.12 + rho = x[1] < 0.5 ? 1.0 : 0.125 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = x[1] < 0.5 ? 1.0 : 0.1 + B1 = 0.75 + B2 = x[1] < 0.5 ? 1.0 : -1.0 + B3 = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_briowu_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = FluxHLL(min_max_speed_einfeldt) -volume_flux = flux_derigs_etal +volume_flux = flux_derigs_etal basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -65,44 +67,45 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level=6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.65) +stepsize_callback = StepsizeCallback(cfl=0.65) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_ec.jl b/examples/tree_1d_dgsem/elixir_mhd_ec.jl index e5da808f696..1f2e77006b1 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_ec.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_ec.jl @@ -10,17 +10,19 @@ equations = IdealGlmMhdEquations1D(gamma) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg = 3, surface_flux = flux_hindenlang_gassner, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_hindenlang_gassner, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,28 +32,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl index 262c90b7dac..0dbb21ad686 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_ryujones_shock_tube.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations1D(gamma) """ @@ -22,46 +22,48 @@ present in the one dimensional MHD equations. It is the second test from Section This paper has a typo in the initial conditions. Their variable `E` should be `p`. """ function initial_condition_ryujones_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [0, 1], γ = 5/3, final time = 0.2 - rho = x[1] <= 0.5 ? 1.08 : 1.0 - v1 = x[1] <= 0.5 ? 1.2 : 0.0 - v2 = x[1] <= 0.5 ? 0.01 : 0.0 - v3 = x[1] <= 0.5 ? 0.5 : 0.0 - p = x[1] <= 0.5 ? 0.95 : 1.0 - inv_sqrt4pi = 1.0 / sqrt(4 * pi) - B1 = 2 * inv_sqrt4pi - B2 = x[1] <= 0.5 ? 3.6 * inv_sqrt4pi : 4.0 * inv_sqrt4pi - B3 = B1 - - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [0, 1], γ = 5/3, final time = 0.2 + rho = x[1] <= 0.5 ? 1.08 : 1.0 + v1 = x[1] <= 0.5 ? 1.2 : 0.0 + v2 = x[1] <= 0.5 ? 0.01 : 0.0 + v3 = x[1] <= 0.5 ? 0.5 : 0.0 + p = x[1] <= 0.5 ? 0.95 : 1.0 + inv_sqrt4pi = 1.0 / sqrt(4 * pi) + B1 = 2 * inv_sqrt4pi + B2 = x[1] <= 0.5 ? 3.6 * inv_sqrt4pi : 4.0 * inv_sqrt4pi + B3 = B1 + + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_ryujones_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = FluxHLL(min_max_speed_einfeldt) -volume_flux = flux_hindenlang_gassner +volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = Trixi.density) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=Trixi.density) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 7, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=7, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -72,26 +74,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.8) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl index 9a9ace4710f..860698d7880 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_shu_osher_shock_tube.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations1D(gamma) """ @@ -17,19 +17,19 @@ Taken from Section 4.1 of [DOI: 10.1016/j.jcp.2016.04.048](https://doi.org/10.1016/j.jcp.2016.04.048) """ function initial_condition_shu_osher_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 - # initial shock location is taken to be at x = -4 - x_0 = -4.0 - rho = x[1] <= x_0 ? 3.5 : 1.0 + 0.2 * sin(5.0 * x[1]) - v1 = x[1] <= x_0 ? 5.8846 : 0.0 - v2 = x[1] <= x_0 ? 1.1198 : 0.0 - v3 = 0.0 - p = x[1] <= x_0 ? 42.0267 : 1.0 - B1 = 1.0 - B2 = x[1] <= x_0 ? 3.6359 : 1.0 - B3 = 0.0 - - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 + # initial shock location is taken to be at x = -4 + x_0 = -4.0 + rho = x[1] <= x_0 ? 3.5 : 1.0 + 0.2 * sin(5.0 * x[1]) + v1 = x[1] <= x_0 ? 5.8846 : 0.0 + v2 = x[1] <= x_0 ? 1.1198 : 0.0 + v3 = 0.0 + p = x[1] <= x_0 ? 42.0267 : 1.0 + B1 = 1.0 + B2 = x[1] <= x_0 ? 3.6359 : 1.0 + B3 = 0.0 + + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end """ @@ -41,49 +41,50 @@ but shock propagates from right to left. !!! note This is useful to exercise some of the components of the HLL flux. """ -function initial_condition_shu_osher_shock_tube_flipped(x, t, - equations::IdealGlmMhdEquations1D) - # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 - # initial shock location is taken to be at x = 4 - x_0 = 4.0 - rho = x[1] <= x_0 ? 1.0 + 0.2 * sin(5.0 * x[1]) : 3.5 - v1 = x[1] <= x_0 ? 0.0 : -5.8846 - v2 = x[1] <= x_0 ? 0.0 : -1.1198 - v3 = 0.0 - p = x[1] <= x_0 ? 1.0 : 42.0267 - B1 = 1.0 - B2 = x[1] <= x_0 ? 1.0 : 3.6359 - B3 = 0.0 - - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) +function initial_condition_shu_osher_shock_tube_flipped(x, t, equations::IdealGlmMhdEquations1D) + # domain must be set to [-5, 5], γ = 5/3, final time = 0.7 + # initial shock location is taken to be at x = 4 + x_0 = 4.0 + rho = x[1] <= x_0 ? 1.0 + 0.2 * sin(5.0 * x[1]) : 3.5 + v1 = x[1] <= x_0 ? 0.0 : -5.8846 + v2 = x[1] <= x_0 ? 0.0 : -1.1198 + v3 = 0.0 + p = x[1] <= x_0 ? 1.0 : 42.0267 + B1 = 1.0 + B2 = x[1] <= x_0 ? 1.0 : 3.6359 + B3 = 0.0 + + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_shu_osher_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = FluxHLL(min_max_speed_einfeldt) -volume_flux = flux_hindenlang_gassner +volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -5.0 -coordinates_max = 5.0 +coordinates_max = 5.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -94,43 +95,42 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 7, max_threshold = 0.01) + base_level=4, + max_level=7, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl index 3b366c35e0f..68556764293 100644 --- a/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhd_torrilhon_shock_tube.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations1D(gamma) """ @@ -16,44 +16,46 @@ Torrilhon's shock tube test case for one dimensional ideal MHD equations. [DOI: 10.1017/S0022377803002186](https://doi.org/10.1017/S0022377803002186) """ function initial_condition_torrilhon_shock_tube(x, t, equations::IdealGlmMhdEquations1D) - # domain must be set to [-1, 1.5], γ = 5/3, final time = 0.4 - rho = x[1] <= 0 ? 3.0 : 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = x[1] <= 0 ? 3.0 : 1.0 - B1 = 1.5 - B2 = x[1] <= 0 ? 1.0 : cos(1.5) - B3 = x[1] <= 0 ? 0.0 : sin(1.5) - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) + # domain must be set to [-1, 1.5], γ = 5/3, final time = 0.4 + rho = x[1] <= 0 ? 3.0 : 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = x[1] <= 0 ? 3.0 : 1.0 + B1 = 1.5 + B2 = x[1] <= 0 ? 1.0 : cos(1.5) + B3 = x[1] <= 0 ? 0.0 : sin(1.5) + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3), equations) end initial_condition = initial_condition_torrilhon_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = flux_lax_friedrichs -volume_flux = flux_central +volume_flux = flux_central basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -1.0 -coordinates_max = 1.5 +coordinates_max = 1.5 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 7, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=7, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -64,28 +66,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl index 831fa7afedb..376f11d52a2 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_briowu_shock_tube.jl @@ -4,8 +4,8 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0), - gas_constants = (2.0, 2.0)) +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0), + gas_constants = (2.0, 2.0)) """ initial_condition_briowu_shock_tube(x, t, equations::IdealGlmMhdMulticomponentEquations1D) @@ -16,62 +16,55 @@ MHD extension of the Sod shock tube. Taken from Section V of the article An Upwind Differencing Scheme for the Equations of Ideal Magnetohydrodynamics [DOI: 10.1016/0021-9991(88)90120-9](https://doi.org/10.1016/0021-9991(88)90120-9) """ -function initial_condition_briowu_shock_tube(x, t, - equations::IdealGlmMhdMulticomponentEquations1D) - # domain must be set to [0, 1], γ = 2, final time = 0.12 - if x[1] < 0.5 - rho = 1.0 - prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i - 1) * (1 - 2) / - (1 - - 2^ncomponents(equations)) * - rho - for i in eachcomponent(equations)) - else - rho = 0.125 - prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i - 1) * (1 - 2) / - (1 - - 2^ncomponents(equations)) * - rho - for i in eachcomponent(equations)) - end - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = x[1] < 0.5 ? 1.0 : 0.1 - B1 = 0.75 - B2 = x[1] < 0.5 ? 1.0 : -1.0 - B3 = 0.0 - - prim_other = SVector(v1, v2, v3, p, B1, B2, B3) - return prim2cons(vcat(prim_other, prim_rho), equations) +function initial_condition_briowu_shock_tube(x, t, equations::IdealGlmMhdMulticomponentEquations1D) + # domain must be set to [0, 1], γ = 2, final time = 0.12 + if x[1] < 0.5 + rho = 1.0 + prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i-1) * (1-2)/(1-2^ncomponents(equations)) * rho for i in eachcomponent(equations)) + else + rho = 0.125 + prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i-1) * (1-2)/(1-2^ncomponents(equations)) * rho for i in eachcomponent(equations)) + end + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = x[1] < 0.5 ? 1.0 : 0.1 + B1 = 0.75 + B2 = x[1] < 0.5 ? 1.0 : -1.0 + B3 = 0.0 + + prim_other = SVector(v1, v2, v3, p, B1, B2, B3) + return prim2cons(vcat(prim_other, prim_rho), equations) end initial_condition = initial_condition_briowu_shock_tube boundary_conditions = BoundaryConditionDirichlet(initial_condition) surface_flux = flux_lax_friedrichs -volume_flux = flux_hindenlang_gassner +volume_flux = flux_hindenlang_gassner basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.8, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.8, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -82,44 +75,45 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level=6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl index a1636c08478..573bf6bc3e9 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_convergence.jl @@ -5,23 +5,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (5 / 3, 5 / 3, 5 / 3), - gas_constants = (2.08, 2.08, 2.08)) +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (5/3, 5/3, 5/3), + gas_constants = (2.08, 2.08, 2.08)) initial_condition = initial_condition_convergence_test volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,18 +33,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 0.5 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -50,10 +51,11 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl index 71466f3138a..69ea0551bed 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_ec.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), gas_constants = (2.0, 2.0, 2.0)) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg = 3, surface_flux = flux_hindenlang_gassner, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_hindenlang_gassner, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,25 +32,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl b/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl index 37623e048ed..93cf3e0fdb2 100644 --- a/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl +++ b/examples/tree_1d_dgsem/elixir_mhdmulti_es.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), +equations = IdealGlmMhdMulticomponentEquations1D(gammas = (2.0, 2.0, 2.0), gas_constants = (2.0, 2.0, 2.0)) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_hindenlang_gassner -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,28 +32,29 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl b/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl index a3df37fb966..1469afec1ca 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_ec.jl @@ -6,7 +6,7 @@ using Trixi # Semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations1D(gravity_constant = 9.81) +equations = ShallowWaterEquations1D(gravity_constant=9.81) # Initial condition with a truly discontinuous water height, velocity, and bottom # topography function as an academic testcase for entropy conservation. @@ -16,23 +16,23 @@ equations = ShallowWaterEquations1D(gravity_constant = 9.81) # 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_discontinuous_bottom(x, t, equations::ShallowWaterEquations1D) - # Set the background values - H = 4.25 - v = 0.0 - b = sin(x[1]) # arbitrary continuous function - - # Setup the discontinuous water height and velocity - if x[1] >= 0.125 && x[1] <= 0.25 - H = 5.0 - v = 0.1882 - end - - # Setup a discontinuous bottom topography - if x[1] >= -0.25 && x[1] <= -0.125 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) - end - - return prim2cons(SVector(H, v, b), equations) + # Set the background values + H = 4.25 + v = 0.0 + b = sin(x[1]) # arbitrary continuous function + + # Setup the discontinuous water height and velocity + if x[1] >= 0.125 && x[1] <= 0.25 + H = 5.0 + v = 0.1882 + end + + # Setup a discontinuous bottom topography + if x[1] >= -0.25 && x[1] <= -0.125 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + end + + return prim2cons(SVector(H, v, b), equations) end initial_condition = initial_condition_ec_discontinuous_bottom @@ -41,9 +41,8 @@ initial_condition = initial_condition_ec_discontinuous_bottom # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 4, - surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -51,8 +50,8 @@ solver = DGSEM(polydeg = 4, coordinates_min = -1.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -69,15 +68,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -85,7 +84,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl b/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl index 6ef697b0b89..62346d7b5ab 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_shock_capturing.jl @@ -5,38 +5,36 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant = 9.812, H0 = 1.75) +equations = ShallowWaterEquations1D(gravity_constant=9.812, H0=1.75) # Initial condition with a truly discontinuous velocity and bottom topography. # Works as intended for TreeMesh1D with `initial_refinement_level=3`. 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_stone_throw_discontinuous_bottom(x, t, - equations::ShallowWaterEquations1D) +function initial_condition_stone_throw_discontinuous_bottom(x, t, equations::ShallowWaterEquations1D) - # Calculate primitive variables + # Calculate primitive variables - # flat lake - H = equations.H0 + # flat lake + H = equations.H0 - # Discontinuous velocity - v = 0.0 - if x[1] >= -0.75 && x[1] <= 0.0 - v = -1.0 - elseif x[1] >= 0.0 && x[1] <= 0.75 - v = 1.0 - end + # Discontinuous velocity + v = 0.0 + if x[1] >= -0.75 && x[1] <= 0.0 + v = -1.0 + elseif x[1] >= 0.0 && x[1] <= 0.75 + v = 1.0 + end - b = (1.5 / exp(0.5 * ((x[1] - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) + b = ( 1.5 / exp( 0.5 * ((x[1] - 1.0)^2 ) ) + + 0.75 / exp( 0.5 * ((x[1] + 1.0)^2 ) ) ) - # Force a discontinuous bottom topography - if x[1] >= -1.5 && x[1] <= 0.0 - b = 0.5 - end + # Force a discontinuous bottom topography + if x[1] >= -1.5 && x[1] <= 0.0 + b = 0.5 + end - return prim2cons(SVector(H, v, b), equations) + return prim2cons(SVector(H, v, b), equations) end initial_condition = initial_condition_stone_throw_discontinuous_bottom @@ -47,19 +45,18 @@ boundary_condition = boundary_condition_slip_wall # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, - hydrostatic_reconstruction_audusse_etal), +surface_flux = (FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal) basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = waterheight_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=waterheight_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) @@ -69,9 +66,9 @@ solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = -3.0 coordinates_max = 3.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, @@ -89,29 +86,28 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (energy_kinetic, - energy_internal, - lake_at_rest_error)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(energy_kinetic, + energy_internal, + lake_at_rest_error)) # Enable in-situ visualization with a new plot generated every 50 time steps # and we explicitly pass that the plot data will be one-dimensional # visualization = VisualizationCallback(interval=50, plot_data_creator=PlotData1D) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)#, -# visualization) + # visualization) ############################################################################### # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-7, reltol=1.0e-7, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl index af596a377f8..2f9f93f4335 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,17 +5,17 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant = 9.81) +equations = ShallowWaterEquations1D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test + ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -23,13 +23,13 @@ solver = DGSEM(polydeg = 3, coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,13 +40,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -54,6 +54,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl index cbc98a30f9f..c8ef1c1b70b 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant = 9.81) +equations = ShallowWaterEquations1D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test @@ -16,8 +16,8 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 3, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -25,14 +25,14 @@ solver = DGSEM(polydeg = 3, surface_flux = surface_flux, coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions = boundary_condition, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -43,13 +43,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -57,6 +57,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl index fc76b4f034b..e9f444aed27 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_convergence.jl @@ -5,18 +5,18 @@ using Trixi ############################################################################### # Semidiscretization of the two-layer shallow water equations -equations = ShallowWaterTwoLayerEquations1D(gravity_constant = 10.0, rho_upper = 0.9, - rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations1D(gravity_constant=10.0, rho_upper=0.9, rho_lower=1.0) initial_condition = initial_condition_convergence_test + ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -24,13 +24,13 @@ solver = DGSEM(polydeg = 3, coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -41,13 +41,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 500, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=500, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -55,6 +55,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-8, reltol = 1.0e-8, - save_everystep = false, callback = callbacks); + sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, + save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl index b2e6a81401b..60770d158fa 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_dam_break.jl @@ -6,29 +6,28 @@ using Trixi # Semidiscretization of the two-layer shallow water equations for a dam break # test with a discontinuous bottom topography function to test entropy conservation -equations = ShallowWaterTwoLayerEquations1D(gravity_constant = 9.81, H0 = 2.0, - rho_upper = 0.9, rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations1D(gravity_constant=9.81, H0=2.0, rho_upper=0.9, rho_lower=1.0) # Initial condition of a dam break with a discontinuous water heights and bottom topography. # Works as intended for TreeMesh1D with `initial_refinement_level=5`. 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_dam_break(x, t, equations::ShallowWaterTwoLayerEquations1D) - v1_upper = 0.0 - v1_lower = 0.0 - - # Set the discontinuity - if x[1] <= 10.0 - H_lower = 2.0 - H_upper = 4.0 - b = 0.0 - else - H_lower = 1.5 - H_upper = 3.0 - b = 0.5 - end - - return prim2cons(SVector(H_upper, v1_upper, H_lower, v1_lower, b), equations) + v1_upper = 0.0 + v1_lower = 0.0 + + # Set the discontinuity + if x[1] <= 10.0 + H_lower = 2.0 + H_upper = 4.0 + b = 0.0 + else + H_lower = 1.5 + H_upper = 3.0 + b = 0.5 + end + + return prim2cons(SVector(H_upper, v1_upper, H_lower, v1_lower, b), equations) end initial_condition = initial_condition_dam_break @@ -37,9 +36,8 @@ initial_condition = initial_condition_dam_break # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a non-periodic mesh @@ -47,20 +45,20 @@ solver = DGSEM(polydeg = 3, coordinates_min = 0.0 coordinates_max = 20.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10000, - periodicity = false) + initial_refinement_level=5, + n_cells_max=10000, + periodicity=false) boundary_condition = boundary_condition_slip_wall # create the semidiscretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_condition) + boundary_conditions=boundary_condition) ############################################################################### # ODE solvers -tspan = (0.0, 0.4) +tspan = (0.0,0.4) ode = semidiscretize(semi, tspan) ############################################################################### @@ -69,19 +67,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal,)) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 500, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=500, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -89,6 +84,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-8, reltol = 1.0e-8, - save_everystep = false, callback = callbacks); -summary_callback() # print the timer summary +sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, + save_everystep=false, callback=callbacks); +summary_callback() # print the timer summary \ No newline at end of file diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl index 7236f1697d0..bec0b8ab69c 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl @@ -5,8 +5,7 @@ using Trixi ############################################################################### # Semidiscretization of the two-layer shallow water equations to test well-balancedness -equations = ShallowWaterTwoLayerEquations1D(gravity_constant = 1.0, H0 = 0.6, - rho_upper = 0.9, rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations1D(gravity_constant=1.0, H0=0.6, rho_upper=0.9, rho_lower=1.0) """ initial_condition_fjordholm_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations1D) @@ -16,8 +15,7 @@ Initial condition to test well balanced with a bottom topography from Fjordholm Energy conservative and stable schemes for the two-layer shallow water equations. [DOI: 10.1142/9789814417099_0039](https://doi.org/10.1142/9789814417099_0039) """ -function initial_condition_fjordholm_well_balanced(x, t, - equations::ShallowWaterTwoLayerEquations1D) +function initial_condition_fjordholm_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations1D) inicenter = 0.5 x_norm = x[1] - inicenter r = abs(x_norm) @@ -26,9 +24,9 @@ function initial_condition_fjordholm_well_balanced(x, t, H_upper = 0.6 v1_upper = 0.0 v1_lower = 0.0 - b = r <= 0.1 ? 0.2 * (cos(10 * pi * (x[1] - 0.5)) + 1) : 0.0 + b = r <= 0.1 ? 0.2 * (cos(10 * pi * (x[1] - 0.5)) + 1) : 0.0 return prim2cons(SVector(H_upper, v1_upper, H_lower, v1_lower, b), equations) -end + end initial_condition = initial_condition_fjordholm_well_balanced @@ -36,9 +34,8 @@ initial_condition = initial_condition_fjordholm_well_balanced # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -46,9 +43,9 @@ solver = DGSEM(polydeg = 3, coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -62,17 +59,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(lake_at_rest_error,)) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -80,7 +76,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl index 649e5023f6d..e07bc04d76a 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations1D(gravity_constant = 9.81, H0 = 3.25) +equations = ShallowWaterEquations1D(gravity_constant=9.81, H0=3.25) # Setup a truly discontinuous bottom topography function for this academic # testcase of well-balancedness. The errors from the analysis callback are @@ -15,19 +15,18 @@ equations = ShallowWaterEquations1D(gravity_constant = 9.81, H0 = 3.25) # Works as intended for TreeMesh1D with `initial_refinement_level=3`. 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_discontinuous_well_balancedness(x, t, - equations::ShallowWaterEquations1D) - # Set the background values - H = equations.H0 - v = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography - if x[1] >= 0.5 && x[1] <= 0.75 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) - end - - return prim2cons(SVector(H, v, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, equations::ShallowWaterEquations1D) + # Set the background values + H = equations.H0 + v = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography + if x[1] >= 0.5 && x[1] <= 0.75 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + end + + return prim2cons(SVector(H, v, b), equations) end initial_condition = initial_condition_discontinuous_well_balancedness @@ -37,17 +36,17 @@ initial_condition = initial_condition_discontinuous_well_balancedness volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 4, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000) + initial_refinement_level=3, + n_cells_max=10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -64,16 +63,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -81,7 +80,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl index 78bdc57e548..4dff087390d 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl @@ -5,19 +5,19 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations1D(gravity_constant = 1.0, H0 = 3.0) +equations = ShallowWaterEquations1D(gravity_constant=1.0, H0=3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations1D) - # Set the background values - H = equations.H0 - v = 0.0 + # Set the background values + H = equations.H0 + v = 0.0 - b = (1.5 / exp(0.5 * ((x[1] - 1.0)^2)) + 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) + b = (1.5 / exp( 0.5 * ((x[1] - 1.0)^2))+ 0.75 / exp(0.5 * ((x[1] + 1.0)^2))) - return prim2cons(SVector(H, v, b), equations) + return prim2cons(SVector(H, v, b), equations) end - + initial_condition = initial_condition_well_balancedness boundary_condition = BoundaryConditionDirichlet(initial_condition) @@ -26,10 +26,8 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 4, - surface_flux = (FluxHLL(min_max_speed_naive), - flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -37,9 +35,9 @@ solver = DGSEM(polydeg = 4, coordinates_min = 0.0 coordinates_max = sqrt(2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, @@ -54,25 +52,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, +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); +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 diff --git a/examples/tree_1d_fdsbp/elixir_burgers_basic.jl b/examples/tree_1d_fdsbp/elixir_burgers_basic.jl index c58fc497e14..c7b0176dfdc 100644 --- a/examples/tree_1d_fdsbp/elixir_burgers_basic.jl +++ b/examples/tree_1d_fdsbp/elixir_burgers_basic.jl @@ -12,23 +12,24 @@ equations = InviscidBurgersEquation1D() initial_condition = initial_condition_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 32) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=32) flux_splitting = splitting_lax_friedrichs solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = 0.0 coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000) + initial_refinement_level=3, + n_cells_max=10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,24 +40,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_errors = (:l2_error_primitive, - :linf_error_primitive)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-9, reltol = 1.0e-9, - ode_default_options()..., callback = callbacks); +sol = solve(ode, SSPRK43(); abstol=1.0e-9, reltol=1.0e-9, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl b/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl index eeaae7a7843..20508feba22 100644 --- a/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl +++ b/examples/tree_1d_fdsbp/elixir_burgers_linear_stability.jl @@ -10,28 +10,28 @@ using Trixi equations = InviscidBurgersEquation1D() function initial_condition_linear_stability(x, t, equation::InviscidBurgersEquation1D) - k = 1 - 2 + sinpi(k * (x[1] - 0.7)) |> SVector + k = 1 + 2 + sinpi(k * (x[1] - 0.7)) |> SVector end D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_lax_friedrichs solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_linear_stability, solver) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_linear_stability, - solver) ############################################################################### # ODE solvers, callbacks etc. @@ -42,18 +42,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_errors = (:l2_error_primitive, - :linf_error_primitive)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_1d_fdsbp/elixir_euler_convergence.jl b/examples/tree_1d_fdsbp/elixir_euler_convergence.jl index 7b6bfee946e..f9f9297f7c8 100644 --- a/examples/tree_1d_fdsbp/elixir_euler_convergence.jl +++ b/examples/tree_1d_fdsbp/elixir_euler_convergence.jl @@ -12,23 +12,24 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 32) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=32) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = 0.0 coordinates_max = 2.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 1, - n_cells_max = 10_000) + initial_refinement_level=1, + n_cells_max=10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,24 +40,25 @@ 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)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl b/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl index a28cd01120b..5c5192a3fbe 100644 --- a/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl +++ b/examples/tree_1d_fdsbp/elixir_euler_density_wave.jl @@ -11,23 +11,24 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_density_wave D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_coirier_vanleer solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = -1.0 -coordinates_max = 1.0 +coordinates_max = 1.0 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000) + initial_refinement_level=2, + n_cells_max=30_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -37,22 +38,23 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 10000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl b/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl index 615da951871..d34399a5576 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_convergence.jl @@ -4,25 +4,26 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global = (0.5, 0.3), c_mean_global = 2.0, - rho_mean_global = 0.9) +equations = AcousticPerturbationEquations2D(v_mean_global=(0.5, 0.3), c_mean_global=2.0, + rho_mean_global=0.9) initial_condition = initial_condition_convergence_test # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max = (2.0, 2.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=3, + 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, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -36,26 +37,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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 = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl b/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl index b3fe55dccea..fa608e78693 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_gauss.jl @@ -10,19 +10,20 @@ rho_mean_global = 1.0 equations = AcousticPerturbationEquations2D(v_mean_global, c_mean_global, rho_mean_global) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # 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 + 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_gauss, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -35,26 +36,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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 = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl b/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl index 918c0831fcd..78102eaf874 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_gauss_wall.jl @@ -4,20 +4,20 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global = (0.5, 0.0), c_mean_global = 1.0, - rho_mean_global = 1.0) +equations = AcousticPerturbationEquations2D(v_mean_global=(0.5, 0.0), c_mean_global=1.0, + rho_mean_global=1.0) # Create DG solver with polynomial degree = 5 and (local) Lax-Friedrichs/Rusanov flux as surface flux -solver = DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=5, surface_flux=flux_lax_friedrichs) coordinates_min = (-100.0, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max = (100.0, 200.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 100_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=100_000, + periodicity=false) """ initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D) @@ -26,19 +26,20 @@ A Gaussian pulse, used in the `gauss_wall` example elixir in combination with [`boundary_condition_wall`](@ref). Uses the global mean values from `equations`. """ function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D) - v1_prime = 0.0 - v2_prime = 0.0 - p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) + v1_prime = 0.0 + v2_prime = 0.0 + p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) - prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) + prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) - return prim2cons(prim, equations) + return prim2cons(prim, equations) end initial_condition = initial_condition_gauss_wall # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_condition_wall) + boundary_conditions=boundary_condition_wall) + ############################################################################### # ODE solvers, callbacks etc. @@ -52,25 +53,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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 = cons2state) +save_solution = SaveSolutionCallback(interval=100, solution_variables=cons2state) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 0.7) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks) +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) # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl b/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl index 71d4f1a9f68..0a0e2520581 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_gaussian_source.jl @@ -3,45 +3,45 @@ using Trixi # Oscillating Gaussian-shaped source terms function source_terms_gauss(u, x, t, equations::AcousticPerturbationEquations2D) - r = 0.1 - A = 1.0 - f = 2.0 + r = 0.1 + A = 1.0 + f = 2.0 - # Velocity sources - s1 = 0.0 - s2 = 0.0 - # Pressure source - s3 = exp(-(x[1]^2 + x[2]^2) / (2 * r^2)) * A * sin(2 * pi * f * t) + # Velocity sources + s1 = 0.0 + s2 = 0.0 + # Pressure source + s3 = exp(-(x[1]^2 + x[2]^2) / (2 * r^2)) * A * sin(2 * pi * f * t) - # Mean sources - s4 = s5 = s6 = s7 = 0.0 + # Mean sources + s4 = s5 = s6 = s7 = 0.0 - return SVector(s1, s2, s3, s4, s5, s6, s7) + return SVector(s1, s2, s3, s4, s5, s6, s7) end ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global = (-0.5, 0.25), - c_mean_global = 1.0, - rho_mean_global = 1.0) +equations = AcousticPerturbationEquations2D(v_mean_global=(-0.5, 0.25), c_mean_global=1.0, + rho_mean_global=1.0) initial_condition = initial_condition_constant # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-3.0, -3.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (3.0, 3.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 3.0, 3.0) # maximum coordinates (max(x), max(y)) # 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 + 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, solver, - source_terms = source_terms_gauss) + source_terms=source_terms_gauss) + ############################################################################### # ODE solvers, callbacks etc. @@ -55,29 +55,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +save_solution = SaveSolutionCallback(interval=100, + solution_variables=cons2prim) # The TimeSeriesCallback records the solution at the given points over time time_series = TimeSeriesCallback(semi, [(0.0, 0.0), (-1.0, 0.5)]) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) # 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, time_series, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl b/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl index d7265775114..0fdcbd22c44 100644 --- a/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl +++ b/examples/tree_2d_dgsem/elixir_acoustics_monopole.jl @@ -4,11 +4,11 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global = (0.0, 0.0), c_mean_global = 0.0, - rho_mean_global = 0.0) +equations = AcousticPerturbationEquations2D(v_mean_global=(0.0, 0.0), c_mean_global=0.0, + rho_mean_global=0.0) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-20.6, 0.0) # minimum coordinates (min(x), min(y)) coordinates_max = (30.6, 51.2) # maximum coordinates (max(x), max(y)) @@ -20,20 +20,20 @@ Initial condition for the monopole in a boundary layer setup, used in combinatio [`boundary_condition_monopole`](@ref). """ function initial_condition_monopole(x, t, equations::AcousticPerturbationEquations2D) - m = 0.3 # Mach number + m = 0.3 # Mach number - v1_prime = 0.0 - v2_prime = 0.0 - p_prime = 0.0 + v1_prime = 0.0 + v2_prime = 0.0 + p_prime = 0.0 - v1_mean = x[2] > 1 ? m : m * (2 * x[2] - 2 * x[2]^2 + x[2]^4) - v2_mean = 0.0 - c_mean = 1.0 - rho_mean = 1.0 + v1_mean = x[2] > 1 ? m : m * (2*x[2] - 2*x[2]^2 + x[2]^4) + v2_mean = 0.0 + c_mean = 1.0 + rho_mean = 1.0 - prim = SVector(v1_prime, v2_prime, p_prime, v1_mean, v2_mean, c_mean, rho_mean) + prim = SVector(v1_prime, v2_prime, p_prime, v1_mean, v2_mean, c_mean, rho_mean) - return prim2cons(prim, equations) + return prim2cons(prim, equations) end initial_condition = initial_condition_monopole # does not use the global mean values given above @@ -45,35 +45,32 @@ Boundary condition for a monopole in a boundary layer at the -y boundary, i.e. ` This will return an error for any other direction. This boundary condition is used in combination with [`initial_condition_monopole`](@ref). """ -function boundary_condition_monopole(u_inner, orientation, direction, x, t, - surface_flux_function, +function boundary_condition_monopole(u_inner, orientation, direction, x, t, surface_flux_function, equations::AcousticPerturbationEquations2D) - if direction != 3 - error("expected direction = 3, got $direction instead") - end - - # Wall at the boundary in -y direction with a monopole at -0.05 <= x <= 0.05. In the monopole area - # we use a sinusoidal boundary state for the perturbed variables. For the rest of the -y boundary - # we set the boundary state to the inner state and multiply the perturbed velocity in the - # y-direction by -1. - if -0.05 <= x[1] <= 0.05 # Monopole - v1_prime = 0.0 - v2_prime = p_prime = sin(2 * pi * t) - - prim_boundary = SVector(v1_prime, v2_prime, p_prime, u_inner[4], u_inner[5], - u_inner[6], u_inner[7]) - - u_boundary = prim2cons(prim_boundary, equations) - else # Wall - u_boundary = SVector(u_inner[1], -u_inner[2], u_inner[3], u_inner[4], u_inner[5], - u_inner[6], - u_inner[7]) - end - - # Calculate boundary flux - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + if direction != 3 + error("expected direction = 3, got $direction instead") + end + + # Wall at the boundary in -y direction with a monopole at -0.05 <= x <= 0.05. In the monopole area + # we use a sinusoidal boundary state for the perturbed variables. For the rest of the -y boundary + # we set the boundary state to the inner state and multiply the perturbed velocity in the + # y-direction by -1. + if -0.05 <= x[1] <= 0.05 # Monopole + v1_prime = 0.0 + v2_prime = p_prime = sin(2 * pi * t) + + prim_boundary = SVector(v1_prime, v2_prime, p_prime, u_inner[4], u_inner[5], u_inner[6], u_inner[7]) - return flux + u_boundary = prim2cons(prim_boundary, equations) + else # Wall + u_boundary = SVector(u_inner[1], -u_inner[2], u_inner[3], u_inner[4], u_inner[5], u_inner[6], + u_inner[7]) + end + + # Calculate boundary flux + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + + return flux end """ @@ -83,42 +80,42 @@ end Boundary condition that uses a boundary state where the state variables are zero and the mean variables are the same as in `u_inner`. """ -function boundary_condition_zero(u_inner, orientation, direction, x, t, - surface_flux_function, +function boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function, equations::AcousticPerturbationEquations2D) - value = zero(eltype(u_inner)) - u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) + value = zero(eltype(u_inner)) + u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end - return flux + return flux end -boundary_conditions = (x_neg = boundary_condition_zero, - x_pos = boundary_condition_zero, - y_neg = boundary_condition_monopole, - y_pos = boundary_condition_zero) +boundary_conditions = (x_neg=boundary_condition_zero, + x_pos=boundary_condition_zero, + y_neg=boundary_condition_monopole, + y_pos=boundary_condition_zero) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 100_000, - periodicity = false) + initial_refinement_level=6, + n_cells_max=100_000, + periodicity=false) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. # Create ODE problem with time span from 0.0 to 24.0 -tspan = (0.0, 24.0) +tspan = (0.0, 24.0) ode = semidiscretize(semi, tspan) # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup @@ -126,25 +123,24 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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 = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks) +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) # Print the timer summary -summary_callback() +summary_callback() \ No newline at end of file diff --git a/examples/tree_2d_dgsem/elixir_advection_amr.jl b/examples/tree_2d_dgsem/elixir_advection_amr.jl index c3f971d2ffc..84841877448 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr.jl @@ -9,16 +9,18 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,36 +30,37 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +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 = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl b/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl index aa042e7500e..897d3569e10 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_coarsen_twice.jl @@ -3,6 +3,7 @@ using OrdinaryDiffEq using Trixi + # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -10,27 +11,27 @@ module TrixiExtensionCoarsen using Trixi -struct IndicatorAlwaysCoarsen{Cache <: NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorAlwaysCoarsen{Cache<:NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorAlwaysCoarsen(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) - return IndicatorAlwaysCoarsen{typeof(cache)}(cache) + return IndicatorAlwaysCoarsen{typeof(cache)}(cache) end -function (indicator::IndicatorAlwaysCoarsen)(u::AbstractArray{<:Any, 4}, +function (indicator::IndicatorAlwaysCoarsen)(u::AbstractArray{<:Any,4}, mesh, equations, dg, cache; t, kwargs...) - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) - alpha .= -1.0 + alpha .= -1.0 - return alpha + return alpha end end # module TrixiExtensionCoarsen @@ -45,16 +46,18 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -64,37 +67,37 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_controller = ControllerThreeLevel(semi, - TrixiExtensionCoarsen.IndicatorAlwaysCoarsen(semi), - base_level = 2, max_level = 2, - med_threshold = 0.1, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, TrixiExtensionCoarsen.IndicatorAlwaysCoarsen(semi), + base_level=2, max_level=2, + med_threshold=0.1, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl index abb8a5035be..42aee985889 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_nonperiodic.jl @@ -14,17 +14,19 @@ initial_condition = initial_condition_gauss # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=30_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -35,26 +37,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +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 = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -63,7 +65,7 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = stepsize_callback(ode), # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), + dt=stepsize_callback(ode), # 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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl b/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl index 7b441775204..e69cab29bb6 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_refine_twice.jl @@ -3,6 +3,7 @@ using OrdinaryDiffEq using Trixi + # Define new structs inside a module to allow re-evaluating the file. # This module name needs to be unique among all examples, otherwise Julia will throw warnings # if multiple test cases using the same module name are run in the same session. @@ -10,27 +11,27 @@ module TrixiExtensionRefine using Trixi -struct IndicatorAlwaysRefine{Cache <: NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorAlwaysRefine{Cache<:NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorAlwaysRefine(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) - return IndicatorAlwaysRefine{typeof(cache)}(cache) + return IndicatorAlwaysRefine{typeof(cache)}(cache) end -function (indicator::IndicatorAlwaysRefine)(u::AbstractArray{<:Any, 4}, +function (indicator::IndicatorAlwaysRefine)(u::AbstractArray{<:Any,4}, mesh, equations, dg, cache; t, kwargs...) - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) - alpha .= 1.0 + alpha .= 1.0 - return alpha + return alpha end end # module TrixiExtensionRefine @@ -45,16 +46,18 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000) + initial_refinement_level=2, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -64,37 +67,37 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_controller = ControllerThreeLevel(semi, - TrixiExtensionRefine.IndicatorAlwaysRefine(semi), - base_level = 4, max_level = 4, - med_threshold = 0.1, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, TrixiExtensionRefine.IndicatorAlwaysRefine(semi), + base_level=4, max_level=4, + med_threshold=0.1, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl b/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl index 03a213689ec..efd282dab1f 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_solution_independent.jl @@ -7,68 +7,69 @@ module TrixiExtension using Trixi -struct IndicatorSolutionIndependent{Cache <: NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorSolutionIndependent{Cache<:NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorSolutionIndependent(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) - return IndicatorSolutionIndependent{typeof(cache)}(cache) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) + return IndicatorSolutionIndependent{typeof(cache)}(cache) end -function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any, 4}, +function (indicator::IndicatorSolutionIndependent)(u::AbstractArray{<:Any,4}, mesh, equations, dg, cache; t, kwargs...) - mesh = indicator.cache.mesh - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) - - #Predict the theoretical center. - advection_velocity = (0.2, -0.7) - center = t .* advection_velocity - - inner_distance = 1 - outer_distance = 1.85 - - #Iterate over all elements - for element in 1:length(alpha) - #Calculate periodic distance between cell and center. - cell_id = cache.elements.cell_ids[element] - coordinates = mesh.tree.coordinates[1:2, cell_id] - - #The geometric shape of the amr should be preserved when the base_level is increased. - #This is done by looking at the original coordinates of each cell. - cell_coordinates = original_coordinates(coordinates, 5 / 8) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) - if cell_distance < (inner_distance + outer_distance) / 2 - cell_coordinates = original_coordinates(coordinates, 5 / 16) - cell_distance = periodic_distance_2d(cell_coordinates, center, 10) - end - - #Set alpha according to cells position inside the circles. - target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) - alpha[element] = target_level / 2 + + mesh = indicator.cache.mesh + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) + + #Predict the theoretical center. + advection_velocity = (0.2, -0.7) + center = t.*advection_velocity + + inner_distance = 1 + outer_distance = 1.85 + + #Iterate over all elements + for element in 1:length(alpha) + #Calculate periodic distance between cell and center. + cell_id = cache.elements.cell_ids[element] + coordinates = mesh.tree.coordinates[1:2, cell_id] + + #The geometric shape of the amr should be preserved when the base_level is increased. + #This is done by looking at the original coordinates of each cell. + cell_coordinates = original_coordinates(coordinates, 5/8) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) + if cell_distance < (inner_distance+outer_distance)/2 + cell_coordinates = original_coordinates(coordinates, 5/16) + cell_distance = periodic_distance_2d(cell_coordinates, center, 10) end - return alpha + + #Set alpha according to cells position inside the circles. + target_level = (cell_distance < inner_distance) + (cell_distance < outer_distance) + alpha[element] = target_level/2 + end + return alpha end # For periodic domains, distance between two points must take into account # periodic extensions of the domain function periodic_distance_2d(coordinates, center, domain_length) - dx = coordinates .- center - dx_shifted = abs.(dx .% domain_length) - dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) - return sqrt(sum(dx_periodic .^ 2)) + dx = coordinates .- center + dx_shifted = abs.(dx .% domain_length) + dx_periodic = min.(dx_shifted, domain_length .- dx_shifted) + return sqrt(sum(dx_periodic.^2)) end #This takes a cells coordinates and transforms them into the coordinates of a parent-cell it originally refined from. #It does it so that the parent-cell has given cell_length. function original_coordinates(coordinates, cell_length) - offset = coordinates .% cell_length - offset_sign = sign.(offset) - border = coordinates - offset - center = border + (offset_sign .* cell_length / 2) - return center + offset = coordinates .% cell_length + offset_sign = sign.(offset) + border = coordinates - offset + center = border + (offset_sign .* cell_length/2) + return center end end # module TrixiExtension @@ -82,16 +83,18 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -101,38 +104,38 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_controller = ControllerThreeLevel(semi, - TrixiExtension.IndicatorSolutionIndependent(semi), - base_level = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, TrixiExtension.IndicatorSolutionIndependent(semi), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl b/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl index 7b67b811177..f517b4eb1cf 100644 --- a/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl +++ b/examples/tree_2d_dgsem/elixir_advection_amr_visualization.jl @@ -9,26 +9,27 @@ using Plots advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) -function initial_condition_gauss_largedomain(x, t, - equation::LinearScalarAdvectionEquation2D) - # Store translated coordinate for easy use of exact solution - domain_length = SVector(10, 10) - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t, domain_length) +function initial_condition_gauss_largedomain(x, t, equation::LinearScalarAdvectionEquation2D) + # Store translated coordinate for easy use of exact solution + domain_length = SVector(10, 10) + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t, domain_length) - return SVector(exp(-(x_trans[1]^2 + x_trans[2]^2))) + return SVector(exp(-(x_trans[1]^2 + x_trans[2]^2))) end initial_condition = initial_condition_gauss_largedomain -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -38,40 +39,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # Enable in-situ visualization with a new plot generated every 20 time steps # and additional plotting options passed as keyword arguments -visualization = VisualizationCallback(interval = 20, clims = (0, 1)) +visualization = VisualizationCallback(interval=20, clims=(0,1)) -amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), - base_level = 3, - med_level = 4, med_threshold = 0.1, - max_level = 5, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=3, + med_level=4, med_threshold=0.1, + max_level=5, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, visualization, 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_basic.jl b/examples/tree_2d_dgsem/elixir_advection_basic.jl index 0ec0bc3629a..269ab8cdd04 100644 --- a/examples/tree_2d_dgsem/elixir_advection_basic.jl +++ b/examples/tree_2d_dgsem/elixir_advection_basic.jl @@ -9,19 +9,19 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # 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 + 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) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -34,26 +34,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_callbacks.jl b/examples/tree_2d_dgsem/elixir_advection_callbacks.jl index 708cd0aa3a3..2ddd3e92ed2 100644 --- a/examples/tree_2d_dgsem/elixir_advection_callbacks.jl +++ b/examples/tree_2d_dgsem/elixir_advection_callbacks.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + # define new structs inside a module to allow re-evaluating the file module TrixiExtensionExample @@ -13,81 +14,83 @@ using OrdinaryDiffEq: DiscreteCallback, u_modified! # each time it is called. Its sole purpose here is to showcase how to implement # a stage callback for Trixi.jl. struct ExampleStageCallback - times::Vector{Float64} - min_values::Vector{Float64} - max_values::Vector{Float64} - - # You can optionally define an inner constructor like the one below to set up - # some required stuff. You can also create outer constructors (not demonstrated - # here) for further customization options. - function ExampleStageCallback() - new(Float64[], Float64[], Float64[]) - end + times::Vector{Float64} + min_values::Vector{Float64} + max_values::Vector{Float64} + + # You can optionally define an inner constructor like the one below to set up + # some required stuff. You can also create outer constructors (not demonstrated + # here) for further customization options. + function ExampleStageCallback() + new(Float64[], Float64[], Float64[]) + end end # This method is called when the `ExampleStageCallback` is used as `stage_limiter!` # which gets called after every RK stage. There is no specific initialization # method for such `stage_limiter!`s in OrdinaryDiffEq.jl. function (example_stage_callback::ExampleStageCallback)(u_ode, _, semi, t) - min_val, max_val = extrema(u_ode) - push!(example_stage_callback.times, t) - push!(example_stage_callback.min_values, min_val) - push!(example_stage_callback.max_values, max_val) - return nothing + min_val, max_val = extrema(u_ode) + push!(example_stage_callback.times, t) + push!(example_stage_callback.min_values, min_val) + push!(example_stage_callback.max_values, max_val) + + return nothing end + # This is an example implementation for a simple step callback (i.e., a callable # that is potentially executed after each Runge-Kutta *step*), which records # some values each time it is called. Its sole purpose here is to showcase # how to implement a step callback for Trixi.jl. struct ExampleStepCallback - message::String - times::Vector{Float64} - min_values::Vector{Float64} - max_values::Vector{Float64} - - # You can optionally define an inner constructor like the one below to set up - # some required stuff. You can also create outer constructors (not demonstrated - # here) for further customization options. - function ExampleStepCallback(message::String) - new(message, Float64[], Float64[], Float64[]) - end + message::String + times::Vector{Float64} + min_values::Vector{Float64} + max_values::Vector{Float64} + + # You can optionally define an inner constructor like the one below to set up + # some required stuff. You can also create outer constructors (not demonstrated + # here) for further customization options. + function ExampleStepCallback(message::String) + new(message, Float64[], Float64[], Float64[]) + end end # This method is called when the `ExampleStepCallback` is used as callback # which gets called after RK steps. function (example_callback::ExampleStepCallback)(integrator) - u_ode = integrator.u - t = integrator.t - # You can also access semi = integrator.p - - min_val, max_val = extrema(u_ode) - push!(example_callback.times, t) - push!(example_callback.min_values, min_val) - push!(example_callback.max_values, max_val) - - # avoid re-evaluating possible FSAL stages - u_modified!(integrator, false) - return nothing + u_ode = integrator.u + t = integrator.t + # You can also access semi = integrator.p + + min_val, max_val = extrema(u_ode) + push!(example_callback.times, t) + push!(example_callback.min_values, min_val) + push!(example_callback.max_values, max_val) + + # avoid re-evaluating possible FSAL stages + u_modified!(integrator, false) + return nothing end # This method is used to wrap an `ExampleStepCallback` inside a `DiscreteCallback` # which gets called after every RK step. You can pass an additional initialization # method and a separate condition specifying whether the callback shall be called. function ExampleStepCallback(; message::String) - # Call the `ExampleStepCallback` after every RK step. - condition = (u_ode, t, integrator) -> true + # Call the `ExampleStepCallback` after every RK step. + condition = (u_ode, t, integrator) -> true - # You can optionally pass an initialization method. There, you can access the - # `ExampleStepCallback` as `cb.affect!`. - initialize = (cb, u_ode, t, integrator) -> println(cb.affect!.message) + # You can optionally pass an initialization method. There, you can access the + # `ExampleStepCallback` as `cb.affect!`. + initialize = (cb, u_ode, t, integrator) -> println(cb.affect!.message) - example_callback = ExampleStepCallback(message) + example_callback = ExampleStepCallback(message) - DiscreteCallback(condition, example_callback, - save_positions = (false, false), - initialize = initialize) + DiscreteCallback(condition, example_callback, + save_positions=(false,false), + initialize=initialize) end end # module TrixiExtensionExample @@ -101,16 +104,18 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -120,19 +125,19 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) -alive_callback = AliveCallback(analysis_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 = cons2cons) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2cons) -example_callback = TrixiExtensionExample.ExampleStepCallback(message = "안녕하세요?") +example_callback = TrixiExtensionExample.ExampleStepCallback(message="안녕하세요?") -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -153,10 +158,9 @@ example_stage_callback! = TrixiExtensionExample.ExampleStageCallback() ############################################################################### # run the simulation -sol = solve(ode, - CarpenterKennedy2N54(example_stage_callback!, 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); +sol = solve(ode, CarpenterKennedy2N54(example_stage_callback!, 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 # Check whether we recorded the same values. diff --git a/examples/tree_2d_dgsem/elixir_advection_diffusion.jl b/examples/tree_2d_dgsem/elixir_advection_diffusion.jl index dc85775bec4..e96e1b5a171 100644 --- a/examples/tree_2d_dgsem/elixir_advection_diffusion.jl +++ b/examples/tree_2d_dgsem/elixir_advection_diffusion.jl @@ -10,31 +10,30 @@ diffusivity() = 5.0e-2 equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = true, - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=4, + periodicity=true, + n_cells_max=30_000) # set maximum capacity of tree data structure # Define initial condition -function initial_condition_diffusive_convergence_test(x, t, - equation::LinearScalarAdvectionEquation2D) - # 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) +function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation2D) + # 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 @@ -46,8 +45,9 @@ boundary_conditions_parabolic = boundary_condition_periodic semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic)) + boundary_conditions=(boundary_conditions, + boundary_conditions_parabolic)) + ############################################################################### # ODE solvers, callbacks etc. @@ -62,21 +62,22 @@ 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) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl index 8da542b0b5d..c3cd2ebeb20 100644 --- a/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_advection_diffusion_nonperiodic.jl @@ -10,16 +10,16 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -0.5) # minimum coordinates (min(x), min(y)) -coordinates_max = (0.0, 0.5) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 0.0, 0.5) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = false, - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=4, + periodicity=false, + n_cells_max=30_000) # set maximum capacity of tree data structure # Example setup taken from # - Truman Ellis, Jesse Chan, and Leszek Demkowicz (2016). @@ -28,22 +28,22 @@ mesh = TreeMesh(coordinates_min, coordinates_max, # to numerical partial differential equations. # [DOI](https://doi.org/10.1007/978-3-319-41640-3_6). function initial_condition_eriksson_johnson(x, t, equations) - l = 4 - epsilon = diffusivity() # TODO: this requires epsilon < .6 due to sqrt - lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) - r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) - u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + - cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) - return SVector{1}(u) + l = 4 + epsilon = diffusivity() # TODO: this requires epsilon < .6 due to sqrt + lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon) + r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon) + u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) + + cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1)) + return SVector{1}(u) end initial_condition = initial_condition_eriksson_johnson boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition), - y_neg = BoundaryConditionDirichlet(initial_condition), - y_pos = BoundaryConditionDirichlet(initial_condition), - x_pos = boundary_condition_do_nothing) + y_neg = BoundaryConditionDirichlet(initial_condition), + y_pos = BoundaryConditionDirichlet(initial_condition), + x_pos = boundary_condition_do_nothing) boundary_conditions_parabolic = BoundaryConditionDirichlet(initial_condition) @@ -51,8 +51,9 @@ boundary_conditions_parabolic = BoundaryConditionDirichlet(initial_condition) semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic)) + boundary_conditions=(boundary_conditions, + boundary_conditions_parabolic)) + ############################################################################### # ODE solvers, callbacks etc. @@ -67,21 +68,22 @@ 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) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks time_int_tol = 1.0e-11 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_extended.jl b/examples/tree_2d_dgsem/elixir_advection_extended.jl index 41321ede5a7..8c837957ffd 100644 --- a/examples/tree_2d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_2d_dgsem/elixir_advection_extended.jl @@ -18,20 +18,21 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # 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 - periodicity = true) + initial_refinement_level=4, + n_cells_max=30_000, # set maximum capacity of tree data structure + periodicity=true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -46,24 +47,24 @@ 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, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.6) +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, @@ -71,13 +72,14 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_2d_dgsem/elixir_advection_mortar.jl b/examples/tree_2d_dgsem/elixir_advection_mortar.jl index 645c55ba438..2a283fb9008 100644 --- a/examples/tree_2d_dgsem/elixir_advection_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_advection_mortar.jl @@ -9,19 +9,22 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) -refinement_patches = ((type = "box", coordinates_min = (0.0, -1.0), - coordinates_max = (1.0, 1.0)),) +coordinates_max = ( 1.0, 1.0) +refinement_patches = ( + (type="box", coordinates_min=(0.0, -1.0), coordinates_max=(1.0, 1.0)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=2, + refinement_patches=refinement_patches, + n_cells_max=10_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,27 +34,28 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_restart.jl b/examples/tree_2d_dgsem/elixir_advection_restart.jl index bf107dc2049..2cb45c0b47e 100644 --- a/examples/tree_2d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_2d_dgsem/elixir_advection_restart.jl @@ -7,6 +7,7 @@ using Trixi trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl")) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -21,10 +22,11 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl b/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl index 06982bb9a27..be87f24f817 100644 --- a/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl +++ b/examples/tree_2d_dgsem/elixir_advection_timeintegration.jl @@ -9,16 +9,18 @@ advection_velocity = (0.2, -0.7) equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0) -coordinates_max = (5.0, 5.0) +coordinates_max = ( 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,38 +30,39 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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 = cons2cons) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2cons) -amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), - base_level = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) + ############################################################################### # run the simulation # sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), ode_algorithm = Trixi.CarpenterKennedy2N54() 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); + 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 diff --git a/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl b/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl index 1393f4a6cc8..c5790e455bc 100644 --- a/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_astro_jet_amr.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5 / 3 +gamma = 5/3 equations = CompressibleEulerEquations2D(gamma) # Initial condition adopted from @@ -13,54 +13,55 @@ equations = CompressibleEulerEquations2D(gamma) # https://tinyurl.com/c76fjtx4 # Mach = 2000 jet function initial_condition_astro_jet(x, t, equations::CompressibleEulerEquations2D) - @unpack gamma = equations - rho = 0.5 - v1 = 0 + @unpack gamma = equations + rho = 0.5 + v1 = 0 + v2 = 0 + p = 0.4127 + # add inflow for t>0 at x=-0.5 + # domain size is [-0.5,+0.5]^2 + if (t > 0) && (x[1] ≈ -0.5) && (abs(x[2]) < 0.05) + rho = 5 + v1 = 800 # about Mach number Ma = 2000 v2 = 0 p = 0.4127 - # add inflow for t>0 at x=-0.5 - # domain size is [-0.5,+0.5]^2 - if (t > 0) && (x[1] ≈ -0.5) && (abs(x[2]) < 0.05) - rho = 5 - v1 = 800 # about Mach number Ma = 2000 - v2 = 0 - p = 0.4127 - end - return prim2cons(SVector(rho, v1, v2, p), equations) + end + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_astro_jet -boundary_conditions = (x_neg = BoundaryConditionDirichlet(initial_condition_astro_jet), - x_pos = BoundaryConditionDirichlet(initial_condition_astro_jet), - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) +boundary_conditions = ( + x_neg=BoundaryConditionDirichlet(initial_condition_astro_jet), + x_pos=BoundaryConditionDirichlet(initial_condition_astro_jet), + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + ) surface_flux = flux_lax_friedrichs # HLLC needs more shock capturing (alpha_max) -volume_flux = flux_ranocha # works with Chandrashekar flux as well +volume_flux = flux_ranocha # works with Chandrashekar flux as well polydeg = 3 basis = LobattoLegendreBasis(polydeg) # shock capturing necessary for this tough example indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.3, - alpha_min = 0.0001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.3, + alpha_min=0.0001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + 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) +coordinates_max = ( 0.5, 0.5) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - periodicity = (false, true), - n_cells_max = 100_000) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + initial_refinement_level=6, + periodicity=(false,true), + n_cells_max=100_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -71,43 +72,43 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) - -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_solution = SaveSolutionCallback(interval = 5000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) - -amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0001, - alpha_smooth = false, - variable = Trixi.density) - -amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, - base_level = 2, - med_level = 0, med_threshold = 0.0003, # med_level = current level - max_level = 8, max_threshold = 0.003, - max_threshold_secondary = indicator_sc.alpha_max) - -amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=5000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) + +amr_indicator = IndicatorHennemannGassner(semi, + alpha_max=1.0, + alpha_min=0.0001, + alpha_smooth=false, + variable=Trixi.density) + +amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, + base_level=2, + med_level =0, med_threshold=0.0003, # med_level = current level + max_level =8, max_threshold=0.003, + max_threshold_secondary=indicator_sc.alpha_max) + +amr_callback = AMRCallback(semi, amr_controller, + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, + analysis_callback, alive_callback, amr_callback, save_solution) # positivity limiter necessary for this tough example -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) ############################################################################### # run the simulation # use adaptive time stepping based on error estimates, time step roughly dt = 1e-7 sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl index ccd7b54086b..0da18b7120d 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave.jl @@ -16,46 +16,48 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -65,26 +67,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl index d32c2e51b06..6ce9268486c 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_amr.jl @@ -16,46 +16,48 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -65,39 +67,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level =6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl index 79d7474dc66..659788f2f5c 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_cnn.jl @@ -2,8 +2,7 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelcnn-0.964-0.001.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelcnn-0.964-0.001.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelcnn-0.964-0.001.bson", network) model2dcnn = load(network, @__MODULE__)[:model2dcnn] using OrdinaryDiffEq @@ -29,50 +28,52 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkCNN(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = true, - alpha_amr = false, - variable = density_pressure, - network = model2dcnn) + indicator_type=NeuralNetworkCNN(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=true, + alpha_amr=false, + variable=density_pressure, + network=model2dcnn) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -82,26 +83,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl index 27398593efd..3f4862674d2 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl @@ -2,8 +2,7 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.904-0.0005.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", network) model2d = load(network, @__MODULE__)[:model2d] using OrdinaryDiffEq @@ -29,50 +28,52 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkPerssonPeraire(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = true, - alpha_amr = false, - variable = density_pressure, - network = model2d) + indicator_type=NeuralNetworkPerssonPeraire(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=true, + alpha_amr=false, + variable=density_pressure, + network=model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -82,26 +83,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl index 6c67f948636..db2fffacb36 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl @@ -3,8 +3,7 @@ using Flux using Random using BSON: load network = joinpath(@__DIR__, "modelnnrhs-0.973-0.001.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrhs-0.973-0.001.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnrhs-0.973-0.001.bson", network) model2d = load(network, @__MODULE__)[:model2d] using OrdinaryDiffEq @@ -30,52 +29,54 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkRayHesthaven(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = true, - alpha_amr = false, - variable = density_pressure, - network = model2d) + indicator_type=NeuralNetworkRayHesthaven(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=true, + alpha_amr=false, + variable=density_pressure, + network=model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) refinement_patches = () # To allow for specifying them via `trixi_include` mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=6, + refinement_patches=refinement_patches, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -85,26 +86,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl b/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl index a2392d05e5a..a0fc9349696 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blast_wave_pure_fv.jl @@ -16,38 +16,40 @@ A medium blast wave taken from [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) """ function initial_condition_blast_wave(x, t, equations::CompressibleEulerEquations2D) - # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" - # 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) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi - v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi - p = r > 0.5 ? 1.0E-3 : 1.245 - - return prim2cons(SVector(rho, v1, v2, p), equations) + # Modified From Hennemann & Gassner JCP paper 2020 (Sec. 6.3) -> "medium blast wave" + # 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) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos_phi + v2 = r > 0.5 ? 0.0 : 0.1882 * sin_phi + p = r > 0.5 ? 1.0E-3 : 1.245 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_blast_wave -surface_flux = flux_hllc +surface_flux = flux_hllc basis = LobattoLegendreBasis(3) volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 10_000) + initial_refinement_level=6, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -57,26 +59,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl b/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl index 2b3659017a3..f4040732667 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blob_amr.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5 / 3 +gamma = 5/3 equations = CompressibleEulerEquations2D(gamma) """ @@ -16,67 +16,67 @@ The blob test case taken from [arXiv: astro-ph/0610051](https://arxiv.org/abs/astro-ph/0610051) """ function initial_condition_blob(x, t, equations::CompressibleEulerEquations2D) - # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf - # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf - # change discontinuity to tanh - # typical domain is rectangular, we change it to a square - # resolution 128^2, 256^2 - # domain size is [-20.0,20.0]^2 - # gamma = 5/3 for this test case - R = 1.0 # radius of the blob - # background density - dens0 = 1.0 - Chi = 10.0 # density contrast - # reference time of characteristic growth of KH instability equal to 1.0 - tau_kh = 1.0 - tau_cr = tau_kh / 1.6 # crushing time - # determine background velocity - velx0 = 2 * R * sqrt(Chi) / tau_cr - vely0 = 0.0 - Ma0 = 2.7 # background flow Mach number Ma=v/c - c = velx0 / Ma0 # sound speed - # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density - p0 = c * c * dens0 / equations.gamma - # initial center of the blob - inicenter = [-15, 0] - x_rel = x - inicenter - r = sqrt(x_rel[1]^2 + x_rel[2]^2) - # steepness of the tanh transition zone - slope = 2 - # density blob - dens = dens0 + - (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) - # velocity blob is zero - velx = velx0 - velx0 * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) - return prim2cons(SVector(dens, velx, vely0, p0), equations) + # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf + # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf + # change discontinuity to tanh + # typical domain is rectangular, we change it to a square + # resolution 128^2, 256^2 + # domain size is [-20.0,20.0]^2 + # gamma = 5/3 for this test case + R = 1.0 # radius of the blob + # background density + dens0 = 1.0 + Chi = 10.0 # density contrast + # reference time of characteristic growth of KH instability equal to 1.0 + tau_kh = 1.0 + tau_cr = tau_kh/1.6 # crushing time + # determine background velocity + velx0 = 2*R*sqrt(Chi)/tau_cr + vely0 = 0.0 + Ma0 = 2.7 # background flow Mach number Ma=v/c + c = velx0/Ma0 # sound speed + # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density + p0 = c*c*dens0/equations.gamma + # initial center of the blob + inicenter = [-15,0] + x_rel = x-inicenter + r = sqrt(x_rel[1]^2 + x_rel[2]^2) + # steepness of the tanh transition zone + slope = 2 + # density blob + dens = dens0 + (Chi-1) * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) + # velocity blob is zero + velx = velx0 - velx0 * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) + return prim2cons(SVector(dens, velx, vely0, p0), equations) end initial_condition = initial_condition_blob surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(4) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.4, - alpha_min = 0.0001, - alpha_smooth = true, - variable = pressure) + alpha_max=0.4, + alpha_min=0.0001, + alpha_smooth=true, + variable=pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-20.0, -20.0) -coordinates_max = (20.0, 20.0) +coordinates_max = ( 20.0, 20.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 100_000) + initial_refinement_level=6, + n_cells_max=100_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -86,41 +86,42 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0001, - alpha_smooth = false, - variable = Trixi.density) + alpha_max=1.0, + alpha_min=0.0001, + alpha_smooth=false, + variable=Trixi.density) amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, - base_level = 4, - med_level = 0, med_threshold = 0.0003, # med_level = current level - max_level = 7, max_threshold = 0.003, - max_threshold_secondary = indicator_sc.alpha_max) + base_level=4, + med_level =0, med_threshold=0.0003, # med_level = current level + max_level =7, max_threshold=0.003, + max_threshold_secondary=indicator_sc.alpha_max) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.25) +stepsize_callback = StepsizeCallback(cfl=0.25) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl b/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl index 8bd5db00c9a..5b7365f860f 100644 --- a/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_euler_blob_mortar.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5 / 3 +gamma = 5/3 equations = CompressibleEulerEquations2D(gamma) """ @@ -16,71 +16,71 @@ The blob test case taken from [arXiv: astro-ph/0610051](https://arxiv.org/abs/astro-ph/0610051) """ function initial_condition_blob(x, t, equations::CompressibleEulerEquations2D) - # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf - # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf - # change discontinuity to tanh - # typical domain is rectangular, we change it to a square - # resolution 128^2, 256^2 - # domain size is [-20.0,20.0]^2 - # gamma = 5/3 for this test case - R = 1.0 # radius of the blob - # background density - dens0 = 1.0 - Chi = 10.0 # density contrast - # reference time of characteristic growth of KH instability equal to 1.0 - tau_kh = 1.0 - tau_cr = tau_kh / 1.6 # crushing time - # determine background velocity - velx0 = 2 * R * sqrt(Chi) / tau_cr - vely0 = 0.0 - Ma0 = 2.7 # background flow Mach number Ma=v/c - c = velx0 / Ma0 # sound speed - # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density - p0 = c * c * dens0 / equations.gamma - # initial center of the blob - inicenter = [-15, 0] - x_rel = x - inicenter - r = sqrt(x_rel[1]^2 + x_rel[2]^2) - # steepness of the tanh transition zone - slope = 2 - # density blob - dens = dens0 + - (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) - # velocity blob is zero - velx = velx0 - velx0 * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) - return prim2cons(SVector(dens, velx, vely0, p0), equations) + # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf + # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf + # change discontinuity to tanh + # typical domain is rectangular, we change it to a square + # resolution 128^2, 256^2 + # domain size is [-20.0,20.0]^2 + # gamma = 5/3 for this test case + R = 1.0 # radius of the blob + # background density + dens0 = 1.0 + Chi = 10.0 # density contrast + # reference time of characteristic growth of KH instability equal to 1.0 + tau_kh = 1.0 + tau_cr = tau_kh/1.6 # crushing time + # determine background velocity + velx0 = 2*R*sqrt(Chi)/tau_cr + vely0 = 0.0 + Ma0 = 2.7 # background flow Mach number Ma=v/c + c = velx0/Ma0 # sound speed + # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density + p0 = c*c*dens0/equations.gamma + # initial center of the blob + inicenter = [-15,0] + x_rel = x-inicenter + r = sqrt(x_rel[1]^2 + x_rel[2]^2) + # steepness of the tanh transition zone + slope = 2 + # density blob + dens = dens0 + (Chi-1) * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) + # velocity blob is zero + velx = velx0 - velx0 * 0.5*(1+(tanh(slope*(r+R)) - (tanh(slope*(r-R)) + 1))) + return prim2cons(SVector(dens, velx, vely0, p0), equations) end initial_condition = initial_condition_blob surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.05, - alpha_min = 0.0001, - alpha_smooth = true, - variable = pressure) + alpha_max=0.05, + alpha_min=0.0001, + alpha_smooth=true, + variable=pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-32.0, -32.0) -coordinates_max = (32.0, 32.0) -refinement_patches = ((type = "box", coordinates_min = (-40.0, -5.0), - coordinates_max = (40.0, 5.0)), - (type = "box", coordinates_min = (-40.0, -5.0), - coordinates_max = (40.0, 5.0))) +coordinates_max = ( 32.0, 32.0) +refinement_patches = ( + (type="box", coordinates_min=(-40.0, -5.0), coordinates_max=(40.0, 5.0)), + (type="box", coordinates_min=(-40.0, -5.0), coordinates_max=(40.0, 5.0)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - refinement_patches = refinement_patches, - n_cells_max = 100_000) + initial_refinement_level=4, + refinement_patches=refinement_patches, + n_cells_max=100_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -90,26 +90,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.7) +stepsize_callback = StepsizeCallback(cfl=0.7) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl b/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl index 984ac3ff1f6..cb2a5b16816 100644 --- a/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl +++ b/examples/tree_2d_dgsem/elixir_euler_colliding_flow.jl @@ -10,71 +10,71 @@ equations = CompressibleEulerEquations2D(gamma) # This is a hand made colliding flow setup without reference. Features Mach=70 inflow from both # sides, with relative low temperature, such that pressure keeps relatively small # Computed with gamma close to 1, to simulate isothermal gas -function initial_condition_colliding_flow_astro(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) - # domain size is [-64,+64]^2 - @unpack gamma = equations - # the quantities are chosen such, that they are as close as possible to the astro examples - # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) - rho = 0.0247 - c = 0.2 - p = c^2 / gamma * rho - vel = 13.907432274789372 - slope = 1.0 - v1 = -vel * tanh(slope * x[1]) - # add small initial disturbance to the field, but only close to the interface - if abs(x[1]) < 10 - v1 = v1 * (1 + 0.01 * sin(pi * x[2])) - end - v2 = 0.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_colliding_flow_astro(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) + # domain size is [-64,+64]^2 + @unpack gamma = equations + # the quantities are chosen such, that they are as close as possible to the astro examples + # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) + rho = 0.0247 + c = 0.2 + p = c^2 / gamma * rho + vel = 13.907432274789372 + slope = 1.0 + v1 = -vel*tanh(slope * x[1]) + # add small initial disturbance to the field, but only close to the interface + if abs(x[1]) < 10 + v1 = v1 * (1 + 0.01 * sin(pi * x[2])) + end + v2 = 0.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_colliding_flow_astro -boundary_conditions = (x_neg = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - x_pos = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) + +boundary_conditions = ( + x_neg=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + x_pos=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + ) + + surface_flux = flux_lax_friedrichs # HLLC needs more shock capturing (alpha_max) -volume_flux = flux_ranocha # works with Chandrashekar flux as well +volume_flux = flux_ranocha # works with Chandrashekar flux as well polydeg = 3 basis = LobattoLegendreBasis(polydeg) # shock capturing necessary for this tough example, however alpha_max = 0.5 is fine indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.0001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.0001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-64.0, -64.0) -coordinates_max = (64.0, 64.0) +coordinates_max = ( 64.0, 64.0) # only refinement in a patch. Needs x=-17/+17 to trigger refinement due to coarse base mesh -refinement_patches = ((type = "box", coordinates_min = (-17, -64), - coordinates_max = (17, 64)), - (type = "box", coordinates_min = (-17, -64), - coordinates_max = (17, 64)), - (type = "box", coordinates_min = (-17, -64), - coordinates_max = (17, 64)), - (type = "box", coordinates_min = (-17, -64), - coordinates_max = (17, 64)) - #(type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), # very high resolution, takes about 1000s on 2 cores - ) +refinement_patches = ( + (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), + (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), + (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), + (type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), + #(type="box", coordinates_min=(-17, -64), coordinates_max=(17, 64)), # very high resolution, takes about 1000s on 2 cores +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - refinement_patches = refinement_patches, - periodicity = (false, true), - n_cells_max = 100_000) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + initial_refinement_level=3, + refinement_patches=refinement_patches, + periodicity=(false,true), + n_cells_max=100_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -85,26 +85,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, + analysis_callback, alive_callback, save_solution) # positivity limiter necessary for this tough example -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) ############################################################################### # run the simulation # use adaptive time stepping based on error estimates, time step roughly dt = 5e-3 sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl b/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl index a9eb671929f..21de07147ca 100644 --- a/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_colliding_flow_amr.jl @@ -10,59 +10,62 @@ equations = CompressibleEulerEquations2D(gamma) # This is a hand made colliding flow setup without reference. Features Mach=70 inflow from both # sides, with relative low temperature, such that pressure keeps relatively small # Computed with gamma close to 1, to simulate isothermal gas -function initial_condition_colliding_flow_astro(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) - # domain size is [-64,+64]^2 - @unpack gamma = equations - # the quantities are chosen such, that they are as close as possible to the astro examples - # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) - rho = 0.0247 - c = 0.2 - p = c^2 / gamma * rho - vel = 13.907432274789372 - slope = 1.0 - v1 = -vel * tanh(slope * x[1]) - # add small initial disturbance to the field, but only close to the interface - if abs(x[1]) < 10 - v1 = v1 * (1 + 0.01 * sin(pi * x[2])) - end - v2 = 0.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_colliding_flow_astro(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # resolution 128^2 elements (refined close to the interface) and polydeg=3 (total of 512^2 DOF) + # domain size is [-64,+64]^2 + @unpack gamma = equations + # the quantities are chosen such, that they are as close as possible to the astro examples + # keep in mind, that in the astro example, the physical units are weird (parsec, mega years, ...) + rho = 0.0247 + c = 0.2 + p = c^2 / gamma * rho + vel = 13.907432274789372 + slope = 1.0 + v1 = -vel*tanh(slope * x[1]) + # add small initial disturbance to the field, but only close to the interface + if abs(x[1]) < 10 + v1 = v1 * (1 + 0.01 * sin(pi*x[2])) + end + v2 = 0.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_colliding_flow_astro -boundary_conditions = (x_neg = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - x_pos = BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) + +boundary_conditions = ( + x_neg=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + x_pos=BoundaryConditionDirichlet(initial_condition_colliding_flow_astro), + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + ) + + surface_flux = flux_lax_friedrichs # HLLC needs more shock capturing (alpha_max) -volume_flux = flux_ranocha # works with Chandrashekar flux as well +volume_flux = flux_ranocha # works with Chandrashekar flux as well polydeg = 3 basis = LobattoLegendreBasis(polydeg) # shock capturing necessary for this tough example, however alpha_max = 0.5 is fine indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.0001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.0001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-64.0, -64.0) -coordinates_max = (64.0, 64.0) +coordinates_max = ( 64.0, 64.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = (false, true), - n_cells_max = 100_000) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + initial_refinement_level=4, + periodicity=(false,true), + n_cells_max=100_000) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -73,44 +76,44 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # Simulation also feasible without AMR: AMR reduces CPU time by a factor of about 2 amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0001, - alpha_smooth = false, - variable = Trixi.density) + alpha_max=1.0, + alpha_min=0.0001, + alpha_smooth=false, + variable=Trixi.density) amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, indicator_sc, - base_level = 2, - med_level = 0, med_threshold = 0.0003, # med_level = current level - max_level = 8, max_threshold = 0.003, - max_threshold_secondary = indicator_sc.alpha_max) + base_level=2, + med_level =0, med_threshold=0.0003, # med_level = current level + max_level =8, max_threshold=0.003, + max_threshold_secondary=indicator_sc.alpha_max) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, + analysis_callback, alive_callback, amr_callback, save_solution) # positivity limiter necessary for this tough example -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) ############################################################################### # run the simulation # use adaptive time stepping based on error estimates, time step roughly dt = 5e-3 sol = solve(ode, SSPRK43(stage_limiter!); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl b/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl index 96184b5ba47..89d7422cfe6 100644 --- a/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl +++ b/examples/tree_2d_dgsem/elixir_euler_convergence_pure_fv.jl @@ -18,11 +18,13 @@ solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -33,16 +35,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -52,7 +54,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_density_wave.jl b/examples/tree_2d_dgsem/elixir_euler_density_wave.jl index 0f9e232fa14..a5e9d30e389 100644 --- a/examples/tree_2d_dgsem/elixir_euler_density_wave.jl +++ b/examples/tree_2d_dgsem/elixir_euler_density_wave.jl @@ -9,16 +9,18 @@ equations = CompressibleEulerEquations2D(gamma) initial_condition = initial_condition_density_wave -solver = DGSEM(polydeg = 5, surface_flux = flux_central) +solver = DGSEM(polydeg=5, surface_flux=flux_central) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000) + initial_refinement_level=2, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,26 +30,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.6) +stepsize_callback = StepsizeCallback(cfl=1.6) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_ec.jl b/examples/tree_2d_dgsem/elixir_euler_ec.jl index e634a383cdf..88f65c3d689 100644 --- a/examples/tree_2d_dgsem/elixir_euler_ec.jl +++ b/examples/tree_2d_dgsem/elixir_euler_ec.jl @@ -9,18 +9,20 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=5, + n_cells_max=10_000, + periodicity=true) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_condition_periodic) + boundary_conditions=boundary_condition_periodic) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,26 +33,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl index 5e6b1e0cc0d..4fdedf516ef 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability.jl @@ -16,41 +16,40 @@ A version of the classical Kelvin-Helmholtz instability based on of the Euler Equations [arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) """ -function initial_condition_kelvin_helmholtz_instability(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.002, - alpha_min = 0.0001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.002, + alpha_min=0.0001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 100_000) + initial_refinement_level=5, + n_cells_max=100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) ############################################################################### @@ -62,26 +61,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 20, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=20, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.3) +stepsize_callback = StepsizeCallback(cfl=1.3) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl index 5c237835cc5..b8927c3fd6b 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr.jl @@ -16,44 +16,45 @@ A version of the classical Kelvin-Helmholtz instability based on of the Euler Equations [arXiv: 2102.06017](https://arxiv.org/abs/2102.06017) """ -function initial_condition_kelvin_helmholtz_instability(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.002, - alpha_min = 0.0001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.002, + alpha_min=0.0001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 100_000) + initial_refinement_level=5, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -63,40 +64,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0001, - alpha_smooth = false, - variable = Trixi.density) + alpha_max=1.0, + alpha_min=0.0001, + alpha_smooth=false, + variable=Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - med_level = 0, med_threshold = 0.0003, # med_level = current level - max_level = 6, max_threshold = 0.003) + base_level=4, + med_level=0, med_threshold=0.0003, # med_level = current level + max_level=6, max_threshold=0.003) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.3) +stepsize_callback = StepsizeCallback(cfl=1.3) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl index d2cab04223e..952fa372696 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl @@ -2,8 +2,7 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.904-0.0005.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", network) model2d = load(network, @__MODULE__)[:model2d] using Random: seed! @@ -29,59 +28,55 @@ equations = CompressibleEulerEquations2D(gamma) A version of the classical Kelvin-Helmholtz instability based on https://rsaa.anu.edu.au/research/established-projects/fyris/2-d-kelvin-helmholtz-test. """ -function initial_condition_kelvin_helmholtz_instability(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-0.5,0.5]^2 - dens0 = 1.0 # outside density - dens1 = 2.0 # inside density - velx0 = -0.5 # outside velocity - velx1 = 0.5 # inside velocity - slope = 50 # used for tanh instead of discontinuous initial condition - # pressure equilibrium - p = 2.5 - # y velocity v2 is only white noise - v2 = 0.01 * (rand(Float64, 1)[1] - 0.5) - # density - rho = dens0 + - (dens1 - dens0) * 0.5 * - (1 + (tanh(slope * (x[2] + 0.25)) - (tanh(slope * (x[2] - 0.25)) + 1))) - # x velocity is also augmented with noise - v1 = velx0 + - (velx1 - velx0) * 0.5 * - (1 + (tanh(slope * (x[2] + 0.25)) - (tanh(slope * (x[2] - 0.25)) + 1))) + - 0.01 * (rand(Float64, 1)[1] - 0.5) - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-0.5,0.5]^2 + dens0 = 1.0 # outside density + dens1 = 2.0 # inside density + velx0 = -0.5 # outside velocity + velx1 = 0.5 # inside velocity + slope = 50 # used for tanh instead of discontinuous initial condition + # pressure equilibrium + p = 2.5 + # y velocity v2 is only white noise + v2 = 0.01*(rand(Float64,1)[1]-0.5) + # density + rho = dens0 + (dens1-dens0) * 0.5*(1+(tanh(slope*(x[2]+0.25)) - (tanh(slope*(x[2]-0.25)) + 1))) + # x velocity is also augmented with noise + v1 = velx0 + (velx1-velx0) * 0.5*(1+(tanh(slope*(x[2]+0.25)) - (tanh(slope*(x[2]-0.25)) + 1)))+0.01*(rand(Float64,1)[1]-0.5) + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkPerssonPeraire(), - alpha_max = 0.002, - alpha_min = 0.0001, - alpha_smooth = true, - alpha_continuous = true, - alpha_amr = false, - variable = density_pressure, - network = model2d) + indicator_type=NeuralNetworkPerssonPeraire(), + alpha_max=0.002, + alpha_min=0.0001, + alpha_smooth=true, + alpha_continuous=true, + alpha_amr=false, + variable=density_pressure, + network=model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + 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) +coordinates_max = ( 0.5, 0.5) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 100_000) + initial_refinement_level=5, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -91,44 +86,45 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorNeuralNetwork(semi, - indicator_type = NeuralNetworkPerssonPeraire(), - alpha_max = 1.0, - alpha_min = 0.0001, - alpha_smooth = false, - alpha_continuous = true, - alpha_amr = true, - variable = density_pressure, - network = model2d) + indicator_type=NeuralNetworkPerssonPeraire(), + alpha_max=1.0, + alpha_min=0.0001, + alpha_smooth=false, + alpha_continuous=true, + alpha_amr=true, + variable=density_pressure, + network=model2d) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - med_level = 6, med_threshold = 0.3, # med_level = current level - max_level = 7, max_threshold = 0.5) + base_level=4, + med_level=6, med_threshold=0.3, # med_level = current level + max_level=7, max_threshold=0.5) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.3) +stepsize_callback = StepsizeCallback(cfl=1.3) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl index 5b2b80d84f3..8e7484a96d4 100644 --- a/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl +++ b/examples/tree_2d_dgsem/elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl @@ -1,6 +1,7 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the compressible Euler equations gamma = 1.4 @@ -15,86 +16,83 @@ A version of the classical Kelvin-Helmholtz instability based on solutions for hyperbolic systems of conservation laws [arXiv: 1402.0909](https://arxiv.org/abs/1402.0909) """ -function initial_condition_kelvin_helmholtz_instability_fjordholm_etal(x, t, - equations::CompressibleEulerEquations2D) - # typical resolution 128^2, 256^2 - # domain size is [0,+1]^2 - # interface is sharp, but randomly perturbed - # The random numbers used in the initial conditions have been generated as follows: - # - # using StableRNGs - # - # rng = StableRNG(100) - # - # a1 = rand(rng, m) - # a2 = rand(rng, m) - # a1 .= a1 / sum(a1) - # a2 .= a2 / sum(a2) - # b1 = (rand(rng, m) .- 0.5) .* pi - # b2 = (rand(rng, m) .- 0.5) .* pi - - m = 10 - a1 = [0.04457096674422902, 0.03891512410182607, 0.0030191053979293433, - 0.0993913172320319, +function initial_condition_kelvin_helmholtz_instability_fjordholm_etal(x, t, equations::CompressibleEulerEquations2D) + # typical resolution 128^2, 256^2 + # domain size is [0,+1]^2 + # interface is sharp, but randomly perturbed + # The random numbers used in the initial conditions have been generated as follows: + # + # using StableRNGs + # + # rng = StableRNG(100) + # + # a1 = rand(rng, m) + # a2 = rand(rng, m) + # a1 .= a1 / sum(a1) + # a2 .= a2 / sum(a2) + # b1 = (rand(rng, m) .- 0.5) .* pi + # b2 = (rand(rng, m) .- 0.5) .* pi + + m = 10 + a1 = [0.04457096674422902, 0.03891512410182607, 0.0030191053979293433, 0.0993913172320319, 0.1622302137588842, 0.1831383653456182, 0.11758003014101702, 0.07964318348142958, 0.0863245324711805, 0.18518716132585408] - a2 = [0.061688440856337096, 0.23000237877135882, 0.04453793881833177, - 0.19251530387370916, + a2 = [0.061688440856337096, 0.23000237877135882, 0.04453793881833177, 0.19251530387370916, 0.11107917357941084, 0.05898041974649702, 0.09949312336096268, 0.07022276346006465, 0.10670366489014596, 0.02477679264318211] - b1 = [0.06582340543754152, 0.9857886297001535, 0.8450452205037154, -1.279648120993805, + b1 = [0.06582340543754152, 0.9857886297001535, 0.8450452205037154, -1.279648120993805, 0.45454198915209526, -0.13359370986823993, 0.07062615913363897, -1.0097986278512623, 1.0810669017430343, -0.14207309803877177] - b2 = [-1.1376882185131414, -1.4798197129947765, 0.6139290513283818, -0.3319087388365522, + b2 = [-1.1376882185131414, -1.4798197129947765, 0.6139290513283818, -0.3319087388365522, 0.14633328999192285, -0.06373231463100072, -0.6270101051216724, 0.13941252226261905, -1.0337526453303645, 1.0441408867083155] - Y1 = 0.0 - Y2 = 0.0 - for n in 1:m - Y1 += a1[n] * cos(b1[n] + 2 * n * pi * x[1]) - Y2 += a2[n] * cos(b2[n] + 2 * n * pi * x[1]) - end - - J1 = 0.25 - J2 = 0.75 - epsilon = 0.01 - I1 = J1 + epsilon * Y1 - I2 = J2 + epsilon * Y2 - - if (x[2] > I1) && (x[2] < I2) - rho = 2 - v1 = -0.5 - else - rho = 1 - v1 = 0.5 - end - v2 = 0 - p = 2.5 - - return prim2cons(SVector(rho, v1, v2, p), equations) + Y1 = 0.0 + Y2 = 0.0 + for n = 1:m + Y1 += a1[n] * cos(b1[n] + 2 * n * pi * x[1]) + Y2 += a2[n] * cos(b2[n] + 2 * n * pi * x[1]) + end + + J1 = 0.25 + J2 = 0.75 + epsilon = 0.01 + I1 = J1 + epsilon * Y1 + I2 = J2 + epsilon * Y2 + + if (x[2] > I1) && (x[2] < I2) + rho = 2 + v1 = -0.5 + else + rho = 1 + v1 = 0.5 + end + v2 = 0 + p = 2.5 + + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability_fjordholm_etal surface_flux = flux_hllc -volume_flux = flux_ranocha +volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.001, - alpha_min = 0.0001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.001, + alpha_min=0.0001, + alpha_smooth=true, + variable=density_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 100_000) + initial_refinement_level=6, + n_cells_max=100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -107,14 +105,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 400 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 400, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=400, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -123,5 +121,5 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation sol = solve(ode, SSPRK43(); - ode_default_options()..., callback = callbacks); + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_euler_positivity.jl b/examples/tree_2d_dgsem/elixir_euler_positivity.jl index 745928c5dc5..e40dc3b47af 100644 --- a/examples/tree_2d_dgsem/elixir_euler_positivity.jl +++ b/examples/tree_2d_dgsem/elixir_euler_positivity.jl @@ -14,51 +14,53 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha +volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 100_000) + initial_refinement_level=6, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -68,40 +70,42 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorLöhner(semi, - variable = density_pressure) + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - med_level = 0, med_threshold = 0.1, # med_level = current level - max_level = 6, max_threshold = 0.3) + base_level=4, + med_level =0, med_threshold=0.1, # med_level = current level + max_level =6, max_threshold=0.3) amr_callback = AMRCallback(semi, amr_controller, - interval = 2, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=2, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6), - variables = (Trixi.density, pressure)) + +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(5.0e-6, 5.0e-6), + variables=(Trixi.density, pressure)) + ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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 diff --git a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl index 10b5d0ce404..da7e1d55c91 100644 --- a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -14,51 +14,53 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 100_000) + initial_refinement_level=6, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -68,29 +70,29 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level =6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -99,7 +101,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl index 97060768e5e..56715789377 100644 --- a/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl +++ b/examples/tree_2d_dgsem/elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl @@ -2,8 +2,7 @@ using Downloads: download using Flux using BSON: load network = joinpath(@__DIR__, "modelnnpp-0.904-0.0005.bson") -download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", - network) +download("https://github.com/trixi-framework/Trixi_IndicatorNeuralNetwork_networks/raw/main/networks/modelnnpp-0.904-0.0005.bson", network) model2d = load(network, @__MODULE__)[:model2d] using OrdinaryDiffEq @@ -27,55 +26,57 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 surface_flux = flux_lax_friedrichs -volume_flux = flux_chandrashekar +volume_flux = flux_chandrashekar basis = LobattoLegendreBasis(3) indicator_sc = IndicatorNeuralNetwork(equations, basis, - indicator_type = NeuralNetworkPerssonPeraire(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = true, - alpha_amr = false, - variable = density_pressure, - network = model2d) + indicator_type=NeuralNetworkPerssonPeraire(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=true, + alpha_amr=false, + variable=density_pressure, + network=model2d) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - n_cells_max = 100_000) + initial_refinement_level=6, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -85,33 +86,33 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorNeuralNetwork(semi, - indicator_type = NeuralNetworkPerssonPeraire(), - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - alpha_continuous = true, - alpha_amr = true, - variable = density_pressure, - network = model2d) + indicator_type=NeuralNetworkPerssonPeraire(), + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + alpha_continuous=true, + alpha_amr=true, + variable=density_pressure, + network=model2d) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.22) + base_level=4, + max_level =6, max_threshold=0.22) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -120,7 +121,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl b/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl index 40f19cbd4e2..f0a7ed0b953 100644 --- a/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl +++ b/examples/tree_2d_dgsem/elixir_euler_shockcapturing.jl @@ -10,26 +10,28 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_lax_friedrichs -volume_flux = flux_shima_etal +volume_flux = flux_shima_etal basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,25 +41,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, stepsize_callback, save_solution, analysis_callback, alive_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_source_terms.jl b/examples/tree_2d_dgsem/elixir_euler_source_terms.jl index ec230145537..36d93147289 100644 --- a/examples/tree_2d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_2d_dgsem/elixir_euler_source_terms.jl @@ -8,16 +8,18 @@ using Trixi equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,16 +30,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -47,7 +49,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl b/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl index 28ab4cec1d3..231486b11c9 100644 --- a/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl +++ b/examples/tree_2d_dgsem/elixir_euler_source_terms_amr_refine_coarsen.jl @@ -10,57 +10,60 @@ module TrixiExtensionEulerAMR using Trixi -struct IndicatorRefineCoarsen{Cache <: NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorRefineCoarsen{Cache<:NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorRefineCoarsen(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - cache = (; semi.mesh, alpha) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + cache = (; semi.mesh, alpha) - return IndicatorRefineCoarsen{typeof(cache)}(cache) + return IndicatorRefineCoarsen{typeof(cache)}(cache) end -function (indicator::IndicatorRefineCoarsen)(u::AbstractArray{<:Any, 4}, +function (indicator::IndicatorRefineCoarsen)(u::AbstractArray{<:Any,4}, mesh, equations, dg, cache; t, kwargs...) - alpha = indicator.cache.alpha - resize!(alpha, nelements(dg, cache)) - - if t >= 0.7 && t < 1.0 - # Refine to max level - alpha .= 1.0 - elseif t >= 1.0 - # Coarsen to base level - alpha .= -1.0 - else - alpha .= 0.0 - end - - return alpha + alpha = indicator.cache.alpha + resize!(alpha, nelements(dg, cache)) + + if t >= 0.7 && t < 1.0 + # Refine to max level + alpha .= 1.0 + elseif t >= 1.0 + # Coarsen to base level + alpha .= -1.0 + else + alpha .= 0.0 + end + + return alpha end end # module TrixiExtensionEulerAMR import .TrixiExtensionEulerAMR + ############################################################################### # semidiscretization of the compressible Euler equations equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000) + initial_refinement_level=3, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -71,26 +74,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -amr_controller = ControllerThreeLevel(semi, - TrixiExtensionEulerAMR.IndicatorRefineCoarsen(semi), - base_level = 3, max_level = 6, - med_threshold = 0.1, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, TrixiExtensionEulerAMR.IndicatorRefineCoarsen(semi), + base_level=3, max_level=6, + med_threshold=0.1, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -100,7 +102,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl index 05ed7ba78cc..9826a53d3d5 100644 --- a/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_euler_source_terms_nonperiodic.jl @@ -12,23 +12,26 @@ initial_condition = initial_condition_convergence_test # you can either use a single function to impose the BCs weakly in all # 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction boundary_condition = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = (x_neg = boundary_condition, - x_pos = boundary_condition, - y_neg = boundary_condition, - y_pos = boundary_condition) +boundary_conditions = (x_neg=boundary_condition, + x_pos=boundary_condition, + y_neg=boundary_condition, + y_pos=boundary_condition,) + +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=4, + n_cells_max=10_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test, - boundary_conditions = boundary_conditions) + source_terms=source_terms_convergence_test, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,19 +42,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -60,7 +63,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex.jl b/examples/tree_2d_dgsem/elixir_euler_vortex.jl index c87d6f49ba8..14e46ce7540 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex.jl @@ -17,45 +17,46 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) +coordinates_max = ( 10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -68,31 +69,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_errors = (:conservation_error,), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_errors=(:conservation_error,), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl index e9831c95526..6f6eb25efa4 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_amr.jl @@ -7,54 +7,55 @@ module TrixiExtension using Trixi -struct IndicatorVortex{Cache <: NamedTuple} <: Trixi.AbstractIndicator - cache::Cache +struct IndicatorVortex{Cache<:NamedTuple} <: Trixi.AbstractIndicator + cache::Cache end function IndicatorVortex(semi) - basis = semi.solver.basis - alpha = Vector{real(basis)}() - A = Array{real(basis), 2} - indicator_threaded = [A(undef, nnodes(basis), nnodes(basis)) - for _ in 1:Threads.nthreads()] - cache = (; semi.mesh, alpha, indicator_threaded) - - return IndicatorVortex{typeof(cache)}(cache) + basis = semi.solver.basis + alpha = Vector{real(basis)}() + A = Array{real(basis), 2} + indicator_threaded = [A(undef, nnodes(basis), nnodes(basis)) + for _ in 1:Threads.nthreads()] + cache = (; semi.mesh, alpha, indicator_threaded) + + return IndicatorVortex{typeof(cache)}(cache) end -function (indicator_vortex::IndicatorVortex)(u::AbstractArray{<:Any, 4}, +function (indicator_vortex::IndicatorVortex)(u::AbstractArray{<:Any,4}, mesh, equations, dg, cache; t, kwargs...) - mesh = indicator_vortex.cache.mesh - alpha = indicator_vortex.cache.alpha - indicator_threaded = indicator_vortex.cache.indicator_threaded - resize!(alpha, nelements(dg, cache)) - - # get analytical vortex center (based on assumption that center=[0.0,0.0] - # at t=0.0 and that we stop after one period) - domain_length = mesh.tree.length_level_0 - if t < 0.5 * domain_length - center = (t, t) - else - center = (t - domain_length, t - domain_length) - end - - Threads.@threads for element in eachelement(dg, cache) - cell_id = cache.elements.cell_ids[element] - coordinates = (mesh.tree.coordinates[1, cell_id], mesh.tree.coordinates[2, cell_id]) - # use the negative radius as indicator since the AMR controller increases - # the level with increasing value of the indicator and we want to use - # high levels near the vortex center - alpha[element] = -periodic_distance_2d(coordinates, center, domain_length) - end - - return alpha + mesh = indicator_vortex.cache.mesh + alpha = indicator_vortex.cache.alpha + indicator_threaded = indicator_vortex.cache.indicator_threaded + resize!(alpha, nelements(dg, cache)) + + + # get analytical vortex center (based on assumption that center=[0.0,0.0] + # at t=0.0 and that we stop after one period) + domain_length = mesh.tree.length_level_0 + if t < 0.5 * domain_length + center = (t, t) + else + center = (t-domain_length, t-domain_length) + end + + Threads.@threads for element in eachelement(dg, cache) + cell_id = cache.elements.cell_ids[element] + coordinates = (mesh.tree.coordinates[1, cell_id], mesh.tree.coordinates[2, cell_id]) + # use the negative radius as indicator since the AMR controller increases + # the level with increasing value of the indicator and we want to use + # high levels near the vortex center + alpha[element] = -periodic_distance_2d(coordinates, center, domain_length) + end + + return alpha end function periodic_distance_2d(coordinates, center, domain_length) - dx = @. abs(coordinates - center) - dx_periodic = @. min(dx, domain_length - dx) - return sqrt(sum(abs2, dx_periodic)) + dx = @. abs(coordinates - center) + dx_periodic = @. min(dx, domain_length - dx) + return sqrt(sum(abs2, dx_periodic)) end end # module TrixiExtension @@ -76,47 +77,48 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - - cent = x - cent # distance to center point - - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + + cent = x - cent # distance to center point + + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) +coordinates_max = ( 10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000) + initial_refinement_level=3, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -130,40 +132,39 @@ summary_callback = SummaryCallback() analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_errors = (:conservation_error,), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_errors=(:conservation_error,), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 50, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=50, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_controller = ControllerThreeLevel(semi, TrixiExtension.IndicatorVortex(semi), - base_level = 3, - med_level = 4, med_threshold = -3.0, - max_level = 5, max_threshold = -2.0) + base_level=3, + med_level=4, med_threshold=-3.0, + max_level=5, max_threshold=-2.0) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl index 858799d2d3d..637133b9b2f 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar.jl @@ -17,48 +17,49 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) -refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0), - coordinates_max = (10.0, 10.0)),) +coordinates_max = ( 10.0, 10.0) +refinement_patches = ( + (type="box", coordinates_min=(0.0, -10.0), coordinates_max=(10.0, 10.0)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=4, + refinement_patches=refinement_patches, + n_cells_max=10_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -71,31 +72,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_errors = (:conservation_error,), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_errors=(:conservation_error,), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.4) +stepsize_callback = StepsizeCallback(cfl=1.4) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl index 026f6d1462c..dc6a326c5d5 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_shockcapturing.jl @@ -17,36 +17,36 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex @@ -56,23 +56,24 @@ volume_flux = flux_shima_etal polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) -refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0), - coordinates_max = (10.0, 10.0)),) +coordinates_max = ( 10.0, 10.0) +refinement_patches = ( + (type="box", coordinates_min=(0.0, -10.0), coordinates_max=(10.0, 10.0)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=4, + refinement_patches=refinement_patches, + n_cells_max=10_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -85,31 +86,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_errors = (:conservation_error,), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_errors=(:conservation_error,), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.7) +stepsize_callback = StepsizeCallback(cfl=0.7) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl index d719e01fd7c..99036c36451 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_mortar_split.jl @@ -17,51 +17,52 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex volume_flux = flux_shima_etal -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) -refinement_patches = ((type = "box", coordinates_min = (0.0, -10.0), - coordinates_max = (10.0, 10.0)),) +coordinates_max = ( 10.0, 10.0) +refinement_patches = ( + (type="box", coordinates_min=(0.0, -10.0), coordinates_max=(10.0, 10.0)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=4, + refinement_patches=refinement_patches, + n_cells_max=10_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -74,31 +75,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_errors = (:conservation_error,), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_errors=(:conservation_error,), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.4) +stepsize_callback = StepsizeCallback(cfl=1.4) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl b/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl index 99e4b090633..65a497374ed 100644 --- a/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl +++ b/examples/tree_2d_dgsem/elixir_euler_vortex_shockcapturing.jl @@ -17,36 +17,36 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - cent = x - cent # distance to center point - # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the vortex is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + cent = x - cent # distance to center point + # cent = cross(iniaxis, cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude / (2*π) * exp(0.5 * (1 - r2)) # vel. perturbation + dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic + rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) + vel = vel + du * cent + v1, v2 = vel + p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex @@ -56,20 +56,20 @@ volume_flux = flux_shima_etal polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) +coordinates_max = ( 10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -82,24 +82,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_errors = (:conservation_error,), - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_errors=(:conservation_error,), + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.7) +stepsize_callback = StepsizeCallback(cfl=0.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -109,7 +107,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl b/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl index ea81bd049e4..38b48b5d537 100644 --- a/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl +++ b/examples/tree_2d_dgsem/elixir_euleracoustics_co-rotating_vortex_pair.jl @@ -19,199 +19,203 @@ module VortexPairSetup using LinearAlgebra: norm using Trixi + # Parameters that describe the co-rotating vortex pair -struct VortexPair{RealT <: Real} - r0::RealT # Distance between origin and each vortex center - rc::RealT # Vortex core radius - c0::RealT # Speed of sound - circulation::RealT # Circulation of the vortices - rho0::RealT # Density +struct VortexPair{RealT<:Real} + r0::RealT # Distance between origin and each vortex center + rc::RealT # Vortex core radius + c0::RealT # Speed of sound + circulation::RealT # Circulation of the vortices + rho0::RealT # Density end + # Analytical flow solution, used for the initial condition of the flow simulation function velocity(x, t, vortex_pair::VortexPair) - @unpack r0, rc, circulation = vortex_pair + @unpack r0, rc, circulation = vortex_pair - omega = circulation / (4 * pi * r0^2) - si, co = sincos(omega * t) - b = SVector(r0 * co, r0 * si) # vortex centers are b and -b - z_plus = x - b - z_minus = x + b + omega = circulation / (4 * pi * r0^2) + si, co = sincos(omega * t) + b = SVector(r0 * co, r0 * si) # vortex centers are b and -b + z_plus = x - b + z_minus = x + b - # Transform to polar coordinates - r_plus = norm(z_plus) - r_minus = norm(z_minus) - theta_plus = atan(z_plus[2], z_plus[1]) - theta_minus = atan(z_minus[2], z_minus[1]) + # Transform to polar coordinates + r_plus = norm(z_plus) + r_minus = norm(z_minus) + theta_plus = atan(z_plus[2], z_plus[1]) + theta_minus = atan(z_minus[2], z_minus[1]) - si_plus, co_plus = sincos(theta_plus) - si_minus, co_minus = sincos(theta_minus) + si_plus, co_plus = sincos(theta_plus) + si_minus, co_minus = sincos(theta_minus) - v1 = -circulation / (2 * pi) * (r_plus / (rc^2 + r_plus^2) * si_plus + - r_minus / (rc^2 + r_minus^2) * si_minus) - v2 = circulation / (2 * pi) * (r_plus / (rc^2 + r_plus^2) * co_plus + - r_minus / (rc^2 + r_minus^2) * co_minus) + v1 = -circulation/(2 * pi) * ( r_plus /(rc^2 + r_plus^2) * si_plus + + r_minus/(rc^2 + r_minus^2) * si_minus) + v2 = circulation/(2 * pi) * ( r_plus /(rc^2 + r_plus^2) * co_plus + + r_minus/(rc^2 + r_minus^2) * co_minus ) - return SVector(v1, v2) + return SVector(v1, v2) end + # Initial condition of the flow simulation. Uses constant density rho0 and analytical velocities. # The pressure is calculated using the given speed of sound c0 and Bernoulli's principle -struct InitialCondition{RealT <: Real} - vortex_pair::VortexPair{RealT} +struct InitialCondition{RealT<:Real} + vortex_pair::VortexPair{RealT} end -function (initial_condition::InitialCondition)(x, t, - equations::CompressibleEulerEquations2D) - @unpack vortex_pair = initial_condition - @unpack rho0, c0 = vortex_pair - gamma = equations.gamma +function (initial_condition::InitialCondition)(x, t, equations::CompressibleEulerEquations2D) + @unpack vortex_pair = initial_condition + @unpack rho0, c0 = vortex_pair + gamma = equations.gamma - v = velocity(x, t, vortex_pair) - p0 = rho0 * c0^2 / gamma - p = p0 - 0.5 * (gamma - 1) / gamma * sum(v .^ 2) # Bernoulli's principle + v = velocity(x, t, vortex_pair) + p0 = rho0 * c0^2 / gamma + p = p0 - 0.5 * (gamma-1)/gamma * sum(v.^2) # Bernoulli's principle - prim = SVector(rho0, v[1], v[2], p) - return prim2cons(prim, equations) + prim = SVector(rho0, v[1], v[2], p) + return prim2cons(prim, equations) end + # For both the flow and acoustics solvers, a sponge layer is used to dampen the density # and pressure towards the freestream values (for the flow solver) and the perturbed pressure # to zero (for the acoustics solver). -struct SpongeLayer{RealT <: Real, uEltype <: Real, N, SourceTerms} - sponge_layer_min::NTuple{4, RealT} # (-x,+x,-y,+y) min coordinates of sponge layer per direction - sponge_layer_max::NTuple{4, RealT} # (-x,+x,-y,+y) max coordinates of sponge layer per direction - reference_values::NTuple{N, uEltype} # reference values for variables affected by sponge layer - source_terms::SourceTerms # source terms to be used outside the sponge zone +struct SpongeLayer{RealT<:Real, uEltype<:Real, N, SourceTerms} + sponge_layer_min::NTuple{4, RealT} # (-x,+x,-y,+y) min coordinates of sponge layer per direction + sponge_layer_max::NTuple{4, RealT} # (-x,+x,-y,+y) max coordinates of sponge layer per direction + reference_values::NTuple{N, uEltype} # reference values for variables affected by sponge layer + source_terms::SourceTerms # source terms to be used outside the sponge zone end -function SpongeLayer(; sponge_layer_min, sponge_layer_max, reference_values, - source_terms = nothing) - return SpongeLayer(sponge_layer_min, sponge_layer_max, reference_values, source_terms) +function SpongeLayer(; sponge_layer_min, sponge_layer_max, reference_values, source_terms=nothing) + return SpongeLayer(sponge_layer_min, sponge_layer_max, reference_values, source_terms) end function (sponge_layer::SpongeLayer)(u, x, t, equations) - @unpack sponge_layer_min, sponge_layer_max, reference_values, source_terms = sponge_layer - - if lies_in_sponge_layer(x, sponge_layer_min, sponge_layer_max) - return source_term_sponge_layer(u, x, t, equations, sponge_layer_min, - sponge_layer_max, - reference_values) - elseif source_terms !== nothing - return source_terms(u, x, t, equations) - else - return SVector(ntuple(v -> zero(eltype(u)), Val(nvariables(equations)))) - end + @unpack sponge_layer_min, sponge_layer_max, reference_values, source_terms = sponge_layer + + if lies_in_sponge_layer(x, sponge_layer_min, sponge_layer_max) + return source_term_sponge_layer(u, x, t, equations, sponge_layer_min, sponge_layer_max, + reference_values) + elseif source_terms !== nothing + return source_terms(u, x, t, equations) + else + return SVector(ntuple(v -> zero(eltype(u)), Val(nvariables(equations)))) + end end function lies_in_sponge_layer(x, sponge_layer_min, sponge_layer_max) - return (sponge_layer_min[1] <= x[1] <= sponge_layer_max[1]) || # -x direction - (sponge_layer_min[2] <= x[1] <= sponge_layer_max[2]) || # +x direction - (sponge_layer_min[3] <= x[2] <= sponge_layer_max[3]) || # -y direction - (sponge_layer_min[4] <= x[2] <= sponge_layer_max[4]) # +y direction + return (sponge_layer_min[1] <= x[1] <= sponge_layer_max[1]) || # -x direction + (sponge_layer_min[2] <= x[1] <= sponge_layer_max[2]) || # +x direction + (sponge_layer_min[3] <= x[2] <= sponge_layer_max[3]) || # -y direction + (sponge_layer_min[4] <= x[2] <= sponge_layer_max[4]) # +y direction end function source_term_sponge_layer(u, x, t, equations::AcousticPerturbationEquations2D, sponge_layer_min::NTuple{4}, sponge_layer_max::NTuple{4}, reference_values) - # Perturbed pressure source is -alpha^2 * (u - reference_value) where alpha in [0,1] is a damping - # factor depending on the position inside the sponge layer + # Perturbed pressure source is -alpha^2 * (u - reference_value) where alpha in [0,1] is a damping + # factor depending on the position inside the sponge layer - # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge - # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge - # zones for two directions overlap - alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), - Val(2 * ndims(equations))) - alpha_square = maximum(alphas)^2 + # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge + # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge + # zones for two directions overlap + alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), + Val(2*ndims(equations))) + alpha_square = maximum(alphas)^2 - return SVector(0, 0, -alpha_square * (u[3] - reference_values[1] / u[6]^2), 0, 0, 0, 0) + return SVector(0, 0, -alpha_square*(u[3] - reference_values[1]/u[6]^2), 0, 0, 0, 0) end function source_term_sponge_layer(u, x, t, equations::CompressibleEulerEquations2D, sponge_layer_min::NTuple{4}, sponge_layer_max::NTuple{4}, reference_values) - # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge - # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge - # zones for two directions overlap - alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), - Val(2 * ndims(equations))) - alpha_square = maximum(alphas)^2 - - u_prim = cons2prim(u, equations) - s = SVector(-alpha_square * (u_prim[1] - reference_values[1]), 0, 0, - -alpha_square * (u_prim[4] - reference_values[2])) - - return prim2cons(s, equations) + # Calculate the damping factors for each direction (=0 if x is not in the corresponding sponge + # zone) and take the maximum. This ensures proper damping if x lies in a corner where the sponge + # zones for two directions overlap + alphas = ntuple(i -> calc_damping_factor(x, i, sponge_layer_min, sponge_layer_max), + Val(2*ndims(equations))) + alpha_square = maximum(alphas)^2 + + u_prim = cons2prim(u, equations) + s = SVector(-alpha_square*(u_prim[1] - reference_values[1]), 0, 0, + -alpha_square*(u_prim[4] - reference_values[2])) + + return prim2cons(s, equations) end function calc_damping_factor(x, direction, sponge_layer_min, sponge_layer_max) - # Damping factor alpha grows linearly from 0 to 1 depending on how deep x lies in the sponge layer - # If x does not lie in the sponge layer, this returns 0 - - # Get the coordinate that determines how deep we are in the sponge zone - if direction in (1, 2) - pos = x[1] - else - pos = x[2] - end - - # Determine where the sponge layer begins/ends to allow calculating the damping factor - if iseven(direction) - sponge_begin = sponge_layer_min[direction] - sponge_end = sponge_layer_max[direction] - else - sponge_begin = sponge_layer_max[direction] - sponge_end = sponge_layer_min[direction] - end - - alpha = (pos - sponge_begin) / (sponge_end - sponge_begin) - - # alpha lies in [0, 1] if and only if x lies in the sponge zone - if 0 <= alpha <= 1 - return alpha - else - return zero(alpha) - end + # Damping factor alpha grows linearly from 0 to 1 depending on how deep x lies in the sponge layer + # If x does not lie in the sponge layer, this returns 0 + + # Get the coordinate that determines how deep we are in the sponge zone + if direction in (1, 2) + pos = x[1] + else + pos = x[2] + end + + # Determine where the sponge layer begins/ends to allow calculating the damping factor + if iseven(direction) + sponge_begin = sponge_layer_min[direction] + sponge_end = sponge_layer_max[direction] + else + sponge_begin = sponge_layer_max[direction] + sponge_end = sponge_layer_min[direction] + end + + alpha = (pos - sponge_begin) / (sponge_end - sponge_begin) + + # alpha lies in [0, 1] if and only if x lies in the sponge zone + if 0 <= alpha <= 1 + return alpha + else + return zero(alpha) + end end + # Boundary condition for the flow problem: The sponge layer dampens density and pressure towards the # freestream values. The freestream values (converted into conservative variables) are therefore # used as a Dirichlet boundary struct BoundaryCondition{uEltype} - rho::uEltype - rho_e::uEltype + rho::uEltype + rho_e::uEltype end function (bc::BoundaryCondition)(u_inner, orientation, direction, x, t, surface_flux_function, equations::CompressibleEulerEquations2D) - u_boundary = SVector(bc.rho, zero(bc.rho), zero(bc.rho), bc.rho_e) + u_boundary = SVector(bc.rho, zero(bc.rho), zero(bc.rho), bc.rho_e) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end - return flux + return flux end end # module + import .VortexPairSetup + ############################################################################### # shared parameters, mesh and solver for both semidiscretizations # Parameters of the vortex pair -Mach = 1 / 9 +Mach = 1/9 c0 = 1.0 r0 = 1.0 circulation = 4 * pi * r0 * c0 * Mach rho = 1.0 -rc = 2 / 9 * r0 * 1.0 +rc = 2/9 * r0 * 1.0 T_r = 8 * pi^2 * r0^2 / circulation # Rotational period of the vortex pair T_a = T_r / 2 # Acoustic period of the vortex pair @@ -219,22 +223,24 @@ T_a = T_r / 2 # Acoustic period of the vortex pair vortex_pair = VortexPairSetup.VortexPair(r0, rc, c0, circulation, rho) # Shared mesh for both semidiscretizations -coordinates_min = (-135 * r0, -135 * r0) # minimum coordinates (min(x), min(y)) -coordinates_max = (135 * r0, 135 * r0) # maximum coordinates (max(x), max(y)) -refinement_patches = ((type = "sphere", center = (0.0, 0.0), radius = 85.0 * r0), - (type = "sphere", center = (0.0, 0.0), radius = 20.0 * r0), - (type = "sphere", center = (0.0, 0.0), radius = 10.0 * r0), - (type = "sphere", center = (0.0, 0.0), radius = 5.0 * r0)) -initial_refinement_level = 7 -n_cells_max = 500_000 +coordinates_min = (-135*r0, -135*r0) # minimum coordinates (min(x), min(y)) +coordinates_max = ( 135*r0, 135*r0) # maximum coordinates (max(x), max(y)) +refinement_patches = ( + (type="sphere", center=(0.0, 0.0), radius=85.0*r0), + (type="sphere", center=(0.0, 0.0), radius=20.0*r0), + (type="sphere", center=(0.0, 0.0), radius=10.0*r0), + (type="sphere", center=(0.0, 0.0), radius=5.0*r0) +) +initial_refinement_level=7 +n_cells_max=500_000 mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = initial_refinement_level, - refinement_patches = refinement_patches, - n_cells_max = n_cells_max, # set maximum capacity of tree data structure - periodicity = false) + initial_refinement_level=initial_refinement_level, + refinement_patches=refinement_patches, + n_cells_max=n_cells_max, # set maximum capacity of tree data structure + periodicity=false) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) ############################################################################### # semidiscretization Euler equations @@ -244,37 +250,24 @@ equations_euler = CompressibleEulerEquations2D(gamma) initial_condition_euler = VortexPairSetup.InitialCondition(vortex_pair) -sponge_layer_euler = VortexPairSetup.SpongeLayer(sponge_layer_min = (-135 * r0, 115 * r0, - -135 * r0, 115 * r0), - sponge_layer_max = (-115 * r0, 135 * r0, - -115 * r0, 135 * r0), - reference_values = (rho, - rho * c0^2 / gamma)) # (rho0, p0) +sponge_layer_euler = VortexPairSetup.SpongeLayer(sponge_layer_min=(-135*r0, 115*r0, -135*r0, 115*r0), + sponge_layer_max=(-115*r0, 135*r0, -115*r0, 135*r0), + reference_values=(rho, rho * c0^2 / gamma)) # (rho0, p0) -boundary_condition_euler = VortexPairSetup.BoundaryCondition(rho, - (rho * c0^2 / gamma) / - (gamma - 1)) +boundary_condition_euler = VortexPairSetup.BoundaryCondition(rho, (rho * c0^2 / gamma) / (gamma-1)) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition_euler, - solver, - boundary_conditions = boundary_condition_euler, - source_terms = sponge_layer_euler) +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition_euler, solver, + boundary_conditions=boundary_condition_euler, + source_terms=sponge_layer_euler) ############################################################################### # semidiscretization acoustic perturbation equations -equations_acoustics = AcousticPerturbationEquations2D(v_mean_global = (13.0, 26.0), - c_mean_global = 39.0, - rho_mean_global = 52.0) # global mean values will be overwritten - -sponge_layer_acoustics = VortexPairSetup.SpongeLayer(sponge_layer_min = (-135 * r0, - 100 * r0, - -135 * r0, - 100 * r0), - sponge_layer_max = (-100 * r0, - 135 * r0, - -100 * r0, - 135 * r0), - reference_values = (0.0,)) +equations_acoustics = AcousticPerturbationEquations2D(v_mean_global=(13.0, 26.0), c_mean_global=39.0, + rho_mean_global=52.0) # global mean values will be overwritten + +sponge_layer_acoustics = VortexPairSetup.SpongeLayer(sponge_layer_min=(-135*r0, 100*r0, -135*r0, 100*r0), + sponge_layer_max=(-100*r0, 135*r0, -100*r0, 135*r0), + reference_values=(0.0,)) """ boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function, @@ -283,27 +276,24 @@ sponge_layer_acoustics = VortexPairSetup.SpongeLayer(sponge_layer_min = (-135 * Boundary condition that uses a boundary state where the state variables are zero and the mean variables are the same as in `u_inner`. """ -function boundary_condition_zero(u_inner, orientation, direction, x, t, - surface_flux_function, +function boundary_condition_zero(u_inner, orientation, direction, x, t, surface_flux_function, equations::AcousticPerturbationEquations2D) - value = zero(eltype(u_inner)) - u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) + value = zero(eltype(u_inner)) + u_boundary = SVector(value, value, value, cons2mean(u_inner, equations)...) - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end - return flux + return flux end -semi_acoustics = SemidiscretizationHyperbolic(mesh, equations_acoustics, - initial_condition_constant, - solver, - boundary_conditions = boundary_condition_zero, - source_terms = sponge_layer_acoustics) +semi_acoustics = SemidiscretizationHyperbolic(mesh, equations_acoustics, initial_condition_constant, + solver, boundary_conditions=boundary_condition_zero, + source_terms=sponge_layer_acoustics) ############################################################################### # ODE solvers, callbacks etc. for averaging the flow field @@ -317,12 +307,12 @@ ode_averaging = semidiscretize(semi_euler, tspan1) summary_callback = SummaryCallback() analysis_interval = 5000 -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) tspan_averaging = (50.0, 400.0) averaging_callback = AveragingCallback(semi_euler, tspan_averaging) -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) callbacks_averaging = CallbackSet(summary_callback, alive_callback, averaging_callback, stepsize_callback) @@ -331,13 +321,14 @@ callbacks_averaging = CallbackSet(summary_callback, alive_callback, averaging_ca # run simulation for averaging the flow field # OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks -sol_averaging = solve(ode_averaging, 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_averaging); +sol_averaging = solve(ode_averaging, 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_averaging); # Print the timer summary summary_callback() + ############################################################################### # set up coupled semidiscretization @@ -346,13 +337,13 @@ source_region(x) = sum(abs2, x) < 6.0^2 # calculate sources within radius 6 arou weights(x) = sum(abs2, x) < 5.0^2 ? 1.0 : cospi(0.5 * (norm(x) - 5.0)) semi = SemidiscretizationEulerAcoustics(semi_acoustics, semi_euler, - source_region = source_region, weights = weights) + source_region=source_region, weights=weights) ############################################################################### # ODE solvers, callbacks etc. for the coupled simulation # Create ODE problem -tspan = (0.0, 7.0 * T_a) +tspan = (0.0, 7.0*T_a) ode = semidiscretize(semi, tspan) # We need an additional ODE for the pure flow problem ode_euler = semidiscretize(semi.semi_euler, tspan) @@ -360,30 +351,28 @@ ode_euler = semidiscretize(semi.semi_euler, tspan) # Set up coupling callback cfl_acoustics = 0.8 cfl_euler = 0.8 -euler_acoustics_coupling = EulerAcousticsCouplingCallback(ode_euler, "out/averaging.h5", - CarpenterKennedy2N54(williamson_condition = false), - cfl_acoustics, cfl_euler, - callback = SaveRestartCallback(interval = 2300, - output_directory = "out/euler/")) +euler_acoustics_coupling = EulerAcousticsCouplingCallback( + ode_euler, "out/averaging.h5", CarpenterKennedy2N54(williamson_condition=false), + cfl_acoustics, cfl_euler, callback=SaveRestartCallback(interval=2300, output_directory="out/euler/")) # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup # and resets the timers summary_callback = SummaryCallback() analysis_interval = 5000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) output_directory = "out/" -save_solution = SaveSolutionCallback(interval = 2300, output_directory = output_directory) -save_restart = SaveRestartCallback(interval = 2300, output_directory = output_directory) +save_solution = SaveSolutionCallback(interval=2300, output_directory=output_directory) +save_restart = SaveRestartCallback(interval=2300, output_directory=output_directory) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback, save_solution, save_restart, euler_acoustics_coupling) -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); +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); # Print the timer summary -summary_callback() +summary_callback() \ No newline at end of file diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl index bc4859e5760..d423b800fd0 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_ec.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,26 +33,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl index 771343937a4..62c5bab51ea 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_convergence_es.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4), gas_constants = (0.4, 0.4)) initial_condition = initial_condition_convergence_test volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,26 +33,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.5) +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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl b/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl index d912a280e49..0715dfe35d6 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_ec.jl @@ -4,23 +4,26 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = 1.4, +equations = CompressibleEulerMulticomponentEquations2D(gammas = 1.4, gas_constants = 0.4) + initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,27 +34,28 @@ summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (Trixi.density,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(Trixi.density,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_es.jl b/examples/tree_2d_dgsem/elixir_eulermulti_es.jl index 470e533ab8d..a3e5580b572 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_es.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_es.jl @@ -4,23 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler multicomponent equations -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4, 1.4, 1.4), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.4, 1.4, 1.4), gas_constants = (0.4, 0.4, 0.4, 0.4)) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 10_000) + initial_refinement_level=5, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,29 +32,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl b/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl index f5ef51c108a..38510446cb1 100644 --- a/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl +++ b/examples/tree_2d_dgsem/elixir_eulermulti_shock_bubble.jl @@ -5,7 +5,7 @@ using Trixi # semidiscretization of the compressible Euler multicomponent equations # 1) Dry Air 2) Helium + 28% Air -equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.648), +equations = CompressibleEulerMulticomponentEquations2D(gammas = (1.4, 1.648), gas_constants = (0.287, 1.578)) """ @@ -16,126 +16,124 @@ A shock-bubble testcase for multicomponent Euler equations Formulation of Entropy-Stable schemes for the multicomponent compressible Euler equations [arXiv: 1904.00972](https://arxiv.org/abs/1904.00972) """ -function initial_condition_shock_bubble(x, t, - equations::CompressibleEulerMulticomponentEquations2D{ - 5, - 2 - }) - # bubble test case, see Gouasmi et al. https://arxiv.org/pdf/1904.00972 - # other reference: https://www.researchgate.net/profile/Pep_Mulet/publication/222675930_A_flux-split_algorithm_applied_to_conservative_models_for_multicomponent_compressible_flows/links/568da54508aeaa1481ae7af0.pdf - # typical domain is rectangular, we change it to a square, as Trixi can only do squares - @unpack gas_constants = equations - - # Positivity Preserving Parameter, can be set to zero if scheme is positivity preserving - delta = 0.03 - - # Region I - rho1_1 = delta - rho2_1 = 1.225 * gas_constants[1] / gas_constants[2] - delta - v1_1 = zero(delta) - v2_1 = zero(delta) - p_1 = 101325 - - # Region II - rho1_2 = 1.225 - delta - rho2_2 = delta - v1_2 = zero(delta) - v2_2 = zero(delta) - p_2 = 101325 - - # Region III - rho1_3 = 1.6861 - delta - rho2_3 = delta - v1_3 = -113.5243 - v2_3 = zero(delta) - p_3 = 159060 - - # Set up Region I & II: - inicenter = SVector(zero(delta), zero(delta)) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - - if (x[1] > 0.50) - # Set up Region III - rho1 = rho1_3 - rho2 = rho2_3 - v1 = v1_3 - v2 = v2_3 - p = p_3 - elseif (r < 0.25) - # Set up Region I - rho1 = rho1_1 - rho2 = rho2_1 - v1 = v1_1 - v2 = v2_1 - p = p_1 - else - # Set up Region II - rho1 = rho1_2 - rho2 = rho2_2 - v1 = v1_2 - v2 = v2_2 - p = p_2 - end - - return prim2cons(SVector(v1, v2, p, rho1, rho2), equations) +function initial_condition_shock_bubble(x, t, equations::CompressibleEulerMulticomponentEquations2D{5, 2}) + # bubble test case, see Gouasmi et al. https://arxiv.org/pdf/1904.00972 + # other reference: https://www.researchgate.net/profile/Pep_Mulet/publication/222675930_A_flux-split_algorithm_applied_to_conservative_models_for_multicomponent_compressible_flows/links/568da54508aeaa1481ae7af0.pdf + # typical domain is rectangular, we change it to a square, as Trixi can only do squares + @unpack gas_constants = equations + + # Positivity Preserving Parameter, can be set to zero if scheme is positivity preserving + delta = 0.03 + + # Region I + rho1_1 = delta + rho2_1 = 1.225 * gas_constants[1]/gas_constants[2] - delta + v1_1 = zero(delta) + v2_1 = zero(delta) + p_1 = 101325 + + # Region II + rho1_2 = 1.225-delta + rho2_2 = delta + v1_2 = zero(delta) + v2_2 = zero(delta) + p_2 = 101325 + + # Region III + rho1_3 = 1.6861 - delta + rho2_3 = delta + v1_3 = -113.5243 + v2_3 = zero(delta) + p_3 = 159060 + + # Set up Region I & II: + inicenter = SVector(zero(delta), zero(delta)) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + + if (x[1] > 0.50) + # Set up Region III + rho1 = rho1_3 + rho2 = rho2_3 + v1 = v1_3 + v2 = v2_3 + p = p_3 + elseif (r < 0.25) + # Set up Region I + rho1 = rho1_1 + rho2 = rho2_1 + v1 = v1_1 + v2 = v2_1 + p = p_1 + else + # Set up Region II + rho1 = rho1_2 + rho2 = rho2_2 + v1 = v1_2 + v2 = v2_2 + p = p_2 + end + + return prim2cons(SVector(v1, v2, p, rho1, rho2), equations) end initial_condition = initial_condition_shock_bubble -surface_flux = flux_lax_friedrichs -volume_flux = flux_ranocha -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 = (-2.25, -2.225) -coordinates_max = (2.20, 2.225) -mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 1_000_000) - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) +surface_flux = flux_lax_friedrichs +volume_flux = flux_ranocha +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 = (-2.25, -2.225) +coordinates_max = ( 2.20, 2.225) +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level=3, + n_cells_max=1_000_000) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 0.01) -ode = semidiscretize(semi, tspan) +tspan = (0.0, 0.01) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() -summary_callback = SummaryCallback() +analysis_interval = 300 +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(Trixi.density,)) -analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (Trixi.density,)) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +save_solution = SaveSolutionCallback(interval=300, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -save_solution = SaveSolutionCallback(interval = 300, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +stepsize_callback = StepsizeCallback(cfl=0.3) -stepsize_callback = StepsizeCallback(cfl = 0.3) +callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback, + save_solution, + stepsize_callback) -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, - maxiters = 1e5); -summary_callback() # print the timer summary +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, + maxiters=1e5); +summary_callback() # print the timer summary \ No newline at end of file diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl b/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl index 1700957d900..abf9735fd28 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_godunov.jl @@ -8,50 +8,51 @@ using Trixi equations = HyperbolicDiffusionEquations2D() function initial_condition_poisson_periodic(x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # depending on initial constant state, c, for phi this converges to the solution ϕ + c - if iszero(t) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - else - phi = sin(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) - q1 = 2 * pi * cos(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) - q2 = 2 * pi * sin(2.0 * pi * x[1]) * cos(2.0 * pi * x[2]) - end - return SVector(phi, q1, q2) + # elliptic equation: -νΔϕ = f + # depending on initial constant state, c, for phi this converges to the solution ϕ + c + if iszero(t) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + else + phi = sin(2.0*pi*x[1])*sin(2.0*pi*x[2]) + q1 = 2*pi*cos(2.0*pi*x[1])*sin(2.0*pi*x[2]) + q2 = 2*pi*sin(2.0*pi*x[1])*cos(2.0*pi*x[2]) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_poisson_periodic -@inline function source_terms_poisson_periodic(u, x, t, - equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) - @unpack inv_Tr = equations - C = -8 * equations.nu * pi^2 - - x1, x2 = x - tmp1 = sinpi(2 * x1) - tmp2 = sinpi(2 * x2) - du1 = -C * tmp1 * tmp2 - du2 = -inv_Tr * u[2] - du3 = -inv_Tr * u[3] - - return SVector(du1, du2, du3) +@inline function source_terms_poisson_periodic(u, x, t, equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -νΔϕ = f + # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) + @unpack inv_Tr = equations + C = -8 * equations.nu * pi^2 + + x1, x2 = x + tmp1 = sinpi(2 * x1) + tmp2 = sinpi(2 * x2) + du1 = -C*tmp1*tmp2 + du2 = -inv_Tr * u[2] + du3 = -inv_Tr * u[3] + + return SVector(du1, du2, du3) end volume_flux = flux_central -solver = DGSEM(polydeg = 4, surface_flux = flux_godunov, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=flux_godunov, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_poisson_periodic) + source_terms=source_terms_poisson_periodic) + ############################################################################### # ODE solvers, callbacks etc. @@ -62,29 +63,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl index e70b91906b1..c144ef47a63 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_harmonic_nonperiodic.jl @@ -7,43 +7,44 @@ using Trixi equations = HyperbolicDiffusionEquations2D() -@inline function initial_condition_harmonic_nonperiodic(x, t, - equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω - if t == 0.0 - phi = 1.0 - q1 = 1.0 - q2 = 1.0 - else - C = inv(sinh(pi)) - sinpi_x1, cospi_x1 = sincos(pi * x[1]) - sinpi_x2, cospi_x2 = sincos(pi * x[2]) - sinh_pix1 = sinh(pi * x[1]) - cosh_pix1 = cosh(pi * x[1]) - sinh_pix2 = sinh(pi * x[2]) - cosh_pix2 = cosh(pi * x[2]) - phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) - q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) - q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) - end - return SVector(phi, q1, q2) +@inline function initial_condition_harmonic_nonperiodic(x, t, equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -ν Δϕ = 0 in Ω, u = g on ∂Ω + if t == 0.0 + phi = 1.0 + q1 = 1.0 + q2 = 1.0 + else + C = inv(sinh(pi)) + sinpi_x1, cospi_x1 = sincos(pi*x[1]) + sinpi_x2, cospi_x2 = sincos(pi*x[2]) + sinh_pix1 = sinh(pi*x[1]) + cosh_pix1 = cosh(pi*x[1]) + sinh_pix2 = sinh(pi*x[2]) + cosh_pix2 = cosh(pi*x[2]) + phi = C * (sinh_pix1 * sinpi_x2 + sinh_pix2 * sinpi_x1) + q1 = C * pi * (cosh_pix1 * sinpi_x2 + sinh_pix2 * cospi_x1) + q2 = C * pi * (sinh_pix1 * cospi_x2 + cosh_pix2 * sinpi_x1) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_harmonic_nonperiodic boundary_conditions = BoundaryConditionDirichlet(initial_condition) -solver = DGSEM(polydeg = 4, surface_flux = flux_godunov) +solver = DGSEM(polydeg=4, surface_flux=flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000, - periodicity = false) + initial_refinement_level=3, + n_cells_max=30_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions, - source_terms = source_terms_harmonic) + boundary_conditions=boundary_conditions, + source_terms=source_terms_harmonic) + ############################################################################### # ODE solvers, callbacks etc. @@ -54,29 +55,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl b/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl index a1a0397a46c..d0d706981a2 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_lax_friedrichs.jl @@ -8,48 +8,49 @@ using Trixi equations = HyperbolicDiffusionEquations2D() function initial_condition_poisson_periodic(x, t, equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # depending on initial constant state, c, for phi this converges to the solution ϕ + c - if iszero(t) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - else - phi = sin(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) - q1 = 2 * pi * cos(2.0 * pi * x[1]) * sin(2.0 * pi * x[2]) - q2 = 2 * pi * sin(2.0 * pi * x[1]) * cos(2.0 * pi * x[2]) - end - return SVector(phi, q1, q2) + # elliptic equation: -νΔϕ = f + # depending on initial constant state, c, for phi this converges to the solution ϕ + c + if iszero(t) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + else + phi = sin(2.0*pi*x[1])*sin(2.0*pi*x[2]) + q1 = 2*pi*cos(2.0*pi*x[1])*sin(2.0*pi*x[2]) + q2 = 2*pi*sin(2.0*pi*x[1])*cos(2.0*pi*x[2]) + end + return SVector(phi, q1, q2) end initial_condition = initial_condition_poisson_periodic -@inline function source_terms_poisson_periodic(u, x, t, - equations::HyperbolicDiffusionEquations2D) - # elliptic equation: -νΔϕ = f - # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) - @unpack inv_Tr = equations - C = -8 * equations.nu * pi^2 - - x1, x2 = x - tmp1 = sinpi(2 * x1) - tmp2 = sinpi(2 * x2) - du1 = -C * tmp1 * tmp2 - du2 = -inv_Tr * u[2] - du3 = -inv_Tr * u[3] - - return SVector(du1, du2, du3) +@inline function source_terms_poisson_periodic(u, x, t, equations::HyperbolicDiffusionEquations2D) + # elliptic equation: -νΔϕ = f + # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) + @unpack inv_Tr = equations + C = -8 * equations.nu * pi^2 + + x1, x2 = x + tmp1 = sinpi(2 * x1) + tmp2 = sinpi(2 * x2) + du1 = -C*tmp1*tmp2 + du2 = -inv_Tr * u[2] + du3 = -inv_Tr * u[3] + + return SVector(du1, du2, du3) end -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_poisson_periodic) + source_terms=source_terms_poisson_periodic) + ############################################################################### # ODE solvers, callbacks etc. @@ -60,30 +61,31 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) + ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = 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 diff --git a/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl index 1396481a3f1..fc825660f1e 100644 --- a/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/tree_2d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -9,23 +9,25 @@ equations = HyperbolicDiffusionEquations2D() initial_condition = initial_condition_poisson_nonperiodic # 1 => -x, 2 => +x, 3 => -y, 4 => +y as usual for orientations -boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, - x_pos = boundary_condition_poisson_nonperiodic, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) +boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, + x_pos=boundary_condition_poisson_nonperiodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic) -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000, - periodicity = (false, true)) + initial_refinement_level=3, + n_cells_max=30_000, + periodicity=(false, true)) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions, - source_terms = source_terms_poisson_nonperiodic) + boundary_conditions=boundary_conditions, + source_terms=source_terms_poisson_nonperiodic) + ############################################################################### # ODE solvers, callbacks etc. @@ -36,29 +38,30 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, steady_state_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_kpp.jl b/examples/tree_2d_dgsem/elixir_kpp.jl index 3b9dc9c59ce..f3cbc1cb664 100644 --- a/examples/tree_2d_dgsem/elixir_kpp.jl +++ b/examples/tree_2d_dgsem/elixir_kpp.jl @@ -25,31 +25,22 @@ end @inline function Trixi.flux_ec(u_ll, u_rr, orientation::Integer, ::KPPEquation2D) # The tolerance of 1e-12 is based on experience and somewhat arbitrarily chosen if abs(u_ll[1] - u_rr[1]) < 1e-12 - return 0.5 * (flux(u_ll, orientation, KPPEquation2D()) + - flux(u_rr, orientation, KPPEquation2D())) + return 0.5 * (flux(u_ll, orientation, KPPEquation2D()) + flux(u_rr, orientation, KPPEquation2D())) else factor = 1.0 / (u_rr[1] - u_ll[1]) if orientation == 1 - return SVector(factor * (-cos(u_rr[1]) + cos(u_ll[1]))) + return SVector(factor*(-cos(u_rr[1]) + cos(u_ll[1]))) else - return SVector(factor * (sin(u_rr[1]) - sin(u_ll[1]))) + return SVector(factor*(sin(u_rr[1]) - sin(u_ll[1]))) end end end # Wavespeeds @inline wavespeed(::KPPEquation2D) = 1.0 -@inline function Trixi.max_abs_speeds(u, equation::KPPEquation2D) - (wavespeed(equation), wavespeed(equation)) -end -@inline function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, - equation::KPPEquation2D) - wavespeed(equation) -end -@inline function Trixi.max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, - equation::KPPEquation2D) - wavespeed(equation) * norm(normal_direction) -end +@inline Trixi.max_abs_speeds(u, equation::KPPEquation2D) = (wavespeed(equation), wavespeed(equation)) +@inline Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, equation::KPPEquation2D) = wavespeed(equation) +@inline Trixi.max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equation::KPPEquation2D) = wavespeed(equation) * norm(normal_direction) # Compute entropy: we use the square entropy @inline Trixi.entropy(u::Real, ::KPPEquation2D) = 0.5 * u^2 @@ -83,25 +74,24 @@ volume_flux = flux_ec polydeg = 3 basis = LobattoLegendreBasis(polydeg) shock_indicator = IndicatorHennemannGassner(equation, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = first) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=first) volume_integral = VolumeIntegralShockCapturingHG(shock_indicator; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) ############################################################################### # Set up the tree mesh (initially a Cartesian grid of [-2,2]^2) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 6, - periodicity = true, - n_cells_max = 500_000) + initial_refinement_level=6, + periodicity=true, + n_cells_max=500_000) ############################################################################### # Create the semi discretization object @@ -110,24 +100,23 @@ semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_kpp, solve ############################################################################### # Set up adaptive mesh refinement amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0001, - alpha_smooth = false, - variable = first) + alpha_max=1.0, + alpha_min=0.0001, + alpha_smooth=false, + variable=first) max_refinement_level = 8 amr_controller = ControllerThreeLevelCombined(semi, amr_indicator, shock_indicator, - base_level = 2, - med_level = 0, med_threshold = 0.0003, - max_level = max_refinement_level, - max_threshold = 0.003, - max_threshold_secondary = shock_indicator.alpha_max) + base_level=2, + med_level=0, med_threshold=0.0003, + max_level=max_refinement_level, max_threshold=0.003, + max_threshold_secondary=shock_indicator.alpha_max) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) ############################################################################### # ODE solvers, callbacks etc. @@ -136,14 +125,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -analysis_callback = AnalysisCallback(semi, interval = 200) +analysis_callback = AnalysisCallback(semi, interval=200) -alive_callback = AliveCallback(analysis_interval = 200) +alive_callback = AliveCallback(analysis_interval=200) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2cons) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2cons) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -151,6 +140,6 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); ode_default_options()..., callback=callbacks) summary_callback() # Print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_lbm_constant.jl b/examples/tree_2d_dgsem/elixir_lbm_constant.jl index 5a4f3074e4e..40b16f41ef6 100644 --- a/examples/tree_2d_dgsem/elixir_lbm_constant.jl +++ b/examples/tree_2d_dgsem/elixir_lbm_constant.jl @@ -5,20 +5,22 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D2Q9 scheme -equations = LatticeBoltzmannEquations2D(Ma = 0.1, Re = Inf) +equations = LatticeBoltzmannEquations2D(Ma=0.1, Re=Inf) initial_condition = initial_condition_constant -solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) +solver = DGSEM(polydeg=3, surface_flux=flux_godunov) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,19 +30,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2macroscopic) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) collision_callback = LBMCollisionCallback() @@ -50,10 +52,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_lbm_couette.jl b/examples/tree_2d_dgsem/elixir_lbm_couette.jl index 1ba040405d1..6a33b2fb0ee 100644 --- a/examples/tree_2d_dgsem/elixir_lbm_couette.jl +++ b/examples/tree_2d_dgsem/elixir_lbm_couette.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D2Q9 scheme -equations = LatticeBoltzmannEquations2D(Ma = 0.05, Re = 2000) +equations = LatticeBoltzmannEquations2D(Ma=0.05, Re=2000) """ initial_condition_couette_unsteady(x, t, equations::LatticeBoltzmannEquations2D) @@ -16,20 +16,19 @@ incompressible Navier-Stokes equations. To be used in combination with this setup will converge to the state set in [`initial_condition_couette_steady`](@ref). """ function initial_condition_couette_unsteady(x, t, equations::LatticeBoltzmannEquations2D) - @unpack L, u0, rho0, nu = equations + @unpack L, u0, rho0, nu = equations - x1, x2 = x - v1 = u0 * x2 / L - for m in 1:100 - lambda_m = m * pi / L - v1 += 2 * u0 * (-1)^m / (lambda_m * L) * exp(-nu * lambda_m^2 * t) * - sin(lambda_m * x2) - end + x1, x2 = x + v1 = u0*x2/L + for m in 1:100 + lambda_m = m * pi / L + v1 += 2 * u0 * (-1)^m/(lambda_m * L) * exp(-nu * lambda_m^2 * t) * sin(lambda_m * x2) + end - rho = 1 - v2 = 0 + rho = 1 + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) + return equilibrium_distribution(rho, v1, v2, equations) end initial_condition = initial_condition_couette_unsteady @@ -45,49 +44,53 @@ Moving *upper* wall boundary condition for a Couette flow setup. To be used in c function boundary_condition_couette(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, - surface_flux_function, equations) + return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, + surface_flux_function, equations) end function boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - @assert direction==4 "moving wall assumed in +y direction" + @assert direction == 4 "moving wall assumed in +y direction" - @unpack rho0, u0, weights, c_s = equations - cs_squared = c_s^2 + @unpack rho0, u0, weights, c_s = equations + cs_squared = c_s^2 - pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared - pdf2 = u_inner[2] # outgoing - pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared - pdf4 = u_inner[2] - pdf5 = u_inner[5] # outgoing - pdf6 = u_inner[6] # outgoing - pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared - pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared - pdf9 = u_inner[9] + pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared + pdf2 = u_inner[2] # outgoing + pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared + pdf4 = u_inner[2] + pdf5 = u_inner[5] # outgoing + pdf6 = u_inner[6] # outgoing + pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared + pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared + pdf9 = u_inner[9] - u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) + u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) - # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) - return surface_flux_function(u_inner, u_boundary, orientation, equations) + # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) + return surface_flux_function(u_inner, u_boundary, orientation, equations) end -boundary_conditions = (x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_noslip_wall, - y_pos = boundary_condition_couette) +boundary_conditions = ( + x_neg=boundary_condition_periodic, + x_pos=boundary_condition_periodic, + y_neg=boundary_condition_noslip_wall, + y_pos=boundary_condition_couette, + ) -solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) +solver = DGSEM(polydeg=3, surface_flux=flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - periodicity = (true, false), - n_cells_max = 10_000) + initial_refinement_level=3, + periodicity=(true, false), + n_cells_max=10_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -98,29 +101,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # Custom solution variables: normalize velocities by reference speed `u0` @inline function macroscopic_normalized(u, equations::LatticeBoltzmannEquations2D) - macroscopic = cons2macroscopic(u, equations) - rho, v1, v2, p = macroscopic + macroscopic = cons2macroscopic(u, equations) + rho, v1, v2, p = macroscopic - # Use `typeof(macroscopic)` to avoid having to explicitly add `using StaticArrays` - convert(typeof(macroscopic), (rho, v1 / equations.u0, v2 / equations.u0, p)) -end -function Trixi.varnames(::typeof(macroscopic_normalized), - equations::LatticeBoltzmannEquations2D) - ("rho", "v1_normalized", "v2_normalized", "p") + # Use `typeof(macroscopic)` to avoid having to explicitly add `using StaticArrays` + convert(typeof(macroscopic), (rho, v1/equations.u0, v2/equations.u0, p)) end +Trixi.varnames(::typeof(macroscopic_normalized), equations::LatticeBoltzmannEquations2D) = ("rho", "v1_normalized", "v2_normalized", "p") -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = macroscopic_normalized) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=macroscopic_normalized) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) collision_callback = LBMCollisionCallback() @@ -130,10 +130,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl b/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl index d00926cafad..a34e784e7ac 100644 --- a/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl +++ b/examples/tree_2d_dgsem/elixir_lbm_lid_driven_cavity.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D2Q9 scheme -equations = LatticeBoltzmannEquations2D(Ma = 0.1, Re = 1000) +equations = LatticeBoltzmannEquations2D(Ma=0.1, Re=1000) """ initial_condition_lid_driven_cavity(x, t, equations::LatticeBoltzmannEquations2D) @@ -14,13 +14,13 @@ Initial state for a lid-driven cavity flow setup. To be used in combination with [`boundary_condition_lid_driven_cavity`](@ref) and [`boundary_condition_noslip_wall`](@ref). """ function initial_condition_lid_driven_cavity(x, t, equations::LatticeBoltzmannEquations2D) - @unpack L, u0, nu = equations + @unpack L, u0, nu = equations - rho = 1 - v1 = 0 - v2 = 0 + rho = 1 + v1 = 0 + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) + return equilibrium_distribution(rho, v1, v2, equations) end initial_condition = initial_condition_lid_driven_cavity @@ -35,49 +35,53 @@ no-slip wall. To be used in combination with [`initial_condition_lid_driven_cavi function boundary_condition_lid_driven_cavity(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, - surface_flux_function, equations) + return boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, + surface_flux_function, equations) end function boundary_condition_moving_wall_ypos(u_inner, orientation, direction, x, t, surface_flux_function, equations::LatticeBoltzmannEquations2D) - @assert direction==4 "moving wall assumed in +y direction" + @assert direction == 4 "moving wall assumed in +y direction" - @unpack rho0, u0, weights, c_s = equations - cs_squared = c_s^2 + @unpack rho0, u0, weights, c_s = equations + cs_squared = c_s^2 - pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared - pdf2 = u_inner[2] # outgoing - pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared - pdf4 = u_inner[2] - pdf5 = u_inner[5] # outgoing - pdf6 = u_inner[6] # outgoing - pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared - pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared - pdf9 = u_inner[9] + pdf1 = u_inner[3] + 2 * weights[1] * rho0 * u0 / cs_squared + pdf2 = u_inner[2] # outgoing + pdf3 = u_inner[1] + 2 * weights[3] * rho0 * (-u0) / cs_squared + pdf4 = u_inner[2] + pdf5 = u_inner[5] # outgoing + pdf6 = u_inner[6] # outgoing + pdf7 = u_inner[5] + 2 * weights[7] * rho0 * (-u0) / cs_squared + pdf8 = u_inner[6] + 2 * weights[8] * rho0 * u0 / cs_squared + pdf9 = u_inner[9] - u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) + u_boundary = SVector(pdf1, pdf2, pdf3, pdf4, pdf5, pdf6, pdf7, pdf8, pdf9) - # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) - return surface_flux_function(u_inner, u_boundary, orientation, equations) + # Calculate boundary flux (u_inner is "left" of boundary, u_boundary is "right" of boundary) + return surface_flux_function(u_inner, u_boundary, orientation, equations) end -boundary_conditions = (x_neg = boundary_condition_noslip_wall, - x_pos = boundary_condition_noslip_wall, - y_neg = boundary_condition_noslip_wall, - y_pos = boundary_condition_lid_driven_cavity) +boundary_conditions = ( + x_neg=boundary_condition_noslip_wall, + x_pos=boundary_condition_noslip_wall, + y_neg=boundary_condition_noslip_wall, + y_pos=boundary_condition_lid_driven_cavity, + ) -solver = DGSEM(polydeg = 5, surface_flux = flux_godunov) +solver = DGSEM(polydeg=5, surface_flux=flux_godunov) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = false, - n_cells_max = 10_000) + initial_refinement_level=4, + periodicity=false, + n_cells_max=10_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -88,16 +92,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2macroscopic) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) collision_callback = LBMCollisionCallback() @@ -107,10 +111,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl b/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl index 93272833b74..14459fa4cb8 100644 --- a/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_linearizedeuler_convergence.jl @@ -4,25 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the linearized Euler equations -equations = LinearizedEulerEquations2D(v_mean_global = (0.0, 0.0), c_mean_global = 1.0, - rho_mean_global = 1.0) +equations = LinearizedEulerEquations2D(v_mean_global=(0.0, 0.0), c_mean_global=1.0, rho_mean_global=1.0) initial_condition = initial_condition_convergence_test # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -37,29 +37,28 @@ summary_callback = SummaryCallback() analysis_interval = 100 # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = analysis_interval, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=analysis_interval, solution_variables=cons2prim) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 0.8) +stepsize_callback = StepsizeCallback(cfl=0.8) # 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, alive_callback, - stepsize_callback) +callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, alive_callback, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # print the timer summary summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl index 377a07e947e..d9e59160e7d 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -4,24 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,25 +32,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.5 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -58,10 +56,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl index aee430e9cf9..6632331eb37 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_alfven_wave_mortar.jl @@ -4,25 +4,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) -refinement_patches = ((type = "box", coordinates_min = 0.25 .* coordinates_max, - coordinates_max = 0.75 .* coordinates_max),) +refinement_patches = ( + (type="box", coordinates_min=0.25 .* coordinates_max, + coordinates_max=0.75 .* coordinates_max), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=4, + refinement_patches=refinement_patches, + n_cells_max=10_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -35,25 +35,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -65,7 +62,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl b/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl index a0909ca7580..af05fffaf54 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_blast_wave.jl @@ -16,50 +16,52 @@ An MHD blast wave taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ 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) - f = (0.1 - r) / 0.01 - if r <= 0.09 - p = 1000.0 - elseif r >= 0.1 - p = 0.1 - else - p = 0.1 + 999.9 * f - end - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - B1 = 100.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) + # 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) + f = (0.1 - r)/0.01 + if r <= 0.09 + p = 1000.0 + elseif r >= 0.1 + p = 0.1 + else + p = 0.1 + 999.9*f + end + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + B1 = 100.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) -volume_flux = (flux_central, flux_nonconservative_powell) +volume_flux = (flux_central, flux_nonconservative_powell) basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + 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) +coordinates_max = ( 0.5, 0.5) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -69,32 +71,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = false, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level =6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 7, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=7, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) cfl = 0.8 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -107,7 +109,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_ec.jl b/examples/tree_2d_dgsem/elixir_mhd_ec.jl index 173d3ed448f..5873388f798 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_ec.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_ec.jl @@ -10,18 +10,19 @@ equations = IdealGlmMhdEquations2D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,19 +32,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -52,10 +53,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl b/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl index 7f26f270d6e..460b24e02b2 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_orszag_tang.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations2D(gamma) """ @@ -16,42 +16,44 @@ The classical Orszag-Tang vortex test case. Here, the setup is taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ function initial_condition_orszag_tang(x, t, equations::IdealGlmMhdEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 5/3 - rho = 1.0 - v1 = -sin(2.0 * pi * x[2]) - v2 = sin(2.0 * pi * x[1]) - v3 = 0.0 - p = 1.0 / equations.gamma - B1 = -sin(2.0 * pi * x[2]) / equations.gamma - B2 = sin(4.0 * pi * x[1]) / equations.gamma - B3 = 0.0 - psi = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 5/3 + rho = 1.0 + v1 = -sin(2.0*pi*x[2]) + v2 = sin(2.0*pi*x[1]) + v3 = 0.0 + p = 1.0 / equations.gamma + B1 = -sin(2.0*pi*x[2]) / equations.gamma + B2 = sin(4.0*pi*x[1]) / equations.gamma + B3 = 0.0 + psi = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) end initial_condition = initial_condition_orszag_tang surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_central, flux_nonconservative_powell) +volume_flux = (flux_central, flux_nonconservative_powell) basis = LobattoLegendreBasis(3) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -61,32 +63,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = false, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level =6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 6, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=6, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) cfl = 1.25 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -99,7 +101,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhd_rotor.jl b/examples/tree_2d_dgsem/elixir_mhd_rotor.jl index 3109b1ce303..c6d880e9e9d 100644 --- a/examples/tree_2d_dgsem/elixir_mhd_rotor.jl +++ b/examples/tree_2d_dgsem/elixir_mhd_rotor.jl @@ -2,6 +2,7 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations equations = IdealGlmMhdEquations2D(1.4) @@ -15,57 +16,59 @@ The classical MHD rotor test case. Here, the setup is taken from [doi: 10.1365/s13291-018-0178-9](https://doi.org/10.1365/s13291-018-0178-9) """ function initial_condition_rotor(x, t, equations::IdealGlmMhdEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 1.4 - dx = x[1] - 0.5 - dy = x[2] - 0.5 - r = sqrt(dx^2 + dy^2) - f = (0.115 - r) / 0.015 - if r <= 0.1 - rho = 10.0 - v1 = -20.0 * dy - v2 = 20.0 * dx - elseif r >= 0.115 - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - else - rho = 1.0 + 9.0 * f - v1 = -20.0 * f * dy - v2 = 20.0 * f * dx - end - v3 = 0.0 - p = 1.0 - B1 = 5.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) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 1.4 + dx = x[1] - 0.5 + dy = x[2] - 0.5 + r = sqrt(dx^2 + dy^2) + f = (0.115 - r)/0.015 + if r <= 0.1 + rho = 10.0 + v1 = -20.0*dy + v2 = 20.0*dx + elseif r >= 0.115 + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + else + rho = 1.0 + 9.0*f + v1 = -20.0*f*dy + v2 = 20.0*f*dx + end + v3 = 0.0 + p = 1.0 + B1 = 5.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_rotor surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -75,32 +78,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = false, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level =6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 6, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=6, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) cfl = 0.35 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -113,7 +116,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl index 4f1f8c5f2b7..a7551f48937 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_convergence.jl @@ -5,24 +5,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5 / 3, 5 / 3, 5 / 3), - gas_constants = (2.08, 2.08, 2.08)) +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5/3, 5/3, 5/3), + gas_constants = (2.08, 2.08, 2.08)) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2), sqrt(2)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -32,20 +33,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -54,10 +54,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl index a7db9eeee96..ec2f3c21cdd 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_ec.jl @@ -5,24 +5,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), - gas_constants = (1.0, 1.0)) +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), + gas_constants = (1.0, 1.0)) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -32,19 +33,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -53,10 +54,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl index fcaabdc7a58..3cd9c621ae3 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_es.jl @@ -5,24 +5,25 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5 / 3, 5 / 3), - gas_constants = (0.2, 0.2)) +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (5/3, 5/3), + gas_constants = (0.2, 0.2)) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) +coordinates_max = ( 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -32,19 +33,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -53,10 +54,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl b/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl index 5ca21cc5e9c..55a4004f794 100644 --- a/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl +++ b/examples/tree_2d_dgsem/elixir_mhdmulti_rotor.jl @@ -2,9 +2,10 @@ using OrdinaryDiffEq using Trixi + ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), +equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), gas_constants = (1.0, 1.0)) """ @@ -13,60 +14,62 @@ equations = IdealGlmMhdMulticomponentEquations2D(gammas = (1.4, 1.4), The classical MHD rotor test case adapted to two density components. """ function initial_condition_rotor(x, t, equations::IdealGlmMhdMulticomponentEquations2D) - # setup taken from Derigs et al. DMV article (2018) - # domain must be [0, 1] x [0, 1], γ = 1.4 - dx = x[1] - 0.5 - dy = x[2] - 0.5 - r = sqrt(dx^2 + dy^2) - f = (0.115 - r) / 0.015 - if r <= 0.1 - rho1 = 10.0 - rho2 = 5.0 - v1 = -20.0 * dy - v2 = 20.0 * dx - elseif r >= 0.115 - rho1 = 1.0 - rho2 = 0.5 - v1 = 0.0 - v2 = 0.0 - else - rho1 = 1.0 + 9.0 * f - rho2 = 0.5 + 4.5 * f - v1 = -20.0 * f * dy - v2 = 20.0 * f * dx - end - v3 = 0.0 - p = 1.0 - B1 = 5.0 / sqrt(4.0 * pi) - B2 = 0.0 - B3 = 0.0 - psi = 0.0 - return prim2cons(SVector(v1, v2, v3, p, B1, B2, B3, psi, rho1, rho2), equations) + # setup taken from Derigs et al. DMV article (2018) + # domain must be [0, 1] x [0, 1], γ = 1.4 + dx = x[1] - 0.5 + dy = x[2] - 0.5 + r = sqrt(dx^2 + dy^2) + f = (0.115 - r)/0.015 + if r <= 0.1 + rho1 = 10.0 + rho2 = 5.0 + v1 = -20.0*dy + v2 = 20.0*dx + elseif r >= 0.115 + rho1 = 1.0 + rho2 = 0.5 + v1 = 0.0 + v2 = 0.0 + else + rho1 = 1.0 + 9.0*f + rho2 = 0.5 + 4.5*f + v1 = -20.0*f*dy + v2 = 20.0*f*dx + end + v3 = 0.0 + p = 1.0 + B1 = 5.0/sqrt(4.0*pi) + B2 = 0.0 + B3 = 0.0 + psi = 0.0 + return prim2cons(SVector(v1, v2, v3, p, B1, B2, B3, psi, rho1, rho2), equations) end initial_condition = initial_condition_rotor surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.8, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.8, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -76,32 +79,32 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = false, - variable = density_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 4, - max_level = 6, max_threshold = 0.01) + base_level=4, + max_level =6, max_threshold=0.01) amr_callback = AMRCallback(semi, amr_controller, - interval = 6, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=6, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -114,7 +117,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl b/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl index f6f0f7ca13e..36a9f52e39d 100644 --- a/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_navierstokes_convergence.jl @@ -8,234 +8,187 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations2D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), - Prandtl = prandtl_number(), - gradient_variables = GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), Prandtl=prandtl_number(), + gradient_variables=GradientVariablesPrimitive()) # 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, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = (true, false), - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=4, + periodicity=(true, false), + n_cells_max=30_000) # set maximum capacity of tree data structure # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion2D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion2D`) # and by the initial condition (which passes in `CompressibleEulerEquations2D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Amplitude and shift - A = 0.5 - c = 2.0 + # Amplitude and shift + A = 0.5 + c = 2.0 - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0))) * cos(pi_t) - v2 = v1 - p = rho^2 + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + v1 = sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A * (x[2] - 1.0)) ) * cos(pi_t) + v2 = v1 + p = rho^2 - return prim2cons(SVector(rho, v1, v2, p), equations) + return prim2cons(SVector(rho, v1, v2, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - y = x[2] - - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Same settings as in `initial_condition` - # Amplitude and shift - A = 0.5 - c = 2.0 - - # convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_t = pi * t - - # compute the manufactured solution and all necessary derivatives - rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) - rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) - rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) - rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) - - v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) - v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_y = sin(pi_x) * - (A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) - v1_xy = pi * cos(pi_x) * - (A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) - v1_yy = (sin(pi_x) * - (2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) - - - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) - - - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_xx = v1_xx - v2_xy = v1_xy - v2_yy = v1_yy - - p = rho * rho - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x - p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y - - # Note this simplifies slightly because the ansatz assumes that v1 = v2 - E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) - E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y - - # Some convenience constants - T_const = equations.gamma * inv_gamma_minus_one / Pr - inv_rho_cubed = 1.0 / (rho^3) - - # compute the source terms - # density equation - du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y - - # x-momentum equation - du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - # stress tensor from x-direction - - - 4.0 / 3.0 * v1_xx * mu_ - + - 2.0 / 3.0 * v2_xy * mu_ - - - v1_yy * mu_ - - - v2_xy * mu_) - # y-momentum equation - du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - # stress tensor from y-direction - - - v1_xy * mu_ - - - v2_xx * mu_ - - - 4.0 / 3.0 * v2_yy * mu_ - + - 2.0 / 3.0 * v1_xy * mu_) - # total energy equation - du4 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - # stress tensor and temperature gradient terms from x-direction - - - 4.0 / 3.0 * v1_xx * v1 * mu_ - + - 2.0 / 3.0 * v2_xy * v1 * mu_ - - - 4.0 / 3.0 * v1_x * v1_x * mu_ - + - 2.0 / 3.0 * v2_y * v1_x * mu_ - - - v1_xy * v2 * mu_ - - - v2_xx * v2 * mu_ - - - v1_y * v2_x * mu_ - - - v2_x * v2_x * mu_ - - - T_const * inv_rho_cubed * - (p_xx * rho * rho - - - 2.0 * p_x * rho * rho_x - + - 2.0 * p * rho_x * rho_x - - - p * rho * rho_xx) * mu_ - # stress tensor and temperature gradient terms from y-direction - - - v1_yy * v1 * mu_ - - - v2_xy * v1 * mu_ - - - v1_y * v1_y * mu_ - - - v2_x * v1_y * mu_ - - - 4.0 / 3.0 * v2_yy * v2 * mu_ - + - 2.0 / 3.0 * v1_xy * v2 * mu_ - - - 4.0 / 3.0 * v2_y * v2_y * mu_ - + - 2.0 / 3.0 * v1_x * v2_y * mu_ - - - T_const * inv_rho_cubed * - (p_yy * rho * rho - - - 2.0 * p_y * rho * rho_y - + - 2.0 * p * rho_y * rho_y - - - p * rho * rho_yy) * mu_) - - return SVector(du1, du2, du3, du4) + y = x[2] + + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Same settings as in `initial_condition` + # Amplitude and shift + A = 0.5 + c = 2.0 + + # convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_t = pi * t + + # compute the manufactured solution and all necessary derivatives + rho = c + A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_t = -pi * A * sin(pi_x) * cos(pi_y) * sin(pi_t) + rho_x = pi * A * cos(pi_x) * cos(pi_y) * cos(pi_t) + rho_y = -pi * A * sin(pi_x) * sin(pi_y) * cos(pi_t) + rho_xx = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + rho_yy = -pi * pi * A * sin(pi_x) * cos(pi_y) * cos(pi_t) + + v1 = sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_t = -pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * sin(pi_t) + v1_x = pi * cos(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_y = sin(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_xx = -pi * pi * sin(pi_x) * log(y + 2.0) * (1.0 - exp(-A * (y - 1.0))) * cos(pi_t) + v1_xy = pi * cos(pi_x) * (A * log(y + 2.0) * exp(-A * (y - 1.0)) + (1.0 - exp(-A * (y - 1.0))) / (y + 2.0)) * cos(pi_t) + v1_yy = (sin(pi_x) * ( 2.0 * A * exp(-A * (y - 1.0)) / (y + 2.0) + - A * A * log(y + 2.0) * exp(-A * (y - 1.0)) + - (1.0 - exp(-A * (y - 1.0))) / ((y + 2.0) * (y + 2.0))) * cos(pi_t)) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_xx = v1_xx + v2_xy = v1_xy + v2_yy = v1_yy + + p = rho * rho + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_xx = 2.0 * rho * rho_xx + 2.0 * rho_x * rho_x + p_yy = 2.0 * rho * rho_yy + 2.0 * rho_y * rho_y + + # Note this simplifies slightly because the ansatz assumes that v1 = v2 + E = p * inv_gamma_minus_one + 0.5 * rho * (v1^2 + v2^2) + E_t = p_t * inv_gamma_minus_one + rho_t * v1^2 + 2.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + rho_x * v1^2 + 2.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + rho_y * v1^2 + 2.0 * rho * v1 * v1_y + + # Some convenience constants + T_const = equations.gamma * inv_gamma_minus_one / Pr + inv_rho_cubed = 1.0 / (rho^3) + + # compute the source terms + # density equation + du1 = rho_t + rho_x * v1 + rho * v1_x + rho_y * v2 + rho * v2_y + + # x-momentum equation + du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + # stress tensor from x-direction + - 4.0 / 3.0 * v1_xx * mu_ + + 2.0 / 3.0 * v2_xy * mu_ + - v1_yy * mu_ + - v2_xy * mu_ ) + # y-momentum equation + du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + # stress tensor from y-direction + - v1_xy * mu_ + - v2_xx * mu_ + - 4.0 / 3.0 * v2_yy * mu_ + + 2.0 / 3.0 * v1_xy * mu_ ) + # total energy equation + du4 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + # stress tensor and temperature gradient terms from x-direction + - 4.0 / 3.0 * v1_xx * v1 * mu_ + + 2.0 / 3.0 * v2_xy * v1 * mu_ + - 4.0 / 3.0 * v1_x * v1_x * mu_ + + 2.0 / 3.0 * v2_y * v1_x * mu_ + - v1_xy * v2 * mu_ + - v2_xx * v2 * mu_ + - v1_y * v2_x * mu_ + - v2_x * v2_x * mu_ + - T_const * inv_rho_cubed * ( p_xx * rho * rho + - 2.0 * p_x * rho * rho_x + + 2.0 * p * rho_x * rho_x + - p * rho * rho_xx ) * mu_ + # stress tensor and temperature gradient terms from y-direction + - v1_yy * v1 * mu_ + - v2_xy * v1 * mu_ + - v1_y * v1_y * mu_ + - v2_x * v1_y * mu_ + - 4.0 / 3.0 * v2_yy * v2 * mu_ + + 2.0 / 3.0 * v1_xy * v2 * mu_ + - 4.0 / 3.0 * v2_y * v2_y * mu_ + + 2.0 / 3.0 * v1_x * v2_y * mu_ + - T_const * inv_rho_cubed * ( p_yy * rho * rho + - 2.0 * p_y * rho * rho_y + + 2.0 * p * rho_y * rho_y + - p * rho * rho_yy ) * mu_ ) + + return SVector(du1, du2, du3, du4) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, - t, - equations)[2:3]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:3]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, - heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_slip_wall, - y_pos = boundary_condition_slip_wall) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_slip_wall, + y_pos = boundary_condition_slip_wall) # define viscous boundary conditions boundary_conditions_parabolic = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_top_bottom, - y_pos = boundary_condition_top_bottom) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_top_bottom, + y_pos = boundary_condition_top_bottom) -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, solver; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic), - source_terms = source_terms_navier_stokes_convergence_test) +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), + source_terms=source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -245,15 +198,16 @@ tspan = (0.0, 0.5) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, dt = 1e-5, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, dt = 1e-5, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary + diff --git a/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl b/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl index 4e3c14c9ed7..81e48737e79 100644 --- a/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl +++ b/examples/tree_2d_dgsem/elixir_navierstokes_lid_driven_cavity.jl @@ -9,27 +9,28 @@ prandtl_number() = 0.72 mu() = 0.001 equations = CompressibleEulerEquations2D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(), - Prandtl = prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(), + Prandtl=prandtl_number()) # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_max = ( 1.0, 1.0) # maximum coordinates (max(x), max(y)) # Create a uniformly refined mesh mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - periodicity = false, - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=4, + periodicity=false, + n_cells_max=30_000) # set maximum capacity of tree data structure + function initial_condition_cavity(x, t, equations::CompressibleEulerEquations2D) - Ma = 0.1 - rho = 1.0 - u, v = 0.0, 0.0 - p = 1.0 / (Ma^2 * equations.gamma) - return prim2cons(SVector(rho, u, v, p), equations) + Ma = 0.1 + rho = 1.0 + u, v = 0.0, 0.0 + p = 1.0 / (Ma^2 * equations.gamma) + return prim2cons(SVector(rho, u, v, p), equations) end initial_condition = initial_condition_cavity @@ -44,15 +45,15 @@ boundary_condition_cavity = BoundaryConditionNavierStokesWall(velocity_bc_cavity boundary_conditions = boundary_condition_slip_wall boundary_conditions_parabolic = (; x_neg = boundary_condition_cavity, - y_neg = boundary_condition_cavity, - y_pos = boundary_condition_lid, - x_pos = boundary_condition_cavity) + y_neg = boundary_condition_cavity, + y_pos = boundary_condition_lid, + x_pos = boundary_condition_cavity) # 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)) + boundary_conditions=(boundary_conditions, + boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. @@ -62,15 +63,17 @@ tspan = (0.0, 25.0) ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 100) +alive_callback = AliveCallback(alive_interval=100) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) callbacks = CallbackSet(summary_callback, alive_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary + + diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl b/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl index bc528ae7756..eed0a350e7e 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_ec.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) # Note, this initial condition is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_ec_discontinuous_bottom` below. @@ -16,18 +16,17 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 4, - surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -47,48 +46,45 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the TreeMesh2D with initial_refinement_level=2. -function initial_condition_ec_discontinuous_bottom(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.7, 0.7) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Set the background values - H = 4.25 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # setup the discontinuous water height and velocities - if element_id == 10 - H = 5.0 - v1 = 0.1882 * cos_phi - v2 = 0.1882 * sin_phi - end - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_ec_discontinuous_bottom(x, t, element_id, equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 4.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 5.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, - equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -97,15 +93,15 @@ end summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(dt = 0.2, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(dt=0.2, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -113,7 +109,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl index c92e885c161..6d4f6fe518c 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -5,17 +5,17 @@ using Trixi ############################################################################### # semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test # MMS EOC test + ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -23,13 +23,13 @@ solver = DGSEM(polydeg = 3, coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,13 +40,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -54,6 +54,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl index f7544b1e32e..c3da957b764 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_source_terms_dirichlet.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # Semidiscretization of the shallow water equations -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test @@ -15,9 +15,8 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -25,14 +24,14 @@ solver = DGSEM(polydeg = 3, coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = false) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=false) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions = boundary_condition, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -43,13 +42,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -57,6 +56,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl index f7c8ab3a249..402361c8823 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl @@ -5,8 +5,7 @@ using Trixi ############################################################################### # Semidiscretization of the two-layer shallow water equations -equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 10.0, rho_upper = 0.9, - rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant=10.0, rho_upper=0.9, rho_lower=1.0) initial_condition = initial_condition_convergence_test @@ -14,9 +13,9 @@ initial_condition = initial_condition_convergence_test # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -24,13 +23,13 @@ solver = DGSEM(polydeg = 3, coordinates_min = (0.0, 0.0) coordinates_max = (sqrt(2.0), sqrt(2.0)) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 20_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=20_000, + periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -41,13 +40,13 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 500, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=500, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -55,6 +54,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(), abstol = 1.0e-8, reltol = 1.0e-8, - save_everystep = false, callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8, +save_everystep=false, callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl index 1495e6d8568..ba4bcd25774 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl @@ -6,24 +6,21 @@ using Trixi # Semidiscretization of the two-layer shallow water equations with a bottom topography function # to test well-balancedness -equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 9.81, H0 = 0.6, - rho_upper = 0.9, rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant=9.81, H0=0.6, rho_upper=0.9, rho_lower=1.0) # An initial condition with constant total water height, zero velocities and a bottom topography to # test well-balancedness function initial_condition_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations2D) - H_lower = 0.5 - H_upper = 0.6 - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? - 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + - -0.5)^2)) + 1) : 0.0) - - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), - equations) + H_lower = 0.5 + H_upper = 0.6 + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + + -0.5)^2)) + 1) : 0.0) + + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) end initial_condition = initial_condition_well_balanced @@ -33,8 +30,8 @@ initial_condition = initial_condition_well_balanced volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 3, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -42,9 +39,9 @@ solver = DGSEM(polydeg = 3, surface_flux = surface_flux, coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=10_000, + periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -58,16 +55,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -75,7 +72,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl index 3408b130620..23efdcb7366 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced.jl @@ -6,22 +6,21 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25) +equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.25) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) + + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -31,17 +30,17 @@ initial_condition = initial_condition_well_balancedness volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 4, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -62,33 +61,30 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the TreeMesh2D with initial_refinement_level=2. -function initial_condition_discontinuous_well_balancedness(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), - element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -97,16 +93,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -114,7 +110,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl index 7facf1170d0..66cd27f6864 100644 --- a/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl +++ b/examples/tree_2d_dgsem/elixir_shallowwater_well_balanced_wall.jl @@ -5,22 +5,21 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25) +equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.25) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) + + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -32,8 +31,8 @@ boundary_condition = boundary_condition_slip_wall volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 4, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the TreeMesh and setup a periodic mesh @@ -41,8 +40,8 @@ solver = DGSEM(polydeg = 4, surface_flux = surface_flux, coordinates_min = (-1.0, -1.0) coordinates_max = (1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000, + initial_refinement_level=2, + n_cells_max=10_000, periodicity = false) # create the semi discretization object @@ -65,33 +64,30 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the TreeMesh2D with initial_refinement_level=2. -function initial_condition_discontinuous_well_balancedness(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), - element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -100,16 +96,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -117,7 +113,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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 +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 \ No newline at end of file diff --git a/examples/tree_2d_fdsbp/elixir_advection_extended.jl b/examples/tree_2d_fdsbp/elixir_advection_extended.jl index 8716a9a6b78..6e599d9f42d 100644 --- a/examples/tree_2d_fdsbp/elixir_advection_extended.jl +++ b/examples/tree_2d_fdsbp/elixir_advection_extended.jl @@ -13,21 +13,22 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) initial_condition = initial_condition_convergence_test D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, accuracy_order = 4, - xmin = 0.0, xmax = 1.0, N = 100) + derivative_order=1, accuracy_order=4, + xmin=0.0, xmax=1.0, N=100) solver = FDSBP(D_SBP, - surface_integral = SurfaceIntegralStrongForm(flux_lax_friedrichs), - volume_integral = VolumeIntegralStrongForm()) + surface_integral=SurfaceIntegralStrongForm(flux_lax_friedrichs), + volume_integral=VolumeIntegralStrongForm()) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 1, - n_cells_max = 30_000, - periodicity = true) + initial_refinement_level=1, + n_cells_max=30_000, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -37,18 +38,19 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (energy_total,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(energy_total,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-9, reltol = 1.0e-9, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-9, reltol=1.0e-9, + ode_default_options()..., callback=callbacks) summary_callback() diff --git a/examples/tree_2d_fdsbp/elixir_euler_convergence.jl b/examples/tree_2d_fdsbp/elixir_euler_convergence.jl index 604ae395105..0843cece67e 100644 --- a/examples/tree_2d_fdsbp/elixir_euler_convergence.jl +++ b/examples/tree_2d_fdsbp/elixir_euler_convergence.jl @@ -12,24 +12,23 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=30_000, + periodicity=true) -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -40,15 +39,15 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (energy_total,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(energy_total,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -58,6 +57,6 @@ callbacks = CallbackSet(summary_callback, ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-9, reltol = 1.0e-9, - ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); abstol=1.0e-9, reltol=1.0e-9, + ode_default_options()..., callback=callbacks) summary_callback() diff --git a/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl b/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl index c8148793542..1e58badf47a 100644 --- a/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl +++ b/examples/tree_2d_fdsbp/elixir_euler_kelvin_helmholtz_instability.jl @@ -8,42 +8,42 @@ using Trixi # semidiscretization of the linear advection equation equations = CompressibleEulerEquations2D(1.4) -function initial_condition_kelvin_helmholtz_instability(x, t, - equations::CompressibleEulerEquations2D) - # change discontinuity to tanh - # typical resolution 128^2, 256^2 - # domain size is [-1,+1]^2 - slope = 15 - amplitude = 0.02 - B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) - rho = 0.5 + 0.75 * B - v1 = 0.5 * (B - 1) - v2 = 0.1 * sin(2 * pi * x[1]) - p = 1.0 - return prim2cons(SVector(rho, v1, v2, p), equations) +function initial_condition_kelvin_helmholtz_instability(x, t, equations::CompressibleEulerEquations2D) + # change discontinuity to tanh + # typical resolution 128^2, 256^2 + # domain size is [-1,+1]^2 + slope = 15 + amplitude = 0.02 + B = tanh(slope * x[2] + 7.5) - tanh(slope * x[2] - 7.5) + rho = 0.5 + 0.75 * B + v1 = 0.5 * (B - 1) + v2 = 0.1 * sin(2 * pi * x[1]) + p = 1.0 + return prim2cons(SVector(rho, v1, v2, p), equations) end initial_condition = initial_condition_kelvin_helmholtz_instability D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_vanleer_haenel solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-1.0, -1.0) -coordinates_max = (1.0, 1.0) +coordinates_max = ( 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000, - periodicity = true) + initial_refinement_level=4, + n_cells_max=30_000, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -53,26 +53,27 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (entropy, - energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(entropy, + energy_total,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, alive_callback) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, dt = 1e-3, - ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, dt=1e-3, + ode_default_options()..., callback=callbacks) summary_callback() diff --git a/examples/tree_2d_fdsbp/elixir_euler_vortex.jl b/examples/tree_2d_fdsbp/elixir_euler_vortex.jl index abac64d008b..abaf3d494d4 100644 --- a/examples/tree_2d_fdsbp/elixir_euler_vortex.jl +++ b/examples/tree_2d_fdsbp/elixir_euler_vortex.jl @@ -18,61 +18,62 @@ The classical isentropic vortex test case of [NASA/CR-97-206253](https://ntrs.nasa.gov/citations/19980007543) """ function initial_condition_isentropic_vortex(x, t, equations::CompressibleEulerEquations2D) - # needs appropriate mesh size, e.g. [-10,-10]x[10,10] - # for error convergence: make sure that the end time is such that the is back at the initial state!! - # for the current velocity and domain size: t_end should be a multiple of 20s - # initial center of the vortex - inicenter = SVector(0.0, 0.0) - # size and strength of the vortex - iniamplitude = 5.0 - # base flow - rho = 1.0 - v1 = 1.0 - v2 = 1.0 - vel = SVector(v1, v2) - p = 25.0 - rt = p / rho # ideal gas equation - t_loc = 0.0 - cent = inicenter + vel * t_loc # advection of center - # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) - - cent = x - cent # distance to center point - - #cent=cross(iniaxis,cent) # distance to axis, tangent vector, length r - # cross product with iniaxis = [0, 0, 1] - cent = SVector(-cent[2], cent[1]) - r2 = cent[1]^2 + cent[2]^2 - du = iniamplitude / (2 * π) * exp(0.5 * (1 - r2)) # vel. perturbation - dtemp = -(equations.gamma - 1) / (2 * equations.gamma * rt) * du^2 # isentropic - rho = rho * (1 + dtemp)^(1 / (equations.gamma - 1)) - vel = vel + du * cent - v1, v2 = vel - p = p * (1 + dtemp)^(equations.gamma / (equations.gamma - 1)) - prim = SVector(rho, v1, v2, p) - return prim2cons(prim, equations) + # needs appropriate mesh size, e.g. [-10,-10]x[10,10] + # for error convergence: make sure that the end time is such that the is back at the initial state!! + # for the current velocity and domain size: t_end should be a multiple of 20s + # initial center of the vortex + inicenter = SVector(0.0, 0.0) + # size and strength of the vortex + iniamplitude = 5.0 + # base flow + rho = 1.0 + v1 = 1.0 + v2 = 1.0 + vel = SVector(v1, v2) + p = 25.0 + rt = p / rho # ideal gas equation + t_loc = 0.0 + cent = inicenter + vel*t_loc # advection of center + # ATTENTION: handle periodic BC, but only for v1 = v2 = 1.0 (!!!!) + + cent = x - cent # distance to center point + + #cent=cross(iniaxis,cent) # distance to axis, tangent vector, length r + # cross product with iniaxis = [0, 0, 1] + cent = SVector(-cent[2], cent[1]) + r2 = cent[1]^2 + cent[2]^2 + du = iniamplitude/(2*π)*exp(0.5*(1-r2)) # vel. perturbation + dtemp = -(equations.gamma-1)/(2*equations.gamma*rt)*du^2 # isentropic + rho = rho * (1+dtemp)^(1/(equations.gamma-1)) + vel = vel + du*cent + v1, v2 = vel + p = p * (1+dtemp)^(equations.gamma/(equations.gamma-1)) + prim = SVector(rho, v1, v2, p) + return prim2cons(prim, equations) end initial_condition = initial_condition_isentropic_vortex D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-10.0, -10.0) -coordinates_max = (10.0, 10.0) +coordinates_max = ( 10.0, 10.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000, - periodicity = true) + initial_refinement_level=3, + n_cells_max=30_000, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -82,23 +83,24 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, alive_callback) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, dt = 1e-3, - ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, dt=1e-3, + ode_default_options()..., callback=callbacks) summary_callback() diff --git a/examples/tree_3d_dgsem/elixir_advection_amr.jl b/examples/tree_3d_dgsem/elixir_advection_amr.jl index 19a9bd18a8a..67664eed563 100644 --- a/examples/tree_3d_dgsem/elixir_advection_amr.jl +++ b/examples/tree_3d_dgsem/elixir_advection_amr.jl @@ -9,16 +9,18 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_gauss -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0, -5.0) -coordinates_max = (5.0, 5.0, 5.0) +coordinates_max = ( 5.0, 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 30_000) + initial_refinement_level=4, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,26 +30,26 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +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 = 4, - med_level = 5, med_threshold = 0.1, - max_level = 6, max_threshold = 0.6) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=0.1, + max_level=6, max_threshold=0.6) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -59,7 +61,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_advection_basic.jl b/examples/tree_3d_dgsem/elixir_advection_basic.jl index 3ea50423be7..da91a70fe6d 100644 --- a/examples/tree_3d_dgsem/elixir_advection_basic.jl +++ b/examples/tree_3d_dgsem/elixir_advection_basic.jl @@ -9,19 +9,19 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) # set maximum capacity of tree data structure + initial_refinement_level=3, + 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) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -34,26 +34,26 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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.2) +stepsize_callback = StepsizeCallback(cfl=1.2) # 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) +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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_3d_dgsem/elixir_advection_extended.jl b/examples/tree_3d_dgsem/elixir_advection_extended.jl index efc20c64f6d..d820f47f25c 100644 --- a/examples/tree_3d_dgsem/elixir_advection_extended.jl +++ b/examples/tree_3d_dgsem/elixir_advection_extended.jl @@ -18,20 +18,21 @@ initial_condition = initial_condition_convergence_test boundary_conditions = boundary_condition_periodic # 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) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000, # set maximum capacity of tree data structure - periodicity = true) + initial_refinement_level=3, + n_cells_max=30_000, # set maximum capacity of tree data structure + periodicity=true) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -46,24 +47,24 @@ 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, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) # The AliveCallback prints short status information in regular intervals -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) # The SaveRestartCallback allows to save a file from which a Trixi simulation can be restarted -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) # The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver callbacks = CallbackSet(summary_callback, @@ -71,13 +72,14 @@ callbacks = CallbackSet(summary_callback, save_restart, 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, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); +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); # Print the timer summary summary_callback() diff --git a/examples/tree_3d_dgsem/elixir_advection_mortar.jl b/examples/tree_3d_dgsem/elixir_advection_mortar.jl index d27a19c7dcf..7b24f152b6a 100644 --- a/examples/tree_3d_dgsem/elixir_advection_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_advection_mortar.jl @@ -9,21 +9,23 @@ advection_velocity = (0.2, -0.7, 0.5) equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +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) -refinement_patches = ((type = "box", coordinates_min = (0.0, -1.0, -1.0), - coordinates_max = (1.0, 1.0, 1.0)), - (type = "box", coordinates_min = (0.0, -0.5, -0.5), - coordinates_max = (0.5, 0.5, 0.5))) +coordinates_max = ( 1.0, 1.0, 1.0) +refinement_patches = ( + (type="box", coordinates_min=(0.0, -1.0, -1.0), coordinates_max=(1.0, 1.0, 1.0)), + (type="box", coordinates_min=(0.0, -0.5, -0.5), coordinates_max=(0.5, 0.5, 0.5)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=2, + refinement_patches=refinement_patches, + n_cells_max=10_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -33,17 +35,17 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.2) +stepsize_callback = StepsizeCallback(cfl=1.2) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -51,10 +53,11 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_advection_restart.jl b/examples/tree_3d_dgsem/elixir_advection_restart.jl index a8e1fb3edde..83bf4418b98 100644 --- a/examples/tree_3d_dgsem/elixir_advection_restart.jl +++ b/examples/tree_3d_dgsem/elixir_advection_restart.jl @@ -7,6 +7,7 @@ using Trixi trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl")) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -21,10 +22,11 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) tspan = (load_time(restart_filename), 2.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_amr.jl b/examples/tree_3d_dgsem/elixir_euler_amr.jl index 9bd7f74c688..f226a6b446d 100644 --- a/examples/tree_3d_dgsem/elixir_euler_amr.jl +++ b/examples/tree_3d_dgsem/elixir_euler_amr.jl @@ -14,28 +14,30 @@ A Gaussian pulse in the density with constant velocity and pressure; reduces the compressible Euler equations to the linear advection equations. """ function initial_condition_density_pulse(x, t, equations::CompressibleEulerEquations3D) - rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2)) / 2 - v1 = 1 - v2 = 1 - v3 = 1 - rho_v1 = rho * v1 - rho_v2 = rho * v2 - rho_v3 = rho * v3 - p = 1 - rho_e = p / (equations.gamma - 1) + 1 / 2 * rho * (v1^2 + v2^2 + v3^2) - return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) + rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2))/2 + v1 = 1 + v2 = 1 + v3 = 1 + rho_v1 = rho * v1 + rho_v2 = rho * v2 + rho_v3 = rho * v3 + p = 1 + rho_e = p/(equations.gamma - 1) + 1/2 * rho * (v1^2 + v2^2 + v3^2) + return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) end initial_condition = initial_condition_density_pulse -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (-5.0, -5.0, -5.0) -coordinates_max = (5.0, 5.0, 5.0) +coordinates_max = ( 5.0, 5.0, 5.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) + initial_refinement_level=4, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -45,39 +47,40 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +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 = 4, - med_level = 5, med_threshold = 1.05, - max_level = 6, max_threshold = 1.3) +amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), + base_level=4, + med_level=5, med_threshold=1.05, + max_level=6, max_threshold=1.3) amr_callback = AMRCallback(semi, amr_controller, - interval = 5, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=5, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl b/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl index 0ce886620cc..a8d112f5b05 100644 --- a/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl +++ b/examples/tree_3d_dgsem/elixir_euler_blob_amr.jl @@ -4,7 +4,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -gamma = 5 / 3 +gamma = 5/3 equations = CompressibleEulerEquations3D(gamma) """ @@ -16,65 +16,63 @@ The blob test case taken from [arXiv: astro-ph/0610051](https://arxiv.org/abs/astro-ph/0610051) """ function initial_condition_blob(x, t, equations::CompressibleEulerEquations3D) - # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf - # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf - # change discontinuity to tanh - # typical domain is rectangular, we change it to a square - # resolution 128^3, 256^3 - # domain size is [-20.0,20.0]^3 - # gamma = 5/3 for this test case - R = 1.0 # radius of the blob - # background density - rho = 1.0 - Chi = 10.0 # density contrast - # reference time of characteristic growth of KH instability equal to 1.0 - tau_kh = 1.0 - tau_cr = tau_kh / 1.6 # crushing time - # determine background velocity - v1 = 2 * R * sqrt(Chi) / tau_cr - v2 = 0.0 - v3 = 0.0 - Ma0 = 2.7 # background flow Mach number Ma=v/c - c = v1 / Ma0 # sound speed - # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density - p = c * c * rho / equations.gamma - # initial center of the blob - inicenter = [-15, 0, 0] - x_rel = x - inicenter - r = sqrt(x_rel[1]^2 + x_rel[2]^2 + x_rel[3]^2) - # steepness of the tanh transition zone - slope = 2 - # density blob - rho = rho + - (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) - # velocity blob is zero - v1 = v1 - v1 * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope * (r - R)) + 1))) - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # blob test case, see Agertz et al. https://arxiv.org/pdf/astro-ph/0610051.pdf + # other reference: https://arxiv.org/pdf/astro-ph/0610051.pdf + # change discontinuity to tanh + # typical domain is rectangular, we change it to a square + # resolution 128^3, 256^3 + # domain size is [-20.0,20.0]^3 + # gamma = 5/3 for this test case + R = 1.0 # radius of the blob + # background density + rho = 1.0 + Chi = 10.0 # density contrast + # reference time of characteristic growth of KH instability equal to 1.0 + tau_kh = 1.0 + tau_cr = tau_kh / 1.6 # crushing time + # determine background velocity + v1 = 2 * R * sqrt(Chi) / tau_cr + v2 = 0.0 + v3 = 0.0 + Ma0 = 2.7 # background flow Mach number Ma=v/c + c = v1 / Ma0 # sound speed + # use perfect gas assumption to compute background pressure via the sound speed c^2 = gamma * pressure/density + p = c * c * rho / equations.gamma + # initial center of the blob + inicenter = [-15, 0, 0] + x_rel = x - inicenter + r = sqrt(x_rel[1]^2 + x_rel[2]^2 + x_rel[3]^2) + # steepness of the tanh transition zone + slope = 2 + # density blob + rho = rho + (Chi - 1) * 0.5 * (1 + (tanh(slope * (r + R)) - (tanh(slope *(r - R)) + 1))) + # velocity blob is zero + v1 = v1 - v1 * 0.5 * (1 + (tanh(slope *(r + R)) - (tanh(slope *(r - R)) + 1))) + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_blob volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_hllc, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-20.0, -20.0, -20.0) -coordinates_max = (20.0, 20.0, 20.0) - -refinement_patches = ((type = "box", coordinates_min = (-20.0, -10.0, -10.0), - coordinates_max = (-10.0, 10.0, 10.0)), - (type = "box", coordinates_min = (-20.0, -5.0, -5.0), - coordinates_max = (-10.0, 5.0, 5.0)), - (type = "box", coordinates_min = (-17.0, -2.0, -2.0), - coordinates_max = (-13.0, 2.0, 2.0)), - (type = "box", coordinates_min = (-17.0, -2.0, -2.0), - coordinates_max = (-13.0, 2.0, 2.0))) +coordinates_max = ( 20.0, 20.0, 20.0) + +refinement_patches = ( + (type="box", coordinates_min=(-20.0, -10.0, -10.0), coordinates_max=(-10.0, 10.0, 10.0)), + (type="box", coordinates_min=(-20.0, -5.0, -5.0), coordinates_max=(-10.0, 5.0, 5.0)), + (type="box", coordinates_min=(-17.0, -2.0, -2.0), coordinates_max=(-13.0, 2.0, 2.0)), + (type="box", coordinates_min=(-17.0, -2.0, -2.0), coordinates_max=(-13.0, 2.0, 2.0)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - refinement_patches = refinement_patches, - n_cells_max = 100_000) + initial_refinement_level=2, + refinement_patches=refinement_patches, + n_cells_max=100_000,) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -84,40 +82,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 200, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=200, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorLöhner(semi, - variable = Trixi.density) + variable=Trixi.density) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 1, - med_level = 0, med_threshold = 0.1, # med_level = current level - max_level = 6, max_threshold = 0.3) + base_level=1, + med_level =0, med_threshold=0.1, # med_level = current level + max_level =6, max_threshold=0.3) amr_callback = AMRCallback(semi, amr_controller, - interval = 3, - adapt_initial_condition = false, - adapt_initial_condition_only_refine = true) + interval=3, + adapt_initial_condition=false, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.7) +stepsize_callback = StepsizeCallback(cfl=1.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, amr_callback, stepsize_callback) -stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (1.0e-4, 1.0e-4), - variables = (Trixi.density, pressure)) + +stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(1.0e-4, 1.0e-4), + variables=(Trixi.density, pressure)) ############################################################################### # run the simulation -sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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); +sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, 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 diff --git a/examples/tree_3d_dgsem/elixir_euler_convergence.jl b/examples/tree_3d_dgsem/elixir_euler_convergence.jl index 5c9675d1711..493fef8309b 100644 --- a/examples/tree_3d_dgsem/elixir_euler_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_euler_convergence.jl @@ -9,17 +9,19 @@ equations = CompressibleEulerEquations3D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg = 3, surface_flux = FluxHLL(min_max_speed_naive), - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), + volume_integral=VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_eoc_test_euler) + source_terms=source_terms_eoc_test_euler) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,26 +32,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl b/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl index 4789b46dacc..dbf5747784c 100644 --- a/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl +++ b/examples/tree_3d_dgsem/elixir_euler_convergence_pure_fv.jl @@ -9,17 +9,19 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, - volume_integral = VolumeIntegralPureLGLFiniteVolume(flux_hllc)) +solver = DGSEM(polydeg=3, surface_flux=flux_hllc, + volume_integral=VolumeIntegralPureLGLFiniteVolume(flux_hllc)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,26 +32,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl b/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl index cad8fc578c8..ee788321c66 100644 --- a/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl +++ b/examples/tree_3d_dgsem/elixir_euler_density_pulse.jl @@ -14,31 +14,33 @@ A Gaussian pulse in the density with constant velocity and pressure; reduces the compressible Euler equations to the linear advection equations. """ function initial_condition_density_pulse(x, t, equations::CompressibleEulerEquations3D) - rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2)) / 2 - v1 = 1 - v2 = 1 - v3 = 1 - rho_v1 = rho * v1 - rho_v2 = rho * v2 - rho_v3 = rho * v3 - p = 1 - rho_e = p / (equations.gamma - 1) + 1 / 2 * rho * (v1^2 + v2^2 + v3^2) - return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) + rho = 1 + exp(-(x[1]^2 + x[2]^2 + x[3]^2))/2 + v1 = 1 + v2 = 1 + v3 = 1 + rho_v1 = rho * v1 + rho_v2 = rho * v2 + rho_v3 = rho * v3 + p = 1 + rho_e = p/(equations.gamma - 1) + 1/2 * rho * (v1^2 + v2^2 + v3^2) + return SVector(rho, rho_v1, rho_v2, rho_v3, rho_e) end initial_condition = initial_condition_density_pulse volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = (2.0, 2.0, 2.0) +coordinates_max = ( 2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 100_000) + initial_refinement_level=3, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -48,29 +50,30 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_restart, 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_ec.jl b/examples/tree_3d_dgsem/elixir_euler_ec.jl index 88d7cbc7ba5..08fd1b998d5 100644 --- a/examples/tree_3d_dgsem/elixir_euler_ec.jl +++ b/examples/tree_3d_dgsem/elixir_euler_ec.jl @@ -10,17 +10,19 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = (2.0, 2.0, 2.0) +coordinates_max = ( 2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 100_000) + initial_refinement_level=3, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,26 +32,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.3) +stepsize_callback = StepsizeCallback(cfl=1.3) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_mortar.jl b/examples/tree_3d_dgsem/elixir_euler_mortar.jl index cf103dc26cf..c9fc2dfed50 100644 --- a/examples/tree_3d_dgsem/elixir_euler_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_euler_mortar.jl @@ -8,19 +8,22 @@ using Trixi equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) -refinement_patches = ((type = "box", coordinates_min = (0.5, 0.5, 0.5), - coordinates_max = (1.5, 1.5, 1.5)),) +refinement_patches = ( + (type="box", coordinates_min=(0.5, 0.5, 0.5), coordinates_max=(1.5, 1.5, 1.5)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=2, + refinement_patches=refinement_patches, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,16 +34,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -50,7 +53,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl index f76272f1dde..8e0625dea3a 100644 --- a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -19,34 +19,34 @@ based on Should be used together with [`boundary_condition_sedov_self_gravity`](@ref). """ function initial_condition_sedov_self_gravity(x, t, equations::CompressibleEulerEquations3D) - # Calculate radius as distance from origin - r = sqrt(x[1]^2 + x[2]^2 + x[3]^2) - - # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 - r0 = 0.25 # = 4.0 * smallest dx (for domain length=8 and max-ref=7) - E = 1.0 - p_inner = (equations.gamma - 1) * E / (4 / 3 * pi * r0^3) - p_ambient = 1e-5 # = true Sedov setup - - # Calculate primitive variables - # use a logistic function to transfer density value smoothly - L = 1.0 # maximum of function - x0 = 1.0 # center point of function - k = -50.0 # sharpness of transfer - logistic_function_rho = L / (1.0 + exp(-k * (r - x0))) - rho_ambient = 1e-5 - rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny - - # velocities are zero - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - - # use a logistic function to transfer pressure value smoothly - logistic_function_p = p_inner / (1.0 + exp(-k * (r - r0))) - p = max(logistic_function_p, p_ambient) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Calculate radius as distance from origin + r = sqrt(x[1]^2 + x[2]^2 + x[3]^2) + + # Setup based on http://flash.uchicago.edu/site/flashcode/user_support/flash4_ug_4p62/node184.html#SECTION010114000000000000000 + r0 = 0.25 # = 4.0 * smallest dx (for domain length=8 and max-ref=7) + E = 1.0 + p_inner = (equations.gamma - 1) * E / (4/3 * pi * r0^3) + p_ambient = 1e-5 # = true Sedov setup + + # Calculate primitive variables + # use a logistic function to transfer density value smoothly + L = 1.0 # maximum of function + x0 = 1.0 # center point of function + k = -50.0 # sharpness of transfer + logistic_function_rho = L/(1.0 + exp(-k*(r - x0))) + rho_ambient = 1e-5 + rho = max(logistic_function_rho, rho_ambient) # clip background density to not be so tiny + + # velocities are zero + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + + # use a logistic function to transfer pressure value smoothly + logistic_function_p = p_inner/(1.0 + exp(-k*(r - r0))) + p = max(logistic_function_p, p_ambient) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_sedov_self_gravity @@ -64,26 +64,26 @@ based on Should be used together with [`initial_condition_sedov_self_gravity`](@ref). """ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, x, t, - surface_flux_function, - equations::CompressibleEulerEquations3D) - # velocities are zero, density/pressure are ambient values according to - # initial_condition_sedov_self_gravity - rho = 1e-5 - v1 = 0.0 - v2 = 0.0 - v3 = 0.0 - p = 1e-5 - - u_boundary = prim2cons(SVector(rho, v1, v2, v3, p), equations) - - # Calculate boundary flux - if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary - flux = surface_flux_function(u_inner, u_boundary, orientation, equations) - else # u_boundary is "left" of boundary, u_inner is "right" of boundary - flux = surface_flux_function(u_boundary, u_inner, orientation, equations) - end - - return flux + surface_flux_function, + equations::CompressibleEulerEquations3D) + # velocities are zero, density/pressure are ambient values according to + # initial_condition_sedov_self_gravity + rho = 1e-5 + v1 = 0.0 + v2 = 0.0 + v3 = 0.0 + p = 1e-5 + + u_boundary = prim2cons(SVector(rho, v1, v2, v3, p), equations) + + # Calculate boundary flux + if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary + flux = surface_flux_function(u_inner, u_boundary, orientation, equations) + else # u_boundary is "left" of boundary, u_inner is "right" of boundary + flux = surface_flux_function(u_boundary, u_inner, orientation, equations) + end + + return flux end boundary_conditions = boundary_condition_sedov_self_gravity @@ -92,24 +92,26 @@ volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.7, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=0.7, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-4.0, -4.0, -4.0) -coordinates_max = (4.0, 4.0, 4.0) +coordinates_max = ( 4.0, 4.0, 4.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 1_000_000, - periodicity = false) + initial_refinement_level=2, + n_cells_max=1_000_000, + periodicity=false) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -120,41 +122,42 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_max = 1.0, - alpha_min = 0.0, - alpha_smooth = false, - variable = density_pressure) + alpha_max=1.0, + alpha_min=0.0, + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 2, - max_level = 7, max_threshold = 0.0003) + base_level=2, + max_level =7, max_threshold=0.0003) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 0.35) +stepsize_callback = StepsizeCallback(cfl=0.35) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl b/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl index 0a90615016c..3015f6c50a4 100644 --- a/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl +++ b/examples/tree_3d_dgsem/elixir_euler_shockcapturing.jl @@ -10,28 +10,30 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_ranocha # OBS! Using a non-dissipative flux is only sensible to test EC, -# but not for real shock simulations + # but not for real shock simulations volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = (2.0, 2.0, 2.0) +coordinates_max = ( 2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 100_000) + initial_refinement_level=3, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -41,26 +43,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.4) +stepsize_callback = StepsizeCallback(cfl=1.4) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl b/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl index be31fbbc42c..3d338cd7f01 100644 --- a/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl +++ b/examples/tree_3d_dgsem/elixir_euler_shockcapturing_amr.jl @@ -10,28 +10,30 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = flux_ranocha # OBS! Using a non-dissipative flux is only sensible to test EC, -# but not for real shock simulations + # but not for real shock simulations volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = (2.0, 2.0, 2.0) +coordinates_max = ( 2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 100_000) + initial_refinement_level=3, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -41,39 +43,41 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) amr_indicator = IndicatorHennemannGassner(semi, - alpha_smooth = false, - variable = density_pressure) + alpha_smooth=false, + variable=density_pressure) amr_controller = ControllerThreeLevel(semi, amr_indicator, - base_level = 2, - max_level = 4, max_threshold = 0.0003) + base_level=2, + max_level =4, max_threshold=0.0003) amr_callback = AMRCallback(semi, amr_controller, - interval = 1, - adapt_initial_condition = true, - adapt_initial_condition_only_refine = true) + interval=1, + adapt_initial_condition=true, + adapt_initial_condition_only_refine=true) -stepsize_callback = StepsizeCallback(cfl = 1.3) +stepsize_callback = StepsizeCallback(cfl=1.3) 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); +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 + diff --git a/examples/tree_3d_dgsem/elixir_euler_source_terms.jl b/examples/tree_3d_dgsem/elixir_euler_source_terms.jl index f0246c30490..3445e9fc433 100644 --- a/examples/tree_3d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_3d_dgsem/elixir_euler_source_terms.jl @@ -9,17 +9,19 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -30,26 +32,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 0.6) +stepsize_callback = StepsizeCallback(cfl=0.6) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl b/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl index 135ee673e44..693f9ce9049 100644 --- a/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl +++ b/examples/tree_3d_dgsem/elixir_euler_taylor_green_vortex.jl @@ -12,37 +12,35 @@ equations = CompressibleEulerEquations3D(1.4) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, - equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + - 1.0 / 16.0 * A^2 * rho * - (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + - cos(2 * x[2]) * cos(2 * x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = (1.0, 1.0, 1.0) .* pi +coordinates_max = ( 1.0, 1.0, 1.0) .* pi mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 100_000) + initial_refinement_level=3, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -52,26 +50,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.4) +stepsize_callback = StepsizeCallback(cfl=1.4) 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); +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 diff --git a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl index 0a8c427bf8d..3935a219a96 100644 --- a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl @@ -15,12 +15,12 @@ solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + +semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, solver_euler, + source_terms=source_terms_eoc_test_coupled_euler_gravity) -semi_euler = SemidiscretizationHyperbolic(mesh, equations_euler, initial_condition, - solver_euler, - source_terms = source_terms_eoc_test_coupled_euler_gravity) ############################################################################### # semidiscretization of the hyperbolic diffusion equations @@ -28,21 +28,22 @@ equations_gravity = HyperbolicDiffusionEquations3D() solver_gravity = DGSEM(polydeg, flux_lax_friedrichs) -semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, - solver_gravity, - source_terms = source_terms_harmonic) +semi_gravity = SemidiscretizationHyperbolic(mesh, equations_gravity, initial_condition, solver_gravity, + source_terms=source_terms_harmonic) + ############################################################################### # combining both semidiscretizations for Euler + self-gravity -parameters = ParametersEulerGravity(background_density = 2.0, # aka rho0 - gravitational_constant = 1.0, # aka G - cfl = 1.5, - resid_tol = 1.0e-10, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_erk52_3Sstar!) +parameters = ParametersEulerGravity(background_density=2.0, # aka rho0 + gravitational_constant=1.0, # aka G + cfl=1.5, + resid_tol=1.0e-10, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_erk52_3Sstar!) semi = SemidiscretizationEulerGravity(semi_euler, semi_gravity, parameters) + ############################################################################### # ODE solvers, callbacks etc. tspan = (0.0, 0.5) @@ -51,20 +52,20 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi_euler, interval = analysis_interval, - save_analysis = true) +analysis_callback = AnalysisCallback(semi_euler, interval=analysis_interval, + save_analysis=true) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -73,10 +74,11 @@ callbacks = CallbackSet(summary_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); +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 println("Number of gravity subcycles: ", semi.gravity_counter.ncalls_since_readout) diff --git a/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl b/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl index 7bba154a925..c7744ce23bd 100644 --- a/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl +++ b/examples/tree_3d_dgsem/elixir_hypdiff_lax_friedrichs.jl @@ -8,52 +8,53 @@ using Trixi equations = HyperbolicDiffusionEquations3D() function initial_condition_poisson_periodic(x, t, equations::HyperbolicDiffusionEquations3D) - # elliptic equation: -νΔϕ = f - # depending on initial constant state, c, for phi this converges to the solution ϕ + c - if iszero(t) - phi = 0.0 - q1 = 0.0 - q2 = 0.0 - q3 = 0.0 - else - phi = sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) - q1 = 2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) - q2 = 2 * pi * sin(2 * pi * x[1]) * cos(2 * pi * x[2]) * sin(2 * pi * x[3]) - q3 = 2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * x[3]) - end - return SVector(phi, q1, q2, q3) + # elliptic equation: -νΔϕ = f + # depending on initial constant state, c, for phi this converges to the solution ϕ + c + if iszero(t) + phi = 0.0 + q1 = 0.0 + q2 = 0.0 + q3 = 0.0 + else + phi = sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) + q1 = 2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * x[3]) + q2 = 2 * pi * sin(2 * pi * x[1]) * cos(2 * pi * x[2]) * sin(2 * pi * x[3]) + q3 = 2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * x[3]) + end + return SVector(phi, q1, q2, q3) end initial_condition = initial_condition_poisson_periodic -@inline function source_terms_poisson_periodic(u, x, t, - equations::HyperbolicDiffusionEquations3D) - # elliptic equation: -νΔϕ = f - # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) - @unpack inv_Tr = equations - C = -12 * equations.nu * pi^2 - - x1, x2, x3 = x - tmp1 = sinpi(2 * x1) - tmp2 = sinpi(2 * x2) - tmp3 = sinpi(2 * x3) - du1 = -C * tmp1 * tmp2 * tmp3 - du2 = -inv_Tr * u[2] - du3 = -inv_Tr * u[3] - du4 = -inv_Tr * u[4] - - return SVector(du1, du2, du3, du4) +@inline function source_terms_poisson_periodic(u, x, t, equations::HyperbolicDiffusionEquations3D) + # elliptic equation: -νΔϕ = f + # analytical solution: phi = sin(2πx)*sin(2πy) and f = -8νπ^2 sin(2πx)*sin(2πy) + @unpack inv_Tr = equations + C = -12 * equations.nu * pi^2 + + x1, x2, x3 = x + tmp1 = sinpi(2 * x1) + tmp2 = sinpi(2 * x2) + tmp3 = sinpi(2 * x3) + du1 = -C*tmp1*tmp2*tmp3 + du2 = -inv_Tr * u[2] + du3 = -inv_Tr * u[3] + du4 = -inv_Tr * u[4] + + return SVector(du1, du2, du3, du4) end -solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 30_000) + initial_refinement_level=3, + n_cells_max=30_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_poisson_periodic) + source_terms=source_terms_poisson_periodic) + ############################################################################### # ODE solvers, callbacks etc. @@ -64,20 +65,20 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 2.4) +stepsize_callback = StepsizeCallback(cfl=2.4) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, @@ -88,6 +89,6 @@ callbacks = CallbackSet(summary_callback, steady_state_callback, # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = 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 diff --git a/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl b/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl index 831e01519b6..beefb22ea1e 100644 --- a/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl +++ b/examples/tree_3d_dgsem/elixir_hypdiff_nonperiodic.jl @@ -8,25 +8,27 @@ using Trixi equations = HyperbolicDiffusionEquations3D() initial_condition = initial_condition_poisson_nonperiodic -boundary_conditions = (x_neg = boundary_condition_poisson_nonperiodic, - x_pos = boundary_condition_poisson_nonperiodic, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic, - z_neg = boundary_condition_periodic, - z_pos = boundary_condition_periodic) +boundary_conditions = (x_neg=boundary_condition_poisson_nonperiodic, + x_pos=boundary_condition_poisson_nonperiodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + z_neg=boundary_condition_periodic, + z_pos=boundary_condition_periodic) -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 30_000, - periodicity = (false, true, true)) + initial_refinement_level=2, + n_cells_max=30_000, + periodicity=(false, true, true)) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_poisson_nonperiodic, - boundary_conditions = boundary_conditions) + source_terms=source_terms_poisson_nonperiodic, + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -37,30 +39,31 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() resid_tol = 1.0e-5 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) +steady_state_callback = SteadyStateCallback(abstol=resid_tol, reltol=0.0) analysis_interval = 200 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (entropy, energy_total)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(entropy, energy_total)) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.8) +stepsize_callback = StepsizeCallback(cfl=1.8) callbacks = CallbackSet(summary_callback, steady_state_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) + ############################################################################### # run the simulation sol = Trixi.solve(ode, Trixi.HypDiffN3Erk3Sstar52(), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = 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 diff --git a/examples/tree_3d_dgsem/elixir_lbm_constant.jl b/examples/tree_3d_dgsem/elixir_lbm_constant.jl index ee38f62887d..269a0da2d50 100644 --- a/examples/tree_3d_dgsem/elixir_lbm_constant.jl +++ b/examples/tree_3d_dgsem/elixir_lbm_constant.jl @@ -5,20 +5,22 @@ using Trixi ############################################################################### # semidiscretization of the Lattice-Boltzmann equations for the D3Q27 scheme -equations = LatticeBoltzmannEquations3D(Ma = 0.1, Re = Inf) +equations = LatticeBoltzmannEquations3D(Ma=0.1, Re=Inf) initial_condition = initial_condition_constant -solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) +solver = DGSEM(polydeg=3, surface_flux=flux_godunov) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = (1.0, 1.0, 1.0) +coordinates_max = ( 1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000) + initial_refinement_level=3, + n_cells_max=10_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -28,19 +30,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 100, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=100, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2macroscopic) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) collision_callback = LBMCollisionCallback() @@ -50,10 +52,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl b/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl index 0980ee56be3..b3835eb1287 100644 --- a/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl +++ b/examples/tree_3d_dgsem/elixir_lbm_taylor_green_vortex.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the Lattice-Boltzmann equations for the D3Q27 scheme L = 1.0 # reference length -equations = LatticeBoltzmannEquations3D(Ma = 0.1, Re = 1600.0; L = L) +equations = LatticeBoltzmannEquations3D(Ma=0.1, Re=1600.0; L=L) """ initial_condition_taylor_green_vortex(x, t, equations::LatticeBoltzmannEquations3D) @@ -14,51 +14,52 @@ equations = LatticeBoltzmannEquations3D(Ma = 0.1, Re = 1600.0; L = L) Initialize the flow field to the Taylor-Green vortex setup """ function initial_condition_taylor_green_vortex(x, t, equations::LatticeBoltzmannEquations3D) - @unpack u0, rho0, L = equations + @unpack u0, rho0, L = equations - v1 = u0 * sin(x[1] / L) * cos(x[2] / L) * cos(x[3] / L) - v2 = -u0 * cos(x[1] / L) * sin(x[2] / L) * cos(x[3] / L) - v3 = 0 - p0 = (pressure(rho0, equations) + - rho0 * u0^2 / 16 * (cos(2 * x[1] / L) + cos(2 * x[2] / L)) * - (cos(2 * x[3] / L) + 2)) - rho = density(p0, equations) + v1 = u0 * sin(x[1] / L) * cos(x[2] / L) * cos(x[3] / L) + v2 = -u0 * cos(x[1] / L) * sin(x[2] / L) * cos(x[3] / L) + v3 = 0 + p0 = (pressure(rho0, equations) + + rho0 * u0^2 / 16 * (cos(2 * x[1] / L) + cos(2 * x[2] / L)) * (cos(2 * x[3] / L) + 2)) + rho = density(p0, equations) - return equilibrium_distribution(rho, v1, v2, v3, equations) + return equilibrium_distribution(rho, v1, v2, v3, equations) end initial_condition = initial_condition_taylor_green_vortex -solver = DGSEM(polydeg = 3, surface_flux = flux_godunov) +solver = DGSEM(polydeg=3, surface_flux=flux_godunov) -coordinates_min = (-pi * L, -pi * L, -pi * L) -coordinates_max = (pi * L, pi * L, pi * L) +coordinates_min = (-pi*L, -pi*L, -pi*L) +coordinates_max = ( pi*L, pi*L, pi*L) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 5, - n_cells_max = 300_000) + initial_refinement_level=5, + n_cells_max=300_000,) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 20 * equations.L / equations.u0) # Final time is `20` in non-dimensional time +tspan = (0.0, 20*equations.L/equations.u0) # Final time is `20` in non-dimensional time ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 20 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (Trixi.energy_kinetic_nondimensional,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(Trixi.energy_kinetic_nondimensional,)) -alive_callback = AliveCallback(analysis_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 = cons2macroscopic) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2macroscopic) -stepsize_callback = StepsizeCallback(cfl = 0.3) +stepsize_callback = StepsizeCallback(cfl=0.3) collision_callback = LBMCollisionCallback() @@ -68,11 +69,12 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, collision_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, - save_start = false, alias_u0 = true); +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, + save_start=false, alias_u0=true); summary_callback() # print the timer summary diff --git a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl index 9aab5e58788..191982bf2d6 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,23 +5,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5 / 3) +equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = (1.0, 1.0, 1.0) +coordinates_max = ( 1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,18 +32,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.5 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -50,10 +51,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl index f5f6e70a592..1d173922391 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_alfven_wave_mortar.jl @@ -5,24 +5,24 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations3D(5 / 3) +equations = IdealGlmMhdEquations3D(5/3) initial_condition = initial_condition_convergence_test volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = (1.0, 1.0, 1.0) -refinement_patches = ((type = "box", coordinates_min = (-0.5, -0.5, -0.5), - coordinates_max = (0.5, 0.5, 0.5)),) +coordinates_max = ( 1.0, 1.0, 1.0) +refinement_patches = ( + (type="box", coordinates_min=(-0.5, -0.5, -0.5), + coordinates_max=( 0.5, 0.5, 0.5)), +) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - refinement_patches = refinement_patches, - n_cells_max = 10_000) + initial_refinement_level=2, + refinement_patches=refinement_patches, + n_cells_max=10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -35,18 +35,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -54,10 +54,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_mhd_ec.jl b/examples/tree_3d_dgsem/elixir_mhd_ec.jl index 1f0088e82c9..057ffcb031f 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_ec.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_ec.jl @@ -10,18 +10,19 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 3, - surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = (2.0, 2.0, 2.0) +coordinates_max = ( 2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -31,19 +32,19 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, @@ -51,10 +52,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl b/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl index f8a72b6f452..6b4f6e310ce 100644 --- a/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl +++ b/examples/tree_3d_dgsem/elixir_mhd_ec_shockcapturing.jl @@ -10,26 +10,25 @@ equations = IdealGlmMhdEquations3D(1.4) initial_condition = initial_condition_weak_blast_wave surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) +volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) polydeg = 4 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) coordinates_min = (-2.0, -2.0, -2.0) -coordinates_max = (2.0, 2.0, 2.0) +coordinates_max = ( 2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 10_000) + initial_refinement_level=3, + n_cells_max=10_000) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -43,24 +42,25 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) cfl = 1.4 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl b/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl index 7d6f6acd166..b32355c48df 100644 --- a/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_navierstokes_convergence.jl @@ -8,257 +8,241 @@ prandtl_number() = 0.72 mu() = 0.01 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), - Prandtl = prandtl_number(), - gradient_variables = GradientVariablesPrimitive()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), Prandtl=prandtl_number(), + gradient_variables=GradientVariablesPrimitive()) # 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, - volume_integral = VolumeIntegralWeakForm()) +solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs, + volume_integral=VolumeIntegralWeakForm()) coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z)) -coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) +coordinates_max = ( 1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z)) # Create a uniformly refined mesh with periodic boundaries mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - periodicity = (true, false, true), - n_cells_max = 50_000) # set maximum capacity of tree data structure + initial_refinement_level=3, + periodicity=(true, false, true), + n_cells_max=50_000) # set maximum capacity of tree data structure # Note: the initial condition cannot be specialized to `CompressibleNavierStokesDiffusion3D` # since it is called by both the parabolic solver (which passes in `CompressibleNavierStokesDiffusion3D`) # and by the initial condition (which passes in `CompressibleEulerEquations3D`). # This convergence test setup was originally derived by Andrew Winters (@andrewwinters5000) function initial_condition_navier_stokes_convergence_test(x, t, equations) - # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * - cos(pi_t) - v2 = v1 - v3 = v1 - p = rho^2 - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) + # Constants. OBS! Must match those in `source_terms_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + v1 = A2 * sin(pi_x) * log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) * sin(pi_z) * cos(pi_t) + v2 = v1 + v3 = v1 + p = rho^2 + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end @inline function source_terms_navier_stokes_convergence_test(u, x, t, equations) - # TODO: parabolic - # we currently need to hardcode these parameters until we fix the "combined equation" issue - # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 - inv_gamma_minus_one = inv(equations.gamma - 1) - Pr = prandtl_number() - mu_ = mu() - - # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` - c = 2.0 - A1 = 0.5 - A2 = 1.0 - A3 = 0.5 - - # Convenience values for trig. functions - pi_x = pi * x[1] - pi_y = pi * x[2] - pi_z = pi * x[3] - pi_t = pi * t - - # Define auxiliary functions for the strange function of the y variable - # to make expressions easier to read - g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) - g_y = (A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) - + - (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0)) - g_yy = (2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) - - - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) - - - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0))) - - # Density and its derivatives - rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) - rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) - rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) - rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) - rho_xx = -pi^2 * (rho - c) - rho_yy = -pi^2 * (rho - c) - rho_zz = -pi^2 * (rho - c) - - # Velocities and their derivatives - # v1 terms - v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) - v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) - v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_xx = -pi^2 * v1 - v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) - v1_zz = -pi^2 * v1 - v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) - v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) - v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) - # v2 terms (simplifies from ansatz) - v2 = v1 - v2_t = v1_t - v2_x = v1_x - v2_y = v1_y - v2_z = v1_z - v2_xx = v1_xx - v2_yy = v1_yy - v2_zz = v1_zz - v2_xy = v1_xy - v2_yz = v1_yz - # v3 terms (simplifies from ansatz) - v3 = v1 - v3_t = v1_t - v3_x = v1_x - v3_y = v1_y - v3_z = v1_z - v3_xx = v1_xx - v3_yy = v1_yy - v3_zz = v1_zz - v3_xz = v1_xz - v3_yz = v1_yz - - # Pressure and its derivatives - p = rho^2 - p_t = 2.0 * rho * rho_t - p_x = 2.0 * rho * rho_x - p_y = 2.0 * rho * rho_y - p_z = 2.0 * rho * rho_z - - # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 - E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 - E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t - E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x - E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y - E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z - - # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho - kappa = equations.gamma * inv_gamma_minus_one / Pr - q_xx = kappa * rho_xx # kappa T_xx - q_yy = kappa * rho_yy # kappa T_yy - q_zz = kappa * rho_zz # kappa T_zz - - # Stress tensor and its derivatives (exploit symmetry) - tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) - tau12 = v1_y + v2_x - tau13 = v1_z + v3_x - tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) - tau23 = v2_z + v3_y - tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) - - tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) - tau12_x = v1_xy + v2_xx - tau13_x = v1_xz + v3_xx - - tau12_y = v1_yy + v2_xy - tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) - tau23_y = v2_yz + v3_yy - - tau13_z = v1_zz + v3_xz - tau23_z = v2_zz + v3_yz - tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) - - # Compute the source terms - # Density equation - du1 = (rho_t + rho_x * v1 + rho * v1_x - + rho_y * v2 + rho * v2_y - + rho_z * v3 + rho * v3_z) - # x-momentum equation - du2 = (rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 - + 2.0 * rho * v1 * v1_x - + rho_y * v1 * v2 - + rho * v1_y * v2 - + rho * v1 * v2_y - + rho_z * v1 * v3 - + rho * v1_z * v3 - + rho * v1 * v3_z - - - mu_ * (tau11_x + tau12_y + tau13_z)) - # y-momentum equation - du3 = (rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 - + rho * v1_x * v2 - + rho * v1 * v2_x - + rho_y * v2^2 - + 2.0 * rho * v2 * v2_y - + rho_z * v2 * v3 - + rho * v2_z * v3 - + rho * v2 * v3_z - - - mu_ * (tau12_x + tau22_y + tau23_z)) - # z-momentum equation - du4 = (rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 - + rho * v1_x * v3 - + rho * v1 * v3_x - + rho_y * v2 * v3 - + rho * v2_y * v3 - + rho * v2 * v3_y - + rho_z * v3^2 - + 2.0 * rho * v3 * v3_z - - - mu_ * (tau13_x + tau23_y + tau33_z)) - # Total energy equation - du5 = (E_t + v1_x * (E + p) + v1 * (E_x + p_x) - + v2_y * (E + p) + v2 * (E_y + p_y) - + v3_z * (E + p) + v3 * (E_z + p_z) - # stress tensor and temperature gradient from x-direction - - - mu_ * (q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 - + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) - # stress tensor and temperature gradient terms from y-direction - - - mu_ * (q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 - + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) - # stress tensor and temperature gradient terms from z-direction - - - mu_ * (q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 - + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z)) - - return SVector(du1, du2, du3, du4, du5) + # TODO: parabolic + # we currently need to hardcode these parameters until we fix the "combined equation" issue + # see also https://github.com/trixi-framework/Trixi.jl/pull/1160 + inv_gamma_minus_one = inv(equations.gamma - 1) + Pr = prandtl_number() + mu_ = mu() + + # Constants. OBS! Must match those in `initial_condition_navier_stokes_convergence_test` + c = 2.0 + A1 = 0.5 + A2 = 1.0 + A3 = 0.5 + + # Convenience values for trig. functions + pi_x = pi * x[1] + pi_y = pi * x[2] + pi_z = pi * x[3] + pi_t = pi * t + + # Define auxiliary functions for the strange function of the y variable + # to make expressions easier to read + g = log(x[2] + 2.0) * (1.0 - exp(-A3 * (x[2] - 1.0))) + g_y = ( A3 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) + + (1.0 - exp(-A3 * (x[2] - 1.0))) / (x[2] + 2.0) ) + g_yy = ( 2.0 * A3 * exp(-A3 * (x[2] - 1.0)) / (x[2] + 2.0) + - (1.0 - exp(-A3 * (x[2] - 1.0))) / ((x[2] + 2.0)^2) + - A3^2 * log(x[2] + 2.0) * exp(-A3 * (x[2] - 1.0)) ) + + # Density and its derivatives + rho = c + A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_t = -pi * A1 * sin(pi_x) * cos(pi_y) * sin(pi_z) * sin(pi_t) + rho_x = pi * A1 * cos(pi_x) * cos(pi_y) * sin(pi_z) * cos(pi_t) + rho_y = -pi * A1 * sin(pi_x) * sin(pi_y) * sin(pi_z) * cos(pi_t) + rho_z = pi * A1 * sin(pi_x) * cos(pi_y) * cos(pi_z) * cos(pi_t) + rho_xx = -pi^2 * (rho - c) + rho_yy = -pi^2 * (rho - c) + rho_zz = -pi^2 * (rho - c) + + # Velocities and their derivatives + # v1 terms + v1 = A2 * sin(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_t = -pi * A2 * sin(pi_x) * g * sin(pi_z) * sin(pi_t) + v1_x = pi * A2 * cos(pi_x) * g * sin(pi_z) * cos(pi_t) + v1_y = A2 * sin(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_z = pi * A2 * sin(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_xx = -pi^2 * v1 + v1_yy = A2 * sin(pi_x) * g_yy * sin(pi_z) * cos(pi_t) + v1_zz = -pi^2 * v1 + v1_xy = pi * A2 * cos(pi_x) * g_y * sin(pi_z) * cos(pi_t) + v1_xz = pi^2 * A2 * cos(pi_x) * g * cos(pi_z) * cos(pi_t) + v1_yz = pi * A2 * sin(pi_x) * g_y * cos(pi_z) * cos(pi_t) + # v2 terms (simplifies from ansatz) + v2 = v1 + v2_t = v1_t + v2_x = v1_x + v2_y = v1_y + v2_z = v1_z + v2_xx = v1_xx + v2_yy = v1_yy + v2_zz = v1_zz + v2_xy = v1_xy + v2_yz = v1_yz + # v3 terms (simplifies from ansatz) + v3 = v1 + v3_t = v1_t + v3_x = v1_x + v3_y = v1_y + v3_z = v1_z + v3_xx = v1_xx + v3_yy = v1_yy + v3_zz = v1_zz + v3_xz = v1_xz + v3_yz = v1_yz + + # Pressure and its derivatives + p = rho^2 + p_t = 2.0 * rho * rho_t + p_x = 2.0 * rho * rho_x + p_y = 2.0 * rho * rho_y + p_z = 2.0 * rho * rho_z + + # Total energy and its derivatives; simiplifies from ansatz that v2 = v1 and v3 = v1 + E = p * inv_gamma_minus_one + 1.5 * rho * v1^2 + E_t = p_t * inv_gamma_minus_one + 1.5 * rho_t * v1^2 + 3.0 * rho * v1 * v1_t + E_x = p_x * inv_gamma_minus_one + 1.5 * rho_x * v1^2 + 3.0 * rho * v1 * v1_x + E_y = p_y * inv_gamma_minus_one + 1.5 * rho_y * v1^2 + 3.0 * rho * v1 * v1_y + E_z = p_z * inv_gamma_minus_one + 1.5 * rho_z * v1^2 + 3.0 * rho * v1 * v1_z + + # Divergence of Fick's law ∇⋅∇q = kappa ∇⋅∇T; simplifies because p = rho², so T = p/rho = rho + kappa = equations.gamma * inv_gamma_minus_one / Pr + q_xx = kappa * rho_xx # kappa T_xx + q_yy = kappa * rho_yy # kappa T_yy + q_zz = kappa * rho_zz # kappa T_zz + + # Stress tensor and its derivatives (exploit symmetry) + tau11 = 4.0 / 3.0 * v1_x - 2.0 / 3.0 * (v2_y + v3_z) + tau12 = v1_y + v2_x + tau13 = v1_z + v3_x + tau22 = 4.0 / 3.0 * v2_y - 2.0 / 3.0 * (v1_x + v3_z) + tau23 = v2_z + v3_y + tau33 = 4.0 / 3.0 * v3_z - 2.0 / 3.0 * (v1_x + v2_y) + + tau11_x = 4.0 / 3.0 * v1_xx - 2.0 / 3.0 * (v2_xy + v3_xz) + tau12_x = v1_xy + v2_xx + tau13_x = v1_xz + v3_xx + + tau12_y = v1_yy + v2_xy + tau22_y = 4.0 / 3.0 * v2_yy - 2.0 / 3.0 * (v1_xy + v3_yz) + tau23_y = v2_yz + v3_yy + + tau13_z = v1_zz + v3_xz + tau23_z = v2_zz + v3_yz + tau33_z = 4.0 / 3.0 * v3_zz - 2.0 / 3.0 * (v1_xz + v2_yz) + + # Compute the source terms + # Density equation + du1 = ( rho_t + rho_x * v1 + rho * v1_x + + rho_y * v2 + rho * v2_y + + rho_z * v3 + rho * v3_z ) + # x-momentum equation + du2 = ( rho_t * v1 + rho * v1_t + p_x + rho_x * v1^2 + + 2.0 * rho * v1 * v1_x + + rho_y * v1 * v2 + + rho * v1_y * v2 + + rho * v1 * v2_y + + rho_z * v1 * v3 + + rho * v1_z * v3 + + rho * v1 * v3_z + - mu_ * (tau11_x + tau12_y + tau13_z) ) + # y-momentum equation + du3 = ( rho_t * v2 + rho * v2_t + p_y + rho_x * v1 * v2 + + rho * v1_x * v2 + + rho * v1 * v2_x + + rho_y * v2^2 + + 2.0 * rho * v2 * v2_y + + rho_z * v2 * v3 + + rho * v2_z * v3 + + rho * v2 * v3_z + - mu_ * (tau12_x + tau22_y + tau23_z) ) + # z-momentum equation + du4 = ( rho_t * v3 + rho * v3_t + p_z + rho_x * v1 * v3 + + rho * v1_x * v3 + + rho * v1 * v3_x + + rho_y * v2 * v3 + + rho * v2_y * v3 + + rho * v2 * v3_y + + rho_z * v3^2 + + 2.0 * rho * v3 * v3_z + - mu_ * (tau13_x + tau23_y + tau33_z) ) + # Total energy equation + du5 = ( E_t + v1_x * (E + p) + v1 * (E_x + p_x) + + v2_y * (E + p) + v2 * (E_y + p_y) + + v3_z * (E + p) + v3 * (E_z + p_z) + # stress tensor and temperature gradient from x-direction + - mu_ * ( q_xx + v1_x * tau11 + v2_x * tau12 + v3_x * tau13 + + v1 * tau11_x + v2 * tau12_x + v3 * tau13_x) + # stress tensor and temperature gradient terms from y-direction + - mu_ * ( q_yy + v1_y * tau12 + v2_y * tau22 + v3_y * tau23 + + v1 * tau12_y + v2 * tau22_y + v3 * tau23_y) + # stress tensor and temperature gradient terms from z-direction + - mu_ * ( q_zz + v1_z * tau13 + v2_z * tau23 + v3_z * tau33 + + v1 * tau13_z + v2 * tau23_z + v3 * tau33_z) ) + + return SVector(du1, du2, du3, du4, du5) end initial_condition = initial_condition_navier_stokes_convergence_test # BC types -velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, - t, - equations)[2:4]) +velocity_bc_top_bottom = NoSlip((x, t, equations) -> initial_condition_navier_stokes_convergence_test(x, t, equations)[2:4]) heat_bc_top_bottom = Adiabatic((x, t, equations) -> 0.0) -boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, - heat_bc_top_bottom) +boundary_condition_top_bottom = BoundaryConditionNavierStokesWall(velocity_bc_top_bottom, heat_bc_top_bottom) # define inviscid boundary conditions boundary_conditions = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_slip_wall, - y_pos = boundary_condition_slip_wall, - z_neg = boundary_condition_periodic, - z_pos = boundary_condition_periodic) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_slip_wall, + y_pos = boundary_condition_slip_wall, + z_neg = boundary_condition_periodic, + z_pos = boundary_condition_periodic) # define viscous boundary conditions boundary_conditions_parabolic = (; x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_top_bottom, - y_pos = boundary_condition_top_bottom, - z_neg = boundary_condition_periodic, - z_pos = boundary_condition_periodic) - -semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, solver; - boundary_conditions = (boundary_conditions, - boundary_conditions_parabolic), - source_terms = source_terms_navier_stokes_convergence_test) + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_top_bottom, + y_pos = boundary_condition_top_bottom, + z_neg = boundary_condition_periodic, + z_pos = boundary_condition_periodic) + +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; + boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), + source_terms=source_terms_navier_stokes_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -268,15 +252,16 @@ tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() -alive_callback = AliveCallback(alive_interval = 10) +alive_callback = AliveCallback(alive_interval=10) analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, dt = 1e-5, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, dt = 1e-5, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary + diff --git a/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl b/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl index 5e2fb4e395e..9cb73a462b7 100644 --- a/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl +++ b/examples/tree_3d_dgsem/elixir_navierstokes_taylor_green_vortex.jl @@ -10,42 +10,39 @@ prandtl_number() = 0.72 mu() = 6.25e-4 # equivalent to Re = 1600 equations = CompressibleEulerEquations3D(1.4) -equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(), - Prandtl = prandtl_number()) +equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu=mu(), + Prandtl=prandtl_number()) """ initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, - equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + - 1.0 / 16.0 * A^2 * rho * - (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + - cos(2 * x[2]) * cos(2 * x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex volume_flux = flux_ranocha -solver = DGSEM(polydeg = 3, surface_flux = flux_hllc, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=3, surface_flux=flux_hllc, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = (1.0, 1.0, 1.0) .* pi +coordinates_max = ( 1.0, 1.0, 1.0) .* pi mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 3, - n_cells_max = 100_000) + initial_refinement_level=3, + n_cells_max=100_000) + semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver) @@ -59,13 +56,12 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 50 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (energy_kinetic, - energy_internal, - enstrophy)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, + extra_analysis_integrals=(energy_kinetic, + energy_internal, + enstrophy)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval,) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -75,6 +71,6 @@ callbacks = CallbackSet(summary_callback, # run the simulation time_int_tol = 1e-8 -sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/tree_3d_fdsbp/elixir_advection_extended.jl b/examples/tree_3d_fdsbp/elixir_advection_extended.jl index 22085a63510..241e0698649 100644 --- a/examples/tree_3d_fdsbp/elixir_advection_extended.jl +++ b/examples/tree_3d_fdsbp/elixir_advection_extended.jl @@ -13,21 +13,22 @@ equations = LinearScalarAdvectionEquation3D(advection_velocity) initial_condition = initial_condition_convergence_test D_SBP = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, accuracy_order = 4, - xmin = 0.0, xmax = 1.0, N = 10) + derivative_order=1, accuracy_order=4, + xmin=0.0, xmax=1.0, N=10) solver = FDSBP(D_SBP, - surface_integral = SurfaceIntegralStrongForm(flux_lax_friedrichs), - volume_integral = VolumeIntegralStrongForm()) + surface_integral=SurfaceIntegralStrongForm(flux_lax_friedrichs), + volume_integral=VolumeIntegralStrongForm()) coordinates_min = (-1.0, -1.0, -1.0) -coordinates_max = (1.0, 1.0, 1.0) +coordinates_max = ( 1.0, 1.0, 1.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 1, - n_cells_max = 30_000, - periodicity = true) + initial_refinement_level=1, + n_cells_max=30_000, + periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -37,18 +38,19 @@ ode = semidiscretize(semi, tspan); summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (energy_total,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(energy_total,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + ############################################################################### # run the simulation -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-9, reltol = 1.0e-9, - ode_default_options()..., callback = callbacks) +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-9, reltol=1.0e-9, + ode_default_options()..., callback=callbacks) summary_callback() diff --git a/examples/tree_3d_fdsbp/elixir_euler_convergence.jl b/examples/tree_3d_fdsbp/elixir_euler_convergence.jl index 8a59af1f921..576a07e6aba 100644 --- a/examples/tree_3d_fdsbp/elixir_euler_convergence.jl +++ b/examples/tree_3d_fdsbp/elixir_euler_convergence.jl @@ -12,23 +12,24 @@ equations = CompressibleEulerEquations3D(1.4) initial_condition = initial_condition_convergence_test D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 10_000) + initial_refinement_level=2, + n_cells_max=10_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) + ############################################################################### # ODE solvers, callbacks etc. @@ -39,26 +40,27 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_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) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.1) +stepsize_callback = StepsizeCallback(cfl=1.1) 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); +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 diff --git a/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl b/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl index 0354200ae42..d2495cff5cd 100644 --- a/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl +++ b/examples/tree_3d_fdsbp/elixir_euler_taylor_green_vortex.jl @@ -14,43 +14,40 @@ equations = CompressibleEulerEquations3D(1.4) The classical inviscid Taylor-Green vortex. """ -function initial_condition_taylor_green_vortex(x, t, - equations::CompressibleEulerEquations3D) - A = 1.0 # magnitude of speed - Ms = 0.1 # maximum Mach number - - rho = 1.0 - v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) - v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) - v3 = 0.0 - p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms - p = p + - 1.0 / 16.0 * A^2 * rho * - (cos(2 * x[1]) * cos(2 * x[3]) + 2 * cos(2 * x[2]) + 2 * cos(2 * x[1]) + - cos(2 * x[2]) * cos(2 * x[3])) - - return prim2cons(SVector(rho, v1, v2, v3, p), equations) +function initial_condition_taylor_green_vortex(x, t, equations::CompressibleEulerEquations3D) + A = 1.0 # magnitude of speed + Ms = 0.1 # maximum Mach number + + rho = 1.0 + v1 = A * sin(x[1]) * cos(x[2]) * cos(x[3]) + v2 = -A * cos(x[1]) * sin(x[2]) * cos(x[3]) + v3 = 0.0 + p = (A / Ms)^2 * rho / equations.gamma # scaling to get Ms + p = p + 1.0/16.0 * A^2 * rho * (cos(2*x[1])*cos(2*x[3]) + 2*cos(2*x[2]) + 2*cos(2*x[1]) + cos(2*x[2])*cos(2*x[3])) + + return prim2cons(SVector(rho, v1, v2, v3, p), equations) end initial_condition = initial_condition_taylor_green_vortex D_upw = upwind_operators(SummationByPartsOperators.Mattsson2017, - derivative_order = 1, - accuracy_order = 4, - xmin = -1.0, xmax = 1.0, - N = 16) + derivative_order=1, + accuracy_order=4, + xmin=-1.0, xmax=1.0, + N=16) flux_splitting = splitting_steger_warming solver = FDSBP(D_upw, - surface_integral = SurfaceIntegralUpwind(flux_splitting), - volume_integral = VolumeIntegralUpwind(flux_splitting)) + surface_integral=SurfaceIntegralUpwind(flux_splitting), + volume_integral=VolumeIntegralUpwind(flux_splitting)) coordinates_min = (-1.0, -1.0, -1.0) .* pi -coordinates_max = (1.0, 1.0, 1.0) .* pi +coordinates_max = ( 1.0, 1.0, 1.0) .* pi mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 2, - n_cells_max = 100_000) + initial_refinement_level=2, + n_cells_max=100_000) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + ############################################################################### # ODE solvers, callbacks etc. @@ -60,27 +57,28 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(energy_total, + energy_kinetic, + energy_internal,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) + ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks) +sol = solve(ode, SSPRK43(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks) summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl b/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl index 8f8e867dca8..2f8228dffb8 100644 --- a/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl +++ b/examples/unstructured_2d_dgsem/elixir_acoustics_gauss_wall.jl @@ -6,18 +6,16 @@ using Trixi ############################################################################### # semidiscretization of the acoustic perturbation equations -equations = AcousticPerturbationEquations2D(v_mean_global = (0.0, -0.5), - c_mean_global = 1.0, - rho_mean_global = 1.0) +equations = AcousticPerturbationEquations2D(v_mean_global=(0.0, -0.5), c_mean_global=1.0, + rho_mean_global=1.0) # Create DG solver with polynomial degree = 4 and (local) Lax-Friedrichs/Rusanov flux -solver = DGSEM(polydeg = 4, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) # Create unstructured quadrilateral mesh from a file default_mesh_file = joinpath(@__DIR__, "mesh_five_circles_in_circle.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/3c79baad6b4d73bb26ec6420b5d16f45/raw/22aefc4ec2107cf0bffc40e81dfbc52240c625b1/mesh_five_circles_in_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/3c79baad6b4d73bb26ec6420b5d16f45/raw/22aefc4ec2107cf0bffc40e81dfbc52240c625b1/mesh_five_circles_in_circle.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = UnstructuredMesh2D(mesh_file) @@ -29,26 +27,27 @@ A Gaussian pulse, used in the `gauss_wall` example elixir in combination with [`boundary_condition_wall`](@ref). Uses the global mean values from `equations`. """ function initial_condition_gauss_wall(x, t, equations::AcousticPerturbationEquations2D) - v1_prime = 0.0 - v2_prime = 0.0 - p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) + v1_prime = 0.0 + v2_prime = 0.0 + p_prime = exp(-log(2) * (x[1]^2 + (x[2] - 25)^2) / 25) - prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) + prim = SVector(v1_prime, v2_prime, p_prime, global_mean_vars(equations)...) - return prim2cons(prim, equations) + return prim2cons(prim, equations) end initial_condition = initial_condition_gauss_wall -boundary_conditions = Dict(:OuterCircle => boundary_condition_slip_wall, - :InnerCircle1 => boundary_condition_slip_wall, - :InnerCircle2 => boundary_condition_slip_wall, - :InnerCircle3 => boundary_condition_slip_wall, - :InnerCircle4 => boundary_condition_slip_wall, - :InnerCircle5 => boundary_condition_slip_wall) +boundary_conditions = Dict( :OuterCircle => boundary_condition_slip_wall, + :InnerCircle1 => boundary_condition_slip_wall, + :InnerCircle2 => boundary_condition_slip_wall, + :InnerCircle3 => boundary_condition_slip_wall, + :InnerCircle4 => boundary_condition_slip_wall, + :InnerCircle5 => boundary_condition_slip_wall ) # A semidiscretization collects data structures and functions for the spatial discretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) + ############################################################################### # ODE solvers, callbacks etc. @@ -62,10 +61,10 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +analysis_callback = AnalysisCallback(semi, interval=100) # The SaveSolutionCallback allows to save the solution to a file in regular intervals -save_solution = SaveSolutionCallback(interval = 50, solution_variables = cons2state) +save_solution = SaveSolutionCallback(interval=50, solution_variables=cons2state) # 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) @@ -74,7 +73,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, save_solution) # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-6, reltol = 1.0e-6, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-6, reltol=1.0e-6, + ode_default_options()..., callback=callbacks); # Print the timer summary summary_callback() diff --git a/examples/unstructured_2d_dgsem/elixir_advection_basic.jl b/examples/unstructured_2d_dgsem/elixir_advection_basic.jl index afef6c2c38f..274978d48b0 100644 --- a/examples/unstructured_2d_dgsem/elixir_advection_basic.jl +++ b/examples/unstructured_2d_dgsem/elixir_advection_basic.jl @@ -12,24 +12,22 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity) ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg = 6, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=6, surface_flux=flux_lax_friedrichs) ############################################################################### # 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) ############################################################################### # create the semi discretization object -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, - solver) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test, solver) ############################################################################### # ODE solvers, callbacks etc. @@ -42,23 +40,22 @@ ode = semidiscretize(semi, (0.0, 1.0)); summary_callback = SummaryCallback() # The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_callback = AnalysisCallback(semi, interval = 100) +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) +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) +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) +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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_basic.jl b/examples/unstructured_2d_dgsem/elixir_euler_basic.jl index cd6a1995757..9fbea47a9d5 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_basic.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_basic.jl @@ -12,24 +12,23 @@ initial_condition = initial_condition_convergence_test source_terms = source_terms_convergence_test boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition) -boundary_conditions = Dict(:Slant => boundary_condition_convergence_test, - :Bezier => boundary_condition_convergence_test, - :Right => boundary_condition_convergence_test, - :Bottom => boundary_condition_convergence_test, - :Top => boundary_condition_convergence_test) +boundary_conditions = Dict( :Slant => boundary_condition_convergence_test, + :Bezier => boundary_condition_convergence_test, + :Right => boundary_condition_convergence_test, + :Bottom => boundary_condition_convergence_test, + :Top => boundary_condition_convergence_test ) ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg = 8, surface_flux = flux_lax_friedrichs) +solver = DGSEM(polydeg=8, surface_flux=flux_lax_friedrichs) ############################################################################### # Get the curved quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_trixi_unstructured_mesh_docs.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/52056f1487853fab63b7f4ed7f171c80/raw/9d573387dfdbb8bce2a55db7246f4207663ac07f/mesh_trixi_unstructured_mesh_docs.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = UnstructuredMesh2D(mesh_file) @@ -38,8 +37,8 @@ mesh = UnstructuredMesh2D(mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms, - boundary_conditions = boundary_conditions) + source_terms=source_terms, + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -50,18 +49,18 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_restart = SaveRestartCallback(interval = 50, - save_final_restart = true) +save_restart = SaveRestartCallback(interval=50, + save_final_restart=true) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 0.9) +stepsize_callback = StepsizeCallback(cfl=0.9) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -73,7 +72,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_ec.jl b/examples/unstructured_2d_dgsem/elixir_euler_ec.jl index 0f53aa62a18..2725142fd17 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_ec.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_ec.jl @@ -6,7 +6,7 @@ using Trixi ############################################################################### # semidiscretization of the compressible Euler equations -equations = CompressibleEulerEquations2D(5 / 3) +equations = CompressibleEulerEquations2D(5/3) initial_condition = initial_condition_weak_blast_wave @@ -14,19 +14,18 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = flux_ranocha -solver = DGSEM(polydeg = 6, surface_flux = flux_ranocha, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=6, surface_flux=flux_ranocha, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the curved quad mesh from a file 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) ############################################################################### # create the semi discretization object @@ -42,15 +41,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -61,7 +60,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl index 1110ebd003f..cb289848039 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl @@ -11,26 +11,25 @@ equations = CompressibleEulerEquations2D(1.4) initial_condition = initial_condition_constant 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) +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 DG approximation space -solver = DGSEM(polydeg = 6, surface_flux = FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg=6, surface_flux=FluxHLL(min_max_speed_naive)) ############################################################################### # 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) +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) @@ -39,7 +38,7 @@ mesh = UnstructuredMesh2D(mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -50,15 +49,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -66,7 +65,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl index 7e90431f5b6..5f248eb110d 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl @@ -15,25 +15,24 @@ boundary_conditions = boundary_condition_periodic ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg = 6, surface_flux = FluxRotated(FluxHLL(min_max_speed_naive))) +solver = DGSEM(polydeg=6, surface_flux=FluxRotated(FluxHLL(min_max_speed_naive))) ############################################################################### # 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) ############################################################################### # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms, - boundary_conditions = boundary_conditions) + source_terms=source_terms, + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -44,14 +43,14 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) ############################################################################### # run the simulation -sol = solve(ode, SSPRK43(); ode_default_options()..., callback = callbacks); +sol = solve(ode, SSPRK43(); ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_euler_restart.jl b/examples/unstructured_2d_dgsem/elixir_euler_restart.jl index 5f66ad15cbd..2ac67652023 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_restart.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_restart.jl @@ -7,6 +7,7 @@ using Trixi trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_basic.jl")) + ############################################################################### # adapt the parameters that have changed compared to "elixir_advection_extended.jl" @@ -17,16 +18,18 @@ restart_filename = joinpath("out", "restart_000050.h5") mesh = load_mesh(restart_filename) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms, - boundary_conditions = boundary_conditions) + source_terms=source_terms, + boundary_conditions=boundary_conditions) tspan = (load_time(restart_filename), 1.0) ode = semidiscretize(semi, tspan, restart_filename); + ############################################################################### # 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); +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 + diff --git a/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl b/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl index 55d63deb135..3d5a391bd90 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_sedov.jl @@ -14,25 +14,25 @@ The Sedov blast wave setup based on Flash - http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 - r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) - E = 1.0 - p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) - p0_outer = 1.0e-5 # = true Sedov 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) + # 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 http://flash.uchicago.edu/site/flashcode/user_support/flash_ug_devel/node184.html#SECTION010114000000000000000 + r0 = 0.21875 # = 3.5 * smallest dx (for domain length=4 and max-ref=6) + E = 1.0 + p0_inner = 3 * (equations.gamma - 1) * E / (3 * pi * r0^2) + p0_outer = 1.0e-5 # = true Sedov 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 @@ -43,25 +43,23 @@ volume_flux = flux_ranocha polydeg = 6 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 1.0, - alpha_min = 0.001, - alpha_smooth = true, - variable = density_pressure) + alpha_max=1.0, + 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) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) # Get the curved quad mesh from a file 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) +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) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # create the semidiscretization semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -75,15 +73,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 300 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 300, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=300, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 0.5) +stepsize_callback = StepsizeCallback(cfl=0.5) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -94,7 +92,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl index 702fe74c73b..e300b39c01e 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl @@ -10,41 +10,40 @@ equations = CompressibleEulerEquations2D(1.4) @inline function uniform_flow_state(x, t, equations::CompressibleEulerEquations2D) - # set the freestream flow parameters - rho_freestream = 1.0 - u_freestream = 0.3 - p_freestream = inv(equations.gamma) - - theta = pi / 90.0 # analogous with a two degree angle of attack - si, co = sincos(theta) - v1 = u_freestream * co - v2 = u_freestream * si - - prim = SVector(rho_freestream, v1, v2, p_freestream) - return prim2cons(prim, equations) + # set the freestream flow parameters + rho_freestream = 1.0 + u_freestream = 0.3 + p_freestream = inv(equations.gamma) + + theta = pi / 90.0 # analogous with a two degree angle of attack + si, co = sincos(theta) + v1 = u_freestream * co + v2 = u_freestream * si + + prim = SVector(rho_freestream, v1, v2, p_freestream) + return prim2cons(prim, equations) end initial_condition = uniform_flow_state boundary_condition_uniform_flow = BoundaryConditionDirichlet(uniform_flow_state) -boundary_conditions = Dict(:Bottom => boundary_condition_uniform_flow, - :Top => boundary_condition_uniform_flow, - :Right => boundary_condition_uniform_flow, - :Left => boundary_condition_uniform_flow, - :Circle => boundary_condition_slip_wall) +boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, + :Top => boundary_condition_uniform_flow, + :Right => boundary_condition_uniform_flow, + :Left => boundary_condition_uniform_flow, + :Circle => boundary_condition_slip_wall ) ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg = 4, surface_flux = FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg=4, surface_flux=FluxHLL(min_max_speed_naive)) ############################################################################### # Get the curved quad mesh from a file default_mesh_file = joinpath(@__DIR__, "mesh_box_around_circle.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8b9b11a1eedfa54b215c122c3d17b271/raw/0d2b5d98c87e67a6f384693a8b8e54b4c9fcbf3d/mesh_box_around_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8b9b11a1eedfa54b215c122c3d17b271/raw/0d2b5d98c87e67a6f384693a8b8e54b4c9fcbf3d/mesh_box_around_circle.mesh", + default_mesh_file) mesh_file = default_mesh_file mesh = UnstructuredMesh2D(mesh_file) @@ -53,7 +52,7 @@ mesh = UnstructuredMesh2D(mesh_file) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions=boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -64,23 +63,22 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 10, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=10, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, - stepsize_callback) +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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl b/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl index 2db133ebb7b..fe7f9851514 100644 --- a/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl +++ b/examples/unstructured_2d_dgsem/elixir_mhd_alfven_wave.jl @@ -5,25 +5,22 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -gamma = 5 / 3 +gamma = 5/3 equations = IdealGlmMhdEquations2D(gamma) initial_condition = initial_condition_convergence_test volume_flux = (flux_central, flux_nonconservative_powell) -solver = DGSEM(polydeg = 7, - surface_flux = (FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=7, surface_flux=(FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -36,24 +33,21 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) - -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) + +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.9 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -62,10 +56,11 @@ callbacks = CallbackSet(summary_callback, stepsize_callback, glm_speed_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl b/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl index a40f92cac02..d75079bb8d7 100644 --- a/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl +++ b/examples/unstructured_2d_dgsem/elixir_mhd_ec.jl @@ -6,42 +6,40 @@ using Trixi ############################################################################### # semidiscretization of the compressible ideal GLM-MHD equations -equations = IdealGlmMhdEquations2D(5 / 3) +equations = IdealGlmMhdEquations2D(5/3) function initial_condition_shifted_weak_blast_wave(x, t, equations::IdealGlmMhdEquations2D) - # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) - # Shift blastwave to center of domain - inicenter = (sqrt(2) / 2, sqrt(2) / 2) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - - # Calculate primitive variables - rho = r > 0.5 ? 1.0 : 1.1691 - v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) - v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) - p = r > 0.5 ? 1.0 : 1.245 - - return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) + # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) + # Shift blastwave to center of domain + inicenter = (sqrt(2)/2, sqrt(2)/2) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + + # Calculate primitive variables + rho = r > 0.5 ? 1.0 : 1.1691 + v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) + v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) + p = r > 0.5 ? 1.0 : 1.245 + + return prim2cons(SVector(rho, v1, v2, 0.0, p, 1.0, 1.0, 1.0, 0.0), equations) end initial_condition = initial_condition_shifted_weak_blast_wave # Get the DG approximation space volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell) -solver = DGSEM(polydeg = 6, - surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=6, surface_flux=(flux_hindenlang_gassner, flux_nonconservative_powell), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -55,24 +53,21 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (entropy, energy_total, - energy_kinetic, - energy_internal, - energy_magnetic, - cross_helicity)) - -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(entropy, energy_total, + energy_kinetic, energy_internal, + energy_magnetic, cross_helicity)) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) cfl = 1.0 -stepsize_callback = StepsizeCallback(cfl = cfl) +stepsize_callback = StepsizeCallback(cfl=cfl) -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) +glm_speed_callback = GlmSpeedCallback(glm_scale=0.5, cfl=cfl) callbacks = CallbackSet(summary_callback, analysis_callback, @@ -84,7 +79,7 @@ callbacks = CallbackSet(summary_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl index 07e0bbdd3ca..9a8a02feaed 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl @@ -7,51 +7,47 @@ using Trixi # semidiscretization of the shallow water equations with a continuous # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant = 1.0, H0 = 3.0) +equations = ShallowWaterEquations2D(gravity_constant=1.0, H0=3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) + + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness boundary_condition_constant = BoundaryConditionDirichlet(initial_condition) -boundary_condition = Dict(:OuterCircle => boundary_condition_constant) +boundary_condition = Dict( :OuterCircle => boundary_condition_constant ) ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 4, - surface_flux = (FluxHLL(min_max_speed_naive), - flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form well-balancedness testing # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_outer_circle.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.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_condition) + boundary_conditions=boundary_condition) ############################################################################### # ODE solvers, callbacks, etc. @@ -62,15 +58,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = true, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + save_analysis=true, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -78,6 +74,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-11, reltol = 1.0e-11, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-11, reltol=1.0e-11, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl index 8e9d396d826..138b256c08b 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl @@ -7,7 +7,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) # Note, this initial condition is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_ec_discontinuous_bottom` below. @@ -17,21 +17,19 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg = 6, - surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=6, surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal), + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form entropy conservation testing (needs periodic BCs) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -51,48 +49,45 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_ec_discontinuous_bottom(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.7, 0.7) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Set the background values - H = 3.25 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # setup the discontinuous water height and velocities - if element_id == 10 - H = 4.0 - v1 = 0.1882 * cos_phi - v2 = 0.1882 * sin_phi - end - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_ec_discontinuous_bottom(x, t, element_id, equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 3.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 4.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, - equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -101,15 +96,15 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -117,7 +112,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl index 94202b81df0..ee3650f3bb5 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_ec_shockcapturing.jl @@ -7,7 +7,7 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) # Note, this initial condition is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_ec_discontinuous_bottom` below. @@ -17,17 +17,17 @@ initial_condition = initial_condition_weak_blast_wave # Get the DG approximation space surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) +volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) polydeg = 6 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = waterheight_pressure) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=waterheight_pressure) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) solver = DGSEM(basis, surface_flux, volume_integral) ############################################################################### @@ -35,12 +35,11 @@ solver = DGSEM(basis, surface_flux, volume_integral) # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -60,48 +59,45 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_ec_discontinuous_bottom(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.7, 0.7) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - phi = atan(y_norm, x_norm) - sin_phi, cos_phi = sincos(phi) - - # Set the background values - H = 3.25 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # setup the discontinuous water height and velocities - if element_id == 10 - H = 4.0 - v1 = 0.1882 * cos_phi - v2 = 0.1882 * sin_phi - end - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_ec_discontinuous_bottom(x, t, element_id, equations::ShallowWaterEquations2D) + # Set up polar coordinates + inicenter = SVector(0.7, 0.7) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + phi = atan(y_norm, x_norm) + sin_phi, cos_phi = sincos(phi) + + # Set the background values + H = 3.25 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # setup the discontinuous water height and velocities + if element_id == 10 + H = 4.0 + v1 = 0.1882 * cos_phi + v2 = 0.1882 * sin_phi + end + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, - equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_ec_discontinuous_bottom(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -110,11 +106,11 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, stepsize_callback) @@ -122,7 +118,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl index 07668688406..e0b64802ff8 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_source_terms.jl @@ -7,7 +7,7 @@ using Trixi # semidiscretization of the shallow water equations with a periodic # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant = 9.81) +equations = ShallowWaterEquations2D(gravity_constant=9.81) initial_condition = initial_condition_convergence_test @@ -16,24 +16,23 @@ initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 6, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=6, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form convergence test on a periodic domain # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -44,15 +43,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -60,7 +59,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl index 2cab68b1cb5..d9e71e4aa44 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_convergence.jl @@ -7,8 +7,7 @@ using Trixi # Semidiscretization of the two-layer shallow water equations with a periodic # bottom topography function (set in the initial conditions) -equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 10.0, rho_upper = 0.9, - rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant=10.0, rho_upper=0.9, rho_lower=1.0) initial_condition = initial_condition_convergence_test @@ -17,24 +16,23 @@ initial_condition = initial_condition_convergence_test volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 6, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=6, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form convergence test on a periodic domain # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # Create the semidiscretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_convergence_test) + source_terms=source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. @@ -45,15 +43,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 500, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=500, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -61,7 +59,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl index 9d70e9287cf..4295f93b342 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_dam_break.jl @@ -7,64 +7,62 @@ using Trixi # Semidiscretization of the two-layer shallow water equations for a dam break test with a # discontinuous bottom topography function to test energy conservation -equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 1.0, rho_upper = 0.9, - rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant=1.0, rho_upper=0.9, rho_lower=1.0) # This test case uses a special work around to setup a truly discontinuous bottom topography # function and initial condition for this academic testcase of entropy conservation. First, a # dummy initial_condition_dam_break is introduced to create the semidiscretization. Then the initial # condition is reset with the true discontinuous values from initial_condition_discontinuous_dam_break. -function initial_condition_dam_break(x, t, equations::ShallowWaterTwoLayerEquations2D) - if x[1] < sqrt(2) / 2 - H_upper = 1.0 - H_lower = 0.6 - b = 0.1 - else - H_upper = 0.9 - H_lower = 0.5 - b = 0.0 - end - - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), - equations) +function initial_condition_dam_break(x, t,equations::ShallowWaterTwoLayerEquations2D) + if x[1] < sqrt(2)/2 + H_upper = 1.0 + H_lower = 0.6 + b = 0.1 + else + H_upper = 0.9 + H_lower = 0.5 + b = 0.0 + end + + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) end initial_condition = initial_condition_dam_break boundary_condition_constant = BoundaryConditionDirichlet(initial_condition_dam_break) + ############################################################################### # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 6, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +surface_flux= (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) +solver = DGSEM(polydeg=6, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = false) +mesh = UnstructuredMesh2D(mesh_file, periodicity=false) # Boundary conditions -boundary_condition = Dict(:Top => boundary_condition_slip_wall, - :Left => boundary_condition_slip_wall, - :Right => boundary_condition_slip_wall, +boundary_condition = Dict(:Top => boundary_condition_slip_wall, + :Left => boundary_condition_slip_wall, + :Right => boundary_condition_slip_wall, :Bottom => boundary_condition_slip_wall) # Create the semi discretization object -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, - solver, boundary_conditions = boundary_condition) +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver, boundary_conditions=boundary_condition) ############################################################################### # ODE solver @@ -81,63 +79,58 @@ ode = semidiscretize(semi, tspan) # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_discontinuous_dam_break(x, t, element_id, +function initial_condition_discontinuous_dam_break(x, t, element_id, equations::ShallowWaterTwoLayerEquations2D) - # Constant values - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - - # Left side of discontinuity - IDs = [1, 2, 5, 6, 9, 10, 13, 14] - if element_id in IDs - H_upper = 1.0 - H_lower = 0.6 - b = 0.0 - # Right side of discontinuity - else - H_upper = 0.9 - H_lower = 0.5 - b = 0.1 - end - - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), - equations) + # Constant values + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + + # Left side of discontinuity + IDs = [1, 2, 5, 6, 9, 10, 13, 14] + if element_id in IDs + H_upper = 1.0 + H_lower = 0.6 + b = 0.0 + # Right side of discontinuity + else + H_upper = 0.9 + H_lower = 0.5 + b = 0.1 + end + + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_discontinuous_dam_break(x_node, first(tspan), element, - equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_discontinuous_dam_break(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end + ############################################################################### # Callbacks summary_callback = SummaryCallback() analysis_interval = 500 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (energy_total, - energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval,save_analysis=false, + extra_analysis_integrals=(energy_total, energy_kinetic, energy_internal,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 500, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=500, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -145,7 +138,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl index 35b027c3a81..40bc9f2ab42 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_twolayer_well_balanced.jl @@ -7,25 +7,22 @@ using Trixi # Semidiscretization of the two-layer shallow water equations with a discontinuous bottom # topography to test well-balancedness -equations = ShallowWaterTwoLayerEquations2D(gravity_constant = 1.0, H0 = 0.6, - rho_upper = 0.9, rho_lower = 1.0) +equations = ShallowWaterTwoLayerEquations2D(gravity_constant=1.0, H0=0.6, rho_upper=0.9, rho_lower=1.0) # An initial condition with constant total water height, zero velocities and a bottom topography to # test well-balancedness function initial_condition_well_balanced(x, t, equations::ShallowWaterTwoLayerEquations2D) - H_lower = 0.5 - H_upper = 0.6 - v1_upper = 0.0 - v2_upper = 0.0 - v1_lower = 0.0 - v2_lower = 0.0 - - # Bottom Topography - b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? - 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + - -0.5)^2)) + 1) : 0.0) - return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), - equations) + H_lower = 0.5 + H_upper = 0.6 + v1_upper = 0.0 + v2_upper = 0.0 + v1_lower = 0.0 + v2_lower = 0.0 + + # Bottom Topography + b = (((x[1] - 0.5)^2 + (x[2] - 0.5)^2) < 0.04 ? 0.2 * (cos(4 * pi * sqrt((x[1] - 0.5)^2 + (x[2] + + -0.5)^2)) + 1) : 0.0) + return prim2cons(SVector(H_upper, v1_upper, v2_upper, H_lower, v1_lower, v2_lower, b), equations) end initial_condition = initial_condition_well_balanced @@ -35,20 +32,19 @@ initial_condition = initial_condition_well_balanced volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 6, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg=6, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form well-balancedness testing # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -62,16 +58,16 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -stepsize_callback = StepsizeCallback(cfl = 1.0) +stepsize_callback = StepsizeCallback(cfl=1.0) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -79,7 +75,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl index f64fc54eef4..ad1471a2d1a 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl @@ -7,67 +7,63 @@ using Trixi # semidiscretization of the shallow water equations with a continuous # bottom topography function -equations = ShallowWaterEquations2D(gravity_constant = 9.812, H0 = 2.0) +equations = ShallowWaterEquations2D(gravity_constant=9.812, H0=2.0) function initial_condition_stone_throw(x, t, equations::ShallowWaterEquations2D) - # Set up polar coordinates - inicenter = SVector(0.15, 0.15) - x_norm = x[1] - inicenter[1] - y_norm = x[2] - inicenter[2] - r = sqrt(x_norm^2 + y_norm^2) - - # Calculate primitive variables - H = equations.H0 - v1 = r < 0.6 ? 2.0 : 0.0 - v2 = r < 0.6 ? -2.0 : 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) - - return prim2cons(SVector(H, v1, v2, b), equations) + # Set up polar coordinates + inicenter = SVector(0.15, 0.15) + x_norm = x[1] - inicenter[1] + y_norm = x[2] - inicenter[2] + r = sqrt(x_norm^2 + y_norm^2) + + # Calculate primitive variables + H = equations.H0 + v1 = r < 0.6 ? 2.0 : 0.0 + v2 = r < 0.6 ? -2.0 : 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) + + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) + + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_stone_throw -boundary_condition = Dict(:OuterCircle => boundary_condition_slip_wall) +boundary_condition = Dict( :OuterCircle => boundary_condition_slip_wall ) ############################################################################### # Get the DG approximation space -surface_flux = (FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), - hydrostatic_reconstruction_audusse_etal), - flux_nonconservative_audusse_etal) +surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal) volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) polydeg = 6 basis = LobattoLegendreBasis(polydeg) indicator_sc = IndicatorHennemannGassner(equations, basis, - alpha_max = 0.5, - alpha_min = 0.001, - alpha_smooth = true, - variable = Trixi.waterheight) + alpha_max=0.5, + alpha_min=0.001, + alpha_smooth=true, + variable=Trixi.waterheight) volume_integral = VolumeIntegralShockCapturingHG(indicator_sc; - volume_flux_dg = volume_flux, - volume_flux_fv = surface_flux) + volume_flux_dg=volume_flux, + volume_flux_fv=surface_flux) -solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, - volume_integral = volume_integral) +solver = DGSEM(polydeg=polydeg, surface_flux=surface_flux, volume_integral=volume_integral) ############################################################################### # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_outer_circle.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/9beddd9cd00e2a0a15865129eeb24928/raw/be71e67fa48bc4e1e97f5f6cd77c3ed34c6ba9be/mesh_outer_circle.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_condition) + boundary_conditions=boundary_condition) ############################################################################### # ODE solvers, callbacks, etc. @@ -78,16 +74,15 @@ ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() analysis_interval = 100 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - save_analysis = false, - extra_analysis_integrals = (energy_kinetic, - energy_internal)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false, + extra_analysis_integrals=(energy_kinetic, + energy_internal)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 100, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) @@ -95,6 +90,6 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav # run the simulation # use a Runge-Kutta method with automatic (error based) time step size control -sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, - ode_default_options()..., callback = callbacks); +sol = solve(ode, RDPK3SpFSAL49(); abstol=1.0e-8, reltol=1.0e-8, + ode_default_options()..., callback=callbacks); summary_callback() # print the timer summary diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl index 944f1f7a746..645f985d10d 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_well_balanced.jl @@ -7,22 +7,21 @@ using Trixi # semidiscretization of the shallow water equations with a discontinuous # bottom topography function (set in the initial conditions) -equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.0) +equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=3.0) # An initial condition with constant total water height and zero velocities to test well-balancedness. # Note, this routine is used to compute errors in the analysis callback but the initialization is # overwritten by `initial_condition_discontinuous_well_balancedness` below. function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) - x1, x2 = x - b = (1.5 / exp(0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2)) - + - 0.75 / exp(0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2))) - return prim2cons(SVector(H, v1, v2, b), equations) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + # bottom topography taken from Pond.control in [HOHQMesh](https://github.com/trixi-framework/HOHQMesh) + x1, x2 = x + b = ( 1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) ) + + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) ) + return prim2cons(SVector(H, v1, v2, b), equations) end initial_condition = initial_condition_well_balancedness @@ -31,21 +30,20 @@ initial_condition = initial_condition_well_balancedness # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -surface_flux = (flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) -solver = DGSEM(polydeg = 6, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +surface_flux=(flux_fjordholm_etal, flux_nonconservative_fjordholm_etal) +solver = DGSEM(polydeg=6, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### # This setup is for the curved, split form well-balancedness testing # Get the unstructured quad mesh from a file (downloads the file if not available locally) default_mesh_file = joinpath(@__DIR__, "mesh_alfven_wave_with_twist_and_flip.mesh") -isfile(default_mesh_file) || - download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", - default_mesh_file) +isfile(default_mesh_file) || download("https://gist.githubusercontent.com/andrewwinters5000/8f8cd23df27fcd494553f2a89f3c1ba4/raw/85e3c8d976bbe57ca3d559d653087b0889535295/mesh_alfven_wave_with_twist_and_flip.mesh", + default_mesh_file) mesh_file = default_mesh_file -mesh = UnstructuredMesh2D(mesh_file, periodicity = true) +mesh = UnstructuredMesh2D(mesh_file, periodicity=true) # Create the semi discretization object semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) @@ -66,33 +64,30 @@ ode = semidiscretize(semi, tspan) # In contrast to the usual signature of initial conditions, this one get passed the # `element_id` explicitly. In particular, this initial conditions works as intended # only for the specific mesh loaded above! -function initial_condition_discontinuous_well_balancedness(x, t, element_id, - equations::ShallowWaterEquations2D) - # Set the background values - H = equations.H0 - v1 = 0.0 - v2 = 0.0 - b = 0.0 - - # Setup a discontinuous bottom topography using the element id number - if element_id == 7 - b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) - end - - return prim2cons(SVector(H, v1, v2, b), equations) +function initial_condition_discontinuous_well_balancedness(x, t, element_id, equations::ShallowWaterEquations2D) + # Set the background values + H = equations.H0 + v1 = 0.0 + v2 = 0.0 + b = 0.0 + + # Setup a discontinuous bottom topography using the element id number + if element_id == 7 + b = 2.0 + 0.5 * sin(2.0 * pi * x[1]) + 0.5 * cos(2.0 * pi * x[2]) + end + + return prim2cons(SVector(H, v1, v2, b), equations) end # point to the data we want to augment u = Trixi.wrap_array(ode.u0, semi) # reset the initial condition for element in eachelement(semi.solver, semi.cache) - for j in eachnode(semi.solver), i in eachnode(semi.solver) - x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, - semi.solver, i, j, element) - u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), - element, equations) - Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) - end + for j in eachnode(semi.solver), i in eachnode(semi.solver) + x_node = Trixi.get_node_coords(semi.cache.elements.node_coordinates, equations, semi.solver, i, j, element) + u_node = initial_condition_discontinuous_well_balancedness(x_node, first(tspan), element, equations) + Trixi.set_node_vars!(u, u_node, equations, semi.solver, i, j, element) + end end ############################################################################### @@ -101,16 +96,16 @@ end summary_callback = SummaryCallback() analysis_interval = 1000 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval, - extra_analysis_integrals = (lake_at_rest_error,)) +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_integrals=(lake_at_rest_error,)) -alive_callback = AliveCallback(analysis_interval = analysis_interval) +alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval = 1000, - save_initial_solution = true, - save_final_solution = true) +save_solution = SaveSolutionCallback(interval=1000, + save_initial_solution=true, + save_final_solution=true) -stepsize_callback = StepsizeCallback(cfl = 3.0) +stepsize_callback = StepsizeCallback(cfl=3.0) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, stepsize_callback) @@ -118,7 +113,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, sav ############################################################################### # 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); +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 diff --git a/src/equations/linearized_euler_2d.jl b/src/equations/linearized_euler_2d.jl index d35e077e4e8..3ebd0f736ba 100644 --- a/src/equations/linearized_euler_2d.jl +++ b/src/equations/linearized_euler_2d.jl @@ -177,8 +177,8 @@ end norm_ = norm(normal_direction) - v_normal = v_mean_global[1] * normal_direction[1] + - v_mean_global[2] * normal_direction[2] + v_normal = + v_mean_global[1] * normal_direction[1] + v_mean_global[2] * normal_direction[2] # The v_normals are already scaled by the norm λ_min = v_normal - c_mean_global * norm_ diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index 3a94db49f93..d8cf9d51b46 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -621,11 +621,11 @@ Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - - v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr) / (h_ll_sqrt + h_rr_sqrt) + + v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr)/(h_ll_sqrt + h_rr_sqrt) return v_roe, c_roe -end +end # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations1D) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index f39f3de5d1d..321d923ffbe 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -966,15 +966,15 @@ slides 8 and 9. h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - + if orientation == 1 # x-direction - v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr) / (h_ll_sqrt + h_rr_sqrt) + v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) else # y-direction - v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr) / (h_ll_sqrt + h_rr_sqrt) + v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) end return v_roe, c_roe -end +end @inline function calc_wavespeed_roe(u_ll, u_rr, normal_direction::AbstractVector, equations::ShallowWaterEquations2D) @@ -990,14 +990,14 @@ end h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - - v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr) / (h_ll_sqrt + h_rr_sqrt) - v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr) / (h_ll_sqrt + h_rr_sqrt) + + v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) + v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) v_roe = (v1_roe * normal_direction[1] + v2_roe * normal_direction[2]) return v_roe, c_roe -end +end # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations2D) diff --git a/test/coverage/coverage.jl b/test/coverage/coverage.jl index 5f1ae8af8fc..fbe89acf702 100644 --- a/test/coverage/coverage.jl +++ b/test/coverage/coverage.jl @@ -9,28 +9,28 @@ const lcov_info_file = "lcov.info" # Change path to root directory cd(joinpath(@__DIR__, "..", "..")) do - # Process coverage files - processed = process_folder("src") - - # Uncomment the following line once Codecov support is enabled - # Codecov.submit_local(processed) - - # Calculate coverage - covered_lines, total_lines = get_summary(processed) - percentage = covered_lines / total_lines * 100 - - # Print coverage in a format that can be easily parsed - println("($(percentage)%) covered") - - # Try to generate a coverage report - isdir(report_dir) || mkdir(report_dir) - tracefile = joinpath(report_dir, lcov_info_file) - Coverage.LCOV.writefile(tracefile, processed) - branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) - commit = strip(read(`git rev-parse --short HEAD`, String)) - title = "commit $(commit) on branch $(branch)" - run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`) - - # Clean up .cov files - clean_folder("src") + # Process coverage files + processed = process_folder("src") + + # Uncomment the following line once Codecov support is enabled + # Codecov.submit_local(processed) + + # Calculate coverage + covered_lines, total_lines = get_summary(processed) + percentage = covered_lines / total_lines * 100 + + # Print coverage in a format that can be easily parsed + println("($(percentage)%) covered") + + # Try to generate a coverage report + isdir(report_dir) || mkdir(report_dir) + tracefile = joinpath(report_dir, lcov_info_file) + Coverage.LCOV.writefile(tracefile, processed) + branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) + commit = strip(read(`git rev-parse --short HEAD`, String)) + title = "commit $(commit) on branch $(branch)" + run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`) + + # Clean up .cov files + clean_folder("src") end diff --git a/test/runtests.jl b/test/runtests.jl index 6c8687039b9..f76811dddbf 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,115 +4,113 @@ using MPI: mpiexec # run tests on Travis CI in parallel const TRIXI_TEST = get(ENV, "TRIXI_TEST", "all") const TRIXI_MPI_NPROCS = clamp(Sys.CPU_THREADS, 2, 3) -const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) +const TRIXI_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) @time @testset "Trixi.jl tests" begin - # This is placed first since tests error out otherwise if `TRIXI_TEST == "all"`, - # at least on some systems. - @time if TRIXI_TEST == "all" || TRIXI_TEST == "mpi" - # Do a dummy `@test true`: - # If the process errors out the testset would error out as well, - # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 - @test true - - # There are spurious test failures of Trixi.jl with MPI on Windows, see - # https://github.com/trixi-framework/Trixi.jl/issues/901 - # To reduce their impact, we do not test MPI with coverage on Windows. - # This reduces the chance to hit a spurious test failure by one half. - # In addition, it looks like the Linux GitHub runners run out of memory during the 3D tests - # with coverage, so we currently do not test MPI with coverage on Linux. For more details, - # see the discussion at https://github.com/trixi-framework/Trixi.jl/pull/1062#issuecomment-1035901020 - cmd = string(Base.julia_cmd()) - coverage = occursin("--code-coverage", cmd) && - !occursin("--code-coverage=none", cmd) - if !(coverage && Sys.iswindows()) && !(coverage && Sys.islinux()) - # We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing - mpiexec() do cmd - run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=1G $(abspath("test_mpi.jl"))`) - end - end - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "threaded" || - TRIXI_TEST == "threaded_legacy" - # Do a dummy `@test true`: - # If the process errors out the testset would error out as well, - # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 - @test true - - run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1" - include("test_tree_1d.jl") - include("test_tree_2d_part1.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part2" - include("test_tree_2d_part2.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part3" - include("test_tree_2d_part3.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part4" - include("test_tree_3d_part1.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part5" - include("test_tree_3d_part2.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part6" - include("test_tree_3d_part3.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "structured" - include("test_structured_1d.jl") - include("test_structured_2d.jl") - include("test_structured_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part1" - include("test_p4est_2d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part2" - include("test_p4est_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "unstructured_dgmulti" - include("test_unstructured_2d.jl") - include("test_dgmulti_1d.jl") - include("test_dgmulti_2d.jl") - include("test_dgmulti_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "parabolic" - include("test_parabolic_1d.jl") - include("test_parabolic_2d.jl") - include("test_parabolic_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part1" - include("test_unit.jl") - include("test_visualization.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part2" - include("test_special_elixirs.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part1" - include("test_performance_specializations_2d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part2" - include("test_performance_specializations_3d.jl") - end - - @time if TRIXI_TEST == "all" || TRIXI_TEST == "paper_self_gravitating_gas_dynamics" - include("test_paper_self_gravitating_gas_dynamics.jl") - end + # This is placed first since tests error out otherwise if `TRIXI_TEST == "all"`, + # at least on some systems. + @time if TRIXI_TEST == "all" || TRIXI_TEST == "mpi" + # Do a dummy `@test true`: + # If the process errors out the testset would error out as well, + # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 + @test true + + # There are spurious test failures of Trixi.jl with MPI on Windows, see + # https://github.com/trixi-framework/Trixi.jl/issues/901 + # To reduce their impact, we do not test MPI with coverage on Windows. + # This reduces the chance to hit a spurious test failure by one half. + # In addition, it looks like the Linux GitHub runners run out of memory during the 3D tests + # with coverage, so we currently do not test MPI with coverage on Linux. For more details, + # see the discussion at https://github.com/trixi-framework/Trixi.jl/pull/1062#issuecomment-1035901020 + cmd = string(Base.julia_cmd()) + coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) + if !(coverage && Sys.iswindows()) && !(coverage && Sys.islinux()) + # We provide a `--heap-size-hint` to avoid/reduce out-of-memory errors during CI testing + mpiexec() do cmd + run(`$cmd -n $TRIXI_MPI_NPROCS $(Base.julia_cmd()) --threads=1 --check-bounds=yes --heap-size-hint=1G $(abspath("test_mpi.jl"))`) + end + end + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "threaded" || TRIXI_TEST == "threaded_legacy" + # Do a dummy `@test true`: + # If the process errors out the testset would error out as well, + # cf. https://github.com/JuliaParallel/MPI.jl/pull/391 + @test true + + run(`$(Base.julia_cmd()) --threads=$TRIXI_NTHREADS --check-bounds=yes --code-coverage=none $(abspath("test_threaded.jl"))`) + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part1" + include("test_tree_1d.jl") + include("test_tree_2d_part1.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part2" + include("test_tree_2d_part2.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part3" + include("test_tree_2d_part3.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part4" + include("test_tree_3d_part1.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part5" + include("test_tree_3d_part2.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "tree_part6" + include("test_tree_3d_part3.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "structured" + include("test_structured_1d.jl") + include("test_structured_2d.jl") + include("test_structured_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part1" + include("test_p4est_2d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "p4est_part2" + include("test_p4est_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "unstructured_dgmulti" + include("test_unstructured_2d.jl") + include("test_dgmulti_1d.jl") + include("test_dgmulti_2d.jl") + include("test_dgmulti_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "parabolic" + include("test_parabolic_1d.jl") + include("test_parabolic_2d.jl") + include("test_parabolic_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part1" + include("test_unit.jl") + include("test_visualization.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "misc_part2" + include("test_special_elixirs.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part1" + include("test_performance_specializations_2d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "performance_specializations_part2" + include("test_performance_specializations_3d.jl") + end + + @time if TRIXI_TEST == "all" || TRIXI_TEST == "paper_self_gravitating_gas_dynamics" + include("test_paper_self_gravitating_gas_dynamics.jl") + end end diff --git a/test/test_dgmulti_1d.jl b/test/test_dgmulti_1d.jl index 3d7730f0d44..7cc31c33040 100644 --- a/test/test_dgmulti_1d.jl +++ b/test/test_dgmulti_1d.jl @@ -9,111 +9,78 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_1d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "DGMulti 1D" begin - @trixi_testset "elixir_advection_gauss_sbp.jl " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"), - cells_per_dimension=(8,), - l2=[2.9953644500009865e-5], - linf=[4.467840577382365e-5]) - end - @trixi_testset "elixir_euler_flux_diff.jl " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension=(16,), - # division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 7.853842541289665e-7, - 9.609905503440606e-7, - 2.832322219966481e-6, - ] ./ sqrt(2.0), - linf=[ - 1.5003758788711963e-6, - 1.802998748523521e-6, - 4.83599270806323e-6, - ]) - end + @trixi_testset "elixir_advection_gauss_sbp.jl " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"), + cells_per_dimension = (8,), + l2 = [2.9953644500009865e-5], + linf = [4.467840577382365e-5] + ) + end - @trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, - "elixir_euler_flux_diff.jl"), 3) - @test isapprox(mean_convergence[:l2], - [4.1558759698638434, 3.977911306037128, 4.041421206468769], - rtol = 0.05) - end + @trixi_testset "elixir_euler_flux_diff.jl " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), + cells_per_dimension = (16,), + # division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain + l2 = [7.853842541289665e-7, 9.609905503440606e-7, 2.832322219966481e-6] ./ sqrt(2.0), + linf = [1.5003758788711963e-6, 1.802998748523521e-6, 4.83599270806323e-6] + ) + end - @trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension=(16,), - approximation_type=SBP(), - l2=[ - 6.437827414849647e-6, - 2.1840558851820947e-6, - 1.3245669629438228e-5, - ], - linf=[ - 2.0715843751295537e-5, - 8.519520630301258e-6, - 4.2642194098885255e-5, - ]) - end + @trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), 3) + @test isapprox(mean_convergence[:l2], [4.1558759698638434, 3.977911306037128, 4.041421206468769], rtol=0.05) + end - @trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension=(4,), - approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, - accuracy_order = 4, - xmin = 0.0, xmax = 1.0, - N = 16), - l2=[ - 1.8684509287853788e-5, - 1.0641411823379635e-5, - 5.178010291876143e-5, - ], - linf=[ - 6.933493585936645e-5, - 3.0277366229292113e-5, - 0.0002220020568932668, - ]) - show(stdout, semi.solver.basis) - show(stdout, MIME"text/plain"(), semi.solver.basis) - end + @trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), + cells_per_dimension = (16,), + approximation_type = SBP(), + l2 = [6.437827414849647e-6, 2.1840558851820947e-6, 1.3245669629438228e-5], + linf = [2.0715843751295537e-5, 8.519520630301258e-6, 4.2642194098885255e-5] + ) + end - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2=[ - 9.146929180585711e-7, - 1.8997616878017292e-6, - 3.991417702211889e-6, - ], - linf=[ - 1.7321089884614338e-6, - 3.3252888855805907e-6, - 6.5252787737613005e-6, - ]) - show(stdout, semi.solver.basis) - show(stdout, MIME"text/plain"(), semi.solver.basis) - end + @trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), + cells_per_dimension = (4,), + approximation_type = derivative_operator( + SummationByPartsOperators.MattssonNordström2004(), + derivative_order=1, accuracy_order=4, + xmin=0.0, xmax=1.0, N=16), + l2 = [1.8684509287853788e-5, 1.0641411823379635e-5, 5.178010291876143e-5], + linf = [6.933493585936645e-5, 3.0277366229292113e-5, 0.0002220020568932668] + ) + show(stdout, semi.solver.basis) + show(stdout, MIME"text/plain"(), semi.solver.basis) + end - @trixi_testset "DGMulti with periodic SBP unit test" begin - # see https://github.com/trixi-framework/Trixi.jl/pull/1013 - dg = DGMulti(element_type = Line(), - approximation_type = periodic_derivative_operator(derivative_order = 1, - accuracy_order = 4, - xmin = -5.0, - xmax = 10.0, N = 50)) - mesh = DGMultiMesh(dg) - @test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst) - # check to make sure nodes are rescaled to [-1, 1] - @test minimum(dg.basis.rst[1]) ≈ -1 - @test maximum(dg.basis.rst[1])≈1 atol=0.35 - end + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + l2 = [9.146929180585711e-7, 1.8997616878017292e-6, 3.991417702211889e-6], + linf = [1.7321089884614338e-6, 3.3252888855805907e-6, 6.5252787737613005e-6] + ) + show(stdout, semi.solver.basis) + show(stdout, MIME"text/plain"(), semi.solver.basis) + end + + @trixi_testset "DGMulti with periodic SBP unit test" begin + # see https://github.com/trixi-framework/Trixi.jl/pull/1013 + dg = DGMulti(element_type = Line(), + approximation_type = periodic_derivative_operator( + derivative_order=1, accuracy_order=4, xmin=-5.0, xmax=10.0, N=50)) + mesh = DGMultiMesh(dg) + @test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst) + # check to make sure nodes are rescaled to [-1, 1] + @test minimum(dg.basis.rst[1]) ≈ -1 + @test maximum(dg.basis.rst[1]) ≈ 1 atol=0.35 + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive = true) +@test_nowarn isdir(outdir) && rm(outdir, recursive=true) end # module diff --git a/test/test_dgmulti_2d.jl b/test/test_dgmulti_2d.jl index 9c6105d85db..861e30045ce 100644 --- a/test/test_dgmulti_2d.jl +++ b/test/test_dgmulti_2d.jl @@ -9,673 +9,357 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_2d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "DGMulti 2D" begin - @trixi_testset "elixir_euler_weakform.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0013536930300254945, - 0.0014315603442106193, - 0.001431560344211359, - 0.0047393341007602625, - ] ./ 2.0, - linf=[ - 0.001514260921466004, - 0.0020623991944839215, - 0.002062399194485476, - 0.004897700392503701, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - approximation_type=SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0074706882014934735, - 0.005306220583603261, - 0.005306220583613591, - 0.014724842607716771, - ] ./ 2.0, - linf=[ - 0.021563604940952885, - 0.01359397832530762, - 0.013593978324845324, - 0.03270995869587523, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - element_type=Quad(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.00031892254415307093, - 0.00033637562986771894, - 0.0003363756298680649, - 0.0011100259064243145, - ] ./ 2.0, - linf=[ - 0.001073298211445639, - 0.0013568139808282087, - 0.0013568139808290969, - 0.0032249020004324613, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (EC) " begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.007801417730672109, - 0.00708583561714128, - 0.0070858356171393, - 0.015217574294198809, - ] ./ 2.0, - linf=[ - 0.011572828457858897, - 0.013965298735070686, - 0.01396529873508534, - 0.04227683691807904, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - approximation_type=SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.01280067571168776, - 0.010607599608273302, - 0.010607599608239775, - 0.026408338014056548, - ] ./ 2.0, - linf=[ - 0.037983023185674814, - 0.05321027922533417, - 0.05321027922608157, - 0.13392025411844033, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - element_type=Quad(), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - approximation_type=SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0029373718090697975, - 0.0030629360605489465, - 0.003062936060545615, - 0.0068486089344859755, - ] ./ 2.0, - linf=[ - 0.01360165305316885, - 0.01267402847925303, - 0.012674028479251254, - 0.02210545278615017, - ]) - end - - @trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_bilinear.jl"), - l2=[ - 1.0259435706215337e-5, - 9.014090233720625e-6, - 9.014090233223014e-6, - 2.738953587401793e-5, - ], - linf=[ - 7.362609083649829e-5, - 6.874188055272512e-5, - 6.874188052830021e-5, - 0.0001912435192696904, - ]) - end - - @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - l2=[ - 1.720476068165337e-5, - 1.592168205710526e-5, - 1.592168205812963e-5, - 4.894094865697305e-5, - ], - linf=[ - 0.00010525416930584619, - 0.00010003778091061122, - 0.00010003778085621029, - 0.00036426282101720275, - ]) - end - - @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - approximation_type=GaussSBP(), - l2=[ - 3.4666312079259457e-6, - 3.4392774480368986e-6, - 3.439277447953705e-6, - 1.0965598424665836e-5, - ], - linf=[ - 1.1327280377004811e-5, - 1.1343911926253725e-5, - 1.1343911906935844e-5, - 3.679582619220412e-5, - ], - rtol=2 * sqrt(eps())) - end - - @trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - element_type=Tri(), approximation_type=Polynomial(), - volume_integral=VolumeIntegralWeakForm(), - l2=[ - 7.905498158659466e-6, - 8.731690809663625e-6, - 8.731690811576996e-6, - 2.9113296018693953e-5, - ], - linf=[ - 3.298811230090237e-5, - 4.032272476939269e-5, - 4.032272526011127e-5, - 0.00012013725458537294, - ]) - end - - @trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_hohqmesh.jl"), - l2=[ - 0.0008153911341517156, - 0.0007768159701964676, - 0.00047902606811690694, - 0.0015551846076348535, - ], - linf=[ - 0.0029301131365355726, - 0.0034427051471457304, - 0.0028721569841545502, - 0.011125365074589944, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (convergence)" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, - "elixir_euler_weakform.jl"), 2) - @test isapprox(mean_convergence[:l2], - [ - 4.243843382379403, - 4.128314378833922, - 4.128314378397532, - 4.081366752807379, - ], rtol = 0.05) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0014986508075708323, - 0.001528523420746786, - 0.0015285234207473158, - 0.004846505183839211, - ] ./ 2.0, - linf=[ - 0.0015062108658376872, - 0.0019373508504645365, - 0.0019373508504538783, - 0.004742686826709086, - ]) - end - - @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_triangulate_pkg_mesh.jl"), - l2=[ - 2.344080455438114e-6, - 1.8610038753097983e-6, - 2.4095165666095305e-6, - 6.373308158814308e-6, - ], - linf=[ - 2.5099852761334418e-5, - 2.2683684021362893e-5, - 2.6180448559287584e-5, - 5.5752932611508044e-5, - ]) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability.jl"), - cells_per_dimension=(32, 32), tspan=(0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.11140378947116614, - 0.06598161188703612, - 0.10448953167839563, - 0.16023209181809595, - ] ./ 2.0, - linf=[ - 0.24033843177853664, - 0.1659992245272325, - 0.1235468309508845, - 0.26911424973147735, - ]) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability.jl"), - cells_per_dimension=(32, 32), element_type=Quad(), - approximation_type=GaussSBP(), tspan=(0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.11141270656347146, - 0.06598888014584121, - 0.1044902203749932, - 0.16023037364774995, - ] ./ 2.0, - linf=[ - 0.2414760062126462, - 0.1662111846065654, - 0.12344140473946856, - 0.26978428189564774, - ]) - end - - @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_rayleigh_taylor_instability.jl"), - cells_per_dimension=(8, 8), tspan=(0.0, 0.2), - l2=[ - 0.0709665896982514, - 0.005182828752164663, - 0.013832655585206478, - 0.03247013800580221, - ], - linf=[ - 0.4783963902824797, - 0.022527207050681054, - 0.040307056293369226, - 0.0852365428206836, - ]) - end - - @trixi_testset "elixir_euler_brown_minion_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_brown_minion_vortex.jl"), - cells_per_dimension=4, tspan=(0.0, 0.1), - l2=[ - 0.006680001611078062, - 0.02151676347585447, - 0.010696524235364626, - 0.15052841129694647, - ], - linf=[ - 0.01544756362800248, - 0.09517304772476806, - 0.021957154972646383, - 0.33773439650806303, - ]) - end - - @trixi_testset "elixir_euler_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - cells_per_dimension=4, tspan=(0.0, 0.1), - l2=[ - 0.05685148333985476, - 0.04308122135907089, - 0.043081221359070915, - 0.21098131003847664, - ], - linf=[ - 0.2360672306096051, - 0.16684417686971842, - 0.1668441768697189, - 0.8572572782118661, - ]) - end - - @trixi_testset "elixir_euler_shockcapturing_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_curved.jl"), - cells_per_dimension=4, tspan=(0.0, 0.1), - l2=[ - 0.05565849298766252, - 0.042322816017256494, - 0.042322816017256466, - 0.2064212098324083, - ], - linf=[ - 0.23633287875008924, - 0.16930148707515683, - 0.16930148707515688, - 0.8587706761131937, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(2, 2), - element_type=Quad(), - cfl=1.0, - approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, - accuracy_order = 4, - xmin = 0.0, xmax = 1.0, - N = 12), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0008966318978421226, - 0.0011418826379110242, - 0.001141882637910878, - 0.0030918374335671393, - ] ./ 2.0, - linf=[ - 0.0015281525343109337, - 0.00162430960401716, - 0.0016243096040242655, - 0.004447503691245913, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension=(2, 2), - element_type=Quad(), - cfl=1.0, - approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, - accuracy_order = 4, - xmin = 0.0, xmax = 1.0, - N = 12), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0014018725496871129, - 0.0015887007320868913, - 0.001588700732086329, - 0.003870926821031202, - ] ./ 2.0, - linf=[ - 0.0029541996523780867, - 0.0034520465226108854, - 0.003452046522624652, - 0.007677153211004928, - ]) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2=[ - 1.3333320340010056e-6, - 2.044834627970641e-6, - 2.044834627855601e-6, - 5.282189803559564e-6, - ], - linf=[ - 2.7000151718858945e-6, - 3.988595028259212e-6, - 3.9885950273710336e-6, - 8.848583042286862e-6, - ]) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - xmin=-200.0, xmax=100.0, #= parameters for reference interval =# - l2=[ - 1.333332034149886e-6, - 2.0448346280892024e-6, - 2.0448346279766305e-6, - 5.282189803510037e-6, - ], - linf=[ - 2.700015170553627e-6, - 3.988595024262409e-6, - 3.988595024928543e-6, - 8.84858303740188e-6, - ]) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - approximation_type=periodic_derivative_operator(derivative_order = 1, - accuracy_order = 4, - xmin = -200.0, - xmax = 100.0, - N = 100), - coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0), - l2=[ - 0.07318831033918516, - 0.10039910610067465, - 0.1003991061006748, - 0.2642450566234564, - ], - linf=[ - 0.36081081739439735, - 0.5244468027020845, - 0.5244468027020814, - 1.2210130256735705, - ]) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - approximation_type=SummationByPartsOperators.couple_continuously(SummationByPartsOperators.legendre_derivative_operator(xmin = 0.0, - xmax = 1.0, - N = 4), - SummationByPartsOperators.UniformPeriodicMesh1D(xmin = -1.0, - xmax = 1.0, - Nx = 10)), - l2=[ - 1.5440402410017893e-5, - 1.4913189903083485e-5, - 1.4913189902797073e-5, - 2.6104615985156992e-5, - ], - linf=[ - 4.16334345412217e-5, - 5.067812788173143e-5, - 5.067812786885284e-5, - 9.887976803746312e-5, - ]) - end - - @trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), - cells_per_dimension=4, - l2=[0.03906769915509508, 0.04923079758984701, - 0.049230797589847136, 0.02660348840973283, - 0.18054907061740028, 0.019195256934309846, - 0.019195256934310016, 0.027856113419468087, - 0.0016567799774264065], - linf=[0.16447597822733662, 0.244157345789029, - 0.24415734578903472, 0.11982440036793476, - 0.7450328339751362, 0.06357382685763713, 0.0635738268576378, - 0.1058830287485999, - 0.005740591170062146]) - end - - @trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), - cells_per_dimension=4, element_type=Tri(), - l2=[0.03372468091254386, 0.03971626483409167, - 0.03971626483409208, 0.021427571421535722, - 0.15079331840847413, 0.015716300366650286, - 0.015716300366652128, 0.022365252076279075, - 0.0009232971979900358], - linf=[0.16290247390873458, 0.2256891306641319, - 0.2256891306641336, 0.09476017042552534, - 0.6906308908961734, 0.05349939593012487, - 0.05349939593013042, 0.08830587480616725, - 0.0029551359803035027]) - end - - @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin - # These setups do not pass CI reliably, see - # https://github.com/trixi-framework/Trixi.jl/pull/880 and - # https://github.com/trixi-framework/Trixi.jl/issues/881 - @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_mhd_weak_blast_wave_SBP.jl"), - cells_per_dimension=4, - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[0.15825983698241494, 0.19897219694837923, - 0.19784182473275247, 0.10482833997417325, - 0.7310752391255246, 0.07374056714564853, - 0.07371172293240634, 0.10782032253431281, - 0.004921676235111545] ./ 2.0, - linf=[0.1765644464978685, 0.2627803272865769, - 0.26358136695848144, 0.12347681727447984, - 0.7733289736898254, 0.06695360844467957, - 0.06650382120802623, 0.10885097000919097, - 0.007212567638078835]) - end - - @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin - # These setups do not pass CI reliably, see - # https://github.com/trixi-framework/Trixi.jl/pull/880 and - # https://github.com/trixi-framework/Trixi.jl/issues/881 - @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_mhd_weak_blast_wave_SBP.jl"), - cells_per_dimension=4, element_type=Tri(), - tspan=(0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2=[0.13825044764021147, 0.15472815448314997, - 0.1549093274293255, 0.053103596213755405, - 0.7246162776815603, 0.07730777596615901, - 0.07733438386480523, 0.109893463921706, - 0.00617678167062838] ./ 2.0, - linf=[0.22701306227317952, 0.2905255794821543, - 0.2912409425436937, 0.08051361477962096, - 1.0842974228656006, 0.07866000368926784, - 0.0786646354518149, 0.1614896380292925, - 0.010358210347485542]) - end - - @trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_reflective_wall.jl"), - cells_per_dimension=4, - l2=[ - 0.0036019536614619687, - 0.001734097206958611, - 0.008375221008997178, - 0.0, - 0.028596796602124414, - 0.0018573693138866614, - 0.0020807798141551166, - 0.0, - 5.301188920230166e-5, - ], - linf=[ - 0.01692601228199253, - 0.009369662298436778, - 0.04145169295835428, - 0.0, - 0.11569908670112738, - 0.00984964453299233, - 0.01141708032148614, - 0.0, - 0.0002992631411931389, - ]) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension=8, element_type=Quad(), - approximation_type=SBP(), - l2=[ - 0.0020316462913319046, - 0.023669019044882247, - 0.03446194752754684, - 1.9333465252381796e-15, - ], - linf=[ - 0.010385010095182778, - 0.08750628939565086, - 0.12088392994348407, - 9.325873406851315e-15, - ]) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension=8, element_type=Tri(), - approximation_type=SBP(), - l2=[ - 0.004180680322490383, - 0.07026192411558974, - 0.11815151697006446, - 2.329788936151192e-15, - ], - linf=[ - 0.02076003852980346, - 0.29169601664914424, - 0.5674183379872275, - 1.1546319456101628e-14, - ]) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension=8, element_type=Tri(), - approximation_type=Polynomial(), - # The last l2, linf error are the L2 projection error in approximating `b`, so they are not - # zero for general non-collocated quadrature rules (e.g., for `element_type=Tri()`, `polydeg > 2`). - l2=[ - 0.0008309356912456799, - 0.01522451288799231, - 0.016033969387208476, - 1.2820247308150876e-5, - ], - linf=[ - 0.001888045014140971, - 0.05466838692127718, - 0.06345885709961152, - 3.3989933098554914e-5, - ]) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension=8, element_type=Quad(), - approximation_type=Polynomial(), - # The last l2, linf error are the L2 projection error in approximating `b`. However, this is zero - # for `Quad()` elements with `Polynomial()` approximations because the quadrature rule defaults to - # a `(polydeg + 1)`-point Gauss quadrature rule in each coordinate (in general, StartUpDG.jl defaults - # to the quadrature rule with the fewest number of points which exactly integrates the mass matrix). - l2=[ - 7.460461950323111e-5, - 0.003685589808444905, - 0.0039101604749887785, - 2.0636891126652983e-15, - ], - linf=[ - 0.000259995400729629, - 0.0072236204211630906, - 0.010364675200833062, - 1.021405182655144e-14, - ]) - end + + @trixi_testset "elixir_euler_weakform.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.0013536930300254945, 0.0014315603442106193, 0.001431560344211359, 0.0047393341007602625] ./ 2.0, + linf = [0.001514260921466004, 0.0020623991944839215, 0.002062399194485476, 0.004897700392503701] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + approximation_type = SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.0074706882014934735, 0.005306220583603261, 0.005306220583613591, 0.014724842607716771] ./ 2.0, + linf = [0.021563604940952885, 0.01359397832530762, 0.013593978324845324, 0.03270995869587523] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + element_type = Quad(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.00031892254415307093, 0.00033637562986771894, 0.0003363756298680649, 0.0011100259064243145] ./ 2.0, + linf = [0.001073298211445639, 0.0013568139808282087, 0.0013568139808290969, 0.0032249020004324613] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (EC) " begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.007801417730672109, 0.00708583561714128, 0.0070858356171393, 0.015217574294198809] ./ 2.0, + linf = [0.011572828457858897, 0.013965298735070686, 0.01396529873508534, 0.04227683691807904] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + approximation_type = SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.01280067571168776, 0.010607599608273302, 0.010607599608239775, 0.026408338014056548] ./ 2.0, + linf = [0.037983023185674814, 0.05321027922533417, 0.05321027922608157, 0.13392025411844033] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + element_type = Quad(), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + approximation_type = SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.0029373718090697975, 0.0030629360605489465, 0.003062936060545615, 0.0068486089344859755] ./ 2.0, + linf = [0.01360165305316885, 0.01267402847925303, 0.012674028479251254, 0.02210545278615017] + ) + end + + @trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_bilinear.jl"), + l2 = [1.0259435706215337e-5, 9.014090233720625e-6, 9.014090233223014e-6, 2.738953587401793e-5], + linf = [7.362609083649829e-5, 6.874188055272512e-5, 6.874188052830021e-5, 0.0001912435192696904] + ) + end + + @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + l2 = [1.720476068165337e-5, 1.592168205710526e-5, 1.592168205812963e-5, 4.894094865697305e-5], + linf = [0.00010525416930584619, 0.00010003778091061122, 0.00010003778085621029, 0.00036426282101720275] + ) + end + + @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + approximation_type = GaussSBP(), + l2 = [3.4666312079259457e-6, 3.4392774480368986e-6, 3.439277447953705e-6, 1.0965598424665836e-5], + linf = [1.1327280377004811e-5, 1.1343911926253725e-5, 1.1343911906935844e-5, 3.679582619220412e-5], + rtol = 2 * sqrt(eps()) + ) + end + + @trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + element_type = Tri(), approximation_type = Polynomial(), volume_integral = VolumeIntegralWeakForm(), + l2 = [7.905498158659466e-6, 8.731690809663625e-6, 8.731690811576996e-6, 2.9113296018693953e-5], + linf = [3.298811230090237e-5, 4.032272476939269e-5, 4.032272526011127e-5, 0.00012013725458537294] + ) + end + + @trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_hohqmesh.jl"), + l2 = [0.0008153911341517156, 0.0007768159701964676, 0.00047902606811690694, 0.0015551846076348535], + linf = [0.0029301131365355726, 0.0034427051471457304, 0.0028721569841545502, 0.011125365074589944] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (convergence)" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), 2) + @test isapprox(mean_convergence[:l2], [4.243843382379403, 4.128314378833922, 4.128314378397532, 4.081366752807379], rtol=0.05) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.0014986508075708323, 0.001528523420746786, 0.0015285234207473158, 0.004846505183839211] ./ 2.0, + linf = [0.0015062108658376872, 0.0019373508504645365, 0.0019373508504538783, 0.004742686826709086] + ) + end + + @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_triangulate_pkg_mesh.jl"), + l2 = [2.344080455438114e-6, 1.8610038753097983e-6, 2.4095165666095305e-6, 6.373308158814308e-6], + linf = [2.5099852761334418e-5, 2.2683684021362893e-5, 2.6180448559287584e-5, 5.5752932611508044e-5] + ) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), + cells_per_dimension = (32, 32), tspan = (0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.11140378947116614, 0.06598161188703612, 0.10448953167839563, 0.16023209181809595] ./ 2.0, + linf = [0.24033843177853664, 0.1659992245272325, 0.1235468309508845, 0.26911424973147735] + ) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), + cells_per_dimension = (32, 32), element_type = Quad(), approximation_type=GaussSBP(), tspan = (0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.11141270656347146, 0.06598888014584121, 0.1044902203749932, 0.16023037364774995] ./ 2.0, + linf = [0.2414760062126462, 0.1662111846065654, 0.12344140473946856, 0.26978428189564774] + ) + end + + @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_rayleigh_taylor_instability.jl"), + cells_per_dimension = (8, 8), tspan = (0.0, 0.2), + l2 = [0.0709665896982514, 0.005182828752164663, 0.013832655585206478, 0.03247013800580221], + linf = [0.4783963902824797, 0.022527207050681054, 0.040307056293369226, 0.0852365428206836] + ) + end + + @trixi_testset "elixir_euler_brown_minion_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_brown_minion_vortex.jl"), + cells_per_dimension = 4, tspan = (0.0, 0.1), + l2 = [0.006680001611078062, 0.02151676347585447, 0.010696524235364626, 0.15052841129694647], + linf = [0.01544756362800248, 0.09517304772476806, 0.021957154972646383, 0.33773439650806303] + ) + end + + @trixi_testset "elixir_euler_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), + cells_per_dimension = 4, tspan = (0.0, 0.1), + l2 = [0.05685148333985476, 0.04308122135907089, 0.043081221359070915, 0.21098131003847664], + linf = [0.2360672306096051, 0.16684417686971842, 0.1668441768697189, 0.8572572782118661] + ) + end + + @trixi_testset "elixir_euler_shockcapturing_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_curved.jl"), + cells_per_dimension = 4, tspan = (0.0, 0.1), + l2 = [0.05565849298766252, 0.042322816017256494, 0.042322816017256466, 0.2064212098324083], + linf = [0.23633287875008924, 0.16930148707515683, 0.16930148707515688, 0.8587706761131937] + ) + end + + + @trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (2, 2), + element_type = Quad(), + cfl = 1.0, + approximation_type = derivative_operator( + SummationByPartsOperators.MattssonNordström2004(), + derivative_order=1, accuracy_order=4, + xmin=0.0, xmax=1.0, N=12), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.0008966318978421226, 0.0011418826379110242, 0.001141882637910878, 0.0030918374335671393] ./ 2.0, + linf = [0.0015281525343109337, 0.00162430960401716, 0.0016243096040242655, 0.004447503691245913] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + cells_per_dimension = (2, 2), + element_type = Quad(), + cfl = 1.0, + approximation_type = derivative_operator( + SummationByPartsOperators.MattssonNordström2004(), + derivative_order=1, accuracy_order=4, + xmin=0.0, xmax=1.0, N=12), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.0014018725496871129, 0.0015887007320868913, 0.001588700732086329, 0.003870926821031202] ./ 2.0, + linf = [0.0029541996523780867, 0.0034520465226108854, 0.003452046522624652, 0.007677153211004928] + ) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + l2 = [1.3333320340010056e-6, 2.044834627970641e-6, 2.044834627855601e-6, 5.282189803559564e-6], + linf = [2.7000151718858945e-6, 3.988595028259212e-6, 3.9885950273710336e-6, 8.848583042286862e-6] + ) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + xmin=-200.0, xmax=100.0 #= parameters for reference interval =#, + l2 = [1.333332034149886e-6, 2.0448346280892024e-6, 2.0448346279766305e-6, 5.282189803510037e-6], + linf = [2.700015170553627e-6, 3.988595024262409e-6, 3.988595024928543e-6, 8.84858303740188e-6] + ) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + approximation_type = periodic_derivative_operator( + derivative_order=1, accuracy_order=4, xmin=-200.0, xmax=100.0, N=100), + coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0), + l2 = [0.07318831033918516, 0.10039910610067465, 0.1003991061006748, 0.2642450566234564], + linf = [0.36081081739439735, 0.5244468027020845, 0.5244468027020814, 1.2210130256735705] + ) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + approximation_type = SummationByPartsOperators.couple_continuously( + SummationByPartsOperators.legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4), + SummationByPartsOperators.UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10)), + l2 = [1.5440402410017893e-5, 1.4913189903083485e-5, 1.4913189902797073e-5, 2.6104615985156992e-5], + linf = [4.16334345412217e-5, 5.067812788173143e-5, 5.067812786885284e-5, 9.887976803746312e-5] + ) + end + + @trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), + cells_per_dimension = 4, + l2 = [0.03906769915509508, 0.04923079758984701, 0.049230797589847136, 0.02660348840973283, + 0.18054907061740028, 0.019195256934309846, 0.019195256934310016, 0.027856113419468087, + 0.0016567799774264065], + linf = [0.16447597822733662, 0.244157345789029, 0.24415734578903472, 0.11982440036793476, + 0.7450328339751362, 0.06357382685763713, 0.0635738268576378, 0.1058830287485999, + 0.005740591170062146] + ) + end + + @trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), + cells_per_dimension = 4, element_type = Tri(), + l2 = [0.03372468091254386, 0.03971626483409167, 0.03971626483409208, 0.021427571421535722, + 0.15079331840847413, 0.015716300366650286, 0.015716300366652128, 0.022365252076279075, + 0.0009232971979900358], + linf = [0.16290247390873458, 0.2256891306641319, 0.2256891306641336, 0.09476017042552534, + 0.6906308908961734, 0.05349939593012487, 0.05349939593013042, 0.08830587480616725, + 0.0029551359803035027] + ) + end + + @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin + # These setups do not pass CI reliably, see + # https://github.com/trixi-framework/Trixi.jl/pull/880 and + # https://github.com/trixi-framework/Trixi.jl/issues/881 + @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave_SBP.jl"), + cells_per_dimension = 4, + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.15825983698241494, 0.19897219694837923, 0.19784182473275247, 0.10482833997417325, + 0.7310752391255246, 0.07374056714564853, 0.07371172293240634, 0.10782032253431281, + 0.004921676235111545] ./ 2.0, + linf = [0.1765644464978685, 0.2627803272865769, 0.26358136695848144, 0.12347681727447984, + 0.7733289736898254, 0.06695360844467957, 0.06650382120802623, 0.10885097000919097, + 0.007212567638078835] + ) + end + + @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin + # These setups do not pass CI reliably, see + # https://github.com/trixi-framework/Trixi.jl/pull/880 and + # https://github.com/trixi-framework/Trixi.jl/issues/881 + @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave_SBP.jl"), + cells_per_dimension = 4, element_type=Tri(), tspan = (0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2 = [0.13825044764021147, 0.15472815448314997, 0.1549093274293255, 0.053103596213755405, + 0.7246162776815603, 0.07730777596615901, 0.07733438386480523, 0.109893463921706, + 0.00617678167062838] ./ 2.0, + linf = [0.22701306227317952, 0.2905255794821543, 0.2912409425436937, 0.08051361477962096, + 1.0842974228656006, 0.07866000368926784, 0.0786646354518149, 0.1614896380292925, + 0.010358210347485542] + ) + end + + @trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_reflective_wall.jl"), + cells_per_dimension = 4, + l2 = [0.0036019536614619687, 0.001734097206958611, 0.008375221008997178, 0.0, 0.028596796602124414, 0.0018573693138866614, 0.0020807798141551166, 0.0, 5.301188920230166e-5], + linf = [0.01692601228199253, 0.009369662298436778, 0.04145169295835428, 0.0, 0.11569908670112738, 0.00984964453299233, 0.01141708032148614, 0.0, 0.0002992631411931389] + ) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension = 8, element_type = Quad(), approximation_type = SBP(), + l2 = [0.0020316462913319046, 0.023669019044882247, 0.03446194752754684, 1.9333465252381796e-15], + linf = [0.010385010095182778, 0.08750628939565086, 0.12088392994348407, 9.325873406851315e-15] + ) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension = 8, element_type = Tri(), approximation_type = SBP(), + l2 = [0.004180680322490383, 0.07026192411558974, 0.11815151697006446, 2.329788936151192e-15], + linf = [0.02076003852980346, 0.29169601664914424, 0.5674183379872275, 1.1546319456101628e-14] + ) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension = 8, element_type = Tri(), approximation_type = Polynomial(), + # The last l2, linf error are the L2 projection error in approximating `b`, so they are not + # zero for general non-collocated quadrature rules (e.g., for `element_type=Tri()`, `polydeg > 2`). + l2 = [0.0008309356912456799, 0.01522451288799231, 0.016033969387208476, 1.2820247308150876e-5], + linf = [0.001888045014140971, 0.05466838692127718, 0.06345885709961152, 3.3989933098554914e-5] + ) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension = 8, element_type = Quad(), approximation_type = Polynomial(), + # The last l2, linf error are the L2 projection error in approximating `b`. However, this is zero + # for `Quad()` elements with `Polynomial()` approximations because the quadrature rule defaults to + # a `(polydeg + 1)`-point Gauss quadrature rule in each coordinate (in general, StartUpDG.jl defaults + # to the quadrature rule with the fewest number of points which exactly integrates the mass matrix). + l2 = [7.460461950323111e-5, 0.003685589808444905, 0.0039101604749887785, 2.0636891126652983e-15], + linf = [0.000259995400729629, 0.0072236204211630906, 0.010364675200833062, 1.021405182655144e-14] + ) + end + + end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive = true) +@test_nowarn isdir(outdir) && rm(outdir, recursive=true) end # module diff --git a/test/test_dgmulti_3d.jl b/test/test_dgmulti_3d.jl index d76da04d5c7..68fa1d13304 100644 --- a/test/test_dgmulti_3d.jl +++ b/test/test_dgmulti_3d.jl @@ -9,286 +9,141 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "dgmulti_3d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "DGMulti 3D" begin - # 3d tet/hex tests - @trixi_testset "elixir_euler_weakform.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0010029534292051608, - 0.0011682205957721673, - 0.001072975385793516, - 0.000997247778892257, - 0.0039364354651358294, - ] ./ sqrt(8), - linf=[ - 0.003660737033303718, - 0.005625620600749226, - 0.0030566354814669516, - 0.0041580358824311325, - 0.019326660236036464, - ]) - end + # 3d tet/hex tests + @trixi_testset "elixir_euler_weakform.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2 = [0.0010029534292051608, 0.0011682205957721673, 0.001072975385793516, 0.000997247778892257, 0.0039364354651358294] ./ sqrt(8), + linf = [0.003660737033303718, 0.005625620600749226, 0.0030566354814669516, 0.0041580358824311325, 0.019326660236036464] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2 = [0.014932088450136542, 0.017080219613061526, 0.016589517840793006, 0.015905000907070196, 0.03903416208587798] ./ sqrt(8), + linf = [0.06856547797256729, 0.08225664880340489, 0.06925055630951782, 0.06913016119820181, 0.19161418499621874] + ) + end + + @trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), + element_type = Hex(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2 = [0.00030580190715769566, 0.00040146357607439464, 0.00040146357607564597, 0.000401463576075708, 0.0015749412434154315] ./ sqrt(8), + linf = [0.00036910287847780054, 0.00042659774184228283, 0.0004265977427213574, 0.00042659774250686233, 0.00143803344597071] + ) + end + + @trixi_testset "elixir_euler_curved.jl (Hex elements, SBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + l2 = [0.018354883045936066, 0.024412704052042846, 0.024408520416087945, 0.01816314570880129, 0.039342805507972006], + linf = [0.14862225990775757, 0.28952368161864683, 0.2912054484817035, 0.1456603133854122, 0.3315354586775472] + ) + end + + @trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), + approximation_type=GaussSBP(), + l2 = [0.002631131519508634, 0.0029144224044954105, 0.002913889110662827, 0.002615140832314194, 0.006881528610614373], + linf = [0.020996114874140215, 0.021314522450134543, 0.021288322783006297, 0.020273381695435244, 0.052598740390024545] + ) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2 = [0.0010317074322517949, 0.0012277090547035293, 0.0011273991123913515, 0.0010418496196130177, 0.004058878478404962] ./ sqrt(8), + linf = [0.003227752881827861, 0.005620317864620361, 0.0030514833972379307, 0.003987027618439498, 0.019282224709831652] + ) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type = Hex(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2 = [0.00034230612468547436, 0.00044397204714598747, 0.0004439720471461567, 0.0004439720471464591, 0.0016639410646990126] ./ sqrt(8), + linf = [0.0003674374460325147, 0.0004253921341716982, 0.0004253921340786615, 0.0004253921340831024, 0.0014333414071048267] + ) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type = Hex(), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + approximation_type = SBP(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2 = [0.001712443468716032, 0.002491315550718859, 0.0024913155507195303, 0.002491315550720031, 0.008585818982343299] ./ sqrt(8), + linf = [0.003810078279323559, 0.004998778644230928, 0.004998778643986235, 0.0049987786444081195, 0.016455044373650196] + ) + end + + @trixi_testset "elixir_euler_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), + polydeg = 3, tspan = (0.0, 1.0), cells_per_dimension = (2, 2, 2), + l2 = [0.0003612827827560599, 0.06219350883951729, 0.062193508839503864, 0.08121963221634831, 0.07082703570808184], + linf = [0.0007893509649821162, 0.1481953939988877, 0.14819539399791176, 0.14847291108358926, 0.21313533492212855] + ) + end + + @trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), + polydeg = 3, approximation_type = GaussSBP(), tspan = (0.0, 1.0), cells_per_dimension = (2, 2, 2), + l2 = [0.00036128278275524326, 0.062193508839511434, 0.06219350883949677, 0.08121963221635205, 0.07082703570765223], + linf = [0.000789350964946367, 0.14819539399525805, 0.14819539399590542, 0.14847291107658706, 0.21313533492059378] + ) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type = Hex(), + cells_per_dimension = (2, 2, 2), + approximation_type = derivative_operator( + SummationByPartsOperators.MattssonNordström2004(), + derivative_order=1, accuracy_order=2, + xmin=0.0, xmax=1.0, N=8), + l2 = [0.0024092707138829925, 0.003318758964118284, 0.0033187589641182386, 0.003318758964118252, 0.012689348410504253], + linf = [0.006118565824207778, 0.008486456080185167, 0.008486456080180282, 0.008486456080185611, 0.035113544599208346] + ) + end + + @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), + element_type = Hex(), + cells_per_dimension = (2, 2, 2), + approximation_type = derivative_operator( + SummationByPartsOperators.MattssonNordström2004(), + derivative_order=1, accuracy_order=2, + xmin=0.0, xmax=1.0, N=8), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + l2 = [0.0034543609010604407, 0.004944363692625066, 0.0049443636926250435, 0.004944363692625037, 0.01788695279620914], + linf = [0.013861851418853988, 0.02126572106620328, 0.021265721066209053, 0.021265721066210386, 0.0771455289446683] + ) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), + l2 = [7.561896970325353e-5, 6.884047859361093e-5, 6.884047859363204e-5, 6.884047859361148e-5, 0.000201107274617457], + linf = [0.0001337520020225913, 0.00011571467799287305, 0.0001157146779990903, 0.00011571467799376123, 0.0003446082308800058] + ) + end + + @trixi_testset "elixir_advection_tensor_wedge.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"), + l2 = [2.30487910e-04] , + linf = [6.31795281e-04] ) + end - @trixi_testset "elixir_euler_weakform.jl (EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 0.014932088450136542, - 0.017080219613061526, - 0.016589517840793006, - 0.015905000907070196, - 0.03903416208587798, - ] ./ sqrt(8), - linf=[ - 0.06856547797256729, - 0.08225664880340489, - 0.06925055630951782, - 0.06913016119820181, - 0.19161418499621874, - ]) - end - - @trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - element_type=Hex(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 0.00030580190715769566, - 0.00040146357607439464, - 0.00040146357607564597, - 0.000401463576075708, - 0.0015749412434154315, - ] ./ sqrt(8), - linf=[ - 0.00036910287847780054, - 0.00042659774184228283, - 0.0004265977427213574, - 0.00042659774250686233, - 0.00143803344597071, - ]) - end - - @trixi_testset "elixir_euler_curved.jl (Hex elements, SBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - l2=[ - 0.018354883045936066, - 0.024412704052042846, - 0.024408520416087945, - 0.01816314570880129, - 0.039342805507972006, - ], - linf=[ - 0.14862225990775757, - 0.28952368161864683, - 0.2912054484817035, - 0.1456603133854122, - 0.3315354586775472, - ]) - end - - @trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - approximation_type=GaussSBP(), - l2=[ - 0.002631131519508634, - 0.0029144224044954105, - 0.002913889110662827, - 0.002615140832314194, - 0.006881528610614373, - ], - linf=[ - 0.020996114874140215, - 0.021314522450134543, - 0.021288322783006297, - 0.020273381695435244, - 0.052598740390024545, - ]) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 0.0010317074322517949, - 0.0012277090547035293, - 0.0011273991123913515, - 0.0010418496196130177, - 0.004058878478404962, - ] ./ sqrt(8), - linf=[ - 0.003227752881827861, - 0.005620317864620361, - 0.0030514833972379307, - 0.003987027618439498, - 0.019282224709831652, - ]) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type=Hex(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 0.00034230612468547436, - 0.00044397204714598747, - 0.0004439720471461567, - 0.0004439720471464591, - 0.0016639410646990126, - ] ./ sqrt(8), - linf=[ - 0.0003674374460325147, - 0.0004253921341716982, - 0.0004253921340786615, - 0.0004253921340831024, - 0.0014333414071048267, - ]) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type=Hex(), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - approximation_type=SBP(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2=[ - 0.001712443468716032, - 0.002491315550718859, - 0.0024913155507195303, - 0.002491315550720031, - 0.008585818982343299, - ] ./ sqrt(8), - linf=[ - 0.003810078279323559, - 0.004998778644230928, - 0.004998778643986235, - 0.0049987786444081195, - 0.016455044373650196, - ]) - end - - @trixi_testset "elixir_euler_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - polydeg=3, tspan=(0.0, 1.0), cells_per_dimension=(2, 2, 2), - l2=[ - 0.0003612827827560599, - 0.06219350883951729, - 0.062193508839503864, - 0.08121963221634831, - 0.07082703570808184, - ], - linf=[ - 0.0007893509649821162, - 0.1481953939988877, - 0.14819539399791176, - 0.14847291108358926, - 0.21313533492212855, - ]) - end - - @trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - polydeg=3, approximation_type=GaussSBP(), tspan=(0.0, 1.0), - cells_per_dimension=(2, 2, 2), - l2=[ - 0.00036128278275524326, - 0.062193508839511434, - 0.06219350883949677, - 0.08121963221635205, - 0.07082703570765223, - ], - linf=[ - 0.000789350964946367, - 0.14819539399525805, - 0.14819539399590542, - 0.14847291107658706, - 0.21313533492059378, - ]) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type=Hex(), - cells_per_dimension=(2, 2, 2), - approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, - accuracy_order = 2, - xmin = 0.0, xmax = 1.0, - N = 8), - l2=[ - 0.0024092707138829925, - 0.003318758964118284, - 0.0033187589641182386, - 0.003318758964118252, - 0.012689348410504253, - ], - linf=[ - 0.006118565824207778, - 0.008486456080185167, - 0.008486456080180282, - 0.008486456080185611, - 0.035113544599208346, - ]) - end - - @trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type=Hex(), - cells_per_dimension=(2, 2, 2), - approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(), - derivative_order = 1, - accuracy_order = 2, - xmin = 0.0, xmax = 1.0, - N = 8), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - l2=[ - 0.0034543609010604407, - 0.004944363692625066, - 0.0049443636926250435, - 0.004944363692625037, - 0.01788695279620914, - ], - linf=[ - 0.013861851418853988, - 0.02126572106620328, - 0.021265721066209053, - 0.021265721066210386, - 0.0771455289446683, - ]) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2=[ - 7.561896970325353e-5, - 6.884047859361093e-5, - 6.884047859363204e-5, - 6.884047859361148e-5, - 0.000201107274617457, - ], - linf=[ - 0.0001337520020225913, - 0.00011571467799287305, - 0.0001157146779990903, - 0.00011571467799376123, - 0.0003446082308800058, - ]) - end - - @trixi_testset "elixir_advection_tensor_wedge.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"), - l2=[2.30487910e-04], - linf=[6.31795281e-04]) - end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive = true) +@test_nowarn isdir(outdir) && rm(outdir, recursive=true) end # module diff --git a/test/test_mpi.jl b/test/test_mpi.jl index ad1ba4e835d..34febf7e268 100644 --- a/test/test_mpi.jl +++ b/test/test_mpi.jl @@ -7,7 +7,7 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) +Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) # CI with MPI and some tests fails often on Windows. Thus, we check whether this # is the case here. We use GitHub Actions, so we can check whether we run CI @@ -16,32 +16,33 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @testset "MPI" begin - # TreeMesh tests - include("test_mpi_tree.jl") - - # P4estMesh tests - include("test_mpi_p4est_2d.jl") - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` above - include("test_mpi_p4est_3d.jl") - end + # TreeMesh tests + include("test_mpi_tree.jl") + + # P4estMesh tests + include("test_mpi_p4est_2d.jl") + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` above + include("test_mpi_p4est_3d.jl") + end end # MPI + @trixi_testset "MPI supporting functionality" begin - using OrdinaryDiffEq - - t = 0.5 - let u = 1.0 - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end - let u = [1.0, -2.0] - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end - let u = [SVector(1.0, -2.0), SVector(0.5, -0.1)] - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end + using OrdinaryDiffEq + + t = 0.5 + let u = 1.0 + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end + let u = [1.0, -2.0] + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end + let u = [SVector(1.0, -2.0), SVector(0.5, -0.1)] + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end end # MPI supporting functionality # Clean up afterwards: delete Trixi.jl output directory -Trixi.mpi_isroot() && @test_nowarn rm(outdir, recursive = true) +Trixi.mpi_isroot() && @test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_mpi_p4est_2d.jl b/test/test_mpi_p4est_2d.jl index be1d6597155..4023997eaf3 100644 --- a/test/test_mpi_p4est_2d.jl +++ b/test/test_mpi_p4est_2d.jl @@ -9,85 +9,69 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_2d_dgsem") @testset "P4estMesh MPI 2D" begin - # Run basic tests - @testset "Examples 2D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) +# Run basic tests +@testset "Examples 2D" begin + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5]) - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && - println("elixir_advection_basic.jl with error-based step size control") + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && println("elixir_advection_basic.jl with error-based step size control") - sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, - ode_default_options()..., callback = callbacks) - summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2≈[3.3022040342579066e-5] rtol=1.0e-4 - @test errors.linf≈[0.00011787417954578494] rtol=1.0e-4 - end - end - end + sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, + ode_default_options()..., callback=callbacks); summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2 ≈ [3.3022040342579066e-5] rtol=1.0e-4 + @test errors.linf ≈ [0.00011787417954578494] rtol=1.0e-4 + end + end + end - @trixi_testset "elixir_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_nonconforming_flag.jl"), - l2=[3.198940059144588e-5], - linf=[0.00030636069494005547]) - end + @trixi_testset "elixir_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), + l2 = [3.198940059144588e-5], + linf = [0.00030636069494005547]) + end - @trixi_testset "elixir_advection_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_unstructured_flag.jl"), - l2=[0.0005379687442422346], - linf=[0.007438525029884735]) - end + @trixi_testset "elixir_advection_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), + l2 = [0.0005379687442422346], + linf = [0.007438525029884735]) + end - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[4.949660644033807e-5], - linf=[0.0004867846262313763], - coverage_override=(maxiters = 6,)) - end + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [4.949660644033807e-5], + linf = [0.0004867846262313763], + coverage_override = (maxiters=6,)) + end - @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_unstructured_flag.jl"), - l2=[0.0012766060609964525], - linf=[0.01750280631586159], - coverage_override=(maxiters = 6,)) - end + @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_flag.jl"), + l2 = [0.0012766060609964525], + linf = [0.01750280631586159], + coverage_override = (maxiters=6,)) + end - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[4.507575525876275e-6], - linf=[6.21489667023134e-5]) - end + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [4.507575525876275e-6], + linf = [6.21489667023134e-5]) + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], + linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) + end +end - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2=[ - 0.0034516244508588046, - 0.0023420334036925493, - 0.0024261923964557187, - 0.004731710454271893, - ], - linf=[ - 0.04155789011775046, - 0.024772109862748914, - 0.03759938693042297, - 0.08039824959535657, - ]) - end - end end # P4estMesh MPI end # module diff --git a/test/test_mpi_p4est_3d.jl b/test/test_mpi_p4est_3d.jl index c8542747b44..f92feb1eed9 100644 --- a/test/test_mpi_p4est_3d.jl +++ b/test/test_mpi_p4est_3d.jl @@ -9,148 +9,89 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem") @testset "P4estMesh MPI 3D" begin - # Run basic tests - @testset "Examples 3D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[0.00016263963870641478], - linf=[0.0014537194925779984]) - - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && - println("elixir_advection_basic.jl with error-based step size control") - - sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, - ode_default_options()..., callback = callbacks) - summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2≈[0.00016800412839949264] rtol=1.0e-4 - @test errors.linf≈[0.0014548839020096516] rtol=1.0e-4 - end - end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[9.773852895157622e-6], - linf=[0.0005853874124926162], - # override values are different from the serial tests to ensure each process holds at least - # one element, otherwise OrdinaryDiffEq fails during initialization - coverage_override=(maxiters = 6, - initial_refinement_level = 2, - base_level = 2, med_level = 3, - max_level = 4)) - end - - @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_unstructured_curved.jl"), - l2=[1.6236411810065552e-5], - linf=[0.0010554006923731395], - tspan=(0.0, 1.0), - coverage_override=(maxiters = 6, - initial_refinement_level = 0, - base_level = 0, med_level = 1, - max_level = 2)) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[0.002590388934758452], - linf=[0.01840757696885409]) - end - - @trixi_testset "elixir_advection_cubed_sphere.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), - l2=[0.002006918015656413], - linf=[0.027655117058380085]) - end - - # Compressible Euler - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), - l2=[ - 4.070355207909268e-5, - 4.4993257426833716e-5, - 5.10588457841744e-5, - 5.102840924036687e-5, - 0.00019986264001630542, - ], - linf=[ - 0.0016987332417202072, - 0.003622956808262634, - 0.002029576258317789, - 0.0024206977281964193, - 0.008526972236273522, - ], - tspan=(0.0, 0.01)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 0.0015106060984283647, - 0.0014733349038567685, - 0.00147333490385685, - 0.001473334903856929, - 0.0028149479453087093, - ], - linf=[ - 0.008070806335238156, - 0.009007245083113125, - 0.009007245083121784, - 0.009007245083102688, - 0.01562861968368434, - ], - tspan=(0.0, 1.0)) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.010380390326164493, - 0.006192950051354618, - 0.005970674274073704, - 0.005965831290564327, - 0.02628875593094754, - ], - linf=[ - 0.3326911600075694, - 0.2824952141320467, - 0.41401037398065543, - 0.45574161423218573, - 0.8099577682187109, - ], - tspan=(0.0, 0.2), - coverage_override=(polydeg = 3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), - l2=[ - 0.0042023406458005464, - 0.004122532789279737, - 0.0042448149597303616, - 0.0036361316700401765, - 0.007389845952982495, - ], - linf=[ - 0.04530610539892499, - 0.02765695110527666, - 0.05670295599308606, - 0.048396544302230504, - 0.1154589758186293, - ]) - end +# Run basic tests +@testset "Examples 3D" begin + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [0.00016263963870641478], + linf = [0.0014537194925779984]) + + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && println("elixir_advection_basic.jl with error-based step size control") + + sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, + ode_default_options()..., callback=callbacks); summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2 ≈ [0.00016800412839949264] rtol=1.0e-4 + @test errors.linf ≈ [0.0014548839020096516] rtol=1.0e-4 + end end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [9.773852895157622e-6], + linf = [0.0005853874124926162], + # override values are different from the serial tests to ensure each process holds at least + # one element, otherwise OrdinaryDiffEq fails during initialization + coverage_override = (maxiters=6, initial_refinement_level=2, base_level=2, med_level=3, max_level=4)) + end + + @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_curved.jl"), + l2 = [1.6236411810065552e-5], + linf = [0.0010554006923731395], + tspan = (0.0, 1.0), + coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=1, max_level=2)) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [0.002590388934758452], + linf = [0.01840757696885409]) + end + + @trixi_testset "elixir_advection_cubed_sphere.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), + l2 = [0.002006918015656413], + linf = [0.027655117058380085]) + end + + # Compressible Euler + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), + l2 = [4.070355207909268e-5, 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, 0.00019986264001630542], + linf = [0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, 0.008526972236273522], + tspan = (0.0, 0.01)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [0.0015106060984283647, 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, 0.0028149479453087093], + linf = [0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, 0.01562861968368434], + tspan = (0.0, 1.0)) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.010380390326164493, 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, 0.02628875593094754], + linf = [0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, 0.8099577682187109], + tspan = (0.0, 0.2), + coverage_override = (polydeg=3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), + l2 = [0.0042023406458005464, 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, 0.007389845952982495], + linf = [0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, 0.1154589758186293]) + end +end + end # P4estMesh MPI end # module diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 7b0a58a3bd9..84d2609cbb1 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -12,309 +12,179 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @testset "TreeMesh MPI" begin - # Run basic tests - @testset "Examples 2D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[7.81674284320524e-6], - linf=[6.314906965243505e-5]) - end - - @trixi_testset "elixir_advection_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[0.0015188466707237375], - linf=[0.008446655719187679]) - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[4.913300828257469e-5], - linf=[0.00045263895394385967], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_nonperiodic.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[3.2207388565869075e-5], - linf=[0.0007508059772436404], - coverage_override=(maxiters = 6,)) - end - - # Linear scalar advection with AMR - # These example files are only for testing purposes and have no practical use - @trixi_testset "elixir_advection_amr_refine_twice.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_refine_twice.jl"), - l2=[0.00020547512522578292], - linf=[0.007831753383083506], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_coarsen_twice.jl"), - l2=[0.0014321062757891826], - linf=[0.0253454486893413], - coverage_override=(maxiters = 6,)) - end - - # Hyperbolic diffusion - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_hypdiff_lax_friedrichs.jl"), - l2=[ - 0.00015687751816056159, - 0.001025986772217084, - 0.0010259867722169909, - ], - linf=[ - 0.0011986956416591976, - 0.006423873516411049, - 0.006423873516411049, - ]) - end - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2=[ - 8.61813235543625e-8, - 5.619399844542781e-7, - 5.6193998447443e-7, - ], - linf=[ - 1.124861862180196e-6, - 8.622436471039663e-6, - 8.622436470151484e-6, - ]) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2=[ - 8.523077653955306e-6, - 2.8779323653065056e-5, - 5.4549427691297846e-5, - ], - linf=[ - 5.5227409524905013e-5, - 0.0001454489597927185, - 0.00032396328684569653, - ]) - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_hypdiff_godunov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), - l2=[ - 5.868147556427088e-6, - 3.80517927324465e-5, - 3.805179273249344e-5, - ], - linf=[ - 3.701965498725812e-5, - 0.0002122422943138247, - 0.00021224229431116015, - ], - atol=2.0e-12) #= required for CI on macOS =# - end - end - - # Compressible Euler - # Note: Some tests here have manually increased relative tolerances since reduction via MPI can - # slightly change the L2 error norms (different floating point truncation errors) - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2=[ - 9.321181253186009e-7, - 1.4181210743438511e-6, - 1.4181210743487851e-6, - 4.824553091276693e-6, - ], - linf=[ - 9.577246529612893e-6, - 1.1707525976012434e-5, - 1.1707525976456523e-5, - 4.8869615580926506e-5, - ], - rtol=2000 * sqrt(eps())) - end - end - - # This example file is only for testing purposes and has no practical use - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_amr_refine_coarsen.jl"), - l2=[ - 4.8226610349853444e-5, - 4.117706709270575e-5, - 4.1177067092959676e-5, - 0.00012205252427437389, - ], - linf=[ - 0.0003543874851490436, - 0.0002973166773747593, - 0.0002973166773760916, - 0.001154106793870291, - ], - # Let this test run until the end to cover the time-dependent lines - # of the indicator and the MPI-specific AMR code. - coverage_override=(maxiters = 10^5,)) - end - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 2.259440511766445e-6, - 2.318888155713922e-6, - 2.3188881557894307e-6, - 6.3327863238858925e-6, - ], - linf=[ - 1.498738264560373e-5, - 1.9182011928187137e-5, - 1.918201192685487e-5, - 6.0526717141407005e-5, - ], - rtol=0.001) - end - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.061751715597716854, - 0.05018223615408711, - 0.05018989446443463, - 0.225871559730513, - ], - linf=[ - 0.29347582879608825, - 0.31081249232844693, - 0.3107380389947736, - 1.0540358049885143, - ]) - - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && - println("elixir_euler_ec.jl with error-based step size control") - - sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, - ode_default_options()..., callback = callbacks) - summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2≈[ - 0.061653630426688116, - 0.05006930431098764, - 0.05007694316484242, - 0.22550689872331683, - ] rtol=1.0e-4 - @test errors.linf≈[ - 0.28516937484583693, - 0.2983633696512788, - 0.297812036335975, - 1.027368795517512, - ] rtol=1.0e-4 - end - end - end - end - - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2=[ - 0.00013492249515826863, - 0.006615696236378061, - 0.006782108219800376, - 0.016393831451740604, - ], - linf=[ - 0.0020782600954247776, - 0.08150078921935999, - 0.08663621974991986, - 0.2829930622010579, - ], - rtol=0.001) - end - - @trixi_testset "elixir_euler_vortex_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[ - 0.0017208369388227673, - 0.09628684992237334, - 0.09620157717330868, - 0.1758809552387432, - ], - linf=[ - 0.021869936355319086, - 0.9956698009442038, - 1.0002507727219028, - 2.223249697515648, - ]) - end - - @trixi_testset "elixir_euler_vortex_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[ - 5.051719943432265e-5, - 0.0022574259317084747, - 0.0021755998463189713, - 0.004346492398617521, - ], - linf=[ - 0.0012880114865917447, - 0.03857193149447702, - 0.031090457959835893, - 0.12125130332971423, - ], - coverage_override=(maxiters = 6,)) - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_vortex_shockcapturing.jl"), - l2=[ - 0.0017158367642679273, - 0.09619888722871434, - 0.09616432767924141, - 0.17553381166255197, - ], - linf=[ - 0.021853862449723982, - 0.9878047229255944, - 0.9880191167111795, - 2.2154030488035588, - ], - rtol=0.001) - end - end +# Run basic tests +@testset "Examples 2D" begin + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [7.81674284320524e-6], + linf = [6.314906965243505e-5]) + end + + @trixi_testset "elixir_advection_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [0.0015188466707237375], + linf = [0.008446655719187679]) + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [4.913300828257469e-5], + linf = [0.00045263895394385967], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [3.2207388565869075e-5], + linf = [0.0007508059772436404], + coverage_override = (maxiters=6,)) + end + + # Linear scalar advection with AMR + # These example files are only for testing purposes and have no practical use + @trixi_testset "elixir_advection_amr_refine_twice.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_refine_twice.jl"), + l2 = [0.00020547512522578292], + linf = [0.007831753383083506], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_coarsen_twice.jl"), + l2 = [0.0014321062757891826], + linf = [0.0253454486893413], + coverage_override = (maxiters=6,)) + end + + # Hyperbolic diffusion + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), + l2 = [0.00015687751816056159, 0.001025986772217084, 0.0010259867722169909], + linf = [0.0011986956416591976, 0.006423873516411049, 0.006423873516411049]) + end + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2 = [8.61813235543625e-8, 5.619399844542781e-7, 5.6193998447443e-7], + linf = [1.124861862180196e-6, 8.622436471039663e-6, 8.622436470151484e-6]) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2 = [8.523077653955306e-6, 2.8779323653065056e-5, 5.4549427691297846e-5], + linf = [5.5227409524905013e-5, 0.0001454489597927185, 0.00032396328684569653]) + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_hypdiff_godunov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), + l2 = [5.868147556427088e-6, 3.80517927324465e-5, 3.805179273249344e-5], + linf = [3.701965498725812e-5, 0.0002122422943138247, 0.00021224229431116015], + atol = 2.0e-12 #= required for CI on macOS =#) + end + end + + + # Compressible Euler + # Note: Some tests here have manually increased relative tolerances since reduction via MPI can + # slightly change the L2 error norms (different floating point truncation errors) + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], + linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], + rtol = 2000*sqrt(eps())) end + end + + # This example file is only for testing purposes and has no practical use + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_amr_refine_coarsen.jl"), + l2 = [4.8226610349853444e-5, 4.117706709270575e-5, 4.1177067092959676e-5, 0.00012205252427437389], + linf = [0.0003543874851490436, 0.0002973166773747593, 0.0002973166773760916, 0.001154106793870291], + # Let this test run until the end to cover the time-dependent lines + # of the indicator and the MPI-specific AMR code. + coverage_override = (maxiters=10^5,)) + end + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], + linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5], + rtol = 0.001) + end + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], + linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) + + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && println("elixir_euler_ec.jl with error-based step size control") + + sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, + ode_default_options()..., callback=callbacks); summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2 ≈ [0.061653630426688116, 0.05006930431098764, 0.05007694316484242, 0.22550689872331683] rtol=1.0e-4 + @test errors.linf ≈ [0.28516937484583693, 0.2983633696512788, 0.297812036335975, 1.027368795517512] rtol=1.0e-4 + end + end + end + end + + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2 = [0.00013492249515826863, 0.006615696236378061, 0.006782108219800376, 0.016393831451740604], + linf = [0.0020782600954247776, 0.08150078921935999, 0.08663621974991986, 0.2829930622010579], + rtol = 0.001) + end + + @trixi_testset "elixir_euler_vortex_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [0.0017208369388227673, 0.09628684992237334, 0.09620157717330868, 0.1758809552387432], + linf = [0.021869936355319086, 0.9956698009442038, 1.0002507727219028, 2.223249697515648]) + end + + @trixi_testset "elixir_euler_vortex_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [5.051719943432265e-5, 0.0022574259317084747, 0.0021755998463189713, 0.004346492398617521], + linf = [0.0012880114865917447, 0.03857193149447702, 0.031090457959835893, 0.12125130332971423], + coverage_override = (maxiters=6,)) + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), + l2 = [0.0017158367642679273, 0.09619888722871434, 0.09616432767924141, 0.17553381166255197], + linf = [0.021853862449723982, 0.9878047229255944, 0.9880191167111795, 2.2154030488035588], + rtol = 0.001) + end + end +end + end # TreeMesh MPI end # module diff --git a/test/test_p4est_2d.jl b/test/test_p4est_2d.jl index 50e80ecd1e2..f66664c7a89 100644 --- a/test/test_p4est_2d.jl +++ b/test/test_p4est_2d.jl @@ -9,279 +9,164 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "P4estMesh2D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_nonconforming_flag.jl"), - l2=[3.198940059144588e-5], - linf=[0.00030636069494005547]) - - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end - - @trixi_testset "elixir_advection_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), - l2=[0.0005379687442422346], - linf=[0.007438525029884735]) - end - - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with StructuredMesh! - l2=[4.949660644033807e-5], - linf=[0.0004867846262313763], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_unstructured_flag.jl"), - l2=[0.0012766060609964525], - linf=[0.01750280631586159], - coverage_override=(maxiters = 6,)) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), + l2 = [3.198940059144588e-5], + linf = [0.00030636069494005547]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + end + + @trixi_testset "elixir_advection_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), + l2 = [0.0005379687442422346], + linf = [0.007438525029884735]) + end + + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with StructuredMesh! + l2 = [4.949660644033807e-5], + linf = [0.0004867846262313763], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_flag.jl"), + l2 = [0.0012766060609964525], + linf = [0.01750280631586159], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [4.507575525876275e-6], + linf = [6.21489667023134e-5]) + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], + linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], + linf = [1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], + atol = 2.0e-12, # required to make CI tests pass on macOS + ) + end + + @trixi_testset "elixir_euler_shockcapturing_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), + l2 = [9.53984675e-02, 1.05633455e-01, 1.05636158e-01, 3.50747237e-01], + linf = [2.94357464e-01, 4.07893014e-01, 3.97334516e-01, 1.08142520e+00], + tspan = (0.0, 1.0)) + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2 = [3.76149952e-01, 2.46970327e-01, 2.46970327e-01, 1.28889042e+00], + linf = [1.22139001e+00, 1.17742626e+00, 1.17742626e+00, 6.20638482e+00], + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_euler_blast_wave_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), + l2 = [6.32183914e-01, 3.86914231e-01, 3.86869171e-01, 1.06575688e+00], + linf = [2.76020890e+00, 2.32659890e+00, 2.32580837e+00, 2.15778188e+00], + tspan = (0.0, 0.3), + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_wall_bc_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"), + l2 = [0.020291447969983396, 0.017479614254319948, 0.011387644425613437, 0.0514420126021293], + linf = [0.3582779022370579, 0.32073537890751663, 0.221818049107692, 0.9209559420400415], + tspan = (0.0, 0.15)) + end + + @trixi_testset "elixir_euler_forward_step_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_forward_step_amr.jl"), + l2 = [0.004194875320833303, 0.003785140699353966, 0.0013696609105790351, 0.03265268616046424], + linf = [2.0585399781442852, 2.213428805506876, 3.862362410419163, 17.75187237459251], + tspan = (0.0, 0.0001), + rtol = 1.0e-7, + skip_coverage=true) + end + + @trixi_testset "elixir_euler_double_mach_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_double_mach_amr.jl"), + l2 = [0.051359355290192046, 0.4266034859911273, 0.2438304855475594, 4.11487176105527], + linf = [6.902000373057003, 53.95714139820832, 24.241610279839758, 561.0630401858057], + tspan = (0.0, 0.0001), + skip_coverage=true) + end + + @trixi_testset "elixir_euler_supersonic_cylinder.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_supersonic_cylinder.jl"), + l2 = [0.026798021911954406, 0.05118546368109259, 0.03206703583774831, 0.19680026567208672], + linf = [3.653905721692421, 4.285035711361009, 6.8544353186357645, 31.748244912257533], + tspan = (0.0, 0.001), + skip_coverage=true) + end + + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], + linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], + tspan = (0.0, 0.1)) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2 = [9.168126407325352e-5, 0.0009795410115453788, 0.002546408320320785, 3.941189812642317e-6], + linf = [0.0009903782521019089, 0.0059752684687262025, 0.010941106525454103, 1.2129488214718265e-5], + tspan = (0.0, 0.1)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [1.0513414461545583e-5, 1.0517900957166411e-6, 1.0517900957304043e-6, 1.511816606372376e-6, + 1.0443997728645063e-6, 7.879639064990798e-7, 7.879639065049896e-7, 1.0628631669056271e-6, + 4.3382328912336153e-7], + linf = [4.255466285174592e-5, 1.0029706745823264e-5, 1.0029706747467781e-5, 1.2122265939010224e-5, + 5.4791097160444835e-6, 5.18922042269665e-6, 5.189220422141538e-6, 9.552667261422676e-6, + 1.4237578427628152e-6]) + end + + @trixi_testset "elixir_mhd_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), + l2 = [0.4552084651735862, 0.8918048264575757, 0.832471223081887, 0.0, + 0.9801264164951583, 0.10475690769435382, 0.1555132409149897, 0.0, + 2.0597079362763556e-5], + linf = [10.194181233788775, 18.25472397868819, 10.031307436191334, 0.0, + 19.647239392277378, 1.3938810140985936, 1.8724965294853084, 0.0, + 0.0016290067532561904], + tspan = (0.0, 0.02)) + end - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[4.507575525876275e-6], - linf=[6.21489667023134e-5]) - end - - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2=[ - 0.0034516244508588046, - 0.0023420334036925493, - 0.0024261923964557187, - 0.004731710454271893, - ], - linf=[ - 0.04155789011775046, - 0.024772109862748914, - 0.03759938693042297, - 0.08039824959535657, - ]) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2=[ - 2.063350241405049e-15, - 1.8571016296925367e-14, - 3.1769447886391905e-14, - 1.4104095258528071e-14, - ], - linf=[1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], - atol=2.0e-12,) - end - - @trixi_testset "elixir_euler_shockcapturing_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), - l2=[ - 9.53984675e-02, - 1.05633455e-01, - 1.05636158e-01, - 3.50747237e-01, - ], - linf=[ - 2.94357464e-01, - 4.07893014e-01, - 3.97334516e-01, - 1.08142520e+00, - ], - tspan=(0.0, 1.0)) - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2=[ - 3.76149952e-01, - 2.46970327e-01, - 2.46970327e-01, - 1.28889042e+00, - ], - linf=[ - 1.22139001e+00, - 1.17742626e+00, - 1.17742626e+00, - 6.20638482e+00, - ], - tspan=(0.0, 0.3)) - end - - @trixi_testset "elixir_euler_blast_wave_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), - l2=[ - 6.32183914e-01, - 3.86914231e-01, - 3.86869171e-01, - 1.06575688e+00, - ], - linf=[ - 2.76020890e+00, - 2.32659890e+00, - 2.32580837e+00, - 2.15778188e+00, - ], - tspan=(0.0, 0.3), - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_wall_bc_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"), - l2=[ - 0.020291447969983396, - 0.017479614254319948, - 0.011387644425613437, - 0.0514420126021293, - ], - linf=[ - 0.3582779022370579, - 0.32073537890751663, - 0.221818049107692, - 0.9209559420400415, - ], - tspan=(0.0, 0.15)) - end - - @trixi_testset "elixir_euler_forward_step_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_forward_step_amr.jl"), - l2=[ - 0.004194875320833303, - 0.003785140699353966, - 0.0013696609105790351, - 0.03265268616046424, - ], - linf=[ - 2.0585399781442852, - 2.213428805506876, - 3.862362410419163, - 17.75187237459251, - ], - tspan=(0.0, 0.0001), - rtol=1.0e-7, - skip_coverage=true) - end - - @trixi_testset "elixir_euler_double_mach_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_double_mach_amr.jl"), - l2=[ - 0.051359355290192046, - 0.4266034859911273, - 0.2438304855475594, - 4.11487176105527, - ], - linf=[ - 6.902000373057003, - 53.95714139820832, - 24.241610279839758, - 561.0630401858057, - ], - tspan=(0.0, 0.0001), - skip_coverage=true) - end - - @trixi_testset "elixir_euler_supersonic_cylinder.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_supersonic_cylinder.jl"), - l2=[ - 0.026798021911954406, - 0.05118546368109259, - 0.03206703583774831, - 0.19680026567208672, - ], - linf=[ - 3.653905721692421, - 4.285035711361009, - 6.8544353186357645, - 31.748244912257533, - ], - tspan=(0.0, 0.001), - skip_coverage=true) - end - - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2=[ - 0.00024871265138964204, - 0.0003370077102132591, - 0.0003370077102131964, - 0.0007231525513793697, - ], - linf=[ - 0.0015813032944647087, - 0.0020494288423820173, - 0.0020494288423824614, - 0.004793821195083758, - ], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2=[ - 9.168126407325352e-5, - 0.0009795410115453788, - 0.002546408320320785, - 3.941189812642317e-6, - ], - linf=[ - 0.0009903782521019089, - 0.0059752684687262025, - 0.010941106525454103, - 1.2129488214718265e-5, - ], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[1.0513414461545583e-5, 1.0517900957166411e-6, - 1.0517900957304043e-6, 1.511816606372376e-6, - 1.0443997728645063e-6, 7.879639064990798e-7, - 7.879639065049896e-7, 1.0628631669056271e-6, - 4.3382328912336153e-7], - linf=[4.255466285174592e-5, 1.0029706745823264e-5, - 1.0029706747467781e-5, 1.2122265939010224e-5, - 5.4791097160444835e-6, 5.18922042269665e-6, - 5.189220422141538e-6, 9.552667261422676e-6, - 1.4237578427628152e-6]) - end - - @trixi_testset "elixir_mhd_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2=[0.4552084651735862, 0.8918048264575757, 0.832471223081887, - 0.0, - 0.9801264164951583, 0.10475690769435382, 0.1555132409149897, - 0.0, - 2.0597079362763556e-5], - linf=[10.194181233788775, 18.25472397868819, 10.031307436191334, - 0.0, - 19.647239392277378, 1.3938810140985936, 1.8724965294853084, - 0.0, - 0.0016290067532561904], - tspan=(0.0, 0.02)) - end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_p4est_3d.jl b/test/test_p4est_3d.jl index bdc0a4410ce..f22e98456ae 100644 --- a/test/test_p4est_3d.jl +++ b/test/test_p4est_3d.jl @@ -9,308 +9,168 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_3d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "P4estMesh3D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[0.00016263963870641478], - linf=[0.0014537194925779984]) - end - - @trixi_testset "elixir_advection_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_unstructured_curved.jl"), - l2=[0.0004750004258546538], - linf=[0.026527551737137167]) - end - - @trixi_testset "elixir_advection_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"), - l2=[0.00253595715323843], - linf=[0.016486952252155795]) - - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[9.773852895157622e-6], - linf=[0.0005853874124926162], - coverage_override=(maxiters = 6, initial_refinement_level = 1, - base_level = 1, med_level = 2, max_level = 3)) - end - - @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_unstructured_curved.jl"), - l2=[1.6236411810065552e-5], - linf=[0.0010554006923731395], - tspan=(0.0, 1.0), - coverage_override=(maxiters = 6, initial_refinement_level = 0, - base_level = 0, med_level = 1, max_level = 2)) - end - - @trixi_testset "elixir_advection_cubed_sphere.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), - l2=[0.002006918015656413], - linf=[0.027655117058380085]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[0.002590388934758452], - linf=[0.01840757696885409]) - end - - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), - l2=[ - 4.070355207909268e-5, - 4.4993257426833716e-5, - 5.10588457841744e-5, - 5.102840924036687e-5, - 0.00019986264001630542, - ], - linf=[ - 0.0016987332417202072, - 0.003622956808262634, - 0.002029576258317789, - 0.0024206977281964193, - 0.008526972236273522, - ], - tspan=(0.0, 0.01)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 0.0015106060984283647, - 0.0014733349038567685, - 0.00147333490385685, - 0.001473334903856929, - 0.0028149479453087093, - ], - linf=[ - 0.008070806335238156, - 0.009007245083113125, - 0.009007245083121784, - 0.009007245083102688, - 0.01562861968368434, - ], - tspan=(0.0, 1.0)) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2=[ - 5.162664597942288e-15, - 1.941857343642486e-14, - 2.0232366394187278e-14, - 2.3381518645408552e-14, - 7.083114561232324e-14, - ], - linf=[ - 7.269740365245525e-13, - 3.289868377720495e-12, - 4.440087186807773e-12, - 3.8686831516088205e-12, - 9.412914891981927e-12, - ], - tspan=(0.0, 0.03)) - end - - @trixi_testset "elixir_euler_free_stream_extruded.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream_extruded.jl"), - l2=[ - 8.444868392439035e-16, - 4.889826056731442e-15, - 2.2921260987087585e-15, - 4.268460455702414e-15, - 1.1356712092620279e-14, - ], - linf=[ - 7.749356711883593e-14, - 2.8792246364872653e-13, - 1.1121659149182506e-13, - 3.3228975127030935e-13, - 9.592326932761353e-13, - ], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.010380390326164493, - 0.006192950051354618, - 0.005970674274073704, - 0.005965831290564327, - 0.02628875593094754, - ], - linf=[ - 0.3326911600075694, - 0.2824952141320467, - 0.41401037398065543, - 0.45574161423218573, - 0.8099577682187109, - ], - tspan=(0.0, 0.2), - coverage_override=(polydeg = 3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2=[ - 7.82070951e-02, - 4.33260474e-02, - 4.33260474e-02, - 4.33260474e-02, - 3.75260911e-01, - ], - linf=[ - 7.45329845e-01, - 3.21754792e-01, - 3.21754792e-01, - 3.21754792e-01, - 4.76151527e+00, - ], - tspan=(0.0, 0.3), - coverage_override=(polydeg = 3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonconforming_earth.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonconforming_earth.jl"), - l2=[ - 6.040180337738628e-6, - 5.4254175153621895e-6, - 5.677698851333843e-6, - 5.8017136892469794e-6, - 1.3637854615117974e-5, - ], - linf=[ - 0.00013996924184311865, - 0.00013681539559939893, - 0.00013681539539733834, - 0.00013681539541021692, - 0.00016833038543762058, - ], - # Decrease tolerance of adaptive time stepping to get similar results across different systems - abstol=1.0e-11, reltol=1.0e-11, - coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_circular_wind_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_circular_wind_nonconforming.jl"), - l2=[ - 1.573832094977477e-7, - 3.863090659429634e-5, - 3.867293305754584e-5, - 3.686550296950078e-5, - 0.05508968493733932, - ], - linf=[ - 2.2695202613887133e-6, - 0.0005314968179916946, - 0.0005314969614147458, - 0.0005130280733059617, - 0.7944959432352334, - ], - tspan=(0.0, 2e2), - coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_baroclinic_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_baroclinic_instability.jl"), - l2=[ - 6.725065410642336e-7, - 0.00021710117340245454, - 0.000438679759422352, - 0.00020836356588024185, - 0.07602006689579247, - ], - linf=[ - 1.9101671995258585e-5, - 0.029803626911022396, - 0.04847630924006063, - 0.022001371349740104, - 4.847761006938526, - ], - tspan=(0.0, 1e2), - # Decrease tolerance of adaptive time stepping to get similar results across different systems - abstol=1.0e-9, reltol=1.0e-9, - coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), - l2=[ - 0.0042023406458005464, - 0.004122532789279737, - 0.0042448149597303616, - 0.0036361316700401765, - 0.007389845952982495, - ], - linf=[ - 0.04530610539892499, - 0.02765695110527666, - 0.05670295599308606, - 0.048396544302230504, - 0.1154589758186293, - ]) - end - - @trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_mhd_alfven_wave_nonconforming.jl"), - l2=[0.00019018725889431733, 0.0006523517707148006, - 0.0002401595437705759, 0.0007796920661427565, - 0.0007095787460334334, 0.0006558819731628876, - 0.0003565026134076906, 0.0007904654548841712, - 9.437300326448332e-7], - linf=[0.0012482306861187897, 0.006408776208178299, - 0.0016845452099629663, 0.0068711236542984555, - 0.004626581522263695, 0.006614624811393632, - 0.0030068344747734566, 0.008277825749754025, - 1.3475027166309006e-5], - tspan=(0.0, 0.25), - coverage_override=(trees_per_dimension = (1, 1, 1),)) - end - - @trixi_testset "elixir_mhd_shockcapturing_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shockcapturing_amr.jl"), - l2=[0.006298541670176575, 0.0064368506652601265, - 0.007108729762852636, 0.006530420607206385, - 0.02061185869237284, 0.005562033787605515, - 0.007571716276627825, 0.005571862660453231, - 3.909755063709152e-6], - linf=[0.20904054009050665, 0.18622917151105936, - 0.2347957890323218, 0.19432508025509926, - 0.6858860133405615, 0.15172116633332622, - 0.22432820727833747, 0.16805989780225183, - 0.000535219040687628], - tspan=(0.0, 0.04), - coverage_override=(maxiters = 6, initial_refinement_level = 1, - base_level = 1, max_level = 2)) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [0.00016263963870641478], + linf = [0.0014537194925779984]) + end + + @trixi_testset "elixir_advection_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_curved.jl"), + l2 = [0.0004750004258546538], + linf = [0.026527551737137167]) + end + + @trixi_testset "elixir_advection_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"), + l2 = [0.00253595715323843], + linf = [0.016486952252155795]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [9.773852895157622e-6], + linf = [0.0005853874124926162], + coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, med_level=2, max_level=3)) + end + + @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_curved.jl"), + l2 = [1.6236411810065552e-5], + linf = [0.0010554006923731395], + tspan = (0.0, 1.0), + coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=1, max_level=2)) + end + + @trixi_testset "elixir_advection_cubed_sphere.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), + l2 = [0.002006918015656413], + linf = [0.027655117058380085]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [0.002590388934758452], + linf = [0.01840757696885409]) + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), + l2 = [4.070355207909268e-5, 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, 0.00019986264001630542], + linf = [0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, 0.008526972236273522], + tspan = (0.0, 0.01)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [0.0015106060984283647, 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, 0.0028149479453087093], + linf = [0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, 0.01562861968368434], + tspan = (0.0, 1.0)) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2 = [5.162664597942288e-15, 1.941857343642486e-14, 2.0232366394187278e-14, 2.3381518645408552e-14, 7.083114561232324e-14], + linf = [7.269740365245525e-13, 3.289868377720495e-12, 4.440087186807773e-12, 3.8686831516088205e-12, 9.412914891981927e-12], + tspan = (0.0, 0.03)) + end + + @trixi_testset "elixir_euler_free_stream_extruded.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream_extruded.jl"), + l2 = [8.444868392439035e-16, 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, 1.1356712092620279e-14], + linf = [7.749356711883593e-14, 2.8792246364872653e-13, 1.1121659149182506e-13, 3.3228975127030935e-13, 9.592326932761353e-13], + tspan=(0.0, 0.1)) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.010380390326164493, 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, 0.02628875593094754], + linf = [0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, 0.8099577682187109], + tspan = (0.0, 0.2), + coverage_override = (polydeg=3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2 = [7.82070951e-02, 4.33260474e-02, 4.33260474e-02, 4.33260474e-02, 3.75260911e-01], + linf = [7.45329845e-01, 3.21754792e-01, 3.21754792e-01, 3.21754792e-01, 4.76151527e+00], + tspan = (0.0, 0.3), + coverage_override = (polydeg=3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonconforming_earth.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_earth.jl"), + l2 = [6.040180337738628e-6, 5.4254175153621895e-6, 5.677698851333843e-6, 5.8017136892469794e-6, 1.3637854615117974e-5], + linf = [0.00013996924184311865, 0.00013681539559939893, 0.00013681539539733834, 0.00013681539541021692, 0.00016833038543762058], + # Decrease tolerance of adaptive time stepping to get similar results across different systems + abstol=1.0e-11, reltol=1.0e-11, + coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_circular_wind_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_circular_wind_nonconforming.jl"), + l2 = [1.573832094977477e-7, 3.863090659429634e-5, 3.867293305754584e-5, 3.686550296950078e-5, 0.05508968493733932], + linf = [2.2695202613887133e-6, 0.0005314968179916946, 0.0005314969614147458, 0.0005130280733059617, 0.7944959432352334], + tspan = (0.0, 2e2), + coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_baroclinic_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_baroclinic_instability.jl"), + l2 = [6.725065410642336e-7, 0.00021710117340245454, 0.000438679759422352, 0.00020836356588024185, 0.07602006689579247], + linf = [1.9101671995258585e-5, 0.029803626911022396, 0.04847630924006063, 0.022001371349740104, 4.847761006938526], + tspan = (0.0, 1e2), + # Decrease tolerance of adaptive time stepping to get similar results across different systems + abstol=1.0e-9, reltol=1.0e-9, + coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), + l2 = [0.0042023406458005464, 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, 0.007389845952982495], + linf = [0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, 0.1154589758186293]) + end + + @trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_nonconforming.jl"), + l2 = [0.00019018725889431733, 0.0006523517707148006, 0.0002401595437705759, 0.0007796920661427565, + 0.0007095787460334334, 0.0006558819731628876, 0.0003565026134076906, 0.0007904654548841712, + 9.437300326448332e-7], + linf = [0.0012482306861187897, 0.006408776208178299, 0.0016845452099629663, 0.0068711236542984555, + 0.004626581522263695, 0.006614624811393632, 0.0030068344747734566, 0.008277825749754025, + 1.3475027166309006e-5], + tspan = (0.0, 0.25), + coverage_override = (trees_per_dimension=(1, 1, 1),)) + end + + @trixi_testset "elixir_mhd_shockcapturing_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shockcapturing_amr.jl"), + l2 = [0.006298541670176575, 0.0064368506652601265, 0.007108729762852636, 0.006530420607206385, + 0.02061185869237284, 0.005562033787605515, 0.007571716276627825, 0.005571862660453231, + 3.909755063709152e-6], + linf = [0.20904054009050665, 0.18622917151105936, 0.2347957890323218, 0.19432508025509926, + 0.6858860133405615, 0.15172116633332622, 0.22432820727833747, 0.16805989780225183, + 0.000535219040687628], + tspan = (0.0, 0.04), + coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, max_level=2)) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_paper_self_gravitating_gas_dynamics.jl b/test/test_paper_self_gravitating_gas_dynamics.jl index 801a95b1467..6a35543fe47 100644 --- a/test/test_paper_self_gravitating_gas_dynamics.jl +++ b/test/test_paper_self_gravitating_gas_dynamics.jl @@ -7,246 +7,127 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) const EXAMPLES_DIR = pkgdir(Trixi, "examples", "paper_self_gravitating_gas_dynamics") # Numerical examples from the Euler-gravity paper @testset "paper_self_gravitating_gas_dynamics" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 0.0001740977055972079, - 0.0003369355182519592, - 0.0003369355182518708, - 0.0006099171220334989, - ], - linf=[ - 0.001079347149189669, - 0.0018836938381321389, - 0.001883693838132583, - 0.003971575376718217, - ]) - end - - @trixi_testset "elixir_euler_convergence.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 1.7187201161597772e-5, - 2.678065111772951e-5, - 2.678065111783027e-5, - 4.952504160091526e-5, - ], - linf=[ - 0.0001501749544159381, - 0.00016549482504535362, - 0.00016549482504601976, - 0.0004372960291432193, - ], - polydeg=4) - end - - @trixi_testset "elixir_hypdiff_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), - l2=[ - 0.003154024896093942, - 0.012394432074951856, - 0.02185973823794725, - ], - linf=[ - 0.01731850928579215, - 0.07843510773347553, - 0.11242300176349201, - ]) - end - - @trixi_testset "elixir_hypdiff_convergence.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), - l2=[ - 0.0002511283012128458, - 0.0008808243846610255, - 0.0016313343228567005, - ], - linf=[ - 0.0017290715087938668, - 0.003129184465704738, - 0.01000728849316701, - ], - polydeg=4) - end - - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2=[ - 0.00024871265138964204, - 0.0003370077102132591, - 0.0003370077102131964, - 0.0007231525513793697, - ], - linf=[ - 0.0015813032944647087, - 0.0020494288423820173, - 0.0020494288423824614, - 0.004793821195083758, - ], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_eulergravity_convergence.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2=[ - 1.9537712148648045e-5, - 2.7564396197947587e-5, - 2.7564396197967635e-5, - 5.688838772067586e-5, - ], - linf=[ - 0.00012335710672761735, - 0.00020086268350816283, - 0.00020086268350727465, - 0.0004962155455632278, - ], - tspan=(0.0, 0.1), polydeg=4) - end - - @trixi_testset "elixir_eulergravity_convergence.jl with 1st order RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2=[ - 0.00024871265138959434, - 0.000337007710281087, - 0.0003370077102811394, - 0.0007231525515231289, - ], - linf=[ - 0.0015813032941613958, - 0.002049428843978518, - 0.0020494288439798503, - 0.004793821198143977, - ], - tspan=(0.0, 0.1), - timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!) - end - - @trixi_testset "elixir_eulergravity_convergence.jl with 3rd order RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2=[ - 0.0002487126513894034, - 0.00033700771023049785, - 0.00033700771023048245, - 0.0007231525514158737, - ], - linf=[ - 0.0015813032943847727, - 0.002049428842844314, - 0.0020494288428452023, - 0.004793821195971937, - ], - tspan=(0.0, 0.1), - timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!) - end - - @trixi_testset "elixir_eulergravity_jeans_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_eulergravity_jeans_instability.jl"), - l2=[ - 10733.63378538114, - 13356.780607423452, - 1.6722844879795038e-6, - 26834.076821148774, - ], - linf=[ - 15194.296424901113, - 18881.481685044182, - 6.809726988008751e-6, - 37972.99700513482, - ], - tspan=(0.0, 0.1), - atol=4.0e-6) - end - - @trixi_testset "elixir_eulergravity_jeans_instability.jl with RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_eulergravity_jeans_instability.jl"), - l2=[ - 10734.598193238024, - 13358.217234481384, - 1.911011743371934e-6, - 26836.487841241516, - ], - linf=[ - 15195.661004798487, - 18883.512035906537, - 7.867948710816926e-6, - 37976.408478975296, - ], - tspan=(0.0, 0.1), - atol=4.0e-6, # the background field is reatively large, so this corresponds to our usual atol - parameters=ParametersEulerGravity(background_density = 1.5e7, - gravitational_constant = 6.674e-8, - cfl = 2.4, - resid_tol = 1.0e-4, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_erk52_3Sstar!)) - end - - @trixi_testset "Printing" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_eulergravity_jeans_instability.jl"), - tspan=(0.0, 1.0e-5), - parameters=ParametersEulerGravity(background_density = 1.5e7, - gravitational_constant = 6.674e-8, - cfl = 2.4, - resid_tol = 1.0e-4, - n_iterations_max = 1000, - timestep_gravity = timestep_gravity_erk52_3Sstar!)) - - show(stdout, parameters) - show(stdout, semi) - show(stdout, semi_euler.boundary_conditions) - show(stdout, TrivialCallback()) - show(stdout, equations_euler) - end - - @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_eulergravity_sedov_blast_wave.jl"), - l2=[ - 0.046315994852653024, - 0.0650818006233669, - 0.06508180062336677, - 0.4896707211656037, - ], - linf=[ - 2.3874843337593776, - 4.07876384374792, - 4.07876384374792, - 16.23914384809855, - ], - tspan=(0.0, 0.05), - coverage_override=(maxiters = 2,)) - end - - @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_eulergravity_sedov_blast_wave.jl"), - l2=[ - 0.00289222135995042, - 0.013724813590853825, - 0.013724813590853832, - 0.05822904710548214, - ], - linf=[ - 0.26361780693997594, - 1.3908873830688688, - 1.3908873830688688, - 4.066701303607613, - ], - tspan=(0.0, 0.005), initial_refinement_level=8, - amr_callback=TrivialCallback()) - end + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [0.0001740977055972079, 0.0003369355182519592, 0.0003369355182518708, 0.0006099171220334989], + linf = [0.001079347149189669, 0.0018836938381321389, 0.001883693838132583, 0.003971575376718217]) + end + + @trixi_testset "elixir_euler_convergence.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [1.7187201161597772e-5, 2.678065111772951e-5, 2.678065111783027e-5, 4.952504160091526e-5], + linf = [0.0001501749544159381, 0.00016549482504535362, 0.00016549482504601976, 0.0004372960291432193], + polydeg = 4) + end + + + @trixi_testset "elixir_hypdiff_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), + l2 = [0.003154024896093942, 0.012394432074951856, 0.02185973823794725], + linf = [0.01731850928579215, 0.07843510773347553, 0.11242300176349201]) + end + + @trixi_testset "elixir_hypdiff_convergence.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), + l2 = [0.0002511283012128458, 0.0008808243846610255, 0.0016313343228567005], + linf = [0.0017290715087938668, 0.003129184465704738, 0.01000728849316701], + polydeg = 4) + end + + + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], + linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], + tspan = (0.0, 0.1)) + end + + @trixi_testset "elixir_eulergravity_convergence.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2 = [1.9537712148648045e-5, 2.7564396197947587e-5, 2.7564396197967635e-5, 5.688838772067586e-5], + linf = [0.00012335710672761735, 0.00020086268350816283, 0.00020086268350727465, 0.0004962155455632278], + tspan = (0.0, 0.1), polydeg = 4) + end + + @trixi_testset "elixir_eulergravity_convergence.jl with 1st order RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2 = [0.00024871265138959434, 0.000337007710281087, 0.0003370077102811394, 0.0007231525515231289], + linf = [0.0015813032941613958, 0.002049428843978518, 0.0020494288439798503, 0.004793821198143977], + tspan = (0.0, 0.1), timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!) + end + + @trixi_testset "elixir_eulergravity_convergence.jl with 3rd order RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2 = [0.0002487126513894034, 0.00033700771023049785, 0.00033700771023048245, 0.0007231525514158737], + linf = [0.0015813032943847727, 0.002049428842844314, 0.0020494288428452023, 0.004793821195971937], + tspan = (0.0, 0.1), timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!) + end + + + @trixi_testset "elixir_eulergravity_jeans_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), + l2 = [10733.63378538114, 13356.780607423452, 1.6722844879795038e-6, 26834.076821148774], + linf = [15194.296424901113, 18881.481685044182, 6.809726988008751e-6, 37972.99700513482], + tspan = (0.0, 0.1), + atol = 4.0e-6 # the background field is reatively large, so this corresponds to our usual atol + ) + end + + @trixi_testset "elixir_eulergravity_jeans_instability.jl with RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), + l2 = [10734.598193238024, 13358.217234481384, 1.911011743371934e-6, 26836.487841241516], + linf = [15195.661004798487, 18883.512035906537, 7.867948710816926e-6, 37976.408478975296], + tspan = (0.0, 0.1), + atol = 4.0e-6, # the background field is reatively large, so this corresponds to our usual atol + parameters=ParametersEulerGravity(background_density=1.5e7, + gravitational_constant=6.674e-8, + cfl=2.4, + resid_tol=1.0e-4, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_erk52_3Sstar!)) + end + + @trixi_testset "Printing" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), + tspan = (0.0, 1.0e-5), + parameters=ParametersEulerGravity(background_density=1.5e7, + gravitational_constant=6.674e-8, + cfl=2.4, + resid_tol=1.0e-4, + n_iterations_max=1000, + timestep_gravity=timestep_gravity_erk52_3Sstar!)) + + show(stdout, parameters) + show(stdout, semi) + show(stdout, semi_euler.boundary_conditions) + show(stdout, TrivialCallback()) + show(stdout, equations_euler) + end + + + @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_sedov_blast_wave.jl"), + l2 = [0.046315994852653024, 0.0650818006233669, 0.06508180062336677, 0.4896707211656037], + linf = [2.3874843337593776, 4.07876384374792, 4.07876384374792, 16.23914384809855], + tspan = (0.0, 0.05), + coverage_override = (maxiters=2,)) + end + + @trixi_testset "elixir_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_sedov_blast_wave.jl"), + l2 = [0.00289222135995042, 0.013724813590853825, 0.013724813590853832, 0.05822904710548214], + linf = [0.26361780693997594, 1.3908873830688688, 1.3908873830688688, 4.066701303607613], + tspan = (0.0, 0.005), initial_refinement_level=8, amr_callback=TrivialCallback()) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end #module diff --git a/test/test_parabolic_1d.jl b/test/test_parabolic_1d.jl index e33edc1a68b..1aaf23d576a 100644 --- a/test/test_parabolic_1d.jl +++ b/test/test_parabolic_1d.jl @@ -5,21 +5,24 @@ using Trixi include("test_trixi.jl") + # Start with a clean environment: remove Trixi output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "SemidiscretizationHyperbolicParabolic (1D)" begin - @trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", - "elixir_advection_diffusion.jl"), - initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3, - l2=[8.389498188525518e-06], - linf=[2.847421658558336e-05]) - end + + @trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_advection_diffusion.jl"), + initial_refinement_level = 4, tspan=(0.0, 0.4), polydeg=3, + l2 = [8.389498188525518e-06], + linf = [2.847421658558336e-05] + ) + end + end # Clean up afterwards: delete Trixi output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive = true) +@test_nowarn isdir(outdir) && rm(outdir, recursive=true) end # module diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 5be1d7870ca..b0ac63d4ce9 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -5,302 +5,204 @@ using Trixi include("test_trixi.jl") + # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "SemidiscretizationHyperbolicParabolic (2D)" begin - @trixi_testset "DGMulti 2D rhs_parabolic!" begin - dg = DGMulti(polydeg = 2, element_type = Quad(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralWeakForm()) - mesh = DGMultiMesh(dg, cells_per_dimension = (2, 2)) - - # test with polynomial initial condition x^2 * y - # test if we recover the exact second derivative - initial_condition = (x, t, equations) -> SVector(x[1]^2 * x[2]) - - equations = LinearScalarAdvectionEquation2D(1.0, 1.0) - equations_parabolic = LaplaceDiffusion2D(1.0, equations) - - semi = SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabolic, - initial_condition, dg) - @test_nowarn_mod show(stdout, semi) - @test_nowarn_mod show(stdout, MIME"text/plain"(), semi) - @test_nowarn_mod show(stdout, boundary_condition_do_nothing) - - @test nvariables(semi) == nvariables(equations) - @test Base.ndims(semi) == Base.ndims(mesh) - @test Base.real(semi) == Base.real(dg) - - ode = semidiscretize(semi, (0.0, 0.01)) - u0 = similar(ode.u0) - Trixi.compute_coefficients!(u0, 0.0, semi) - @test u0 ≈ ode.u0 - - # test "do nothing" BC just returns first argument - @test boundary_condition_do_nothing(u0, nothing) == u0 - - @unpack cache, cache_parabolic, equations_parabolic = semi - @unpack gradients = cache_parabolic - for dim in eachindex(gradients) - fill!(gradients[dim], zero(eltype(gradients[dim]))) - end - - t = 0.0 - # pass in `boundary_condition_periodic` to skip boundary flux/integral evaluation - Trixi.calc_gradient!(gradients, ode.u0, t, mesh, equations_parabolic, - boundary_condition_periodic, dg, cache, cache_parabolic) - @unpack x, y, xq, yq = mesh.md - @test getindex.(gradients[1], 1) ≈ 2 * xq .* yq - @test getindex.(gradients[2], 1) ≈ xq .^ 2 - - u_flux = similar.(gradients) - Trixi.calc_viscous_fluxes!(u_flux, ode.u0, gradients, mesh, equations_parabolic, - dg, cache, cache_parabolic) - @test u_flux[1] ≈ gradients[1] - @test u_flux[2] ≈ gradients[2] - - du = similar(ode.u0) - Trixi.calc_divergence!(du, ode.u0, t, u_flux, mesh, equations_parabolic, - boundary_condition_periodic, - dg, semi.solver_parabolic, cache, cache_parabolic) - @test getindex.(du, 1) ≈ 2 * y - end - - @trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_advection_diffusion.jl"), - cells_per_dimension=(4, 4), tspan=(0.0, 0.1), - l2=[0.2485803335154642], - linf=[1.079606969242132]) - end - - @trixi_testset "DGMulti: elixir_advection_diffusion_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_advection_diffusion_periodic.jl"), - cells_per_dimension=(4, 4), tspan=(0.0, 0.1), - l2=[0.03180371984888462], - linf=[0.2136821621370909]) - end - - @trixi_testset "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_advection_diffusion_nonperiodic.jl"), - cells_per_dimension=(4, 4), tspan=(0.0, 0.1), - l2=[0.002123168335604323], - linf=[0.00963640423513712]) - end - - @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_navierstokes_convergence.jl"), - cells_per_dimension=(4, 4), tspan=(0.0, 0.1), - l2=[ - 0.0015355076812510957, - 0.0033843168272696756, - 0.0036531858107443434, - 0.009948436427519214, - ], - linf=[ - 0.005522560467190019, - 0.013425258500730508, - 0.013962115643482154, - 0.027483102120502423, - ]) - end - - @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_navierstokes_convergence_curved.jl"), - cells_per_dimension=(4, 4), tspan=(0.0, 0.1), - l2=[ - 0.004255101916146187, - 0.011118488923215765, - 0.011281831283462686, - 0.03573656447388509, - ], - linf=[ - 0.015071710669706473, - 0.04103132025858458, - 0.03990424085750277, - 0.1309401718598764, - ],) - end - - @trixi_testset "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_navierstokes_lid_driven_cavity.jl"), - cells_per_dimension=(4, 4), tspan=(0.0, 0.5), - l2=[ - 0.00022156125227115747, - 0.028318325921401, - 0.009509168701070296, - 0.028267900513550506, - ], - linf=[ - 0.001562278941298234, - 0.14886653390744856, - 0.0716323565533752, - 0.19472785105241996, - ]) - end - - @trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_advection_diffusion.jl"), - initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5, - l2=[4.0915532997994255e-6], - linf=[2.3040850347877395e-5]) - end - @trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_advection_diffusion_nonperiodic.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - l2=[0.007646800618485118], - linf=[0.10067621050468958]) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - l2=[ - 0.002111672530658797, - 0.0034322351490857846, - 0.0038742528195910416, - 0.012469246082568561, - ], - linf=[ - 0.012006418939223495, - 0.035520871209746126, - 0.024512747492231427, - 0.11191122588756564, - ]) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, - t, - equations), - equations)), - l2=[ - 0.002103629650383915, - 0.003435843933396454, - 0.00386735987813341, - 0.012670355349235728, - ], - linf=[ - 0.012006261793147788, - 0.03550212518982032, - 0.025107947319661185, - 0.11647078036571124, - ]) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - gradient_variables=GradientVariablesEntropy(), - l2=[ - 0.0021403742517389513, - 0.0034258287094908572, - 0.0038915122886898517, - 0.012506862343013842, - ], - linf=[ - 0.012244412004628336, - 0.03507559186162224, - 0.024580892345558894, - 0.11425600758350107, - ]) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - gradient_variables=GradientVariablesEntropy(), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, - t, - equations), - equations)), - l2=[ - 0.0021349737347844907, - 0.0034301388278203033, - 0.0038928324474291572, - 0.012693611436230873, - ], - linf=[ - 0.01224423627586213, - 0.035054066314102905, - 0.025099598504931965, - 0.11795616324751634, - ]) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - volume_integral=VolumeIntegralFluxDifferencing(flux_central), - l2=[ - 0.0021116725306633594, - 0.0034322351490827557, - 0.0038742528196093542, - 0.012469246082526909, - ], - linf=[ - 0.012006418939291663, - 0.035520871209594115, - 0.024512747491801577, - 0.11191122588591007, - ]) - end - - @trixi_testset "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_navierstokes_lid_driven_cavity.jl"), - initial_refinement_level=2, tspan=(0.0, 0.5), - l2=[ - 0.00015144571529699053, - 0.018766076072331623, - 0.007065070765652574, - 0.0208399005734258, - ], - linf=[ - 0.0014523369373669048, - 0.12366779944955864, - 0.05532450997115432, - 0.16099927805328207, - ]) - end - - @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", - "elixir_advection_diffusion_periodic.jl"), - trees_per_dimension=(1, 1), initial_refinement_level=2, - tspan=(0.0, 0.5), - l2=[0.0023754695605828443], - linf=[0.008154128363741964]) - end + @trixi_testset "DGMulti 2D rhs_parabolic!" begin + + dg = DGMulti(polydeg = 2, element_type = Quad(), approximation_type = Polynomial(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralWeakForm()) + mesh = DGMultiMesh(dg, cells_per_dimension=(2, 2)) + + # test with polynomial initial condition x^2 * y + # test if we recover the exact second derivative + initial_condition = (x, t, equations) -> SVector(x[1]^2 * x[2]) + + equations = LinearScalarAdvectionEquation2D(1.0, 1.0) + equations_parabolic = LaplaceDiffusion2D(1.0, equations) + + semi = SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabolic, initial_condition, dg) + @test_nowarn_mod show(stdout, semi) + @test_nowarn_mod show(stdout, MIME"text/plain"(), semi) + @test_nowarn_mod show(stdout, boundary_condition_do_nothing) + + @test nvariables(semi) == nvariables(equations) + @test Base.ndims(semi) == Base.ndims(mesh) + @test Base.real(semi) == Base.real(dg) + + ode = semidiscretize(semi, (0.0, 0.01)) + u0 = similar(ode.u0) + Trixi.compute_coefficients!(u0, 0.0, semi) + @test u0 ≈ ode.u0 + + # test "do nothing" BC just returns first argument + @test boundary_condition_do_nothing(u0, nothing) == u0 + + @unpack cache, cache_parabolic, equations_parabolic = semi + @unpack gradients = cache_parabolic + for dim in eachindex(gradients) + fill!(gradients[dim], zero(eltype(gradients[dim]))) + end + + t = 0.0 + # pass in `boundary_condition_periodic` to skip boundary flux/integral evaluation + Trixi.calc_gradient!(gradients, ode.u0, t, mesh, equations_parabolic, + boundary_condition_periodic, dg, cache, cache_parabolic) + @unpack x, y, xq, yq = mesh.md + @test getindex.(gradients[1], 1) ≈ 2 * xq .* yq + @test getindex.(gradients[2], 1) ≈ xq.^2 + + u_flux = similar.(gradients) + Trixi.calc_viscous_fluxes!(u_flux, ode.u0, gradients, mesh, equations_parabolic, + dg, cache, cache_parabolic) + @test u_flux[1] ≈ gradients[1] + @test u_flux[2] ≈ gradients[2] + + du = similar(ode.u0) + Trixi.calc_divergence!(du, ode.u0, t, u_flux, mesh, equations_parabolic, boundary_condition_periodic, + dg, semi.solver_parabolic, cache, cache_parabolic) + @test getindex.(du, 1) ≈ 2 * y + end + + @trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion.jl"), + cells_per_dimension = (4, 4), tspan=(0.0, 0.1), + l2 = [0.2485803335154642], + linf = [1.079606969242132] + ) + end + + @trixi_testset "DGMulti: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion_periodic.jl"), + cells_per_dimension = (4, 4), tspan=(0.0, 0.1), + l2 = [0.03180371984888462], + linf = [0.2136821621370909] + ) + end + + @trixi_testset "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion_nonperiodic.jl"), + cells_per_dimension = (4, 4), tspan=(0.0, 0.1), + l2 = [0.002123168335604323], + linf = [0.00963640423513712] + ) + end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_convergence.jl"), + cells_per_dimension = (4, 4), tspan=(0.0, 0.1), + l2 = [0.0015355076812510957, 0.0033843168272696756, 0.0036531858107443434, 0.009948436427519214], + linf = [0.005522560467190019, 0.013425258500730508, 0.013962115643482154, 0.027483102120502423] + ) + end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_convergence_curved.jl"), + cells_per_dimension = (4, 4), tspan=(0.0, 0.1), + l2 = [0.004255101916146187, 0.011118488923215765, 0.011281831283462686, 0.03573656447388509], + linf = [0.015071710669706473, 0.04103132025858458, 0.03990424085750277, 0.1309401718598764], + ) + end + + @trixi_testset "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_lid_driven_cavity.jl"), + cells_per_dimension = (4, 4), tspan=(0.0, 0.5), + l2 = [0.00022156125227115747, 0.028318325921401, 0.009509168701070296, 0.028267900513550506], + linf = [0.001562278941298234, 0.14886653390744856, 0.0716323565533752, 0.19472785105241996] + ) + end + + @trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.4), polydeg=5, + l2 = [4.0915532997994255e-6], + linf = [2.3040850347877395e-5] + ) + end + + @trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion_nonperiodic.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + l2 = [0.007646800618485118], + linf = [0.10067621050468958] + ) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + l2 = [0.002111672530658797, 0.0034322351490857846, 0.0038742528195910416, 0.012469246082568561], + linf = [0.012006418939223495, 0.035520871209746126, 0.024512747492231427, 0.11191122588756564] + ) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), + l2 = [0.002103629650383915, 0.003435843933396454, 0.00386735987813341, 0.012670355349235728], + linf = [0.012006261793147788, 0.03550212518982032, 0.025107947319661185, 0.11647078036571124] + ) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), + l2 = [0.0021403742517389513, 0.0034258287094908572, 0.0038915122886898517, 0.012506862343013842], + linf = [0.012244412004628336, 0.03507559186162224, 0.024580892345558894, 0.11425600758350107] + ) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), + l2 = [0.0021349737347844907, 0.0034301388278203033, 0.0038928324474291572, 0.012693611436230873], + linf = [0.01224423627586213, 0.035054066314102905, 0.025099598504931965, 0.11795616324751634] + ) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + volume_integral=VolumeIntegralFluxDifferencing(flux_central), + l2 = [0.0021116725306633594, 0.0034322351490827557, 0.0038742528196093542, 0.012469246082526909], + linf = [0.012006418939291663, 0.035520871209594115, 0.024512747491801577, 0.11191122588591007] + ) + end + + @trixi_testset "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_lid_driven_cavity.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.5), + l2 = [0.00015144571529699053, 0.018766076072331623, 0.007065070765652574, 0.0208399005734258], + linf = [0.0014523369373669048, 0.12366779944955864, 0.05532450997115432, 0.16099927805328207] + ) + end + + @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic.jl"), + trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), + l2 = [0.0023754695605828443], + linf = [0.008154128363741964] + ) + end + + @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic_curved.jl"), + trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), + l2 = [0.012380458938507371], + linf = [0.10860506906472567] + ) + end - @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", - "elixir_advection_diffusion_periodic_curved.jl"), - trees_per_dimension=(1, 1), initial_refinement_level=2, - tspan=(0.0, 0.5), - l2=[0.012380458938507371], - linf=[0.10860506906472567]) - end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive = true) +@test_nowarn isdir(outdir) && rm(outdir, recursive=true) end # module diff --git a/test/test_parabolic_3d.jl b/test/test_parabolic_3d.jl index 62fcc5c950e..1ae5eed44ae 100644 --- a/test/test_parabolic_3d.jl +++ b/test/test_parabolic_3d.jl @@ -7,202 +7,88 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "SemidiscretizationHyperbolicParabolic (3D)" begin - @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", - "elixir_navierstokes_convergence.jl"), - cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1), - l2=[ - 0.0005532847115849239, - 0.000659263490965341, - 0.0007776436127362806, - 0.0006592634909662951, - 0.0038073628897809185, - ], - linf=[ - 0.0017039861523615585, - 0.002628561703560073, - 0.003531057425112172, - 0.0026285617036090336, - 0.015587829540351095, - ]) - end - - @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", - "elixir_navierstokes_convergence_curved.jl"), - cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1), - l2=[ - 0.0014027227251207474, - 0.0021322235533273513, - 0.0027873741447455194, - 0.0024587473070627423, - 0.00997836818019202, - ], - linf=[ - 0.006341750402837576, - 0.010306014252246865, - 0.01520740250924979, - 0.010968264045485565, - 0.047454389831591115, - ]) - end - - @trixi_testset "DGMulti: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", - "elixir_navierstokes_taylor_green_vortex.jl"), - cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.25), - l2=[ - 0.0001825713444029892, - 0.015589736382772248, - 0.015589736382771884, - 0.021943924667273653, - 0.01927370280244222, - ], - linf=[ - 0.0006268463584697681, - 0.03218881662749007, - 0.03218881662697948, - 0.053872495395614256, - 0.05183822000984151, - ]) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - l2=[ - 0.0019582188528512257, - 0.002653449504302844, - 0.002898264205184629, - 0.002653449504302853, - 0.009511572365085706, - ], - linf=[ - 0.013680656759085918, - 0.0356910450154318, - 0.023526343547736236, - 0.035691045015431855, - 0.11482570604041165, - ]) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, - t, - equations), - equations)), - l2=[ - 0.00195468651965362, - 0.0026554367897028506, - 0.002892730402724066, - 0.002655436789702817, - 0.009596351796609566, - ], - linf=[ - 0.013680508110645473, - 0.035673446359424356, - 0.024024936779729028, - 0.03567344635942474, - 0.11839497110809383, - ]) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - gradient_variables=GradientVariablesEntropy(), - l2=[ - 0.0019770444875099307, - 0.0026524750946399327, - 0.00290860030832445, - 0.0026524750946399396, - 0.009509568981439294, - ], - linf=[ - 0.01387936112914212, - 0.03526260609304053, - 0.023554197097368997, - 0.035262606093040896, - 0.11719963716509518, - ]) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - gradient_variables=GradientVariablesEntropy(), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, - t, - equations), - equations)), - l2=[ - 0.001974631423398113, - 0.002654768259143932, - 0.002907031063651286, - 0.002654768259143901, - 0.009587792882971452, - ], - linf=[ - 0.01387919380137137, - 0.035244084526358944, - 0.02398614622061363, - 0.03524408452635828, - 0.12005056512506407, - ]) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (flux differencing)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", - "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), - volume_integral=VolumeIntegralFluxDifferencing(flux_central), - l2=[ - 0.0019582188528180213, - 0.002653449504301736, - 0.0028982642051960006, - 0.0026534495043017384, - 0.009511572364811033, - ], - linf=[ - 0.013680656758949583, - 0.035691045015224444, - 0.02352634354676752, - 0.035691045015223424, - 0.11482570603751441, - ]) - end - - @trixi_testset "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", - "elixir_navierstokes_taylor_green_vortex.jl"), - initial_refinement_level=2, tspan=(0.0, 0.25), - l2=[ - 0.00024173250389635442, - 0.015684268393762454, - 0.01568426839376248, - 0.021991909545192333, - 0.02825413672911425, - ], - linf=[ - 0.0008410587892853094, - 0.04740176181772552, - 0.04740176181772507, - 0.07483494924031157, - 0.150181591534448, - ]) - end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_convergence.jl"), + cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.1), + l2 = [0.0005532847115849239, 0.000659263490965341, 0.0007776436127362806, 0.0006592634909662951, 0.0038073628897809185], + linf = [0.0017039861523615585, 0.002628561703560073, 0.003531057425112172, 0.0026285617036090336, 0.015587829540351095] + ) + end + + @trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_convergence_curved.jl"), + cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.1), + l2 = [0.0014027227251207474, 0.0021322235533273513, 0.0027873741447455194, 0.0024587473070627423, 0.00997836818019202], + linf = [0.006341750402837576, 0.010306014252246865, 0.01520740250924979, 0.010968264045485565, 0.047454389831591115] + ) + end + + @trixi_testset "DGMulti: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_taylor_green_vortex.jl"), + cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.25), + l2 = [0.0001825713444029892, 0.015589736382772248, 0.015589736382771884, 0.021943924667273653, 0.01927370280244222], + linf = [0.0006268463584697681, 0.03218881662749007, 0.03218881662697948, 0.053872495395614256, 0.05183822000984151] + ) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + l2 = [0.0019582188528512257, 0.002653449504302844, 0.002898264205184629, 0.002653449504302853, 0.009511572365085706], + linf = [0.013680656759085918, 0.0356910450154318, 0.023526343547736236, 0.035691045015431855, 0.11482570604041165] + ) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), + l2 = [0.00195468651965362, 0.0026554367897028506, 0.002892730402724066, 0.002655436789702817, 0.009596351796609566], + linf = [0.013680508110645473, 0.035673446359424356, 0.024024936779729028, 0.03567344635942474, 0.11839497110809383] + ) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), + l2 = [0.0019770444875099307, 0.0026524750946399327, 0.00290860030832445, 0.0026524750946399396, 0.009509568981439294], + linf = [0.01387936112914212, 0.03526260609304053, 0.023554197097368997, 0.035262606093040896, 0.11719963716509518] + ) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), + l2 = [0.001974631423398113, 0.002654768259143932, 0.002907031063651286, 0.002654768259143901, 0.009587792882971452], + linf = [0.01387919380137137, 0.035244084526358944, 0.02398614622061363, 0.03524408452635828, 0.12005056512506407] + ) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (flux differencing)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.1), + volume_integral=VolumeIntegralFluxDifferencing(flux_central), + l2 = [0.0019582188528180213, 0.002653449504301736, 0.0028982642051960006, 0.0026534495043017384, 0.009511572364811033], + linf = [0.013680656758949583, 0.035691045015224444, 0.02352634354676752, 0.035691045015223424, 0.11482570603751441] + ) + end + + @trixi_testset "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), + initial_refinement_level = 2, tspan=(0.0, 0.25), + l2 = [0.00024173250389635442, 0.015684268393762454, 0.01568426839376248, 0.021991909545192333, 0.02825413672911425], + linf = [0.0008410587892853094, 0.04740176181772552, 0.04740176181772507, 0.07483494924031157, 0.150181591534448] + ) + end + end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive = true) +@test_nowarn isdir(outdir) && rm(outdir, recursive=true) end # module diff --git a/test/test_performance_specializations_2d.jl b/test/test_performance_specializations_2d.jl index f0100b76cfa..eaf2a66e84f 100644 --- a/test/test_performance_specializations_2d.jl +++ b/test/test_performance_specializations_2d.jl @@ -7,169 +7,169 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) + @testset "Performance specializations 2D" begin - @timed_testset "TreeMesh2D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_shima_etal_turbo, - surface_flux = flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline - end + @timed_testset "TreeMesh2D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - - @timed_testset "TreeMesh2D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline - end + end + + @timed_testset "TreeMesh2D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - - @timed_testset "StructuredMesh2D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension = (1, 1), tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_shima_etal_turbo, - surface_flux = flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline - end + end + + @timed_testset "StructuredMesh2D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension=(1, 1), tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - - @timed_testset "StructuredMesh2D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension = (1, 1), tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline - end + end + + @timed_testset "StructuredMesh2D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension=(1, 1), tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end + end end + # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end #module diff --git a/test/test_performance_specializations_3d.jl b/test/test_performance_specializations_3d.jl index 71c11742212..f767930996a 100644 --- a/test/test_performance_specializations_3d.jl +++ b/test/test_performance_specializations_3d.jl @@ -7,169 +7,169 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) + @testset "Performance specializations 3D" begin - @timed_testset "TreeMesh3D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_shima_etal_turbo, - surface_flux = flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline - end + @timed_testset "TreeMesh3D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - - @timed_testset "TreeMesh3D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline - end + end + + @timed_testset "TreeMesh3D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - - @timed_testset "StructuredMesh3D, flux_shima_etal_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension = (1, 1, 1), tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_shima_etal_turbo, - surface_flux = flux_shima_etal_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline - end + end + + @timed_testset "StructuredMesh3D, flux_shima_etal_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension=(1, 1, 1), tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - - @timed_testset "StructuredMesh3D, flux_ranocha_turbo" begin - trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension = (1, 1, 1), tspan = (0.0, 0.0), polydeg = 3, - volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) - u_ode = copy(sol.u[end]) - du_ode = zero(u_ode) - - # Preserve original memory since it will be `unsafe_wrap`ped and might - # thus otherwise be garbage collected - GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, - semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline - end + end + + @timed_testset "StructuredMesh3D, flux_ranocha_turbo" begin + trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension=(1, 1, 1), tspan=(0.0, 0.0), polydeg=3, + volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + u_ode = copy(sol.u[end]) + du_ode = zero(u_ode) + + # Preserve original memory since it will be `unsafe_wrap`ped and might + # thus otherwise be garbage collected + GC.@preserve u_ode du_ode begin + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!( + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end + end end + # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end #module diff --git a/test/test_special_elixirs.jl b/test/test_special_elixirs.jl index 6d1a1fe6f96..35f5b5cfbf8 100644 --- a/test/test_special_elixirs.jl +++ b/test/test_special_elixirs.jl @@ -10,7 +10,7 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) const EXAMPLES_DIR = pkgdir(Trixi, "examples") @@ -18,315 +18,250 @@ cmd = string(Base.julia_cmd()) coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) @testset "Special elixirs" begin - @testset "Convergence test" begin - if !coverage - @timed_testset "tree_2d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_advection_extended.jl"), - 3, initial_refinement_level = 2) - @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) - end - - @timed_testset "structured_2d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, - "structured_2d_dgsem", - "elixir_advection_extended.jl"), - 3, cells_per_dimension = (5, 9)) - @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) - end - - @timed_testset "structured_2d_dgsem coupled" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, - "structured_2d_dgsem", - "elixir_advection_coupled.jl"), - 3) - @test isapprox(mean_convergence[1][:l2], [4.0], rtol = 0.05) - @test isapprox(mean_convergence[2][:l2], [4.0], rtol = 0.05) - end - - @timed_testset "p4est_2d_dgsem" begin - # Run convergence test on unrefined mesh - no_refine = @cfunction((p4est, which_tree, quadrant)->Cint(0), Cint, - (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, - Ptr{Trixi.p4est_quadrant_t})) - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "p4est_2d_dgsem", - "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - 2, refine_fn_c = no_refine) - @test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol = 0.05) - end - - @timed_testset "structured_3d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, - "structured_3d_dgsem", - "elixir_advection_basic.jl"), - 2, cells_per_dimension = (7, 4, 5)) - @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) - end - - @timed_testset "p4est_3d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "p4est_3d_dgsem", - "elixir_advection_unstructured_curved.jl"), - 2, initial_refinement_level = 0) - @test isapprox(mean_convergence[:l2], [2.7], rtol = 0.05) - end - - @timed_testset "paper_self_gravitating_gas_dynamics" begin - mean_convergence = convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, - "paper_self_gravitating_gas_dynamics", - "elixir_eulergravity_convergence.jl"), - 2, tspan = (0.0, 0.25), - initial_refinement_level = 1) - @test isapprox(mean_convergence[:l2], 4 * ones(4), atol = 0.4) - end - else - # Without coverage, just run simple convergence tests to cover - # the convergence test logic - @test_nowarn_mod convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_advection_basic.jl"), 2, - tspan = (0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_advection_extended.jl"), 2, - initial_refinement_level = 0, - tspan = (0.0, 0.1)) - @test_nowarn_mod convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "structured_2d_dgsem", - "elixir_advection_basic.jl"), 2, - tspan = (0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "structured_2d_dgsem", - "elixir_advection_coupled.jl"), 2, - tspan = (0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, - joinpath(EXAMPLES_DIR, "structured_2d_dgsem", - "elixir_advection_extended.jl"), 2, - cells_per_dimension = (1, 1), - tspan = (0.0, 0.1)) - end + @testset "Convergence test" begin + if !coverage + @timed_testset "tree_2d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), 3, initial_refinement_level=2) + @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) + end + + @timed_testset "structured_2d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_extended.jl"), 3, cells_per_dimension=(5, 9)) + @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) + end + + @timed_testset "structured_2d_dgsem coupled" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_coupled.jl"), 3) + @test isapprox(mean_convergence[1][:l2], [4.0], rtol=0.05) + @test isapprox(mean_convergence[2][:l2], [4.0], rtol=0.05) + end + + @timed_testset "p4est_2d_dgsem" begin + # Run convergence test on unrefined mesh + no_refine = @cfunction((p4est, which_tree, quadrant) -> Cint(0), Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), 2, refine_fn_c=no_refine) + @test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol=0.05) + end + + @timed_testset "structured_3d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_3d_dgsem", "elixir_advection_basic.jl"), 2, cells_per_dimension=(7, 4, 5)) + @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) + end + + @timed_testset "p4est_3d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "p4est_3d_dgsem", "elixir_advection_unstructured_curved.jl"), 2, initial_refinement_level=0) + @test isapprox(mean_convergence[:l2], [2.7], rtol=0.05) + end + + @timed_testset "paper_self_gravitating_gas_dynamics" begin + mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "paper_self_gravitating_gas_dynamics", "elixir_eulergravity_convergence.jl"), 2, tspan=(0.0, 0.25), initial_refinement_level=1) + @test isapprox(mean_convergence[:l2], 4 * ones(4), atol=0.4) + end + else + # Without coverage, just run simple convergence tests to cover + # the convergence test logic + @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_basic.jl"), 2, tspan=(0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), 2, initial_refinement_level=0, tspan=(0.0, 0.1)) + @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_basic.jl"), 2, tspan=(0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_coupled.jl"), 2, tspan=(0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_extended.jl"), 2, cells_per_dimension=(1, 1), tspan=(0.0, 0.1)) end - - @timed_testset "Test linear structure (2D)" begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_advection_extended.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 2) - A, b = linear_structure(semi) - λ = eigvals(Matrix(A)) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_hypdiff_lax_friedrichs.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 2) - A, b = linear_structure(semi) - λ = eigvals(Matrix(A)) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - # check whether the user can modify `b` without changing `A` - x = vec(ode.u0) - Ax = A * x - @. b = 2 * b + x - @test A * x ≈ Ax + end + + + @timed_testset "Test linear structure (2D)" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), + tspan=(0.0, 0.0), initial_refinement_level=2) + A, b = linear_structure(semi) + λ = eigvals(Matrix(A)) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_hypdiff_lax_friedrichs.jl"), + tspan=(0.0, 0.0), initial_refinement_level=2) + A, b = linear_structure(semi) + λ = eigvals(Matrix(A)) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + # check whether the user can modify `b` without changing `A` + x = vec(ode.u0) + Ax = A * x + @. b = 2 * b + x + @test A * x ≈ Ax + end + + + @testset "Test Jacobian of DG (2D)" begin + @timed_testset "Linear advection" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), + tspan=(0.0, 0.0), initial_refinement_level=2) + A, _ = linear_structure(semi) + + J = jacobian_ad_forward(semi) + @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + J = jacobian_fd(semi) + @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) end - @testset "Test Jacobian of DG (2D)" begin - @timed_testset "Linear advection" begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_advection_extended.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 2) - A, _ = linear_structure(semi) - - J = jacobian_ad_forward(semi) - @test Matrix(A) ≈ J - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - J = jacobian_fd(semi) - @test Matrix(A) ≈ J - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - end + @timed_testset "Compressible Euler equations" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_euler_density_wave.jl"), + tspan=(0.0, 0.0), initial_refinement_level=1) - @timed_testset "Compressible Euler equations" begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_euler_density_wave.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 1) - - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - - J = jacobian_fd(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-3 - - # This does not work yet because of the indicators... - @test_skip begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_euler_shockcapturing.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 1) - jacobian_ad_forward(semi) - end - - @timed_testset "DGMulti (weak form)" begin - gamma = 1.4 - equations = CompressibleEulerEquations2D(gamma) - initial_condition = initial_condition_density_wave - - solver = DGMulti(polydeg = 5, element_type = Quad(), - approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralWeakForm()) - - # DGMultiMesh is on [-1, 1]^ndims by default - mesh = DGMultiMesh(solver, cells_per_dimension = (2, 2), - periodicity = (true, true)) - - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, - solver) - - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - end - - @timed_testset "DGMulti (SBP, flux differencing)" begin - gamma = 1.4 - equations = CompressibleEulerEquations2D(gamma) - initial_condition = initial_condition_density_wave - - solver = DGMulti(polydeg = 5, element_type = Quad(), - approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralFluxDifferencing(flux_central)) - - # DGMultiMesh is on [-1, 1]^ndims by default - mesh = DGMultiMesh(solver, cells_per_dimension = (2, 2), - periodicity = (true, true)) - - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, - solver) - - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - end - end + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 - @timed_testset "MHD" begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_2d_dgsem", - "elixir_mhd_alfven_wave.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 0) - @test_nowarn jacobian_ad_forward(semi) - end - end + J = jacobian_fd(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-3 - @timed_testset "Test linear structure (3D)" begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_3d_dgsem", - "elixir_advection_extended.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 1) - A, b = linear_structure(semi) - λ = eigvals(Matrix(A)) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - end + # This does not work yet because of the indicators... + @test_skip begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_euler_shockcapturing.jl"), + tspan=(0.0, 0.0), initial_refinement_level=1) + jacobian_ad_forward(semi) + end + + @timed_testset "DGMulti (weak form)" begin + gamma = 1.4 + equations = CompressibleEulerEquations2D(gamma) + initial_condition = initial_condition_density_wave + + solver = DGMulti(polydeg = 5, element_type = Quad(), approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralWeakForm()) + + # DGMultiMesh is on [-1, 1]^ndims by default + mesh = DGMultiMesh(solver, cells_per_dimension=(2, 2), periodicity=(true, true)) - @timed_testset "Test Jacobian of DG (3D)" begin - trixi_include(@__MODULE__, - joinpath(EXAMPLES_DIR, "tree_3d_dgsem", - "elixir_advection_extended.jl"), - tspan = (0.0, 0.0), initial_refinement_level = 1) - A, _ = linear_structure(semi) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) J = jacobian_ad_forward(semi) - @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + end - J = jacobian_fd(semi) - @test Matrix(A) ≈ J + @timed_testset "DGMulti (SBP, flux differencing)" begin + gamma = 1.4 + equations = CompressibleEulerEquations2D(gamma) + initial_condition = initial_condition_density_wave + + solver = DGMulti(polydeg = 5, element_type = Quad(), approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralFluxDifferencing(flux_central)) + + # DGMultiMesh is on [-1, 1]^ndims by default + mesh = DGMultiMesh(solver, cells_per_dimension=(2, 2), periodicity=(true, true)) + + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + end end - @testset "AD using ForwardDiff" begin - @timed_testset "Euler equations 1D" begin - function entropy_at_final_time(k) # k is the wave number of the initial condition - equations = CompressibleEulerEquations1D(1.4) - mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level = 3, - n_cells_max = 10^4) - solver = DGSEM(3, FluxHLL(min_max_speed_naive), - VolumeIntegralFluxDifferencing(flux_ranocha)) - initial_condition = (x, t, equations) -> begin - rho = 2 + sinpi(k * sum(x)) - v1 = 0.1 - p = 10.0 - return prim2cons(SVector(rho, v1, p), equations) - end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, - solver, - uEltype = typeof(k)) - ode = semidiscretize(semi, (0.0, 1.0)) - summary_callback = SummaryCallback() - analysis_interval = 100 - analysis_callback = AnalysisCallback(semi, interval = analysis_interval) - alive_callback = AliveCallback(analysis_interval = analysis_interval) - callbacks = CallbackSet(summary_callback, - analysis_callback, - alive_callback) - sol = solve(ode, SSPRK43(), callback = callbacks) - Trixi.integrate(entropy, sol.u[end], semi) - end - ForwardDiff.derivative(entropy_at_final_time, 1.0) ≈ -0.4524664696235628 + @timed_testset "MHD" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_mhd_alfven_wave.jl"), + tspan=(0.0, 0.0), initial_refinement_level=0) + @test_nowarn jacobian_ad_forward(semi) + end + end + + + @timed_testset "Test linear structure (3D)" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_3d_dgsem", "elixir_advection_extended.jl"), + tspan=(0.0, 0.0), initial_refinement_level=1) + A, b = linear_structure(semi) + λ = eigvals(Matrix(A)) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + end + + + @timed_testset "Test Jacobian of DG (3D)" begin + trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_3d_dgsem", "elixir_advection_extended.jl"), + tspan=(0.0, 0.0), initial_refinement_level=1) + A, _ = linear_structure(semi) + + J = jacobian_ad_forward(semi) + @test Matrix(A) ≈ J + + J = jacobian_fd(semi) + @test Matrix(A) ≈ J + end + + + @testset "AD using ForwardDiff" begin + @timed_testset "Euler equations 1D" begin + function entropy_at_final_time(k) # k is the wave number of the initial condition + equations = CompressibleEulerEquations1D(1.4) + mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=3, n_cells_max=10^4) + solver = DGSEM(3, FluxHLL(min_max_speed_naive), VolumeIntegralFluxDifferencing(flux_ranocha)) + initial_condition = (x, t, equations) -> begin + rho = 2 + sinpi(k * sum(x)) + v1 = 0.1 + p = 10.0 + return prim2cons(SVector(rho, v1, p), equations) end + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + uEltype=typeof(k)) + ode = semidiscretize(semi, (0.0, 1.0)) + summary_callback = SummaryCallback() + analysis_interval = 100 + analysis_callback = AnalysisCallback(semi, interval=analysis_interval) + alive_callback = AliveCallback(analysis_interval=analysis_interval) + callbacks = CallbackSet( + summary_callback, + analysis_callback, + alive_callback + ) + sol = solve(ode, SSPRK43(), callback=callbacks) + Trixi.integrate(entropy, sol.u[end], semi) + end + ForwardDiff.derivative(entropy_at_final_time, 1.0) ≈ -0.4524664696235628 + end - @timed_testset "Linear advection 2D" begin - function energy_at_final_time(k) # k is the wave number of the initial condition - equations = LinearScalarAdvectionEquation2D(0.2, -0.7) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, - n_cells_max = 10^4) - solver = DGSEM(3, flux_lax_friedrichs) - initial_condition = (x, t, equation) -> begin - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) - return SVector(sinpi(k * sum(x_trans))) - end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, - solver, - uEltype = typeof(k)) - ode = semidiscretize(semi, (0.0, 1.0)) - summary_callback = SummaryCallback() - analysis_interval = 100 - analysis_callback = AnalysisCallback(semi, interval = analysis_interval) - alive_callback = AliveCallback(analysis_interval = analysis_interval) - stepsize_callback = StepsizeCallback(cfl = 1.6) - callbacks = CallbackSet(summary_callback, - analysis_callback, - alive_callback, - stepsize_callback) - sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - save_everystep = false, adaptive = false, dt = 1.0, - callback = callbacks) - Trixi.integrate(energy_total, sol.u[end], semi) - end - ForwardDiff.derivative(energy_at_final_time, 1.0) ≈ 1.4388628342896945e-5 + @timed_testset "Linear advection 2D" begin + function energy_at_final_time(k) # k is the wave number of the initial condition + equations = LinearScalarAdvectionEquation2D(0.2, -0.7) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) + solver = DGSEM(3, flux_lax_friedrichs) + initial_condition = (x, t, equation) -> begin + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) + return SVector(sinpi(k * sum(x_trans))) end + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + uEltype=typeof(k)) + ode = semidiscretize(semi, (0.0, 1.0)) + summary_callback = SummaryCallback() + analysis_interval = 100 + analysis_callback = AnalysisCallback(semi, interval=analysis_interval) + alive_callback = AliveCallback(analysis_interval=analysis_interval) + stepsize_callback = StepsizeCallback(cfl=1.6) + callbacks = CallbackSet( + summary_callback, + analysis_callback, + alive_callback, + stepsize_callback + ) + sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), save_everystep=false, adaptive=false, dt=1.0, callback=callbacks) + Trixi.integrate(energy_total, sol.u[end], semi) + end + ForwardDiff.derivative(energy_at_final_time, 1.0) ≈ 1.4388628342896945e-5 + end - @timed_testset "elixir_euler_ad.jl" begin - @test_trixi_include(joinpath(examples_dir(), "special_elixirs", - "elixir_euler_ad.jl")) - end + @timed_testset "elixir_euler_ad.jl" begin + @test_trixi_include(joinpath(examples_dir(), "special_elixirs", "elixir_euler_ad.jl")) end + end end + # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end #module diff --git a/test/test_structured_1d.jl b/test/test_structured_1d.jl index c9f6fa2fc6f..ec8c7a138d5 100644 --- a/test/test_structured_1d.jl +++ b/test/test_structured_1d.jl @@ -9,68 +9,51 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_1d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "StructuredMesh1D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[6.0388296447998465e-6], - linf=[3.217887726258972e-5]) - end - - @trixi_testset "elixir_advection_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), - l2=[5.641921365468918e-5], - linf=[0.00021049780975179733]) - end - - @trixi_testset "elixir_advection_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_shockcapturing.jl"), - l2=[0.08015029105233593], - linf=[0.610709468736576], - atol=1.0e-5) - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2=[3.67478226e-01, 3.49491179e-01, 8.08910759e-01], - linf=[1.58971947e+00, 1.59812384e+00, 1.94732969e+00], - tspan=(0.0, 0.3)) - end - - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[ - 2.2527950196212703e-8, - 1.8187357193835156e-8, - 7.705669939973104e-8, - ], - linf=[ - 1.6205433861493646e-7, - 1.465427772462391e-7, - 5.372255111879554e-7, - ]) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 3.8099996914101204e-6, - 1.6745575717106341e-6, - 7.732189531480852e-6, - ], - linf=[ - 1.2971473393186272e-5, - 9.270328934274374e-6, - 3.092514399671842e-5, - ]) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [6.0388296447998465e-6], + linf = [3.217887726258972e-5]) + end + + @trixi_testset "elixir_advection_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), + l2 = [5.641921365468918e-5], + linf = [0.00021049780975179733]) + end + + @trixi_testset "elixir_advection_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_shockcapturing.jl"), + l2 = [0.08015029105233593], + linf = [0.610709468736576], + atol = 1.0e-5) + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2 = [3.67478226e-01, 3.49491179e-01, 8.08910759e-01], + linf = [1.58971947e+00, 1.59812384e+00, 1.94732969e+00], + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [2.2527950196212703e-8, 1.8187357193835156e-8, 7.705669939973104e-8], + linf = [1.6205433861493646e-7, 1.465427772462391e-7, 5.372255111879554e-7]) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [3.8099996914101204e-6, 1.6745575717106341e-6, 7.732189531480852e-6], + linf = [1.2971473393186272e-5, 9.270328934274374e-6, 3.092514399671842e-5]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index b7022a42811..16fc72f0a46 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -9,458 +9,279 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "StructuredMesh2D" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_coupled.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"), + l2 = [7.816742843181738e-6, 7.816742843196112e-6], + linf = [6.314906965543265e-5, 6.314906965410039e-5], + coverage_override = (maxiters=10^5,)) + + @testset "analysis_callback(sol) for AnalysisCallbackCoupled" begin + errors = analysis_callback(sol) + @test errors.l2 ≈ [7.816742843181738e-6, 7.816742843196112e-6] rtol=1.0e-4 + @test errors.linf ≈ [6.314906965543265e-5, 6.314906965410039e-5] rtol=1.0e-4 end - - @trixi_testset "elixir_advection_coupled.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"), - l2=[7.816742843181738e-6, 7.816742843196112e-6], - linf=[6.314906965543265e-5, 6.314906965410039e-5], - coverage_override=(maxiters = 10^5,)) - - @testset "analysis_callback(sol) for AnalysisCallbackCoupled" begin - errors = analysis_callback(sol) - @test errors.l2≈[7.816742843181738e-6, 7.816742843196112e-6] rtol=1.0e-4 - @test errors.linf≈[6.314906965543265e-5, 6.314906965410039e-5] rtol=1.0e-4 - end - end - - @trixi_testset "elixir_advection_extended.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[4.220397559713772e-6], - linf=[3.477948874874848e-5]) - end - - @trixi_testset "elixir_advection_extended.jl with polydeg=4" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[5.32996976442737e-7], - linf=[4.1344662966569246e-6], - atol=1e-12, # required to make CI tests pass on macOS - cells_per_dimension=(16, 23), - polydeg=4, - cfl=1.4) - end - - @testset "elixir_advection_rotated.jl" begin - @trixi_testset "elixir_advection_rotated.jl with α = 0.0" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5], - alpha=0.0) - end - - @trixi_testset "elixir_advection_rotated.jl with α = 0.1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors differ only slightly from elixir_advection_basic! - l2=[8.3122750550501e-6], - linf=[6.626802581322089e-5], - alpha=0.1) - end - - @trixi_testset "elixir_advection_rotated.jl with α = 0.5 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5], - alpha=0.5 * pi) - end - end - - @trixi_testset "elixir_advection_parallelogram.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_parallelogram.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_waving_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_waving_flag.jl"), - l2=[0.00018553859900545866], - linf=[0.0016167719118129753]) - end - - @trixi_testset "elixir_advection_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), - l2=[6.8925194184204476e-15], - linf=[9.903189379656396e-14]) - end - - @trixi_testset "elixir_advection_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), - l2=[0.00025552740731641223], - linf=[0.007252625722805939]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[4.219208035582454e-6], - linf=[3.438434404412494e-5]) - end - - @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[0.00016265538265929818], - linf=[0.0015194252169410394], - rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) - elixir_file="elixir_advection_waving_flag.jl", - restart_file="restart_000021.h5") - end - - @trixi_testset "elixir_advection_restart.jl with free stream mesh" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[7.841217436552029e-15], - linf=[1.0857981180834031e-13], - elixir_file="elixir_advection_free_stream.jl", - restart_file="restart_000036.h5") - end - - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[ - 9.321181253186009e-7, - 1.4181210743438511e-6, - 1.4181210743487851e-6, - 4.824553091276693e-6, - ], - linf=[ - 9.577246529612893e-6, - 1.1707525976012434e-5, - 1.1707525976456523e-5, - 4.8869615580926506e-5, - ]) - end - - @testset "elixir_euler_source_terms_rotated.jl" begin - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.0" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_rotated.jl"), - # Expected errors are exactly the same as in elixir_euler_source_terms! - l2=[ - 9.321181253186009e-7, - 1.4181210743438511e-6, - 1.4181210743487851e-6, - 4.824553091276693e-6, - ], - linf=[ - 9.577246529612893e-6, - 1.1707525976012434e-5, - 1.1707525976456523e-5, - 4.8869615580926506e-5, - ], - alpha=0.0) - end - - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_rotated.jl"), - # Expected errors differ only slightly from elixir_euler_source_terms! - l2=[ - 9.321188057029291e-7, - 1.3195106906473365e-6, - 1.510307360354032e-6, - 4.82455408101712e-6, - ], - linf=[ - 9.57723626271445e-6, - 1.0480225511866337e-5, - 1.2817828088262928e-5, - 4.886962393513272e-5, - ], - alpha=0.1) - end - - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.2 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_rotated.jl"), - # Expected errors differ only slightly from elixir_euler_source_terms! - l2=[ - 9.32127973957391e-7, - 8.477824799744325e-7, - 1.8175286311402784e-6, - 4.824562453521076e-6, - ], - linf=[ - 9.576898420737834e-6, - 5.057704352218195e-6, - 1.635260719945464e-5, - 4.886978754825577e-5, - ], - alpha=0.2 * pi) - end - - @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.5 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_rotated.jl"), - # Expected errors are exactly the same as in elixir_euler_source_terms! - l2=[ - 9.321181253186009e-7, - 1.4181210743438511e-6, - 1.4181210743487851e-6, - 4.824553091276693e-6, - ], - linf=[ - 9.577246529612893e-6, - 1.1707525976012434e-5, - 1.1707525976456523e-5, - 4.8869615580926506e-5, - ], - alpha=0.5 * pi) - end - end - - @trixi_testset "elixir_euler_source_terms_parallelogram.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_parallelogram.jl"), - l2=[ - 1.1167802955144833e-5, - 1.0805775514153104e-5, - 1.953188337010932e-5, - 5.5033856574857146e-5, - ], - linf=[ - 8.297006495561199e-5, - 8.663281475951301e-5, - 0.00012264160606778596, - 0.00041818802502024965, - ]) - end - - @trixi_testset "elixir_euler_source_terms_waving_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_waving_flag.jl"), - l2=[ - 2.991891317562739e-5, - 3.6063177168283174e-5, - 2.7082941743640572e-5, - 0.00011414695350996946, - ], - linf=[ - 0.0002437454930492855, - 0.0003438936171968887, - 0.00024217622945688078, - 0.001266380414757684, - ]) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2=[ - 2.063350241405049e-15, - 1.8571016296925367e-14, - 3.1769447886391905e-14, - 1.4104095258528071e-14, - ], - linf=[ - 1.9539925233402755e-14, - 2.9791447087035294e-13, - 6.502853810985698e-13, - 2.7000623958883807e-13, - ], - atol=7.0e-13) - end - - @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - surface_flux=FluxRotated(flux_lax_friedrichs), - l2=[ - 2.063350241405049e-15, - 1.8571016296925367e-14, - 3.1769447886391905e-14, - 1.4104095258528071e-14, - ], - linf=[ - 1.9539925233402755e-14, - 2.9791447087035294e-13, - 6.502853810985698e-13, - 2.7000623958883807e-13, - ], - atol=7.0e-13) + end + + @trixi_testset "elixir_advection_extended.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [4.220397559713772e-6], + linf = [3.477948874874848e-5]) + end + + @trixi_testset "elixir_advection_extended.jl with polydeg=4" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [5.32996976442737e-7], + linf = [4.1344662966569246e-6], + atol = 1e-12, # required to make CI tests pass on macOS + cells_per_dimension = (16, 23), + polydeg = 4, + cfl = 1.4) + end + + @testset "elixir_advection_rotated.jl" begin + @trixi_testset "elixir_advection_rotated.jl with α = 0.0" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5], + alpha = 0.0) end - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 2.259440511901724e-6, - 2.3188881559075347e-6, - 2.3188881559568146e-6, - 6.332786324137878e-6, - ], - linf=[ - 1.4987382622067003e-5, - 1.918201192063762e-5, - 1.918201192019353e-5, - 6.052671713430158e-5, - ]) + @trixi_testset "elixir_advection_rotated.jl with α = 0.1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors differ only slightly from elixir_advection_basic! + l2 = [8.3122750550501e-6], + linf = [6.626802581322089e-5], + alpha = 0.1) end - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.03774907669925568, - 0.02845190575242045, - 0.028262802829412605, - 0.13785915638851698, - ], - linf=[ - 0.3368296929764073, - 0.27644083771519773, - 0.27990039685141377, - 1.1971436487402016, - ], - tspan=(0.0, 0.3)) + @trixi_testset "elixir_advection_rotated.jl with α = 0.5 * pi" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5], + alpha = 0.5 * pi) end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2=[ - 3.69856202e-01, - 2.35242180e-01, - 2.41444928e-01, - 1.28807120e+00, - ], - linf=[ - 1.82786223e+00, - 1.30452904e+00, - 1.40347257e+00, - 6.21791658e+00, - ], - tspan=(0.0, 0.3)) - end - - @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_rayleigh_taylor_instability.jl"), - l2=[ - 0.06365630381017849, - 0.007166887387738937, - 0.002878708825497772, - 0.010247678114070121, - ], - linf=[ - 0.4799214336153155, - 0.024595483032220266, - 0.02059808120543466, - 0.03190756362943725, - ], - cells_per_dimension=(8, 8), - tspan=(0.0, 0.3)) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2=[0.8799744480157664, 0.8535008397034816, 0.7851383019164209], - linf=[1.0771947577311836, 1.9143913544309838, 2.149549109115789], - tspan=(0.0, 0.1), - coverage_override=(polydeg = 3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2=[ - 0.19357947606509474, - 0.47041398037626814, - 0.4704139803762686, - ], - linf=[ - 0.35026352556630114, - 0.8344372248051408, - 0.8344372248051408, - ], - tspan=(0.0, 0.1), - coverage_override=(polydeg = 3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2=[0.04937480811868297, 0.06117033019988596, - 0.060998028674664716, 0.03155145889799417, - 0.2319175391388658, 0.02476283192966346, - 0.024483244374818587, 0.035439957899127385, - 0.0016022148194667542], - linf=[0.24749024430983746, 0.2990608279625713, - 0.3966937932860247, 0.22265033744519683, - 0.9757376320946505, 0.12123736788315098, - 0.12837436699267113, 0.17793825293524734, - 0.03460761690059514], - tspan=(0.0, 0.3)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[0.02890769490562535, 0.0062599448721613205, - 0.005650300017676721, 0.007334415940022972, - 0.00490446035599909, 0.007202284100220619, - 0.007003258686714405, 0.006734267830082687, - 0.004253003868791559], - linf=[0.17517380432288565, 0.06197353710696667, - 0.038494840938641646, 0.05293345499813148, - 0.03817506476831778, 0.042847170999492534, - 0.03761563456810613, 0.048184237474911844, - 0.04114666955364693], - tspan=(0.0, 1.0)) + end + + @trixi_testset "elixir_advection_parallelogram.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_parallelogram.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_waving_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_waving_flag.jl"), + l2 = [0.00018553859900545866], + linf = [0.0016167719118129753]) + end + + @trixi_testset "elixir_advection_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), + l2 = [6.8925194184204476e-15], + linf = [9.903189379656396e-14]) + end + + @trixi_testset "elixir_advection_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), + l2 = [0.00025552740731641223], + linf = [0.007252625722805939]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [4.219208035582454e-6], + linf = [3.438434404412494e-5]) + end + + @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [0.00016265538265929818], + linf = [0.0015194252169410394], + rtol = 5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) + elixir_file="elixir_advection_waving_flag.jl", + restart_file="restart_000021.h5") + end + + @trixi_testset "elixir_advection_restart.jl with free stream mesh" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [7.841217436552029e-15], + linf = [1.0857981180834031e-13], + elixir_file="elixir_advection_free_stream.jl", + restart_file="restart_000036.h5") + end + + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], + linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5]) + end + + @testset "elixir_euler_source_terms_rotated.jl" begin + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.0" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), + # Expected errors are exactly the same as in elixir_euler_source_terms! + l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], + linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], + alpha = 0.0) end - @trixi_testset "elixir_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2=[ - 0.0017285599436729316, - 0.025584610912606776, - 0.028373834961180594, - 6.274146767730866e-5, - ], - linf=[ - 0.012972309788264802, - 0.108283714215621, - 0.15831585777928936, - 0.00018196759554722775, - ], - tspan=(0.0, 0.05)) + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), + # Expected errors differ only slightly from elixir_euler_source_terms! + l2 = [9.321188057029291e-7, 1.3195106906473365e-6, 1.510307360354032e-6, 4.82455408101712e-6], + linf = [9.57723626271445e-6, 1.0480225511866337e-5, 1.2817828088262928e-5, 4.886962393513272e-5], + alpha = 0.1) end - @trixi_testset "elixir_shallowwater_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2=[ - 0.7920927046419308, - 9.92129670988898e-15, - 1.0118635033124588e-14, - 0.7920927046419308, - ], - linf=[ - 2.408429868800133, - 5.5835419986809516e-14, - 5.448874313931364e-14, - 2.4084298688001335, - ], - tspan=(0.0, 0.25)) + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.2 * pi" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), + # Expected errors differ only slightly from elixir_euler_source_terms! + l2 = [9.32127973957391e-7, 8.477824799744325e-7, 1.8175286311402784e-6, 4.824562453521076e-6], + linf = [9.576898420737834e-6, 5.057704352218195e-6, 1.635260719945464e-5, 4.886978754825577e-5], + alpha = 0.2 * pi) end - @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2=[0.0364192725149364, 0.0426667193422069, 0.04261673001449095, - 0.025884071405646924, - 0.16181626564020496, 0.017346518770783536, - 0.017291573200291104, 0.026856206495339655, - 0.0007443858043598808], - linf=[0.25144373906033013, 0.32881947152723745, - 0.3053266801502693, 0.20989755319972866, - 0.9927517314507455, 0.1105172121361323, 0.1257708104676617, - 0.1628334844841588, - 0.02624301627479052]) + @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.5 * pi" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), + # Expected errors are exactly the same as in elixir_euler_source_terms! + l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], + linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], + alpha = 0.5 * pi) end + end + + @trixi_testset "elixir_euler_source_terms_parallelogram.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_parallelogram.jl"), + l2 = [1.1167802955144833e-5, 1.0805775514153104e-5, 1.953188337010932e-5, 5.5033856574857146e-5], + linf = [8.297006495561199e-5, 8.663281475951301e-5, 0.00012264160606778596, 0.00041818802502024965]) + end + + @trixi_testset "elixir_euler_source_terms_waving_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_waving_flag.jl"), + l2 = [2.991891317562739e-5, 3.6063177168283174e-5, 2.7082941743640572e-5, 0.00011414695350996946], + linf = [0.0002437454930492855, 0.0003438936171968887, 0.00024217622945688078, 0.001266380414757684]) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], + linf = [1.9539925233402755e-14, 2.9791447087035294e-13, 6.502853810985698e-13, 2.7000623958883807e-13], + atol = 7.0e-13) + end + + @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + surface_flux=FluxRotated(flux_lax_friedrichs), + l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], + linf = [1.9539925233402755e-14, 2.9791447087035294e-13, 6.502853810985698e-13, 2.7000623958883807e-13], + atol = 7.0e-13) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [2.259440511901724e-6, 2.3188881559075347e-6, 2.3188881559568146e-6, 6.332786324137878e-6], + linf = [1.4987382622067003e-5, 1.918201192063762e-5, 1.918201192019353e-5, 6.052671713430158e-5]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.03774907669925568, 0.02845190575242045, 0.028262802829412605, 0.13785915638851698], + linf = [0.3368296929764073, 0.27644083771519773, 0.27990039685141377, 1.1971436487402016], + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2 = [3.69856202e-01, 2.35242180e-01, 2.41444928e-01, 1.28807120e+00], + linf = [1.82786223e+00, 1.30452904e+00, 1.40347257e+00, 6.21791658e+00], + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_rayleigh_taylor_instability.jl"), + l2 = [0.06365630381017849, 0.007166887387738937, 0.002878708825497772, 0.010247678114070121], + linf = [0.4799214336153155, 0.024595483032220266, 0.02059808120543466, 0.03190756362943725], + cells_per_dimension = (8,8), + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2 = [0.8799744480157664, 0.8535008397034816, 0.7851383019164209], + linf = [1.0771947577311836, 1.9143913544309838, 2.149549109115789], + tspan = (0.0, 0.1), + coverage_override = (polydeg=3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2 = [0.19357947606509474, 0.47041398037626814, 0.4704139803762686], + linf = [0.35026352556630114, 0.8344372248051408, 0.8344372248051408], + tspan = (0.0, 0.1), + coverage_override = (polydeg=3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2 = [0.04937480811868297, 0.06117033019988596, 0.060998028674664716, 0.03155145889799417, + 0.2319175391388658, 0.02476283192966346, 0.024483244374818587, 0.035439957899127385, + 0.0016022148194667542], + linf = [0.24749024430983746, 0.2990608279625713, 0.3966937932860247, 0.22265033744519683, + 0.9757376320946505, 0.12123736788315098, 0.12837436699267113, 0.17793825293524734, + 0.03460761690059514], + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [0.02890769490562535, 0.0062599448721613205, 0.005650300017676721, 0.007334415940022972, + 0.00490446035599909, 0.007202284100220619, 0.007003258686714405, 0.006734267830082687, + 0.004253003868791559], + linf = [0.17517380432288565, 0.06197353710696667, 0.038494840938641646, 0.05293345499813148, + 0.03817506476831778, 0.042847170999492534, 0.03761563456810613, 0.048184237474911844, + 0.04114666955364693], + tspan = (0.0, 1.0)) + end + + @trixi_testset "elixir_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2 = [0.0017285599436729316, 0.025584610912606776, 0.028373834961180594, 6.274146767730866e-5], + linf = [0.012972309788264802, 0.108283714215621, 0.15831585777928936, 0.00018196759554722775], + tspan = (0.0, 0.05)) + end + + @trixi_testset "elixir_shallowwater_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), + l2 = [0.7920927046419308, 9.92129670988898e-15, 1.0118635033124588e-14, 0.7920927046419308], + linf = [2.408429868800133, 5.5835419986809516e-14, 5.448874313931364e-14, 2.4084298688001335], + tspan = (0.0, 0.25)) + end + + @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), + l2 = [0.0364192725149364, 0.0426667193422069, 0.04261673001449095, 0.025884071405646924, + 0.16181626564020496, 0.017346518770783536, 0.017291573200291104, 0.026856206495339655, + 0.0007443858043598808], + linf = [0.25144373906033013, 0.32881947152723745, 0.3053266801502693, 0.20989755319972866, + 0.9927517314507455, 0.1105172121361323, 0.1257708104676617, 0.1628334844841588, + 0.02624301627479052]) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_structured_3d.jl b/test/test_structured_3d.jl index 55634ae0a5f..124c073f2d6 100644 --- a/test/test_structured_3d.jl +++ b/test/test_structured_3d.jl @@ -9,217 +9,128 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_3d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "Structured mesh" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[0.00016263963870641478], - linf=[0.0014537194925779984]) - end - - @trixi_testset "elixir_advection_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), - l2=[1.2908196366970896e-14], - linf=[1.0262901639634947e-12], - atol=8e-13,) - end - - @trixi_testset "elixir_advection_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_nonperiodic_curved.jl"), - l2=[0.0004483892474201268], - linf=[0.009201820593762955]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2=[0.0025903889347585777], - linf=[0.018407576968841655]) - end - - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[ - 0.010385936842224346, - 0.009776048833895767, - 0.00977604883389591, - 0.009776048833895733, - 0.01506687097416608, - ], - linf=[ - 0.03285848350791731, - 0.0321792316408982, - 0.032179231640894645, - 0.032179231640895534, - 0.0655408023333299, - ]) - end - - @trixi_testset "elixir_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2=[ - 2.8815700334367128e-15, - 9.361915278236651e-15, - 9.95614203619935e-15, - 1.6809941842374106e-14, - 1.4815037041566735e-14, - ], - linf=[ - 4.1300296516055823e-14, - 2.0444756998472258e-13, - 1.0133560657266116e-13, - 2.0627943797535409e-13, - 2.8954616482224083e-13, - ]) - end - - @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - surface_flux=FluxRotated(flux_lax_friedrichs), - l2=[ - 2.8815700334367128e-15, - 9.361915278236651e-15, - 9.95614203619935e-15, - 1.6809941842374106e-14, - 1.4815037041566735e-14, - ], - linf=[ - 4.1300296516055823e-14, - 2.0444756998472258e-13, - 1.0133560657266116e-13, - 2.0627943797535409e-13, - 2.8954616482224083e-13, - ]) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic_curved.jl"), - l2=[ - 0.0032940531178824463, - 0.003275679548217804, - 0.0030020672748714084, - 0.00324007343451744, - 0.005721986362580164, - ], - linf=[ - 0.03156756290660656, - 0.033597629023726316, - 0.02095783702361409, - 0.03353574465232212, - 0.05873635745032857, - ]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.011367083018614027, - 0.007022020327490176, - 0.006759580335962235, - 0.006820337637760632, - 0.02912659127566544, - ], - linf=[ - 0.2761764220925329, - 0.20286331858055706, - 0.18763944865434593, - 0.19313636558790004, - 0.707563913727584, - ], - tspan=(0.0, 0.25), - coverage_override=(polydeg = 3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2=[ - 5.30310390e-02, - 2.53167260e-02, - 2.64276438e-02, - 2.52195992e-02, - 3.56830295e-01, - ], - linf=[ - 6.16356950e-01, - 2.50600049e-01, - 2.74796377e-01, - 2.46448217e-01, - 4.77888479e+00, - ], - tspan=(0.0, 0.3)) - end - - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2=[0.009082353036644902, 0.007128360240528109, - 0.006970330025996491, 0.006898850266874514, - 0.03302008823756457, 0.003203389099143526, - 0.003077498677885352, 0.0030740006760477624, - 4.192129696970217e-5], - linf=[0.2883946030582689, 0.25956437344015054, - 0.2614364943543665, 0.24617277938134657, - 1.1370443512475847, 0.1278041831463388, 0.13347391885068594, - 0.1457563463643099, - 0.0021174246048172563], - tspan=(0.0, 0.25)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[0.003015476175153681, 0.00145499403283373, - 0.0009125744757935803, 0.0017703080480578979, - 0.0013046447673965966, 0.0014564863387645508, - 0.0013332311430907598, 0.001647832598455728, - 0.0013647609788548722], - linf=[0.027510637768610846, 0.02797062834945721, - 0.01274249949295704, 0.038940694415543736, - 0.02200825678588325, 0.03167600959583505, - 0.021420957993862344, 0.03386589835999665, - 0.01888303191983353], - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override=(polydeg = 3,)) - end - - @trixi_testset "elixir_mhd_alfven_wave.jl with flux_lax_friedrichs" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[0.003047854479955232, 0.0014572199588782184, - 0.0009093737183251411, 0.0017937548694553895, - 0.0013010437110755424, 0.0014545607744895874, - 0.001328514015121245, 0.001671342529206066, - 0.0013653963058149186], - linf=[0.027719103797310463, 0.027570111789910784, - 0.012561901006903103, 0.03903568568480584, - 0.021311996934554767, 0.03154849824135775, - 0.020996033645485412, 0.03403185137382961, - 0.019488952445771597], - surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override=(polydeg = 3,)) - end - - @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2=[0.009352631220872144, 0.008058649103542618, - 0.008027041293333663, 0.008071417851552725, - 0.034909149665869485, 0.00393019428600812, - 0.0039219074393817, 0.003906321245184237, - 4.197255300781248e-5], - linf=[0.30749098250807516, 0.2679008863509767, - 0.271243087484388, 0.26545396569129537, - 0.9620950892188596, 0.18163281157498123, - 0.15995708312378454, 0.17918221526906408, - 0.015138346608166353], - tspan=(0.0, 0.25), - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override=(polydeg = 3,)) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [0.00016263963870641478], + linf = [0.0014537194925779984]) + end + + @trixi_testset "elixir_advection_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), + l2 = [1.2908196366970896e-14], + linf = [1.0262901639634947e-12], + atol = 8e-13, # required to make tests pass on Windows + ) + end + + @trixi_testset "elixir_advection_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic_curved.jl"), + l2 = [0.0004483892474201268], + linf = [0.009201820593762955]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2 = [0.0025903889347585777], + linf = [0.018407576968841655]) + end + + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2 = [0.010385936842224346, 0.009776048833895767, 0.00977604883389591, 0.009776048833895733, 0.01506687097416608], + linf = [0.03285848350791731, 0.0321792316408982, 0.032179231640894645, 0.032179231640895534, 0.0655408023333299]) + end + + @trixi_testset "elixir_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2 = [2.8815700334367128e-15, 9.361915278236651e-15, 9.95614203619935e-15, 1.6809941842374106e-14, 1.4815037041566735e-14], + linf = [4.1300296516055823e-14, 2.0444756998472258e-13, 1.0133560657266116e-13, 2.0627943797535409e-13, 2.8954616482224083e-13]) + end + + @trixi_testset "elixir_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + surface_flux=FluxRotated(flux_lax_friedrichs), + l2 = [2.8815700334367128e-15, 9.361915278236651e-15, 9.95614203619935e-15, 1.6809941842374106e-14, 1.4815037041566735e-14], + linf = [4.1300296516055823e-14, 2.0444756998472258e-13, 1.0133560657266116e-13, 2.0627943797535409e-13, 2.8954616482224083e-13]) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_curved.jl"), + l2 = [0.0032940531178824463, 0.003275679548217804, 0.0030020672748714084, 0.00324007343451744, 0.005721986362580164], + linf = [0.03156756290660656, 0.033597629023726316, 0.02095783702361409, 0.03353574465232212, 0.05873635745032857]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.011367083018614027, 0.007022020327490176, 0.006759580335962235, 0.006820337637760632, 0.02912659127566544], + linf = [0.2761764220925329, 0.20286331858055706, 0.18763944865434593, 0.19313636558790004, 0.707563913727584], + tspan = (0.0, 0.25), + coverage_override = (polydeg=3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2 = [5.30310390e-02, 2.53167260e-02, 2.64276438e-02, 2.52195992e-02, 3.56830295e-01], + linf = [6.16356950e-01, 2.50600049e-01, 2.74796377e-01, 2.46448217e-01, 4.77888479e+00], + tspan = (0.0, 0.3)) + end + + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2 = [0.009082353036644902, 0.007128360240528109, 0.006970330025996491, 0.006898850266874514, + 0.03302008823756457, 0.003203389099143526, 0.003077498677885352, 0.0030740006760477624, + 4.192129696970217e-5], + linf = [0.2883946030582689, 0.25956437344015054, 0.2614364943543665, 0.24617277938134657, + 1.1370443512475847, 0.1278041831463388, 0.13347391885068594, 0.1457563463643099, + 0.0021174246048172563], + tspan = (0.0, 0.25)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [0.003015476175153681, 0.00145499403283373, 0.0009125744757935803, 0.0017703080480578979, + 0.0013046447673965966, 0.0014564863387645508, 0.0013332311430907598, 0.001647832598455728, + 0.0013647609788548722], + linf = [0.027510637768610846, 0.02797062834945721, 0.01274249949295704, 0.038940694415543736, + 0.02200825678588325, 0.03167600959583505, 0.021420957993862344, 0.03386589835999665, + 0.01888303191983353], + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override = (polydeg=3,)) + end + + @trixi_testset "elixir_mhd_alfven_wave.jl with flux_lax_friedrichs" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [0.003047854479955232, 0.0014572199588782184, 0.0009093737183251411, 0.0017937548694553895, + 0.0013010437110755424, 0.0014545607744895874, 0.001328514015121245, 0.001671342529206066, + 0.0013653963058149186], + linf = [0.027719103797310463, 0.027570111789910784, 0.012561901006903103, 0.03903568568480584, + 0.021311996934554767, 0.03154849824135775, 0.020996033645485412, 0.03403185137382961, + 0.019488952445771597], + surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override = (polydeg=3,)) + end + + @trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), + l2 = [0.009352631220872144, 0.008058649103542618, 0.008027041293333663, 0.008071417851552725, + 0.034909149665869485, 0.00393019428600812, 0.0039219074393817, 0.003906321245184237, + 4.197255300781248e-5], + linf = [0.30749098250807516, 0.2679008863509767, 0.271243087484388, 0.26545396569129537, + 0.9620950892188596, 0.18163281157498123, 0.15995708312378454, 0.17918221526906408, + 0.015138346608166353], + tspan = (0.0, 0.25), + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override = (polydeg=3,)) + end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive = true) +@test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_threaded.jl b/test/test_threaded.jl index 4ad619ccf65..1e750707981 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -7,208 +7,124 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) +Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) @testset "Threaded tests" begin - @testset "TreeMesh" begin - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the serial test! - l2=[7.81674284320524e-6], - linf=[6.314906965243505e-5]) - end - - @trixi_testset "elixir_advection_amr_refine_twice.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_advection_amr_refine_twice.jl"), - l2=[0.00020547512522578292], - linf=[0.007831753383083506]) - end - - @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_advection_amr_coarsen_twice.jl"), - l2=[0.0014321062757891826], - linf=[0.0253454486893413]) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 2.259440511766445e-6, - 2.318888155713922e-6, - 2.3188881557894307e-6, - 6.3327863238858925e-6, - ], - linf=[ - 1.498738264560373e-5, - 1.9182011928187137e-5, - 1.918201192685487e-5, - 6.0526717141407005e-5, - ], - rtol=0.001) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", - "elixir_euler_ec.jl"), - l2=[ - 0.061751715597716854, - 0.05018223615408711, - 0.05018989446443463, - 0.225871559730513, - ], - linf=[ - 0.29347582879608825, - 0.31081249232844693, - 0.3107380389947736, - 1.0540358049885143, - ]) - end + @testset "TreeMesh" begin + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl"), + # Expected errors are exactly the same as in the serial test! + l2 = [7.81674284320524e-6], + linf = [6.314906965243505e-5]) end - @testset "StructuredMesh" begin - @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin - @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", - "elixir_advection_restart.jl"), - l2=[0.00016265538265929818], - linf=[0.0015194252169410394], - rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) - elixir_file="elixir_advection_waving_flag.jl", - restart_file="restart_000021.h5") - end - - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", - "elixir_mhd_ec.jl"), - l2=[0.04937480811868297, 0.06117033019988596, - 0.060998028674664716, 0.03155145889799417, - 0.2319175391388658, 0.02476283192966346, - 0.024483244374818587, 0.035439957899127385, - 0.0016022148194667542], - linf=[0.24749024430983746, 0.2990608279625713, - 0.3966937932860247, 0.22265033744519683, - 0.9757376320946505, 0.12123736788315098, - 0.12837436699267113, 0.17793825293524734, - 0.03460761690059514], - tspan=(0.0, 0.3)) - end + @trixi_testset "elixir_advection_amr_refine_twice.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_refine_twice.jl"), + l2 = [0.00020547512522578292], + linf = [0.007831753383083506]) end - @testset "UnstructuredMesh" begin - @trixi_testset "elixir_acoustics_gauss_wall.jl" begin - @test_trixi_include(joinpath(examples_dir(), "unstructured_2d_dgsem", - "elixir_acoustics_gauss_wall.jl"), - l2=[0.029330394861252995, 0.029345079728907965, - 0.03803795043486467, 0.0, - 7.175152371650832e-16, 1.4350304743301665e-15, - 1.4350304743301665e-15], - linf=[0.36236334472179443, 0.3690785638275256, - 0.8475748723784078, 0.0, - 8.881784197001252e-16, 1.7763568394002505e-15, - 1.7763568394002505e-15], - tspan=(0.0, 5.0)) - end + @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_coarsen_twice.jl"), + l2 = [0.0014321062757891826], + linf = [0.0253454486893413]) end - @testset "P4estMesh" begin - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", - "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2=[ - 0.0034516244508588046, - 0.0023420334036925493, - 0.0024261923964557187, - 0.004731710454271893, - ], - linf=[ - 0.04155789011775046, - 0.024772109862748914, - 0.03759938693042297, - 0.08039824959535657, - ]) - end - - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", - "elixir_eulergravity_convergence.jl"), - l2=[ - 0.00024871265138964204, - 0.0003370077102132591, - 0.0003370077102131964, - 0.0007231525513793697, - ], - linf=[ - 0.0015813032944647087, - 0.0020494288423820173, - 0.0020494288423824614, - 0.004793821195083758, - ], - tspan=(0.0, 0.1)) - end + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], + linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5], + rtol = 0.001) end - @testset "DGMulti" begin - @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_euler_weakform.jl"), - cells_per_dimension=(4, 4), - volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral=SurfaceIntegralWeakForm(flux_ranocha), - approximation_type=SBP(), - l2=[ - 0.006400337855843578, - 0.005303799804137764, - 0.005303799804119745, - 0.013204169007030144, - ], - linf=[ - 0.03798302318566282, - 0.05321027922532284, - 0.05321027922605448, - 0.13392025411839015, - ],) - end - - @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_euler_triangulate_pkg_mesh.jl"), - l2=[ - 2.344080455438114e-6, - 1.8610038753097983e-6, - 2.4095165666095305e-6, - 6.373308158814308e-6, - ], - linf=[ - 2.5099852761334418e-5, - 2.2683684021362893e-5, - 2.6180448559287584e-5, - 5.5752932611508044e-5, - ]) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", - "elixir_euler_fdsbp_periodic.jl"), - l2=[ - 1.3333320340010056e-6, - 2.044834627970641e-6, - 2.044834627855601e-6, - 5.282189803559564e-6, - ], - linf=[ - 2.7000151718858945e-6, - 3.988595028259212e-6, - 3.9885950273710336e-6, - 8.848583042286862e-6, - ]) - end + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], + linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) end + end + + + @testset "StructuredMesh" begin + @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin + @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", "elixir_advection_restart.jl"), + l2 = [0.00016265538265929818], + linf = [0.0015194252169410394], + rtol = 5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) + elixir_file="elixir_advection_waving_flag.jl", + restart_file="restart_000021.h5") + end + + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", "elixir_mhd_ec.jl"), + l2 = [0.04937480811868297, 0.06117033019988596, 0.060998028674664716, 0.03155145889799417, + 0.2319175391388658, 0.02476283192966346, 0.024483244374818587, 0.035439957899127385, + 0.0016022148194667542], + linf = [0.24749024430983746, 0.2990608279625713, 0.3966937932860247, 0.22265033744519683, + 0.9757376320946505, 0.12123736788315098, 0.12837436699267113, 0.17793825293524734, + 0.03460761690059514], + tspan = (0.0, 0.3)) + end + end + + + @testset "UnstructuredMesh" begin + @trixi_testset "elixir_acoustics_gauss_wall.jl" begin + @test_trixi_include(joinpath(examples_dir(), "unstructured_2d_dgsem", "elixir_acoustics_gauss_wall.jl"), + l2 = [0.029330394861252995, 0.029345079728907965, 0.03803795043486467, 0.0, + 7.175152371650832e-16, 1.4350304743301665e-15, 1.4350304743301665e-15], + linf = [0.36236334472179443, 0.3690785638275256, 0.8475748723784078, 0.0, + 8.881784197001252e-16, 1.7763568394002505e-15, 1.7763568394002505e-15], + tspan = (0.0, 5.0)) + end + end + + + @testset "P4estMesh" begin + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], + linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) + end + + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_eulergravity_convergence.jl"), + l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], + linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], + tspan = (0.0, 0.1)) + end + end + + + @testset "DGMulti" begin + @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_weakform.jl"), + cells_per_dimension = (4, 4), + volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral = SurfaceIntegralWeakForm(flux_ranocha), + approximation_type = SBP(), + l2 = [0.006400337855843578, 0.005303799804137764, 0.005303799804119745, 0.013204169007030144], + linf = [0.03798302318566282, 0.05321027922532284, 0.05321027922605448, 0.13392025411839015], + ) + end + + @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_triangulate_pkg_mesh.jl"), + l2 = [2.344080455438114e-6, 1.8610038753097983e-6, 2.4095165666095305e-6, 6.373308158814308e-6], + linf = [2.5099852761334418e-5, 2.2683684021362893e-5, 2.6180448559287584e-5, 5.5752932611508044e-5] + ) + end + + @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_fdsbp_periodic.jl"), + l2 = [1.3333320340010056e-6, 2.044834627970641e-6, 2.044834627855601e-6, 5.282189803559564e-6], + linf = [2.7000151718858945e-6, 3.988595028259212e-6, 3.9885950273710336e-6, 8.848583042286862e-6] + ) + end + end end # Clean up afterwards: delete Trixi.jl output directory -Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive = true) +Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive=true) end # module diff --git a/test/test_tree_1d.jl b/test/test_tree_1d.jl index ce01edf6046..7737a93a15a 100644 --- a/test/test_tree_1d.jl +++ b/test/test_tree_1d.jl @@ -9,295 +9,275 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive = true) +isdir(outdir) && rm(outdir, recursive=true) @testset "TreeMesh1D" begin - # Run basic tests - @testset "Examples 1D" begin - # Linear scalar advection - include("test_tree_1d_advection.jl") - - # Burgers - include("test_tree_1d_burgers.jl") - - # Hyperbolic diffusion - include("test_tree_1d_hypdiff.jl") - - # Compressible Euler - include("test_tree_1d_euler.jl") - - # Compressible Euler Multicomponent - include("test_tree_1d_eulermulti.jl") - - # MHD - include("test_tree_1d_mhd.jl") - - # MHD Multicomponent - include("test_tree_1d_mhdmulti.jl") - - # Compressible Euler with self-gravity - include("test_tree_1d_eulergravity.jl") - - # Shallow water - include("test_tree_1d_shallowwater.jl") - # Two-layer Shallow Water - include("test_tree_1d_shallowwater_twolayer.jl") - - # FDSBP methods on the TreeMesh - include("test_tree_1d_fdsbp.jl") +# Run basic tests +@testset "Examples 1D" begin + # Linear scalar advection + include("test_tree_1d_advection.jl") + + # Burgers + include("test_tree_1d_burgers.jl") + + # Hyperbolic diffusion + include("test_tree_1d_hypdiff.jl") + + # Compressible Euler + include("test_tree_1d_euler.jl") + + # Compressible Euler Multicomponent + include("test_tree_1d_eulermulti.jl") + + # MHD + include("test_tree_1d_mhd.jl") + + # MHD Multicomponent + include("test_tree_1d_mhdmulti.jl") + + # Compressible Euler with self-gravity + include("test_tree_1d_eulergravity.jl") + + # Shallow water + include("test_tree_1d_shallowwater.jl") + # Two-layer Shallow Water + include("test_tree_1d_shallowwater_twolayer.jl") + + # FDSBP methods on the TreeMesh + include("test_tree_1d_fdsbp.jl") +end + +# Coverage test for all initial conditions +@testset "Tests for initial conditions" begin + # Linear scalar advection + @trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [0.00017373554109980247], + linf = [0.0006021275678165239], + maxiters = 1, + initial_condition = Trixi.initial_condition_sin) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [2.441369287653687e-16], + linf = [4.440892098500626e-16], + maxiters = 1, + initial_condition = initial_condition_constant) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [1.9882464973192864e-16], + linf = [1.4432899320127035e-15], + maxiters = 1, + initial_condition = Trixi.initial_condition_linear_x, + boundary_conditions = Trixi.boundary_condition_linear_x, + periodicity=false) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_convergence_test" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [6.1803596620800215e-6], + linf = [2.4858560899509996e-5], + maxiters = 1, + initial_condition = initial_condition_convergence_test, + boundary_conditions = BoundaryConditionDirichlet(initial_condition_convergence_test), + periodicity=false) + end +end + + +@testset "Displaying components 1D" begin + @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) + + # test both short and long printing formats + @test_nowarn show(mesh); println() + @test_nowarn println(mesh) + @test_nowarn display(mesh) + + @test_nowarn show(equations); println() + @test_nowarn println(equations) + @test_nowarn display(equations) + + @test_nowarn show(solver); println() + @test_nowarn println(solver) + @test_nowarn display(solver) + + @test_nowarn show(solver.basis); println() + @test_nowarn println(solver.basis) + @test_nowarn display(solver.basis) + + @test_nowarn show(solver.mortar); println() + @test_nowarn println(solver.mortar) + @test_nowarn display(solver.mortar) + + @test_nowarn show(solver.volume_integral); println() + @test_nowarn println(solver.volume_integral) + @test_nowarn display(solver.volume_integral) + + @test_nowarn show(semi); println() + @test_nowarn println(semi) + @test_nowarn display(semi) + + @test_nowarn show(summary_callback); println() + @test_nowarn println(summary_callback) + @test_nowarn display(summary_callback) + + @test_nowarn show(amr_controller); println() + @test_nowarn println(amr_controller) + @test_nowarn display(amr_controller) + + @test_nowarn show(amr_callback); println() + @test_nowarn println(amr_callback) + @test_nowarn display(amr_callback) + + @test_nowarn show(stepsize_callback); println() + @test_nowarn println(stepsize_callback) + @test_nowarn display(stepsize_callback) + + @test_nowarn show(save_solution); println() + @test_nowarn println(save_solution) + @test_nowarn display(save_solution) + + @test_nowarn show(analysis_callback); println() + @test_nowarn println(analysis_callback) + @test_nowarn display(analysis_callback) + + @test_nowarn show(alive_callback); println() + @test_nowarn println(alive_callback) + @test_nowarn display(alive_callback) + + @test_nowarn println(callbacks) + + # Check whether all output is suppressed if the summary, analysis and alive + # callbacks are set to the TrivialCallback(). Modelled using `@test_nowarn` + # as basis. + let fname = tempname() + try + open(fname, "w") do f + redirect_stderr(f) do + trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + summary_callback=TrivialCallback(), + analysis_callback=TrivialCallback(), + alive_callback=TrivialCallback()) + end + end + output = read(fname, String) + output = replace(output, "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n" => "") + @test isempty(output) + finally + rm(fname, force=true) end + end +end - # Coverage test for all initial conditions - @testset "Tests for initial conditions" begin - # Linear scalar advection - @trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[0.00017373554109980247], - linf=[0.0006021275678165239], - maxiters=1, - initial_condition=Trixi.initial_condition_sin) - end - @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[2.441369287653687e-16], - linf=[4.440892098500626e-16], - maxiters=1, - initial_condition=initial_condition_constant) - end +@testset "Additional tests in 1D" begin + @testset "compressible Euler" begin + eqn = CompressibleEulerEquations1D(1.4) - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[1.9882464973192864e-16], - linf=[1.4432899320127035e-15], - maxiters=1, - initial_condition=Trixi.initial_condition_linear_x, - boundary_conditions=Trixi.boundary_condition_linear_x, - periodicity=false) - end + @test isapprox(Trixi.entropy_thermodynamic([1.0, 2.0, 20.0], eqn), 1.9740810260220094) + @test isapprox(Trixi.entropy_math([1.0, 2.0, 20.0], eqn), -4.935202565055024) + @test isapprox(Trixi.entropy([1.0, 2.0, 20.0], eqn), -4.935202565055024) - @trixi_testset "elixir_advection_extended.jl with initial_condition_convergence_test" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[6.1803596620800215e-6], - linf=[2.4858560899509996e-5], - maxiters=1, - initial_condition=initial_condition_convergence_test, - boundary_conditions=BoundaryConditionDirichlet(initial_condition_convergence_test), - periodicity=false) - end - end + @test isapprox(energy_total([1.0, 2.0, 20.0], eqn), 20.0) + @test isapprox(energy_kinetic([1.0, 2.0, 20.0], eqn), 2.0) + @test isapprox(energy_internal([1.0, 2.0, 20.0], eqn), 18.0) + end +end - @testset "Displaying components 1D" begin - @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) - - # test both short and long printing formats - @test_nowarn show(mesh) - println() - @test_nowarn println(mesh) - @test_nowarn display(mesh) - - @test_nowarn show(equations) - println() - @test_nowarn println(equations) - @test_nowarn display(equations) - - @test_nowarn show(solver) - println() - @test_nowarn println(solver) - @test_nowarn display(solver) - - @test_nowarn show(solver.basis) - println() - @test_nowarn println(solver.basis) - @test_nowarn display(solver.basis) - - @test_nowarn show(solver.mortar) - println() - @test_nowarn println(solver.mortar) - @test_nowarn display(solver.mortar) - - @test_nowarn show(solver.volume_integral) - println() - @test_nowarn println(solver.volume_integral) - @test_nowarn display(solver.volume_integral) - - @test_nowarn show(semi) - println() - @test_nowarn println(semi) - @test_nowarn display(semi) - - @test_nowarn show(summary_callback) - println() - @test_nowarn println(summary_callback) - @test_nowarn display(summary_callback) - - @test_nowarn show(amr_controller) - println() - @test_nowarn println(amr_controller) - @test_nowarn display(amr_controller) - - @test_nowarn show(amr_callback) - println() - @test_nowarn println(amr_callback) - @test_nowarn display(amr_callback) - - @test_nowarn show(stepsize_callback) - println() - @test_nowarn println(stepsize_callback) - @test_nowarn display(stepsize_callback) - - @test_nowarn show(save_solution) - println() - @test_nowarn println(save_solution) - @test_nowarn display(save_solution) - - @test_nowarn show(analysis_callback) - println() - @test_nowarn println(analysis_callback) - @test_nowarn display(analysis_callback) - - @test_nowarn show(alive_callback) - println() - @test_nowarn println(alive_callback) - @test_nowarn display(alive_callback) - - @test_nowarn println(callbacks) - - # Check whether all output is suppressed if the summary, analysis and alive - # callbacks are set to the TrivialCallback(). Modelled using `@test_nowarn` - # as basis. - let fname = tempname() - try - open(fname, "w") do f - redirect_stderr(f) do - trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_extended.jl"), - summary_callback = TrivialCallback(), - analysis_callback = TrivialCallback(), - alive_callback = TrivialCallback()) - end - end - output = read(fname, String) - output = replace(output, - "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n" => "") - @test isempty(output) - finally - rm(fname, force = true) - end - end - end +@trixi_testset "Nonconservative terms in 1D (linear advection)" begin + # Same setup as docs/src/adding_new_equations/nonconservative_advection.md - @testset "Additional tests in 1D" begin - @testset "compressible Euler" begin - eqn = CompressibleEulerEquations1D(1.4) + # Define new physics + using Trixi + using Trixi: AbstractEquations, get_node_vars - @test isapprox(Trixi.entropy_thermodynamic([1.0, 2.0, 20.0], eqn), - 1.9740810260220094) - @test isapprox(Trixi.entropy_math([1.0, 2.0, 20.0], eqn), -4.935202565055024) - @test isapprox(Trixi.entropy([1.0, 2.0, 20.0], eqn), -4.935202565055024) + # Since there is no native support for variable coefficients, we use two + # variables: one for the basic unknown `u` and another one for the coefficient `a` + struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, + 2 #= two variables (u,a) =#} + end - @test isapprox(energy_total([1.0, 2.0, 20.0], eqn), 20.0) - @test isapprox(energy_kinetic([1.0, 2.0, 20.0], eqn), 2.0) - @test isapprox(energy_internal([1.0, 2.0, 20.0], eqn), 18.0) - end - end + Trixi.varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") - @trixi_testset "Nonconservative terms in 1D (linear advection)" begin - # Same setup as docs/src/adding_new_equations/nonconservative_advection.md + Trixi.default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () - # Define new physics - using Trixi - using Trixi: AbstractEquations, get_node_vars - # Since there is no native support for variable coefficients, we use two - # variables: one for the basic unknown `u` and another one for the coefficient `a` - struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# - 2} #= two variables (u,a) =# - end + # The conservative part of the flux is zero + Trixi.flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) - function Trixi.varnames(::typeof(cons2cons), - ::NonconservativeLinearAdvectionEquation) - ("scalar", "advection_velocity") - end + # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation + function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) + _, advection_velocity_ll = u_ll + _, advection_velocity_rr = u_rr - Trixi.default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () + return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) + end - # The conservative part of the flux is zero - function Trixi.flux(u, orientation, - equation::NonconservativeLinearAdvectionEquation) - zero(u) - end - # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation - function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, - ::NonconservativeLinearAdvectionEquation) - _, advection_velocity_ll = u_ll - _, advection_velocity_rr = u_rr + # We use nonconservative terms + Trixi.have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() - return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) - end + function flux_nonconservative(u_mine, u_other, orientation, + equations::NonconservativeLinearAdvectionEquation) + _, advection_velocity = u_mine + scalar, _ = u_other - # We use nonconservative terms - function Trixi.have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) - Trixi.True() - end + return SVector(advection_velocity * scalar, zero(scalar)) + end - function flux_nonconservative(u_mine, u_other, orientation, - equations::NonconservativeLinearAdvectionEquation) - _, advection_velocity = u_mine - scalar, _ = u_other - return SVector(advection_velocity * scalar, zero(scalar)) - end + # Create a simulation setup + using Trixi + using OrdinaryDiffEq - # Create a simulation setup - using Trixi - using OrdinaryDiffEq + equation = NonconservativeLinearAdvectionEquation() - equation = NonconservativeLinearAdvectionEquation() + # You can derive the exact solution for this setup using the method of + # characteristics + function initial_condition_sine(x, t, equation::NonconservativeLinearAdvectionEquation) + x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) + scalar = sin(x0) + advection_velocity = 2 + cos(x[1]) + SVector(scalar, advection_velocity) + end - # You can derive the exact solution for this setup using the method of - # characteristics - function initial_condition_sine(x, t, - equation::NonconservativeLinearAdvectionEquation) - x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) - scalar = sin(x0) - advection_velocity = 2 + cos(x[1]) - SVector(scalar, advection_velocity) - end + # Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries + mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates + initial_refinement_level=4, n_cells_max=10^4) - # Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries - mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level = 4, n_cells_max = 10^4) + # Create a DGSEM solver with polynomials of degree `polydeg` + volume_flux = (flux_central, flux_nonconservative) + surface_flux = (flux_lax_friedrichs, flux_nonconservative) + solver = DGSEM(polydeg=3, surface_flux=surface_flux, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) - # Create a DGSEM solver with polynomials of degree `polydeg` - volume_flux = (flux_central, flux_nonconservative) - surface_flux = (flux_lax_friedrichs, flux_nonconservative) - solver = DGSEM(polydeg = 3, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + # Setup the spatial semidiscretization containing all ingredients + semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) - # Setup the spatial semidiscretization containing all ingredients - semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) + # Create an ODE problem with given time span + tspan = (0.0, 1.0) + ode = semidiscretize(semi, tspan); - # Create an ODE problem with given time span - tspan = (0.0, 1.0) - ode = semidiscretize(semi, tspan) + summary_callback = SummaryCallback() + analysis_callback = AnalysisCallback(semi, interval=50) + callbacks = CallbackSet(summary_callback, analysis_callback); - summary_callback = SummaryCallback() - analysis_callback = AnalysisCallback(semi, interval = 50) - callbacks = CallbackSet(summary_callback, analysis_callback) + # OrdinaryDiffEq's `solve` method evolves the solution in time and executes + # the passed callbacks + sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, + save_everystep=false, callback=callbacks); - # OrdinaryDiffEq's `solve` method evolves the solution in time and executes - # the passed callbacks - sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, - save_everystep = false, callback = callbacks) + @test analysis_callback(sol).l2 ≈ [0.00029609575838969394, 5.5681704039507985e-6] +end - @test analysis_callback(sol).l2 ≈ [0.00029609575838969394, 5.5681704039507985e-6] - end - # Clean up afterwards: delete Trixi.jl output directory - @test_nowarn rm(outdir, recursive = true) +# Clean up afterwards: delete Trixi.jl output directory +@test_nowarn rm(outdir, recursive=true) + end # TreeMesh1D end # module diff --git a/test/test_tree_1d_advection.jl b/test/test_tree_1d_advection.jl index 63c9e777ce1..0cf0f2c1170 100644 --- a/test/test_tree_1d_advection.jl +++ b/test/test_tree_1d_advection.jl @@ -8,31 +8,31 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - l2=[6.0388296447998465e-6], - linf=[3.217887726258972e-5]) - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - l2=[0.3540206249507417], - linf=[0.9999896603382347], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - l2=[4.283508859843524e-6], - linf=[3.235356127918171e-5], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_finite_volume.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"), - l2=[0.011662300515980219], - linf=[0.01647256923710194]) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + l2 = [6.0388296447998465e-6], + linf = [3.217887726258972e-5]) + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + l2 = [0.3540206249507417], + linf = [0.9999896603382347], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), + l2 = [4.283508859843524e-6], + linf = [3.235356127918171e-5], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_finite_volume.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"), + l2 = [0.011662300515980219], + linf = [0.01647256923710194]) + end end end # module diff --git a/test/test_tree_1d_burgers.jl b/test/test_tree_1d_burgers.jl index c8144e3a4fa..8c4cfaa406d 100644 --- a/test/test_tree_1d_burgers.jl +++ b/test/test_tree_1d_burgers.jl @@ -8,29 +8,29 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Inviscid Burgers" begin - @trixi_testset "elixir_burgers_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2=[2.967470209082194e-5], - linf=[0.00016152468882624227]) - end - - @trixi_testset "elixir_burgers_linear_stability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), - l2=[0.5660569881106876], - linf=[1.9352238038313998]) - end - - @trixi_testset "elixir_burgers_shock.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_shock.jl"), - l2=[0.4422505602587537], - linf=[1.0000000000000009]) - end - - @trixi_testset "elixir_burgers_rarefaction.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_rarefaction.jl"), - l2=[0.4038224690923722], - linf=[1.0049201454652736]) - end + @trixi_testset "elixir_burgers_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2 = [2.967470209082194e-5], + linf = [0.00016152468882624227]) + end + + @trixi_testset "elixir_burgers_linear_stability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), + l2 = [0.5660569881106876], + linf = [1.9352238038313998]) + end + + @trixi_testset "elixir_burgers_shock.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_shock.jl"), + l2 = [0.4422505602587537], + linf = [1.0000000000000009]) + end + + @trixi_testset "elixir_burgers_rarefaction.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_rarefaction.jl"), + l2 = [0.4038224690923722], + linf = [1.0049201454652736]) + end end end # module diff --git a/test/test_tree_1d_euler.jl b/test/test_tree_1d_euler.jl index 7fa9432b1fd..1eda4649f65 100644 --- a/test/test_tree_1d_euler.jl +++ b/test/test_tree_1d_euler.jl @@ -8,257 +8,145 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2=[ - 2.2527950196212703e-8, - 1.8187357193835156e-8, - 7.705669939973104e-8, - ], - linf=[ - 1.6205433861493646e-7, - 1.465427772462391e-7, - 5.372255111879554e-7, - ]) - end - - @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2=[ - 0.019355699748523896, - 0.022326984561234497, - 0.02523665947241734, - ], - linf=[ - 0.02895961127645519, - 0.03293442484199227, - 0.04246098278632804, - ]) - end - - @trixi_testset "elixir_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2=[ - 0.0011482554820217855, - 0.00011482554830323462, - 5.741277429325267e-6, - ], - linf=[ - 0.004090978306812376, - 0.0004090978313582294, - 2.045489210189544e-5, - ]) - end - - @trixi_testset "elixir_euler_density_wave.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2=[ - 7.71293052584723e-16, - 1.9712947511091717e-14, - 7.50672833504266e-15, - ], - linf=[ - 3.774758283725532e-15, - 6.733502644351574e-14, - 2.4868995751603507e-14, - ], - initial_condition=initial_condition_constant) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 3.8099996914101204e-6, - 1.6745575717106341e-6, - 7.732189531480852e-6, - ], - linf=[ - 1.2971473393186272e-5, - 9.270328934274374e-6, - 3.092514399671842e-5, - ]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.11821957357197649, - 0.15330089521538678, - 0.4417674632047301, - ], - linf=[ - 0.24280567569982958, - 0.29130548795961936, - 0.8847009003152442, - ]) - end - - @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.07803455838661963, - 0.10032577312032283, - 0.29228156303827935, - ], - linf=[ - 0.2549869853794955, - 0.3376472164661263, - 0.9650477546553962, - ], - maxiters=10, - surface_flux=flux_kennedy_gruber, - volume_flux=flux_kennedy_gruber) - end - - @trixi_testset "elixir_euler_ec.jl with flux_shima_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.07800654460172655, - 0.10030365573277883, - 0.2921481199111959, - ], - linf=[ - 0.25408579350400395, - 0.3388657679031271, - 0.9776486386921928, - ], - maxiters=10, - surface_flux=flux_shima_etal, - volume_flux=flux_shima_etal) - end - - @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.07801923089205756, - 0.10039557434912669, - 0.2922210399923278, - ], - linf=[ - 0.2576521982607225, - 0.3409717926625057, - 0.9772961936567048, - ], - maxiters=10, - surface_flux=flux_chandrashekar, - volume_flux=flux_chandrashekar) - end - - @trixi_testset "elixir_euler_ec.jl with flux_hll" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[0.07852272782240548, 0.10209790867523805, 0.293873048809011], - linf=[ - 0.19244768908604093, - 0.2515941686151897, - 0.7258000837553769, - ], - maxiters=10, - surface_flux=FluxHLL(min_max_speed_naive), - volume_flux=flux_ranocha) - end - - @trixi_testset "elixir_euler_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2=[ - 0.11606096465319675, - 0.15028768943458806, - 0.4328230323046703, - ], - linf=[ - 0.18031710091067965, - 0.2351582421501841, - 0.6776805692092567, - ]) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2=[1.250005061244617, 0.06878411345533507, 0.9264328311018613], - linf=[ - 2.9766770877037168, - 0.16838100902295852, - 2.6655773445485798, - ], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_sedov_blast_wave_pure_fv.jl"), - l2=[1.0735456065491455, 0.07131078703089379, 0.9205739468590453], - linf=[ - 3.4296365168219216, - 0.17635583964559245, - 2.6574584326179505, - ], - # Let this test run longer to cover some lines in flux_hllc - coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl with pressure" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2=[1.297525985166995, 0.07964929522694145, 0.9269991156246368], - linf=[ - 3.1773015255764427, - 0.21331831536493773, - 2.6650170188241047, - ], - shock_indicator_variable=pressure, - cfl=0.2, - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl with density" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2=[1.2798798835860528, 0.07103461242058921, 0.9273792517187003], - linf=[ - 3.1087017048015824, - 0.17734706962928956, - 2.666689753470263, - ], - shock_indicator_variable=density, - cfl=0.2, - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_positivity.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), - l2=[1.6493820253458906, 0.19793887460986834, 0.9783506076125921], - linf=[4.71751203912051, 0.5272411022735763, 2.7426163947635844], - coverage_override=(maxiters = 3,)) - end - - @trixi_testset "elixir_euler_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), - l2=[0.21934822867340323, 0.28131919126002686, 0.554361702716662], - linf=[ - 1.5180897390290355, - 1.3967085956620369, - 2.0663825294019595, - ], - maxiters=30) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), - l2=[0.21814833203212694, 0.2818328665444332, 0.5528379124720818], - linf=[1.5548653877320868, 1.4474018998129738, 2.071919577393772], - maxiters=30) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2=[0.22054468879127423, 0.2828269190680846, 0.5542369885642424], - linf=[ - 1.5623359741479623, - 1.4290121654488288, - 2.1040405133123072, - ], - maxiters=30) - end + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2 = [2.2527950196212703e-8, 1.8187357193835156e-8, 7.705669939973104e-8], + linf = [1.6205433861493646e-7, 1.465427772462391e-7, 5.372255111879554e-7]) + end + + @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), + l2 = [0.019355699748523896, 0.022326984561234497, 0.02523665947241734], + linf = [0.02895961127645519, 0.03293442484199227, 0.04246098278632804]) + end + + @trixi_testset "elixir_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2 = [0.0011482554820217855, 0.00011482554830323462, 5.741277429325267e-6], + linf = [0.004090978306812376, 0.0004090978313582294, 2.045489210189544e-5]) + end + + @trixi_testset "elixir_euler_density_wave.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2 = [7.71293052584723e-16, 1.9712947511091717e-14, 7.50672833504266e-15], + linf = [3.774758283725532e-15, 6.733502644351574e-14, 2.4868995751603507e-14], + initial_condition = initial_condition_constant) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [3.8099996914101204e-6, 1.6745575717106341e-6, 7.732189531480852e-6], + linf = [1.2971473393186272e-5, 9.270328934274374e-6, 3.092514399671842e-5]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.11821957357197649, 0.15330089521538678, 0.4417674632047301], + linf = [0.24280567569982958, 0.29130548795961936, 0.8847009003152442]) + end + + @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.07803455838661963, 0.10032577312032283, 0.29228156303827935], + linf = [0.2549869853794955, 0.3376472164661263, 0.9650477546553962], + maxiters = 10, + surface_flux = flux_kennedy_gruber, + volume_flux = flux_kennedy_gruber) + end + + @trixi_testset "elixir_euler_ec.jl with flux_shima_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.07800654460172655, 0.10030365573277883, 0.2921481199111959], + linf = [0.25408579350400395, 0.3388657679031271, 0.9776486386921928], + maxiters = 10, + surface_flux = flux_shima_etal, + volume_flux = flux_shima_etal) + end + + @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.07801923089205756, 0.10039557434912669, 0.2922210399923278], + linf = [0.2576521982607225, 0.3409717926625057, 0.9772961936567048], + maxiters = 10, + surface_flux = flux_chandrashekar, + volume_flux = flux_chandrashekar) + end + + @trixi_testset "elixir_euler_ec.jl with flux_hll" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.07852272782240548, 0.10209790867523805, 0.293873048809011], + linf = [0.19244768908604093, 0.2515941686151897, 0.7258000837553769], + maxiters = 10, + surface_flux = FluxHLL(min_max_speed_naive), + volume_flux = flux_ranocha) + end + + @trixi_testset "elixir_euler_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), + l2 = [0.11606096465319675, 0.15028768943458806, 0.4328230323046703], + linf = [0.18031710091067965, 0.2351582421501841, 0.6776805692092567]) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2 = [1.250005061244617, 0.06878411345533507, 0.9264328311018613], + linf = [2.9766770877037168, 0.16838100902295852, 2.6655773445485798], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave_pure_fv.jl"), + l2 = [1.0735456065491455, 0.07131078703089379, 0.9205739468590453], + linf = [3.4296365168219216, 0.17635583964559245, 2.6574584326179505], + # Let this test run longer to cover some lines in flux_hllc + coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl with pressure" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2 = [1.297525985166995, 0.07964929522694145, 0.9269991156246368], + linf = [3.1773015255764427, 0.21331831536493773, 2.6650170188241047], + shock_indicator_variable = pressure, + cfl = 0.2, + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl with density" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2 = [1.2798798835860528, 0.07103461242058921, 0.9273792517187003], + linf = [3.1087017048015824, 0.17734706962928956, 2.666689753470263], + shock_indicator_variable = density, + cfl = 0.2, + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_positivity.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), + l2 = [1.6493820253458906, 0.19793887460986834, 0.9783506076125921], + linf = [4.71751203912051, 0.5272411022735763, 2.7426163947635844], + coverage_override = (maxiters=3,)) + end + + @trixi_testset "elixir_euler_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), + l2 = [0.21934822867340323, 0.28131919126002686, 0.554361702716662], + linf = [1.5180897390290355, 1.3967085956620369, 2.0663825294019595], + maxiters = 30) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), + l2 = [0.21814833203212694, 0.2818328665444332, 0.5528379124720818], + linf = [1.5548653877320868, 1.4474018998129738, 2.071919577393772], + maxiters = 30) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2 = [0.22054468879127423, 0.2828269190680846, 0.5542369885642424], + linf = [1.5623359741479623, 1.4290121654488288, 2.1040405133123072], + maxiters = 30) + end end end # module diff --git a/test/test_tree_1d_eulergravity.jl b/test/test_tree_1d_eulergravity.jl index 05af290ba5a..966add0cdf3 100644 --- a/test/test_tree_1d_eulergravity.jl +++ b/test/test_tree_1d_eulergravity.jl @@ -8,19 +8,11 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler with self-gravity" begin - @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2=[ - 0.0002170799126638106, - 0.0002913792848717502, - 0.0006112320856262327, - ], - linf=[ - 0.0004977401033188222, - 0.0013594223337776157, - 0.002041891084400227, - ]) - end + @trixi_testset "elixir_eulergravity_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), + l2 = [0.0002170799126638106, 0.0002913792848717502, 0.0006112320856262327], + linf = [0.0004977401033188222, 0.0013594223337776157, 0.002041891084400227]) + end end end # module diff --git a/test/test_tree_1d_eulermulti.jl b/test/test_tree_1d_eulermulti.jl index daaeb0ace56..e880f98e2d0 100644 --- a/test/test_tree_1d_eulermulti.jl +++ b/test/test_tree_1d_eulermulti.jl @@ -8,80 +8,56 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler Multicomponent" begin - @trixi_testset "elixir_eulermulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), - l2=[0.15330089521538684, 0.4417674632047301, - 0.016888510510282385, 0.03377702102056477, - 0.06755404204112954], - linf=[0.29130548795961864, 0.8847009003152357, - 0.034686525099975274, 0.06937305019995055, - 0.1387461003999011]) - end - @trixi_testset "elixir_eulermulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), - l2=[ - 0.1522380497572071, - 0.43830846465313206, - 0.03907262116499431, - 0.07814524232998862, - ], - linf=[ - 0.24939193075537294, - 0.7139395740052739, - 0.06324208768391237, - 0.12648417536782475, - ]) - end + @trixi_testset "elixir_eulermulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), + l2 = [0.15330089521538684, 0.4417674632047301, 0.016888510510282385, 0.03377702102056477, + 0.06755404204112954], + linf = [0.29130548795961864, 0.8847009003152357, 0.034686525099975274, 0.06937305019995055, + 0.1387461003999011]) + end + + @trixi_testset "elixir_eulermulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), + l2 = [0.1522380497572071, 0.43830846465313206, 0.03907262116499431, 0.07814524232998862], + linf = [0.24939193075537294, 0.7139395740052739, 0.06324208768391237, 0.12648417536782475]) + end + + @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), + l2 = [8.575236038539227e-5, 0.00016387804318585358, 1.9412699303977585e-5, 3.882539860795517e-5], + linf = [0.00030593277277124464, 0.0006244803933350696, 7.253121435135679e-5, 0.00014506242870271358]) + end + + @trixi_testset "elixir_eulermulti_convergence_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2 = [1.8983933794407234e-5, 6.207744299844731e-5, 1.5466205761868047e-6, 3.0932411523736094e-6, + 6.186482304747219e-6, 1.2372964609494437e-5], + linf = [0.00012014372605895218, 0.0003313207215800418, 6.50836791016296e-6, 1.301673582032592e-5, + 2.603347164065184e-5, 5.206694328130368e-5]) + end + + @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2 = [1.888450477353845e-5, 5.4910600482795386e-5, 9.426737161533622e-7, 1.8853474323067245e-6, + 3.770694864613449e-6, 7.541389729226898e-6], + linf = [0.00011622351152063004, 0.0003079221967086099, 3.2177423254231563e-6, 6.435484650846313e-6, + 1.2870969301692625e-5, 2.574193860338525e-5], + volume_flux = flux_chandrashekar) + end + + @trixi_testset "elixir_eulermulti_two_interacting_blast_waves.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_two_interacting_blast_waves.jl"), + l2 = [1.288867611915533, 82.71335258388848, 0.00350680272313187, 0.013698784353152794, + 0.019179518517518084], + linf = [29.6413044707026, 1322.5844802186496, 0.09191919374782143, 0.31092970966717925, + 0.4417989757182038], + tspan = (0.0, 0.0001)) + end - @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), - l2=[ - 8.575236038539227e-5, - 0.00016387804318585358, - 1.9412699303977585e-5, - 3.882539860795517e-5, - ], - linf=[ - 0.00030593277277124464, - 0.0006244803933350696, - 7.253121435135679e-5, - 0.00014506242870271358, - ]) - end - @trixi_testset "elixir_eulermulti_convergence_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2=[1.8983933794407234e-5, 6.207744299844731e-5, - 1.5466205761868047e-6, 3.0932411523736094e-6, - 6.186482304747219e-6, 1.2372964609494437e-5], - linf=[0.00012014372605895218, 0.0003313207215800418, - 6.50836791016296e-6, 1.301673582032592e-5, - 2.603347164065184e-5, 5.206694328130368e-5]) - end +end - @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2=[1.888450477353845e-5, 5.4910600482795386e-5, - 9.426737161533622e-7, 1.8853474323067245e-6, - 3.770694864613449e-6, 7.541389729226898e-6], - linf=[0.00011622351152063004, 0.0003079221967086099, - 3.2177423254231563e-6, 6.435484650846313e-6, - 1.2870969301692625e-5, 2.574193860338525e-5], - volume_flux=flux_chandrashekar) - end - @trixi_testset "elixir_eulermulti_two_interacting_blast_waves.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_eulermulti_two_interacting_blast_waves.jl"), - l2=[1.288867611915533, 82.71335258388848, 0.00350680272313187, - 0.013698784353152794, - 0.019179518517518084], - linf=[29.6413044707026, 1322.5844802186496, 0.09191919374782143, - 0.31092970966717925, - 0.4417989757182038], - tspan=(0.0, 0.0001)) - end -end end # module diff --git a/test/test_tree_1d_fdsbp.jl b/test/test_tree_1d_fdsbp.jl index 847608add5e..a966b3836f3 100644 --- a/test/test_tree_1d_fdsbp.jl +++ b/test/test_tree_1d_fdsbp.jl @@ -8,114 +8,79 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_fdsbp") @testset "Inviscid Burgers" begin - @trixi_testset "elixir_burgers_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2=[8.316190308678742e-7], - linf=[7.1087263324720595e-6], - tspan=(0.0, 0.5)) + @trixi_testset "elixir_burgers_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2 = [8.316190308678742e-7], + linf = [7.1087263324720595e-6], + tspan = (0.0, 0.5)) - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 end + end - # same tolerances as above since the methods should be identical (up to - # machine precision) - @trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2=[8.316190308678742e-7], - linf=[7.1087263324720595e-6], - tspan=(0.0, 0.5), - solver=DG(D_upw, nothing, - SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)), - VolumeIntegralUpwind(flux_splitting))) - end + # same tolerances as above since the methods should be identical (up to + # machine precision) + @trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2 = [8.316190308678742e-7], + linf = [7.1087263324720595e-6], + tspan = (0.0, 0.5), + solver = DG(D_upw, nothing, SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)), VolumeIntegralUpwind(flux_splitting))) + end - @trixi_testset "elixir_burgers_linear_stability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), - l2=[0.9999995642691271], - linf=[1.824702804788453], - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_burgers_linear_stability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), + l2 = [0.9999995642691271], + linf = [1.824702804788453], + tspan = (0.0, 0.25)) + end end @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 4.1370344463620254e-6, - 4.297052451817826e-6, - 9.857382045003056e-6, - ], - linf=[ - 1.675305070092392e-5, - 1.3448113863834266e-5, - 3.8185336878271414e-5, - ], - tspan=(0.0, 0.5)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [4.1370344463620254e-6, 4.297052451817826e-6, 9.857382045003056e-6], + linf = [1.675305070092392e-5, 1.3448113863834266e-5, 3.8185336878271414e-5], + tspan = (0.0, 0.5)) - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 end + end - @trixi_testset "elixir_euler_convergence.jl with splitting_vanleer_haenel" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 3.413790589105506e-6, - 4.243957977156001e-6, - 8.667369423676437e-6, - ], - linf=[ - 1.4228079689537765e-5, - 1.3249887941046978e-5, - 3.201552933251861e-5, - ], - tspan=(0.0, 0.5), - flux_splitting=splitting_vanleer_haenel) - end + @trixi_testset "elixir_euler_convergence.jl with splitting_vanleer_haenel" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [3.413790589105506e-6, 4.243957977156001e-6, 8.667369423676437e-6], + linf = [1.4228079689537765e-5, 1.3249887941046978e-5, 3.201552933251861e-5], + tspan = (0.0, 0.5), + flux_splitting = splitting_vanleer_haenel) + end - @trixi_testset "elixir_euler_convergence.jl with VolumeIntegralStrongForm" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 8.6126767518378e-6, - 7.670897071480729e-6, - 1.4972772284191368e-5, - ], - linf=[ - 6.707982777909294e-5, - 3.487256699541419e-5, - 0.00010170331350556339, - ], - tspan=(0.0, 0.5), - solver=DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), - VolumeIntegralStrongForm())) - end + @trixi_testset "elixir_euler_convergence.jl with VolumeIntegralStrongForm" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [8.6126767518378e-6, 7.670897071480729e-6, 1.4972772284191368e-5], + linf = [6.707982777909294e-5, 3.487256699541419e-5, 0.00010170331350556339], + tspan = (0.0, 0.5), + solver = DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), VolumeIntegralStrongForm())) + end - @trixi_testset "elixir_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2=[ - 1.5894925236031034e-5, - 9.428412101106044e-6, - 0.0008986477358789918, - ], - linf=[ - 4.969438024382544e-5, - 2.393091812063694e-5, - 0.003271817388146303, - ], - tspan=(0.0, 0.005), abstol=1.0e-9, reltol=1.0e-9) - end + @trixi_testset "elixir_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2 = [1.5894925236031034e-5, 9.428412101106044e-6, 0.0008986477358789918], + linf = [4.969438024382544e-5, 2.393091812063694e-5, 0.003271817388146303], + tspan = (0.0, 0.005), abstol = 1.0e-9, reltol = 1.0e-9) + end end end # module diff --git a/test/test_tree_1d_hypdiff.jl b/test/test_tree_1d_hypdiff.jl index a9332943a6b..560f77b2a13 100644 --- a/test/test_tree_1d_hypdiff.jl +++ b/test/test_tree_1d_hypdiff.jl @@ -8,20 +8,20 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Hyperbolic diffusion" begin - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2=[1.3655114954641076e-7, 1.0200345025539218e-6], - linf=[7.173286515893551e-7, 4.507116363683394e-6], - atol=2.5e-13) - end - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2=[3.0130941075207524e-12, 2.6240829677090014e-12], - linf=[4.054534485931072e-12, 3.8826719617190975e-12], - atol=2.5e-13) - end + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2 = [1.3655114954641076e-7, 1.0200345025539218e-6], + linf = [7.173286515893551e-7, 4.507116363683394e-6], + atol = 2.5e-13) + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2 = [3.0130941075207524e-12, 2.6240829677090014e-12], + linf = [4.054534485931072e-12, 3.8826719617190975e-12], + atol = 2.5e-13) + end end end # module diff --git a/test/test_tree_1d_mhd.jl b/test/test_tree_1d_mhd.jl index 0ab19b7c487..e3a0cda3250 100644 --- a/test/test_tree_1d_mhd.jl +++ b/test/test_tree_1d_mhd.jl @@ -8,235 +8,73 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "MHD" begin - @trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[ - 1.440611823425164e-15, - 1.1373567770134494e-14, - 3.024482376149653e-15, - 2.0553143516814395e-15, - 3.9938347410210535e-14, - 3.984545392098788e-16, - 2.4782402104201577e-15, - 1.551737464879987e-15, - ], - linf=[ - 1.9984014443252818e-15, - 1.3405943022348765e-14, - 3.3584246494910985e-15, - 3.164135620181696e-15, - 7.815970093361102e-14, - 8.881784197001252e-16, - 2.886579864025407e-15, - 2.942091015256665e-15, - ], - initial_condition=initial_condition_constant, - tspan=(0.0, 1.0)) - end - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[ - 1.0375628983659061e-5, - 6.571144191446236e-7, - 3.5833569836289104e-5, - 3.583356983615859e-5, - 5.084863194951084e-6, - 1.1963224165731992e-16, - 3.598916927583752e-5, - 3.598916927594727e-5, - ], - linf=[ - 2.614095879338585e-5, - 9.577266731216823e-7, - 0.00012406198007461344, - 0.00012406198007509917, - 1.5066209528846741e-5, - 2.220446049250313e-16, - 0.00012658678753942054, - 0.00012658678753908748, - ]) - end + @trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [1.440611823425164e-15, 1.1373567770134494e-14, 3.024482376149653e-15, 2.0553143516814395e-15, 3.9938347410210535e-14, 3.984545392098788e-16, 2.4782402104201577e-15, 1.551737464879987e-15], + linf = [1.9984014443252818e-15, 1.3405943022348765e-14, 3.3584246494910985e-15, 3.164135620181696e-15, 7.815970093361102e-14, 8.881784197001252e-16, 2.886579864025407e-15, 2.942091015256665e-15], + initial_condition = initial_condition_constant, + tspan = (0.0,1.0)) + end - @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[ - 1.4396053943470756e-5, - 1.1211016739165248e-5, - 3.577870687983967e-5, - 3.577870687982181e-5, - 1.967962220860377e-6, - 1.1963224165731992e-16, - 3.583562899483433e-5, - 3.583562899486565e-5, - ], - linf=[ - 5.830577969345718e-5, - 3.280495696370357e-5, - 0.00012279619948236953, - 0.00012279619948227238, - 6.978806516122482e-6, - 2.220446049250313e-16, - 0.00012564003648959932, - 0.00012564003648994626, - ], - volume_flux=flux_derigs_etal) - end + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [1.0375628983659061e-5, 6.571144191446236e-7, 3.5833569836289104e-5, 3.583356983615859e-5, 5.084863194951084e-6, 1.1963224165731992e-16, 3.598916927583752e-5, 3.598916927594727e-5], + linf = [2.614095879338585e-5, 9.577266731216823e-7, 0.00012406198007461344, 0.00012406198007509917, 1.5066209528846741e-5, 2.220446049250313e-16, 0.00012658678753942054, 0.00012658678753908748]) + end - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2=[ - 0.05815183849746399, - 0.08166807325621023, - 0.054659228513541165, - 0.054659228513541165, - 0.15578125987042743, - 4.130462730494e-17, - 0.05465258887150046, - 0.05465258887150046, - ], - linf=[ - 0.12165312668363826, - 0.1901920742264952, - 0.10059813883022554, - 0.10059813883022554, - 0.44079257431070706, - 1.1102230246251565e-16, - 0.10528911365809579, - 0.10528911365809579, - ]) - end + @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [1.4396053943470756e-5, 1.1211016739165248e-5, 3.577870687983967e-5, 3.577870687982181e-5, 1.967962220860377e-6, 1.1963224165731992e-16, 3.583562899483433e-5, 3.583562899486565e-5], + linf = [5.830577969345718e-5, 3.280495696370357e-5, 0.00012279619948236953, 0.00012279619948227238, 6.978806516122482e-6, 2.220446049250313e-16, 0.00012564003648959932, 0.00012564003648994626], + volume_flux = flux_derigs_etal) + end - @trixi_testset "elixir_mhd_briowu_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_briowu_shock_tube.jl"), - l2=[ - 0.17477712356961989, - 0.19489623595086944, - 0.3596546157640463, - 0.0, - 0.3723215736814466, - 1.2060075775846403e-15, - 0.36276754492568164, - 0.0, - ], - linf=[ - 0.5797109945880677, - 0.4372991899547103, - 1.0906536287185835, - 0.0, - 1.0526758874956808, - 5.995204332975845e-15, - 1.5122922036932964, - 0.0, - ], - coverage_override=(maxiters = 6,)) - end + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2 = [0.05815183849746399, 0.08166807325621023, 0.054659228513541165, 0.054659228513541165, 0.15578125987042743, 4.130462730494e-17, 0.05465258887150046, 0.05465258887150046], + linf = [0.12165312668363826, 0.1901920742264952, 0.10059813883022554, 0.10059813883022554, 0.44079257431070706, 1.1102230246251565e-16, 0.10528911365809579, 0.10528911365809579]) + end - @trixi_testset "elixir_mhd_torrilhon_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"), - l2=[ - 0.45700904847931145, - 0.4792535936512035, - 0.340651203521865, - 0.4478034694296928, - 0.9204708961093411, - 1.3216517820475193e-16, - 0.28897419402047725, - 0.25521206483145126, - ], - linf=[ - 1.2185238171352286, - 0.8913202384963431, - 0.8488793580488431, - 0.973083603686, - 1.660723397705417, - 2.220446049250313e-16, - 0.6874726847741993, - 0.65536978110274, - ]) - end + @trixi_testset "elixir_mhd_briowu_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_briowu_shock_tube.jl"), + l2 = [0.17477712356961989, 0.19489623595086944, 0.3596546157640463, 0.0, 0.3723215736814466, 1.2060075775846403e-15, 0.36276754492568164, 0.0], + linf = [0.5797109945880677, 0.4372991899547103, 1.0906536287185835, 0.0, 1.0526758874956808, 5.995204332975845e-15, 1.5122922036932964, 0.0], + coverage_override = (maxiters=6,)) + end - @trixi_testset "elixir_mhd_ryujones_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ryujones_shock_tube.jl"), - l2=[ - 0.23469781891518154, - 0.3916675299696121, - 0.08245195301016353, - 0.1745346945706147, - 0.9606363432904367, - 6.608258910237605e-17, - 0.21542929107153735, - 0.10705457908737925, - ], - linf=[ - 0.6447951791685409, - 0.9461857095377463, - 0.35074627554617605, - 0.8515177411529542, - 2.0770652030507053, - 1.1102230246251565e-16, - 0.49670855513788204, - 0.24830199967863564, - ], - tspan=(0.0, 0.1)) - end + @trixi_testset "elixir_mhd_torrilhon_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"), + l2 = [0.45700904847931145, 0.4792535936512035, 0.340651203521865, 0.4478034694296928, 0.9204708961093411, 1.3216517820475193e-16, 0.28897419402047725, 0.25521206483145126], + linf = [1.2185238171352286, 0.8913202384963431, 0.8488793580488431, 0.973083603686, 1.660723397705417, 2.220446049250313e-16, 0.6874726847741993, 0.65536978110274]) + end - @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - l2=[ - 1.01126210e+00, - 8.27157902e+00, - 1.30882545e+00, - 0.00000000e+00, - 5.21930435e+01, - 6.56538824e-16, - 1.01022340e+00, - 0.00000000e+00, - ], - linf=[ - 2.87172004e+00, - 2.26438057e+01, - 4.16672442e+00, - 0.00000000e+00, - 1.35152372e+02, - 3.44169138e-15, - 2.83556069e+00, - 0.00000000e+00, - ], - tspan=(0.0, 0.2), - coverage_override=(maxiters = 6,)) - end + @trixi_testset "elixir_mhd_ryujones_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ryujones_shock_tube.jl"), + l2 = [0.23469781891518154, 0.3916675299696121, 0.08245195301016353, 0.1745346945706147, 0.9606363432904367, 6.608258910237605e-17, 0.21542929107153735, 0.10705457908737925], + linf = [0.6447951791685409, 0.9461857095377463, 0.35074627554617605, 0.8515177411529542, 2.0770652030507053, 1.1102230246251565e-16, 0.49670855513788204, 0.24830199967863564], + tspan = (0.0, 0.1)) + end - @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin - # Include this elixir to make `initial_condition_shu_osher_shock_tube_flipped` available, which is used below - trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - tspan = (0.0, 0.0)) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - l2=[ - 1.01539817e+00, - 8.29625810e+00, - 1.29548008e+00, - 0.00000000e+00, - 5.23565514e+01, - 3.18641825e-16, - 1.00485291e+00, - 0.00000000e+00, - ], - linf=[ - 2.92876280e+00, - 2.28341581e+01, - 4.11643561e+00, - 0.00000000e+00, - 1.36966213e+02, - 1.55431223e-15, - 2.80548864e+00, - 0.00000000e+00, - ], - initial_condition=initial_condition_shu_osher_shock_tube_flipped, - boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped), - tspan=(0.0, 0.2), - coverage_override=(maxiters = 6,)) - end + @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), + l2 = [1.01126210e+00, 8.27157902e+00, 1.30882545e+00, 0.00000000e+00, 5.21930435e+01, 6.56538824e-16, 1.01022340e+00, 0.00000000e+00], + linf = [2.87172004e+00, 2.26438057e+01, 4.16672442e+00, 0.00000000e+00, 1.35152372e+02, 3.44169138e-15, 2.83556069e+00, 0.00000000e+00], + tspan = (0.0, 0.2), + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin + # Include this elixir to make `initial_condition_shu_osher_shock_tube_flipped` available, which is used below + trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), tspan=(0.0, 0.0)) + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), + l2 = [1.01539817e+00, 8.29625810e+00, 1.29548008e+00, 0.00000000e+00, 5.23565514e+01, 3.18641825e-16, 1.00485291e+00, 0.00000000e+00], + linf = [2.92876280e+00, 2.28341581e+01, 4.11643561e+00, 0.00000000e+00, 1.36966213e+02, 1.55431223e-15, 2.80548864e+00, 0.00000000e+00], + initial_condition = initial_condition_shu_osher_shock_tube_flipped, + boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped), + tspan = (0.0, 0.2), + coverage_override = (maxiters=6,)) + end end end # module diff --git a/test/test_tree_1d_mhdmulti.jl b/test/test_tree_1d_mhdmulti.jl index 61d85b58f7e..5214ed26d38 100644 --- a/test/test_tree_1d_mhdmulti.jl +++ b/test/test_tree_1d_mhdmulti.jl @@ -8,77 +8,59 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "MHD Multicomponent" begin - @trixi_testset "elixir_mhdmulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2=[0.08166807325620999, 0.054659228513541616, - 0.054659228513541616, 0.15578125987042812, - 4.130462730494e-17, 0.054652588871500665, - 0.054652588871500665, 0.008307405499637766, - 0.01661481099927553, 0.03322962199855106], - linf=[0.19019207422649645, 0.10059813883022888, - 0.10059813883022888, 0.4407925743107146, - 1.1102230246251565e-16, 0.10528911365809623, - 0.10528911365809623, 0.01737901809766182, - 0.03475803619532364, 0.06951607239064728]) - end - @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2=[0.08151404166186461, 0.054640238302693274, - 0.054640238302693274, 0.15536125426328573, - 4.130462730494e-17, 0.054665489963920275, - 0.054665489963920275, 0.008308349501359825, - 0.01661669900271965, 0.0332333980054393], - linf=[0.1824424257860952, 0.09734687137001484, - 0.09734687137001484, 0.4243089502087325, - 1.1102230246251565e-16, 0.09558639591092555, - 0.09558639591092555, 0.017364773041550624, - 0.03472954608310125, 0.0694590921662025], - volume_flux=flux_derigs_etal) - end + @trixi_testset "elixir_mhdmulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2 = [0.08166807325620999, 0.054659228513541616, 0.054659228513541616, 0.15578125987042812, + 4.130462730494e-17, 0.054652588871500665, 0.054652588871500665, 0.008307405499637766, + 0.01661481099927553, 0.03322962199855106], + linf = [0.19019207422649645, 0.10059813883022888, 0.10059813883022888, 0.4407925743107146, + 1.1102230246251565e-16, 0.10528911365809623, 0.10528911365809623, 0.01737901809766182, + 0.03475803619532364, 0.06951607239064728]) + end - @trixi_testset "elixir_mhdmulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), - l2=[0.07994082660130175, 0.053940174914031976, - 0.053940174914031976, 0.15165513559250643, - 4.130462730494e-17, 0.05363207135290325, - 0.05363207135290325, 0.008258265884659555, - 0.01651653176931911, 0.03303306353863822], - linf=[0.14101014428198477, 0.07762441749521025, - 0.07762441749521025, 0.3381334453289866, - 1.1102230246251565e-16, 0.07003646400675223, - 0.07003646400675223, 0.014962483760600165, - 0.02992496752120033, 0.05984993504240066]) - end + @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2 = [0.08151404166186461, 0.054640238302693274, 0.054640238302693274, 0.15536125426328573, + 4.130462730494e-17, 0.054665489963920275, 0.054665489963920275, 0.008308349501359825, + 0.01661669900271965, 0.0332333980054393], + linf = [0.1824424257860952, 0.09734687137001484, 0.09734687137001484, 0.4243089502087325, + 1.1102230246251565e-16, 0.09558639591092555, 0.09558639591092555, 0.017364773041550624, + 0.03472954608310125, 0.0694590921662025], + volume_flux = flux_derigs_etal) + end - @trixi_testset "elixir_mhdmulti_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), - l2=[1.7337265267786785e-5, 0.00032976971029271364, - 0.0003297697102926479, 6.194071694759044e-5, - 4.130462730494001e-17, 0.00032596825025664136, - 0.0003259682502567132, 2.5467510126885455e-5, - 5.093502025377091e-5, 0.00010187004050754182], - linf=[3.877554303711845e-5, 0.0012437848638874956, - 0.0012437848638876898, 0.00016431262020277781, - 1.1102230246251565e-16, 0.0012443734922607112, - 0.001244373492260704, 5.691007974162332e-5, - 0.00011382015948324664, 0.00022764031896649328]) + @trixi_testset "elixir_mhdmulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), + l2 = [0.07994082660130175, 0.053940174914031976, 0.053940174914031976, 0.15165513559250643, + 4.130462730494e-17, 0.05363207135290325, 0.05363207135290325, 0.008258265884659555, + 0.01651653176931911, 0.03303306353863822], + linf = [0.14101014428198477, 0.07762441749521025, 0.07762441749521025, 0.3381334453289866, + 1.1102230246251565e-16, 0.07003646400675223, 0.07003646400675223, 0.014962483760600165, + 0.02992496752120033, 0.05984993504240066]) + end + + @trixi_testset "elixir_mhdmulti_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), + l2 = [1.7337265267786785e-5, 0.00032976971029271364, 0.0003297697102926479, 6.194071694759044e-5, + 4.130462730494001e-17, 0.00032596825025664136, 0.0003259682502567132, 2.5467510126885455e-5, + 5.093502025377091e-5, 0.00010187004050754182], + linf = [3.877554303711845e-5, 0.0012437848638874956, 0.0012437848638876898, 0.00016431262020277781, + 1.1102230246251565e-16, 0.0012443734922607112, 0.001244373492260704, 5.691007974162332e-5, + 0.00011382015948324664, 0.00022764031896649328]) end - @trixi_testset "elixir_mhdmulti_briowu_shock_tube.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_briowu_shock_tube.jl"), - l2=[0.1877830835572639, 0.3455841730726793, 0.0, - 0.35413123388836687, - 8.745556626531982e-16, 0.3629920109231055, 0.0, - 0.05329005553971236, - 0.10658011107942472], - linf=[0.4288187627971754, 1.0386547815614993, 0.0, - 0.9541678878162702, - 5.773159728050814e-15, 1.4595119339458051, 0.0, - 0.18201910908829552, - 0.36403821817659104], - coverage_override=(maxiters = 6,)) + @trixi_testset "elixir_mhdmulti_briowu_shock_tube.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_briowu_shock_tube.jl"), + l2 = [0.1877830835572639, 0.3455841730726793, 0.0, 0.35413123388836687, + 8.745556626531982e-16, 0.3629920109231055, 0.0, 0.05329005553971236, + 0.10658011107942472], + linf = [0.4288187627971754, 1.0386547815614993, 0.0, 0.9541678878162702, + 5.773159728050814e-15, 1.4595119339458051, 0.0, 0.18201910908829552, + 0.36403821817659104], + coverage_override = (maxiters=6,)) end + end end # module diff --git a/test/test_tree_1d_shallowwater.jl b/test/test_tree_1d_shallowwater.jl index b972def59dc..c66260c0018 100644 --- a/test/test_tree_1d_shallowwater.jl +++ b/test/test_tree_1d_shallowwater.jl @@ -8,169 +8,86 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Shallow Water" begin - @trixi_testset "elixir_shallowwater_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2=[0.244729018751225, 0.8583565222389505, 0.07330427577586297], - linf=[ - 2.1635021283528504, - 3.8717508164234453, - 1.7711213427919539, - ], - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), + l2 = [0.244729018751225, 0.8583565222389505, 0.07330427577586297], + linf = [2.1635021283528504, 3.8717508164234453, 1.7711213427919539], + tspan = (0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_ec.jl with initial_condition_weak_blast_wave" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2=[ - 0.39464782107209717, - 2.03880864210846, - 4.1623084150546725e-10, - ], - linf=[ - 0.778905801278281, - 3.2409883402608273, - 7.419800190922032e-10, - ], - initial_condition=initial_condition_weak_blast_wave, - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_ec.jl with initial_condition_weak_blast_wave" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), + l2 = [0.39464782107209717, 2.03880864210846, 4.1623084150546725e-10], + linf = [0.778905801278281, 3.2409883402608273, 7.419800190922032e-10], + initial_condition=initial_condition_weak_blast_wave, + tspan = (0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2=[ - 0.10416666834254829, - 1.4352935256803184e-14, - 0.10416666834254838, - ], - linf=[1.9999999999999996, 3.248036646353028e-14, 2.0], - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), + l2 = [0.10416666834254829, 1.4352935256803184e-14, 0.10416666834254838], + linf = [1.9999999999999996, 3.248036646353028e-14, 2.0], + tspan = (0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2=[ - 0.10416666834254835, - 1.1891029971551825e-14, - 0.10416666834254838, - ], - linf=[2.0000000000000018, 2.4019608337954543e-14, 2.0], - surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, - hydrostatic_reconstruction_audusse_etal), - flux_nonconservative_audusse_etal), - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), + l2 = [0.10416666834254835, 1.1891029971551825e-14, 0.10416666834254838], + linf = [2.0000000000000018, 2.4019608337954543e-14, 2.0], + surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), + tspan = (0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2=[ - 0.0022363707373868713, - 0.01576799981934617, - 4.436491725585346e-5, - ], - linf=[ - 0.00893601803417754, - 0.05939797350246456, - 9.098379777405796e-5, - ], - tspan=(0.0, 0.025)) - end + @trixi_testset "elixir_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2 = [0.0022363707373868713, 0.01576799981934617, 4.436491725585346e-5], + linf = [0.00893601803417754, 0.05939797350246456, 9.098379777405796e-5], + tspan = (0.0, 0.025)) + end - @trixi_testset "elixir_shallowwater_source_terms.jl with flux_hll" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2=[ - 0.0022758146627220154, - 0.015864082886204556, - 4.436491725585346e-5, - ], - linf=[ - 0.008457195427364006, - 0.057201667446161064, - 9.098379777405796e-5, - ], - tspan=(0.0, 0.025), - surface_flux=(FluxHLL(min_max_speed_naive), - flux_nonconservative_fjordholm_etal)) - end + @trixi_testset "elixir_shallowwater_source_terms.jl with flux_hll" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2 = [0.0022758146627220154, 0.015864082886204556, 4.436491725585346e-5], + linf = [0.008457195427364006, 0.057201667446161064, 9.098379777405796e-5], + tspan = (0.0, 0.025), surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal)) + end - @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_source_terms_dirichlet.jl"), - l2=[ - 0.0022851099219788917, - 0.01560453773635554, - 4.43649172558535e-5, - ], - linf=[ - 0.008934615705174398, - 0.059403169140869405, - 9.098379777405796e-5, - ], - tspan=(0.0, 0.025)) - end + @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), + l2 = [0.0022851099219788917, 0.01560453773635554, 4.43649172558535e-5], + linf = [0.008934615705174398, 0.059403169140869405, 9.098379777405796e-5], + tspan = (0.0, 0.025)) + end - @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_source_terms_dirichlet.jl"), - l2=[ - 0.0022956052733432287, - 0.015540053559855601, - 4.43649172558535e-5, - ], - linf=[ - 0.008460440313118323, - 0.05720939349382359, - 9.098379777405796e-5, - ], - surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), - hydrostatic_reconstruction_audusse_etal), - flux_nonconservative_audusse_etal), - tspan=(0.0, 0.025)) - end + @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), + l2 = [0.0022956052733432287, 0.015540053559855601, 4.43649172558535e-5], + linf = [0.008460440313118323, 0.05720939349382359, 9.098379777405796e-5], + surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), + tspan = (0.0, 0.025)) + end - @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with Dirichlet boundary" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_well_balanced_nonperiodic.jl"), - l2=[ - 1.725964362045055e-8, - 5.0427180314307505e-16, - 1.7259643530442137e-8, - ], - linf=[ - 3.844551077492042e-8, - 3.469453422316143e-15, - 3.844551077492042e-8, - ], - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with Dirichlet boundary" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_nonperiodic.jl"), + l2 = [1.725964362045055e-8, 5.0427180314307505e-16, 1.7259643530442137e-8], + linf = [3.844551077492042e-8, 3.469453422316143e-15, 3.844551077492042e-8], + tspan = (0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_well_balanced_nonperiodic.jl"), - l2=[ - 1.7259643614361866e-8, - 3.5519018243195145e-16, - 1.7259643530442137e-8, - ], - linf=[ - 3.844551010878661e-8, - 9.846474508971374e-16, - 3.844551077492042e-8, - ], - tspan=(0.0, 0.25), - boundary_condition=boundary_condition_slip_wall) - end + @trixi_testset "elixir_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_nonperiodic.jl"), + l2 = [1.7259643614361866e-8, 3.5519018243195145e-16, 1.7259643530442137e-8], + linf = [3.844551010878661e-8, 9.846474508971374e-16, 3.844551077492042e-8], + tspan = (0.0, 0.25), + boundary_condition = boundary_condition_slip_wall) + end - @trixi_testset "elixir_shallowwater_shock_capturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_shock_capturing.jl"), - l2=[0.07424140641160326, 0.2148642632748155, 0.0372579849000542], - linf=[ - 1.1209754279344226, - 1.3230788645853582, - 0.8646939843534251, - ], - tspan=(0.0, 0.05)) - end + @trixi_testset "elixir_shallowwater_shock_capturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_shock_capturing.jl"), + l2 = [0.07424140641160326, 0.2148642632748155, 0.0372579849000542], + linf = [1.1209754279344226, 1.3230788645853582, 0.8646939843534251], + tspan = (0.0, 0.05)) + end end end # module diff --git a/test/test_tree_1d_shallowwater_twolayer.jl b/test/test_tree_1d_shallowwater_twolayer.jl index ac5ae500afc..0d8a83806f9 100644 --- a/test/test_tree_1d_shallowwater_twolayer.jl +++ b/test/test_tree_1d_shallowwater_twolayer.jl @@ -8,61 +8,43 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Shallow Water Two layer" begin - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_twolayer_convergence.jl"), - l2=[0.0050681532925156945, 0.002089013899370176, - 0.005105544300292713, 0.002526442122643306, - 0.0004744186597732706], - linf=[0.022256679217306008, 0.005421833004652266, - 0.02233993939574197, 0.008765261497422516, - 0.0008992474511784199], - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), + l2 = [0.0050681532925156945, 0.002089013899370176, 0.005105544300292713, 0.002526442122643306, + 0.0004744186597732706], + linf = [0.022256679217306008, 0.005421833004652266, 0.02233993939574197, 0.008765261497422516, + 0.0008992474511784199], + tspan = (0.0, 0.25)) + end + + @trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), + l2 = [0.0027681377074701345, 0.0018007543202559165, 0.0028036917433720576, + 0.0013980358596935737, 0.0004744186597732706], + linf = [0.005699303919826093, 0.006432952918256296, 0.0058507082844360125, 0.002717615543961216, + 0.0008992474511784199], + surface_flux=(flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), + tspan = (0.0, 0.25)) + end + + @trixi_testset "elixir_shallowwater_twolayer_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_well_balanced.jl"), + l2 = [8.949288784402005e-16, 4.0636427176237915e-17, 0.001002881985401548, + 2.133351105037203e-16, 0.0010028819854016578], + linf = [2.6229018956769323e-15, 1.878451903240623e-16, 0.005119880996670156, + 8.003199803957679e-16, 0.005119880996670666], + tspan = (0.0, 0.25)) + end + + @trixi_testset "elixir_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_dam_break.jl"), + l2 = [0.10010269243463918, 0.5668733957648654, 0.08759617327649398, + 0.4538443183566172, 0.013638618139749523], + linf = [0.5854202777756559, 2.1278930820498934, 0.5193686074348809, 1.8071213168086229, 0.5], + surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), + tspan = (0.0, 0.25)) + end - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_twolayer_convergence.jl"), - l2=[0.0027681377074701345, 0.0018007543202559165, - 0.0028036917433720576, - 0.0013980358596935737, 0.0004744186597732706], - linf=[0.005699303919826093, 0.006432952918256296, - 0.0058507082844360125, 0.002717615543961216, - 0.0008992474511784199], - surface_flux=(flux_es_fjordholm_etal, - flux_nonconservative_fjordholm_etal), - tspan=(0.0, 0.25)) - end - - @trixi_testset "elixir_shallowwater_twolayer_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_twolayer_well_balanced.jl"), - l2=[8.949288784402005e-16, 4.0636427176237915e-17, - 0.001002881985401548, - 2.133351105037203e-16, 0.0010028819854016578], - linf=[2.6229018956769323e-15, 1.878451903240623e-16, - 0.005119880996670156, - 8.003199803957679e-16, 0.005119880996670666], - tspan=(0.0, 0.25)) - end - - @trixi_testset "elixir_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_shallowwater_twolayer_dam_break.jl"), - l2=[0.10010269243463918, 0.5668733957648654, - 0.08759617327649398, - 0.4538443183566172, 0.013638618139749523], - linf=[ - 0.5854202777756559, - 2.1278930820498934, - 0.5193686074348809, - 1.8071213168086229, - 0.5, - ], - surface_flux=(flux_lax_friedrichs, - flux_nonconservative_fjordholm_etal), - tspan=(0.0, 0.25)) - end end end # module diff --git a/test/test_tree_2d_acoustics.jl b/test/test_tree_2d_acoustics.jl index 1bb3521569b..b443573e3ac 100644 --- a/test/test_tree_2d_acoustics.jl +++ b/test/test_tree_2d_acoustics.jl @@ -8,95 +8,40 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Acoustic Perturbation" begin - @trixi_testset "elixir_acoustics_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_convergence.jl"), - l2=[ - 0.0019921138796370834, - 0.002090394698052287, - 0.0006091925854593805, - 0.0, - 0.0, - 0.0, - 0.0, - ], - linf=[ - 0.00769282588065634, - 0.008276649669227254, - 0.004196479023954813, - 0.0, - 0.0, - 0.0, - 0.0, - ]) - end - - @trixi_testset "elixir_acoustics_gauss.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss.jl"), - l2=[ - 0.08005276517890283, - 0.08005276517890268, - 0.4187202920734123, - 0.0, - 0.0, - 0.0, - 0.0, - ], - linf=[ - 0.17261097190220992, - 0.17261097190220973, - 1.13601894068238, - 0.0, - 0.0, - 0.0, - 0.0, - ]) - end - - @trixi_testset "elixir_acoustics_gaussian_source.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gaussian_source.jl"), - l2=[ - 0.004296394903650806, - 0.004241280404758938, - 0.006269684906035964, - 0.0, - 0.0, - 0.0, - 0.0, - ], - linf=[ - 0.03970270697049378, - 0.04151096349298151, - 0.0640019829058819, - 0.0, - 0.0, - 0.0, - 0.0, - ]) - end - - @trixi_testset "elixir_acoustics_gauss_wall.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss_wall.jl"), - l2=[0.019419398248465843, 0.019510701017551826, - 0.04818246051887614, - 7.382060834820337e-17, 0.0, 1.4764121669640674e-16, - 1.4764121669640674e-16], - linf=[0.18193631937316496, 0.1877464607867628, - 1.0355388011792845, - 2.220446049250313e-16, 0.0, 4.440892098500626e-16, - 4.440892098500626e-16]) - end - - @trixi_testset "elixir_acoustics_monopole.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_monopole.jl"), - l2=[0.006816790293009947, 0.0065068948357351625, - 0.008724512056168938, - 0.0009894398191644543, 0.0, 7.144325530679576e-17, - 7.144325530679576e-17], - linf=[1.000633375007386, 0.5599788929862504, 0.5738432957070382, - 0.015590137026938428, 0.0, 2.220446049250313e-16, - 2.220446049250313e-16], - maxiters=50) - end + @trixi_testset "elixir_acoustics_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_convergence.jl"), + l2 = [0.0019921138796370834, 0.002090394698052287, 0.0006091925854593805, 0.0, 0.0, 0.0, 0.0], + linf = [0.00769282588065634, 0.008276649669227254, 0.004196479023954813, 0.0, 0.0, 0.0, 0.0]) + end + + @trixi_testset "elixir_acoustics_gauss.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss.jl"), + l2 = [0.08005276517890283, 0.08005276517890268, 0.4187202920734123, 0.0, 0.0, 0.0, 0.0], + linf = [0.17261097190220992, 0.17261097190220973, 1.13601894068238, 0.0, 0.0, 0.0, 0.0]) + end + + @trixi_testset "elixir_acoustics_gaussian_source.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gaussian_source.jl"), + l2 = [0.004296394903650806, 0.004241280404758938, 0.006269684906035964, 0.0, 0.0, 0.0, 0.0], + linf = [0.03970270697049378, 0.04151096349298151, 0.0640019829058819, 0.0, 0.0, 0.0, 0.0]) + end + + @trixi_testset "elixir_acoustics_gauss_wall.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss_wall.jl"), + l2 = [0.019419398248465843, 0.019510701017551826, 0.04818246051887614, + 7.382060834820337e-17, 0.0, 1.4764121669640674e-16, 1.4764121669640674e-16], + linf = [0.18193631937316496, 0.1877464607867628, 1.0355388011792845, + 2.220446049250313e-16, 0.0, 4.440892098500626e-16, 4.440892098500626e-16]) + end + + @trixi_testset "elixir_acoustics_monopole.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_monopole.jl"), + l2 = [0.006816790293009947, 0.0065068948357351625, 0.008724512056168938, + 0.0009894398191644543, 0.0, 7.144325530679576e-17, 7.144325530679576e-17], + linf = [1.000633375007386, 0.5599788929862504, 0.5738432957070382, + 0.015590137026938428, 0.0, 2.220446049250313e-16, 2.220446049250313e-16], + maxiters=50) + end end -end # module +end # module \ No newline at end of file diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index 3fae6efaa42..973d0caf88b 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -8,199 +8,198 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5], - # Let the small basic test run to the end - coverage_override=(maxiters = 10^5,)) - end - - @trixi_testset "elixir_advection_extended.jl with polydeg=1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[0.02134571266411136], - linf=[0.04347734797775926], - polydeg=1) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[7.81674284320524e-6], - linf=[6.314906965243505e-5]) - end - - @trixi_testset "elixir_advection_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[0.0015188466707237375], - linf=[0.008446655719187679]) - - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[4.913300828257469e-5], - linf=[0.00045263895394385967], - # Let this test run to the end to cover some AMR code - coverage_override=(maxiters = 10^5,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[3.2207388565869075e-5], - linf=[0.0007508059772436404], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_solution_independent.jl"), - l2=[4.949660644033807e-5], - linf=[0.0004867846262313763], - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_advection_amr_visualization.jl" begin - # To make CI tests work, disable showing a plot window with the GR backend of the Plots package - # Xref: https://github.com/jheinen/GR.jl/issues/278 - # Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103 - if !isinteractive() - restore = get(ENV, "GKSwstype", nothing) - ENV["GKSwstype"] = "100" - end - - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_visualization.jl"), - l2=[0.0007225529919720868], - linf=[0.005954447875428925], - coverage_override=(maxiters = 6,)) - - # Restore GKSwstype to previous value (if it was set) - if !isinteractive() - if isnothing(restore) - delete!(ENV, "GKSwstype") - else - ENV["GKSwstype"] = restore - end - end - end - - @trixi_testset "elixir_advection_timeintegration.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2=[2.4976030518356626e-5], - linf=[0.0005531580316338533], - # Let this test terminate by time instead of maxiters to cover some lines - # in time_integration/methods_2N.jl - coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) - end - - @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2=[2.5314747030031457e-5], - linf=[0.0005437136621948904], - ode_algorithm=Trixi.CarpenterKennedy2N43(), - cfl=1.0) - end - - @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2=[1.2135350502911197e-5], - linf=[9.999985420537649e-5], - ode_algorithm=Trixi.CarpenterKennedy2N43(), - cfl=1.0, - maxiters=1) - end - - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2=[2.4976673477385313e-5], - linf=[0.0005534166916640881], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94()) - end - - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2=[3.667894656471403e-5], - linf=[0.0005799465470165757], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), - cfl=1.0) - end - - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2=[1.2198725469737875e-5], - linf=[9.977247740793407e-5], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), - cfl=1.0, - maxiters=1) - end - - @trixi_testset "elixir_advection_callbacks.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_callbacks.jl"), - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) - end + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5], + # Let the small basic test run to the end + coverage_override = (maxiters=10^5,)) + end + + @trixi_testset "elixir_advection_extended.jl with polydeg=1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [0.02134571266411136], + linf = [0.04347734797775926], + polydeg=1) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [7.81674284320524e-6], + linf = [6.314906965243505e-5]) + end + + @trixi_testset "elixir_advection_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [0.0015188466707237375], + linf = [0.008446655719187679]) + + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [4.913300828257469e-5], + linf = [0.00045263895394385967], + # Let this test run to the end to cover some AMR code + coverage_override = (maxiters=10^5,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [3.2207388565869075e-5], + linf = [0.0007508059772436404], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), + l2 = [4.949660644033807e-5], + linf = [0.0004867846262313763], + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_advection_amr_visualization.jl" begin + # To make CI tests work, disable showing a plot window with the GR backend of the Plots package + # Xref: https://github.com/jheinen/GR.jl/issues/278 + # Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103 + if !isinteractive() + restore = get(ENV, "GKSwstype", nothing) + ENV["GKSwstype"] = "100" + end + + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_visualization.jl"), + l2 = [0.0007225529919720868], + linf = [0.005954447875428925], + coverage_override = (maxiters=6,)) + + # Restore GKSwstype to previous value (if it was set) + if !isinteractive() + if isnothing(restore) + delete!(ENV, "GKSwstype") + else + ENV["GKSwstype"] = restore + end + end + end + + @trixi_testset "elixir_advection_timeintegration.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2 = [2.4976030518356626e-5], + linf = [0.0005531580316338533], + # Let this test terminate by time instead of maxiters to cover some lines + # in time_integration/methods_2N.jl + coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) + end + + @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2 = [2.5314747030031457e-5], + linf = [0.0005437136621948904], + ode_algorithm=Trixi.CarpenterKennedy2N43(), + cfl = 1.0) + end + + @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2 = [1.2135350502911197e-5], + linf = [9.999985420537649e-5], + ode_algorithm=Trixi.CarpenterKennedy2N43(), + cfl = 1.0, + maxiters = 1) + end + + @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2 = [2.4976673477385313e-5], + linf = [0.0005534166916640881], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94()) + end + + @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2 = [3.667894656471403e-5], + linf = [0.0005799465470165757], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), + cfl = 1.0) + end + + @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), + l2 = [1.2198725469737875e-5], + linf = [9.977247740793407e-5], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), + cfl = 1.0, + maxiters = 1) + end + + @trixi_testset "elixir_advection_callbacks.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_callbacks.jl"), + l2 = [8.311947673061856e-6], + linf = [6.627000273229378e-5]) + end end # Coverage test for all initial conditions @testset "Linear scalar advection: Tests for initial conditions" begin - # Linear scalar advection - @trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[0.0001420618061089383], - linf=[0.0007140570281718439], - maxiters=1, - initial_condition=Trixi.initial_condition_sin_sin) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[3.8302867746057483e-16], - linf=[1.3322676295501878e-15], - maxiters=1, - initial_condition=initial_condition_constant) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x_y" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[2.7276160570381226e-16], - linf=[5.10702591327572e-15], - maxiters=1, - initial_condition=Trixi.initial_condition_linear_x_y, - boundary_conditions=Trixi.boundary_condition_linear_x_y, - periodicity=false) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[1.5121648229368207e-16], - linf=[1.3322676295501878e-15], - maxiters=1, - initial_condition=Trixi.initial_condition_linear_x, - boundary_conditions=Trixi.boundary_condition_linear_x, - periodicity=false) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_y" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[1.714292614252588e-16], - linf=[2.220446049250313e-15], - maxiters=1, - initial_condition=Trixi.initial_condition_linear_y, - boundary_conditions=Trixi.boundary_condition_linear_y, - periodicity=false) - end + # Linear scalar advection + @trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [0.0001420618061089383], + linf = [0.0007140570281718439], + maxiters = 1, + initial_condition = Trixi.initial_condition_sin_sin) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [3.8302867746057483e-16], + linf = [1.3322676295501878e-15], + maxiters = 1, + initial_condition = initial_condition_constant) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x_y" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [2.7276160570381226e-16], + linf = [5.10702591327572e-15], + maxiters = 1, + initial_condition = Trixi.initial_condition_linear_x_y, + boundary_conditions = Trixi.boundary_condition_linear_x_y, + periodicity=false) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [1.5121648229368207e-16], + linf = [1.3322676295501878e-15], + maxiters = 1, + initial_condition = Trixi.initial_condition_linear_x, + boundary_conditions = Trixi.boundary_condition_linear_x, + periodicity=false) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_y" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [1.714292614252588e-16], + linf = [2.220446049250313e-15], + maxiters = 1, + initial_condition = Trixi.initial_condition_linear_y, + boundary_conditions = Trixi.boundary_condition_linear_y, + periodicity=false) + end end end # module diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 443fe8d818d..6de380288db 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -8,647 +8,282 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2=[ - 9.321181253186009e-7, - 1.4181210743438511e-6, - 1.4181210743487851e-6, - 4.824553091276693e-6, - ], - linf=[ - 9.577246529612893e-6, - 1.1707525976012434e-5, - 1.1707525976456523e-5, - 4.8869615580926506e-5, - ]) - end - - @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2=[ - 0.026440292358506527, - 0.013245905852168414, - 0.013245905852168479, - 0.03912520302609374, - ], - linf=[ - 0.042130817806361964, - 0.022685499230187034, - 0.022685499230187922, - 0.06999771202145322, - ]) - end - - @trixi_testset "elixir_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2=[ - 0.0010600778457964775, - 0.00010600778457634275, - 0.00021201556915872665, - 2.650194614399671e-5, - ], - linf=[ - 0.006614198043413566, - 0.0006614198043973507, - 0.001322839608837334, - 0.000165354951256802, - ], - tspan=(0.0, 0.5)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonperiodic.jl"), - l2=[ - 2.259440511766445e-6, - 2.318888155713922e-6, - 2.3188881557894307e-6, - 6.3327863238858925e-6, - ], - linf=[ - 1.498738264560373e-5, - 1.9182011928187137e-5, - 1.918201192685487e-5, - 6.0526717141407005e-5, - ]) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.061751715597716854, - 0.05018223615408711, - 0.05018989446443463, - 0.225871559730513, - ], - linf=[ - 0.29347582879608825, - 0.31081249232844693, - 0.3107380389947736, - 1.0540358049885143, - ]) - end - - @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.03481471610306124, - 0.027694280613944234, - 0.027697905866996532, - 0.12932052501462554, - ], - linf=[ - 0.31052098400669004, - 0.3481295959664616, - 0.34807152194137336, - 1.1044947556170719, - ], - maxiters=10, - surface_flux=flux_kennedy_gruber, - volume_flux=flux_kennedy_gruber) - end - - @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.03481122603050542, - 0.027662840593087695, - 0.027665658732350273, - 0.12927455860656786, - ], - linf=[ - 0.3110089578739834, - 0.34888111987218107, - 0.3488278669826813, - 1.1056349046774305, - ], - maxiters=10, - surface_flux=flux_chandrashekar, - volume_flux=flux_chandrashekar) - end - - @trixi_testset "elixir_euler_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2=[ - 0.05380629130119074, - 0.04696798008325309, - 0.04697067787841479, - 0.19687382235494968, - ], - linf=[ - 0.18527440131928286, - 0.2404798030563736, - 0.23269573860381076, - 0.6874012187446894, - ]) - end - - @trixi_testset "elixir_euler_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), - l2=[ - 0.14170569763947993, - 0.11647068900798814, - 0.11647072556898294, - 0.3391989213659599, - ], - linf=[ - 1.6544204510794196, - 1.35194638484646, - 1.3519463848472744, - 1.831228461662809, - ], - maxiters=30) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), - l2=[ - 0.4758794741390833, - 0.21045415565179362, - 0.21045325630191866, - 0.7022517958549878, - ], - linf=[ - 1.710832148442441, - 0.9711663578827681, - 0.9703787873632452, - 2.9619758810532653, - ], - initial_refinement_level=4, - maxiters=50) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2=[ - 0.472445774440313, - 0.2090782039442978, - 0.20885558673697927, - 0.700569533591275, - ], - linf=[ - 1.7066492792835155, - 0.9856122336679919, - 0.9784316656930644, - 2.9372978989672873, - ], - initial_refinement_level=4, - maxiters=50) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl with mortars" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2=[ - 0.016486406327766923, - 0.03097329879894433, - 0.03101012918167401, - 0.15157175775429868, - ], - linf=[ - 0.27688647744873407, - 0.5653724536715139, - 0.565695523611447, - 2.513047611639946, - ], - refinement_patches=((type = "box", - coordinates_min = (-0.25, -0.25), - coordinates_max = (0.25, 0.25)), - (type = "box", - coordinates_min = (-0.125, -0.125), - coordinates_max = (0.125, 0.125))), - initial_refinement_level=4, - maxiters=5) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_cnn.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_blast_wave_neuralnetwork_cnn.jl"), - l2=[ - 0.4795795496408325, - 0.2125148972465021, - 0.21311260934645868, - 0.7033388737692883, - ], - linf=[ - 1.8295385992182336, - 0.9687795218482794, - 0.9616033072376108, - 2.9513245978047133, - ], - initial_refinement_level=4, - maxiters=50, - rtol=1.0e-7) - end - - @trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_pure_fv.jl"), - l2=[ - 0.39957047631960346, - 0.21006912294983154, - 0.21006903549932, - 0.6280328163981136, - ], - linf=[ - 2.20417889887697, - 1.5487238480003327, - 1.5486788679247812, - 2.4656795949035857, - ], - tspan=(0.0, 0.5), - # Let this test run longer to cover some lines in flux_hllc - coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) - end - - @trixi_testset "elixir_euler_blast_wave_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), - l2=[ - 0.6835576416907511, - 0.2839963955262972, - 0.28399565983676, - 0.7229447806293277, - ], - linf=[ - 3.0969614882801393, - 1.7967947300740248, - 1.7967508302506658, - 3.040149575567518, - ], - tspan=(0.0, 1.0), - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2=[ - 0.4866953770742574, - 0.1673477470091984, - 0.16734774700934, - 0.6184367248923149, - ], - linf=[ - 2.6724832723962053, - 1.2916089288910635, - 1.2916089289001427, - 6.474699399394252, - ], - tspan=(0.0, 1.0), - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl"), - l2=[ - 0.0845430093623868, - 0.09271459184623232, - 0.09271459184623232, - 0.4377291875101709, - ], - linf=[ - 1.3608553480069898, - 1.6822884847136004, - 1.6822884847135997, - 4.220147414536653, - ], - maxiters=30, - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_positivity.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), - l2=[ - 0.48862067511841695, - 0.16787541578869494, - 0.16787541578869422, - 0.6184319933114926, - ], - linf=[ - 2.6766520821013002, - 1.2910938760258996, - 1.2910938760258899, - 6.473385481404865, - ], - tspan=(0.0, 1.0), - coverage_override=(maxiters = 3,)) - end - - @trixi_testset "elixir_euler_blob_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_mortar.jl"), - l2=[ - 0.22271619518391986, - 0.6284824759323494, - 0.24864213447943648, - 2.9591811489995474, - ], - linf=[ - 9.15245400430106, - 24.96562810334389, - 10.388109127032374, - 101.20581544156934, - ], - tspan=(0.0, 0.5)) - end - - @trixi_testset "elixir_euler_blob_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_amr.jl"), - l2=[ - 0.2086261501910662, - 1.2118352377894666, - 0.10255333189606497, - 5.296238138639236, - ], - linf=[ - 14.829071984498198, - 74.12967742435727, - 6.863554388300223, - 303.58813147491134, - ], - tspan=(0.0, 0.12), - # Let this test run longer to cover the ControllerThreeLevelCombined lines - coverage_override=(maxiters = 10^5,)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl"), - l2=[ - 0.1057230211245312, - 0.10621112311257341, - 0.07260957505339989, - 0.11178239111065721, - ], - linf=[ - 2.998719417992662, - 2.1400285015556166, - 1.1569648700415078, - 1.8922492268110913, - ], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability.jl"), - l2=[ - 0.055691508271624536, - 0.032986009333751655, - 0.05224390923711999, - 0.08009536362771563, - ], - linf=[ - 0.24043622527087494, - 0.1660878796929941, - 0.12355946691711608, - 0.2694290787257758, - ], - tspan=(0.0, 0.2)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability_amr.jl"), - l2=[ - 0.05569452733654995, - 0.033107109983417926, - 0.05223609622852158, - 0.08007777597488817, - ], - linf=[ - 0.2535807803900303, - 0.17397028249895308, - 0.12321616095649354, - 0.269046666668995, - ], - tspan=(0.0, 0.2), - coverage_override=(maxiters = 2,)) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl"), - # This stuff is experimental and annoying to test. In the future, we plan - # to move it to another repository. Thus, we save developer time right now - # and do not run these tests anymore. - # l2 = [0.0009823702998067061, 0.004943231496200673, 0.0048604522073091815, 0.00496983530893294], - # linf = [0.00855717053383187, 0.02087422420794427, 0.017121993783086185, 0.02720703869972585], - maxiters=30, - coverage_override=(maxiters = 2,)) - end - - @trixi_testset "elixir_euler_colliding_flow.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow.jl"), - l2=[ - 0.007237139090503349, - 0.044887582765386916, - 1.0453570959003603e-6, - 0.6627307840935432, - ], - linf=[ - 0.19437260992446315, - 0.5554343646648533, - 5.943891455255412e-5, - 15.188919846360125, - ], - tspan=(0.0, 0.1)) - end - - @trixi_testset "elixir_euler_colliding_flow_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow_amr.jl"), - l2=[ - 0.006768801432802192, - 0.032184992228603666, - 6.923887797276484e-7, - 0.6784222932398366, - ], - linf=[ - 0.2508663007713608, - 0.4097017076529792, - 0.0003528986458217968, - 22.435474993016918, - ], - tspan=(0.0, 0.1), - coverage_override=(maxiters = 2,)) - end - - @trixi_testset "elixir_euler_astro_jet_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_astro_jet_amr.jl"), - l2=[ - 0.011338365293662804, - 10.09743543555765, - 0.00392429463200361, - 4031.7811487690506, - ], - linf=[ - 3.3178633141984193, - 2993.6445033486402, - 8.031723414357423, - 1.1918867260293828e6, - ], - tspan=(0.0, 1.0e-7), - coverage_override=(maxiters = 6,)) - end - - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2=[ - 0.00013492249515826863, - 0.006615696236378061, - 0.006782108219800376, - 0.016393831451740604, - ], - linf=[ - 0.0020782600954247776, - 0.08150078921935999, - 0.08663621974991986, - 0.2829930622010579, - ]) - end - - @trixi_testset "elixir_euler_vortex_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[ - 0.0017208369388227673, - 0.09628684992237334, - 0.09620157717330868, - 0.1758809552387432, - ], - linf=[ - 0.021869936355319086, - 0.9956698009442038, - 1.0002507727219028, - 2.223249697515648, - ]) - end - - @trixi_testset "elixir_euler_vortex_mortar_split.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_split.jl"), - l2=[ - 0.0017203323613648241, - 0.09628962878682261, - 0.09621241164155782, - 0.17585995600340926, - ], - linf=[ - 0.021740570456931674, - 0.9938841665880938, - 1.004140123355135, - 2.224108857746245, - ]) - end - - @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), - l2=[ - 0.0017158367642679273, - 0.09619888722871434, - 0.09616432767924141, - 0.17553381166255197, - ], - linf=[ - 0.021853862449723982, - 0.9878047229255944, - 0.9880191167111795, - 2.2154030488035588, - ]) - end - - @trixi_testset "elixir_euler_vortex_mortar_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_vortex_mortar_shockcapturing.jl"), - l2=[ - 0.0017203324051381415, - 0.09628962899999398, - 0.0962124115572114, - 0.1758599596626405, - ], - linf=[ - 0.021740568112562086, - 0.9938841624655501, - 1.0041401179009877, - 2.2241087041100798, - ]) - end - - @trixi_testset "elixir_euler_vortex_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), - # Expected errors are exactly the same as in the parallel test! - l2=[ - 5.051719943432265e-5, - 0.0022574259317084747, - 0.0021755998463189713, - 0.004346492398617521, - ], - linf=[ - 0.0012880114865917447, - 0.03857193149447702, - 0.031090457959835893, - 0.12125130332971423, - ], - # Let this test run longer to cover some lines in the AMR indicator - coverage_override=(maxiters = 10^5, tspan = (0.0, 10.5))) - end - - @trixi_testset "elixir_euler_ec.jl with boundary_condition_slip_wall" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2=[ - 0.03341239373099515, - 0.026673245711492915, - 0.026678871434568822, - 0.12397486476145089, - ], - linf=[ - 0.3290981764688339, - 0.3812055782309788, - 0.3812041851225023, - 1.168251216556933, - ], - periodicity=false, - boundary_conditions=boundary_condition_slip_wall, - cfl=0.3, tspan=(0.0, 0.1)) # this test is sensitive to the CFL factor - end + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], + linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5]) + end + + @trixi_testset "elixir_euler_convergence_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), + l2 = [0.026440292358506527, 0.013245905852168414, 0.013245905852168479, 0.03912520302609374], + linf = [0.042130817806361964, 0.022685499230187034, 0.022685499230187922, 0.06999771202145322]) + end + + @trixi_testset "elixir_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2 = [0.0010600778457964775, 0.00010600778457634275, 0.00021201556915872665, 2.650194614399671e-5], + linf = [0.006614198043413566, 0.0006614198043973507, 0.001322839608837334, 0.000165354951256802], + tspan = (0.0, 0.5)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), + l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], + linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5]) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], + linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) + end + + @trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.03481471610306124, 0.027694280613944234, 0.027697905866996532, 0.12932052501462554], + linf = [0.31052098400669004, 0.3481295959664616, 0.34807152194137336, 1.1044947556170719], + maxiters = 10, + surface_flux = flux_kennedy_gruber, + volume_flux = flux_kennedy_gruber) + end + + @trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.03481122603050542, 0.027662840593087695, 0.027665658732350273, 0.12927455860656786], + linf = [0.3110089578739834, 0.34888111987218107, 0.3488278669826813, 1.1056349046774305], + maxiters = 10, + surface_flux = flux_chandrashekar, + volume_flux = flux_chandrashekar) + end + + @trixi_testset "elixir_euler_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), + l2 = [0.05380629130119074, 0.04696798008325309, 0.04697067787841479, 0.19687382235494968], + linf = [0.18527440131928286, 0.2404798030563736, 0.23269573860381076, 0.6874012187446894]) + end + + @trixi_testset "elixir_euler_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), + l2 = [0.14170569763947993, 0.11647068900798814, 0.11647072556898294, 0.3391989213659599], + linf = [1.6544204510794196, 1.35194638484646, 1.3519463848472744, 1.831228461662809], + maxiters = 30) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), + l2 = [0.4758794741390833, 0.21045415565179362, 0.21045325630191866, 0.7022517958549878], + linf = [1.710832148442441, 0.9711663578827681, 0.9703787873632452, 2.9619758810532653], + initial_refinement_level = 4, + maxiters = 50) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2 = [0.472445774440313, 0.2090782039442978, 0.20885558673697927, 0.700569533591275], + linf = [1.7066492792835155, 0.9856122336679919, 0.9784316656930644, 2.9372978989672873], + initial_refinement_level = 4, + maxiters = 50) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl with mortars" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2 = [0.016486406327766923, 0.03097329879894433, 0.03101012918167401, 0.15157175775429868], + linf = [0.27688647744873407, 0.5653724536715139, 0.565695523611447, 2.513047611639946], + refinement_patches=( + (type="box", coordinates_min=(-0.25, -0.25), coordinates_max=(0.25, 0.25)), + (type="box", coordinates_min=(-0.125, -0.125), coordinates_max=(0.125, 0.125)),), + initial_refinement_level = 4, + maxiters = 5) + end + + @trixi_testset "elixir_euler_blast_wave_neuralnetwork_cnn.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_cnn.jl"), + l2 = [0.4795795496408325, 0.2125148972465021, 0.21311260934645868, 0.7033388737692883], + linf = [1.8295385992182336, 0.9687795218482794, 0.9616033072376108, 2.9513245978047133], + initial_refinement_level = 4, + maxiters = 50, + rtol = 1.0e-7) + end + + @trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_pure_fv.jl"), + l2 = [0.39957047631960346, 0.21006912294983154, 0.21006903549932, 0.6280328163981136], + linf = [2.20417889887697, 1.5487238480003327, 1.5486788679247812, 2.4656795949035857], + tspan = (0.0, 0.5), + # Let this test run longer to cover some lines in flux_hllc + coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) + end + + @trixi_testset "elixir_euler_blast_wave_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), + l2 = [0.6835576416907511, 0.2839963955262972, 0.28399565983676, 0.7229447806293277], + linf = [3.0969614882801393, 1.7967947300740248, 1.7967508302506658, 3.040149575567518], + tspan = (0.0, 1.0), + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2 = [0.4866953770742574, 0.1673477470091984, 0.16734774700934, 0.6184367248923149], + linf = [2.6724832723962053, 1.2916089288910635, 1.2916089289001427, 6.474699399394252], + tspan = (0.0, 1.0), + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl"), + l2 = [0.0845430093623868, 0.09271459184623232, 0.09271459184623232, 0.4377291875101709], + linf = [1.3608553480069898, 1.6822884847136004, 1.6822884847135997, 4.220147414536653], + maxiters = 30, + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_positivity.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), + l2 = [0.48862067511841695, 0.16787541578869494, 0.16787541578869422, 0.6184319933114926], + linf = [2.6766520821013002, 1.2910938760258996, 1.2910938760258899, 6.473385481404865], + tspan = (0.0, 1.0), + coverage_override = (maxiters=3,)) + end + + @trixi_testset "elixir_euler_blob_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_mortar.jl"), + l2 = [0.22271619518391986, 0.6284824759323494, 0.24864213447943648, 2.9591811489995474], + linf = [9.15245400430106, 24.96562810334389, 10.388109127032374, 101.20581544156934], + tspan = (0.0, 0.5)) + end + + @trixi_testset "elixir_euler_blob_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_amr.jl"), + l2 = [0.2086261501910662, 1.2118352377894666, 0.10255333189606497, 5.296238138639236], + linf = [14.829071984498198, 74.12967742435727, 6.863554388300223, 303.58813147491134], + tspan = (0.0, 0.12), + # Let this test run longer to cover the ControllerThreeLevelCombined lines + coverage_override = (maxiters=10^5,)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl"), + l2 = [0.1057230211245312, 0.10621112311257341, 0.07260957505339989, 0.11178239111065721], + linf = [2.998719417992662, 2.1400285015556166, 1.1569648700415078, 1.8922492268110913], + tspan = (0.0, 0.1)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), + l2 = [0.055691508271624536, 0.032986009333751655, 0.05224390923711999, 0.08009536362771563], + linf = [0.24043622527087494, 0.1660878796929941, 0.12355946691711608, 0.2694290787257758], + tspan = (0.0, 0.2)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_amr.jl"), + l2 = [0.05569452733654995, 0.033107109983417926, 0.05223609622852158, 0.08007777597488817], + linf = [0.2535807803900303, 0.17397028249895308, 0.12321616095649354, 0.269046666668995], + tspan = (0.0, 0.2), + coverage_override = (maxiters=2,)) + end + + @trixi_testset "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl"), + # This stuff is experimental and annoying to test. In the future, we plan + # to move it to another repository. Thus, we save developer time right now + # and do not run these tests anymore. + # l2 = [0.0009823702998067061, 0.004943231496200673, 0.0048604522073091815, 0.00496983530893294], + # linf = [0.00855717053383187, 0.02087422420794427, 0.017121993783086185, 0.02720703869972585], + maxiters = 30, + coverage_override = (maxiters=2,)) + end + + @trixi_testset "elixir_euler_colliding_flow.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow.jl"), + l2 = [0.007237139090503349, 0.044887582765386916, 1.0453570959003603e-6, 0.6627307840935432], + linf = [0.19437260992446315, 0.5554343646648533, 5.943891455255412e-5, 15.188919846360125], + tspan = (0.0, 0.1)) + end + + @trixi_testset "elixir_euler_colliding_flow_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow_amr.jl"), + l2 = [0.006768801432802192, 0.032184992228603666, 6.923887797276484e-7, 0.6784222932398366], + linf = [0.2508663007713608, 0.4097017076529792, 0.0003528986458217968, 22.435474993016918], + tspan = (0.0, 0.1), + coverage_override = (maxiters=2,)) + end + + @trixi_testset "elixir_euler_astro_jet_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_astro_jet_amr.jl"), + l2 = [0.011338365293662804, 10.09743543555765, 0.00392429463200361, 4031.7811487690506], + linf = [3.3178633141984193, 2993.6445033486402, 8.031723414357423, 1.1918867260293828e6], + tspan = (0.0, 1.0e-7), + coverage_override = (maxiters=6,)) + end + + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2 = [0.00013492249515826863, 0.006615696236378061, 0.006782108219800376, 0.016393831451740604], + linf = [0.0020782600954247776, 0.08150078921935999, 0.08663621974991986, 0.2829930622010579]) + end + + @trixi_testset "elixir_euler_vortex_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [0.0017208369388227673, 0.09628684992237334, 0.09620157717330868, 0.1758809552387432], + linf = [0.021869936355319086, 0.9956698009442038, 1.0002507727219028, 2.223249697515648]) + end + + @trixi_testset "elixir_euler_vortex_mortar_split.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_split.jl"), + l2 = [0.0017203323613648241, 0.09628962878682261, 0.09621241164155782, 0.17585995600340926], + linf = [0.021740570456931674, 0.9938841665880938, 1.004140123355135, 2.224108857746245]) + end + + @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), + l2 = [0.0017158367642679273, 0.09619888722871434, 0.09616432767924141, 0.17553381166255197], + linf = [0.021853862449723982, 0.9878047229255944, 0.9880191167111795, 2.2154030488035588]) + end + + @trixi_testset "elixir_euler_vortex_mortar_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_shockcapturing.jl"), + l2 = [0.0017203324051381415, 0.09628962899999398, 0.0962124115572114, 0.1758599596626405], + linf = [0.021740568112562086, 0.9938841624655501, 1.0041401179009877, 2.2241087041100798]) + end + + @trixi_testset "elixir_euler_vortex_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), + # Expected errors are exactly the same as in the parallel test! + l2 = [5.051719943432265e-5, 0.0022574259317084747, 0.0021755998463189713, 0.004346492398617521], + linf = [0.0012880114865917447, 0.03857193149447702, 0.031090457959835893, 0.12125130332971423], + # Let this test run longer to cover some lines in the AMR indicator + coverage_override = (maxiters=10^5, tspan=(0.0, 10.5))) + end + + @trixi_testset "elixir_euler_ec.jl with boundary_condition_slip_wall" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2 = [0.03341239373099515, 0.026673245711492915, 0.026678871434568822, 0.12397486476145089], + linf = [0.3290981764688339, 0.3812055782309788, 0.3812041851225023, 1.168251216556933], + periodicity = false, boundary_conditions = boundary_condition_slip_wall, + cfl = 0.3, tspan = (0.0, 0.1)) # this test is sensitive to the CFL factor + end end # Coverage test for all initial conditions @testset "Compressible Euler: Tests for initial conditions" begin - @trixi_testset "elixir_euler_vortex.jl one step with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2=[ - 1.1790213022362371e-16, - 8.580657423476384e-17, - 1.3082387431804115e-16, - 1.6182739965672862e-15, - ], - linf=[ - 3.3306690738754696e-16, - 2.220446049250313e-16, - 5.273559366969494e-16, - 3.552713678800501e-15, - ], - maxiters=1, - initial_condition=initial_condition_constant) - end - - @trixi_testset "elixir_euler_sedov_blast_wave.jl one step" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2=[ - 0.0021196114178949396, - 0.010703549234544042, - 0.01070354923454404, - 0.10719124037195142, - ], - linf=[ - 0.11987270645890724, - 0.7468615461136827, - 0.7468615461136827, - 3.910689155287799, - ], - maxiters=1) - end + @trixi_testset "elixir_euler_vortex.jl one step with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2 = [1.1790213022362371e-16, 8.580657423476384e-17, 1.3082387431804115e-16, 1.6182739965672862e-15], + linf = [3.3306690738754696e-16, 2.220446049250313e-16, 5.273559366969494e-16, 3.552713678800501e-15], + maxiters = 1, + initial_condition = initial_condition_constant) + end + + @trixi_testset "elixir_euler_sedov_blast_wave.jl one step" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2 = [0.0021196114178949396, 0.010703549234544042, 0.01070354923454404, 0.10719124037195142], + linf = [0.11987270645890724, 0.7468615461136827, 0.7468615461136827, 3.910689155287799], + maxiters=1) + end end end # module diff --git a/test/test_tree_2d_euleracoustics.jl b/test/test_tree_2d_euleracoustics.jl index c217ccbbd06..01ac939f8aa 100644 --- a/test/test_tree_2d_euleracoustics.jl +++ b/test/test_tree_2d_euleracoustics.jl @@ -8,30 +8,14 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "Acoustic perturbation coupled with compressible Euler" begin - @trixi_testset "elixir_euleracoustics_co-rotating_vortex_pair.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euleracoustics_co-rotating_vortex_pair.jl"), - initial_refinement_level=5, - tspan1=(0.0, 1.0), tspan_averaging=(0.0, 1.0), tspan=(0.0, 1.0), - l2=[ - 0.00013268029905807722, - 0.0001335062197031223, - 0.00021776333678401362, - 13.000001753042364, - 26.00000080243847, - 38.00000884725549, - 51.000000003859995, - ], - linf=[ - 0.22312716933051027, - 0.1579924424942319, - 0.25194831158255576, - 13.468872744263273, - 26.54666679978679, - 38.139032147739684, - 51.378134660241294, - ]) - end + @trixi_testset "elixir_euleracoustics_co-rotating_vortex_pair.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euleracoustics_co-rotating_vortex_pair.jl"), + initial_refinement_level=5, + tspan1=(0.0, 1.0), tspan_averaging=(0.0, 1.0), tspan=(0.0, 1.0), + l2 = [0.00013268029905807722, 0.0001335062197031223, 0.00021776333678401362, 13.000001753042364, 26.00000080243847, 38.00000884725549, 51.000000003859995], + linf = [0.22312716933051027, 0.1579924424942319, 0.25194831158255576, 13.468872744263273, 26.54666679978679, 38.139032147739684, 51.378134660241294] + ) + end end -end # module +end # module \ No newline at end of file diff --git a/test/test_tree_2d_eulermulti.jl b/test/test_tree_2d_eulermulti.jl index 1184e09488e..800dc31f84f 100644 --- a/test/test_tree_2d_eulermulti.jl +++ b/test/test_tree_2d_eulermulti.jl @@ -8,121 +8,47 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Compressible Euler Multicomponent" begin - # NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the - # simulations are set up with dimensional states. For example, the reference pressure in SI - # units is 101325 Pa, i.e., pressure has values of O(10^5) - - @trixi_testset "elixir_eulermulti_shock_bubble.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble.jl"), - l2=[ - 73.78467629094177, - 0.9174752929795251, - 57942.83587826468, - 0.1828847253029943, - 0.011127037850925347, - ], - linf=[ - 196.81051991521073, - 7.8456811648529605, - 158891.88930113698, - 0.811379581519794, - 0.08011973559187913, - ], - tspan=(0.0, 0.001)) - end - - @trixi_testset "elixir_eulermulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), - l2=[ - 0.050182236154087095, - 0.050189894464434635, - 0.2258715597305131, - 0.06175171559771687, - ], - linf=[ - 0.3108124923284472, - 0.3107380389947733, - 1.054035804988521, - 0.29347582879608936, - ]) - end - - @trixi_testset "elixir_eulermulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), - l2=[ - 0.0496546258404055, - 0.04965550099933263, - 0.22425206549856372, - 0.004087155041747821, - 0.008174310083495642, - 0.016348620166991283, - 0.032697240333982566, - ], - linf=[ - 0.2488251110766228, - 0.24832493304479406, - 0.9310354690058298, - 0.017452870465607374, - 0.03490574093121475, - 0.0698114818624295, - 0.139622963724859, - ]) - end - - @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), - l2=[ - 0.00012290225488326508, - 0.00012290225488321876, - 0.00018867397906337653, - 4.8542321753649044e-5, - 9.708464350729809e-5, - ], - linf=[ - 0.0006722819239133315, - 0.0006722819239128874, - 0.0012662292789555885, - 0.0002843844182700561, - 0.0005687688365401122, - ]) - end - - @trixi_testset "elixir_eulermulti_convergence_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2=[ - 2.2661773867001696e-6, - 2.266177386666318e-6, - 6.593514692980009e-6, - 8.836308667348217e-7, - 1.7672617334696433e-6, - ], - linf=[ - 1.4713170997993075e-5, - 1.4713170997104896e-5, - 5.115618808515521e-5, - 5.3639516094383666e-6, - 1.0727903218876733e-5, - ]) - end - - @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2=[ - 1.8621737639352465e-6, - 1.862173764098385e-6, - 5.942585713809631e-6, - 6.216263279534722e-7, - 1.2432526559069443e-6, - ], - linf=[ - 1.6235495582606063e-5, - 1.6235495576388814e-5, - 5.854523678827661e-5, - 5.790274858807898e-6, - 1.1580549717615796e-5, - ], - volume_flux=flux_chandrashekar) - end + # NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the + # simulations are set up with dimensional states. For example, the reference pressure in SI + # units is 101325 Pa, i.e., pressure has values of O(10^5) + + @trixi_testset "elixir_eulermulti_shock_bubble.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble.jl"), + l2 = [73.78467629094177, 0.9174752929795251, 57942.83587826468, 0.1828847253029943, 0.011127037850925347], + linf = [196.81051991521073, 7.8456811648529605, 158891.88930113698, 0.811379581519794, 0.08011973559187913], + tspan = (0.0, 0.001)) + end + + @trixi_testset "elixir_eulermulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), + l2 = [0.050182236154087095, 0.050189894464434635, 0.2258715597305131, 0.06175171559771687], + linf = [0.3108124923284472, 0.3107380389947733, 1.054035804988521, 0.29347582879608936]) + end + + @trixi_testset "elixir_eulermulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), + l2 = [0.0496546258404055, 0.04965550099933263, 0.22425206549856372, 0.004087155041747821, 0.008174310083495642, 0.016348620166991283, 0.032697240333982566], + linf = [0.2488251110766228, 0.24832493304479406, 0.9310354690058298, 0.017452870465607374, 0.03490574093121475, 0.0698114818624295, 0.139622963724859]) + end + + @trixi_testset "elixir_eulermulti_convergence_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), + l2 = [0.00012290225488326508, 0.00012290225488321876, 0.00018867397906337653, 4.8542321753649044e-5, 9.708464350729809e-5], + linf = [0.0006722819239133315, 0.0006722819239128874, 0.0012662292789555885, 0.0002843844182700561, 0.0005687688365401122]) + end + + @trixi_testset "elixir_eulermulti_convergence_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2 = [2.2661773867001696e-6, 2.266177386666318e-6, 6.593514692980009e-6, 8.836308667348217e-7, 1.7672617334696433e-6], + linf = [1.4713170997993075e-5, 1.4713170997104896e-5, 5.115618808515521e-5, 5.3639516094383666e-6, 1.0727903218876733e-5]) + end + + @trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), + l2 = [1.8621737639352465e-6, 1.862173764098385e-6, 5.942585713809631e-6, 6.216263279534722e-7, 1.2432526559069443e-6], + linf = [1.6235495582606063e-5, 1.6235495576388814e-5, 5.854523678827661e-5, 5.790274858807898e-6, 1.1580549717615796e-5], + volume_flux = flux_chandrashekar) + end end end # module diff --git a/test/test_tree_2d_fdsbp.jl b/test/test_tree_2d_fdsbp.jl index 094092106f9..7c58ef89a6c 100644 --- a/test/test_tree_2d_fdsbp.jl +++ b/test/test_tree_2d_fdsbp.jl @@ -8,101 +8,60 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_fdsbp") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_extended.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2=[2.898644263922225e-6], - linf=[8.491517930142578e-6], - rtol=1.0e-7) # These results change a little bit and depend on the CI system + @trixi_testset "elixir_advection_extended.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2 = [2.898644263922225e-6], + linf = [8.491517930142578e-6], + rtol = 1.0e-7) # These results change a little bit and depend on the CI system - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 end + end end @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 1.7088389997042244e-6, - 1.7437997855125774e-6, - 1.7437997855350776e-6, - 5.457223460127621e-6, - ], - linf=[ - 9.796504903736292e-6, - 9.614745892783105e-6, - 9.614745892783105e-6, - 4.026107182575345e-5, - ], - tspan=(0.0, 0.1)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [1.7088389997042244e-6, 1.7437997855125774e-6, 1.7437997855350776e-6, 5.457223460127621e-6], + linf = [9.796504903736292e-6, 9.614745892783105e-6, 9.614745892783105e-6, 4.026107182575345e-5], + tspan = (0.0, 0.1)) - # Ensure that we do not have excessive memory allocations - # (e.g., from type instabilities) - let - t = sol.t[end] - u_ode = sol.u[end] - du_ode = similar(u_ode) - @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 end + end - @trixi_testset "elixir_euler_convergence.jl with Lax-Friedrichs splitting" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2=[ - 2.1149087345799973e-6, - 1.9391438806845798e-6, - 1.9391438806759794e-6, - 5.842833764682604e-6, - ], - linf=[ - 1.3679037540903494e-5, - 1.1770587849069258e-5, - 1.1770587848403125e-5, - 4.68952678644996e-5, - ], - tspan=(0.0, 0.1), flux_splitting=splitting_lax_friedrichs) - end + @trixi_testset "elixir_euler_convergence.jl with Lax-Friedrichs splitting" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2 = [2.1149087345799973e-6, 1.9391438806845798e-6, 1.9391438806759794e-6, 5.842833764682604e-6], + linf = [1.3679037540903494e-5, 1.1770587849069258e-5, 1.1770587848403125e-5, 4.68952678644996e-5], + tspan = (0.0, 0.1), flux_splitting = splitting_lax_friedrichs) + end - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_kelvin_helmholtz_instability.jl"), - l2=[ - 0.02607850081951497, - 0.020357717558016252, - 0.028510191844948945, - 0.02951535039734857, - ], - linf=[ - 0.12185328623662173, - 0.1065055387595834, - 0.06257122956937419, - 0.11992349951978643, - ], - tspan=(0.0, 0.1)) - end + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), + l2 = [0.02607850081951497, 0.020357717558016252, 0.028510191844948945, 0.02951535039734857], + linf = [0.12185328623662173, 0.1065055387595834, 0.06257122956937419, 0.11992349951978643], + tspan = (0.0, 0.1)) + end - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2=[ - 0.0005330228930711585, - 0.028475888529345014, - 0.02847513865894387, - 0.056259951995581196, - ], - linf=[ - 0.007206088611304784, - 0.31690373882847234, - 0.31685665067192326, - 0.7938167296134893, - ], - tspan=(0.0, 0.25)) - end + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2 = [0.0005330228930711585, 0.028475888529345014, 0.02847513865894387, 0.056259951995581196], + linf = [0.007206088611304784, 0.31690373882847234, 0.31685665067192326, 0.7938167296134893], + tspan = (0.0, 0.25)) + end end end # module diff --git a/test/test_tree_2d_hypdiff.jl b/test/test_tree_2d_hypdiff.jl index 0b50f2d27f4..eb8f8b297b6 100644 --- a/test/test_tree_2d_hypdiff.jl +++ b/test/test_tree_2d_hypdiff.jl @@ -8,63 +8,30 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Hyperbolic diffusion" begin - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2=[ - 0.00015687751817403066, - 0.001025986772216324, - 0.0010259867722164071, - ], - linf=[ - 0.001198695637957381, - 0.006423873515531753, - 0.006423873515533529, - ]) - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2=[ - 8.618132355121019e-8, - 5.619399844384306e-7, - 5.619399844844044e-7, - ], - linf=[ - 1.1248618588430072e-6, - 8.622436487026874e-6, - 8.622436487915053e-6, - ]) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2=[ - 8.523077653954864e-6, - 2.8779323653020624e-5, - 5.454942769125663e-5, - ], - linf=[ - 5.522740952468297e-5, - 0.00014544895978971679, - 0.00032396328684924924, - ]) - end - - @trixi_testset "elixir_hypdiff_godunov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), - l2=[ - 5.868147556427088e-6, - 3.80517927324465e-5, - 3.805179273249344e-5, - ], - linf=[ - 3.701965498725812e-5, - 0.0002122422943138247, - 0.00021224229431116015, - ], - atol=2.0e-12) #= required for CI on macOS =# - end + @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), + l2 = [0.00015687751817403066, 0.001025986772216324, 0.0010259867722164071], + linf = [0.001198695637957381, 0.006423873515531753, 0.006423873515533529]) + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2 = [8.618132355121019e-8, 5.619399844384306e-7, 5.619399844844044e-7], + linf = [1.1248618588430072e-6, 8.622436487026874e-6, 8.622436487915053e-6]) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2 = [8.523077653954864e-6, 2.8779323653020624e-5, 5.454942769125663e-5], + linf = [5.522740952468297e-5, 0.00014544895978971679, 0.00032396328684924924]) + end + + @trixi_testset "elixir_hypdiff_godunov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), + l2 = [5.868147556427088e-6, 3.80517927324465e-5, 3.805179273249344e-5], + linf = [3.701965498725812e-5, 0.0002122422943138247, 0.00021224229431116015], + atol = 2.0e-12 #= required for CI on macOS =#) + end end end # module diff --git a/test/test_tree_2d_kpp.jl b/test/test_tree_2d_kpp.jl index 17a8927cb92..26074ea487f 100644 --- a/test/test_tree_2d_kpp.jl +++ b/test/test_tree_2d_kpp.jl @@ -8,16 +8,16 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "KPP" begin - @trixi_testset "elixir_kpp.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_kpp.jl"), - l2=[0.36563290910786106], - linf=[9.116732052340398], - max_refinement_level=6, - tspan=(0.0, 0.01), - atol=1e-6, - rtol=1e-6, - skip_coverage=true) - end + @trixi_testset "elixir_kpp.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_kpp.jl"), + l2 = [0.36563290910786106], + linf = [9.116732052340398], + max_refinement_level = 6, + tspan = (0.0, 0.01), + atol = 1e-6, + rtol = 1e-6, + skip_coverage = true) + end end end # module diff --git a/test/test_tree_2d_lbm.jl b/test/test_tree_2d_lbm.jl index cba5e2aa558..b516708e6cd 100644 --- a/test/test_tree_2d_lbm.jl +++ b/test/test_tree_2d_lbm.jl @@ -8,102 +8,71 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Lattice-Boltzmann" begin - @trixi_testset "elixir_lbm_constant.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_constant.jl"), - l2=[4.888991832247047e-15, 4.8856380534982224e-15, - 5.140829677785587e-16, - 7.340293204570167e-16, 2.0559494114924474e-15, - 6.125746684189216e-16, - 1.6545443003155128e-16, 6.001333022242579e-16, - 9.450994018139234e-15], - linf=[5.551115123125783e-15, 5.662137425588298e-15, - 1.2212453270876722e-15, - 1.27675647831893e-15, 2.4980018054066022e-15, - 7.494005416219807e-16, - 4.3021142204224816e-16, 8.881784197001252e-16, - 1.0436096431476471e-14]) - end + @trixi_testset "elixir_lbm_constant.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_constant.jl"), + l2 = [4.888991832247047e-15, 4.8856380534982224e-15, 5.140829677785587e-16, + 7.340293204570167e-16, 2.0559494114924474e-15, 6.125746684189216e-16, + 1.6545443003155128e-16, 6.001333022242579e-16, 9.450994018139234e-15], + linf = [5.551115123125783e-15, 5.662137425588298e-15, 1.2212453270876722e-15, + 1.27675647831893e-15, 2.4980018054066022e-15, 7.494005416219807e-16, + 4.3021142204224816e-16, 8.881784197001252e-16, 1.0436096431476471e-14]) + end - @trixi_testset "elixir_lbm_couette.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), - l2=[0.0007899749117603378, 7.0995283148275575e-6, - 0.0007454191223764233, - 1.6482025869100257e-5, 0.00012684365365448903, - 0.0001198942846383015, - 0.00028436349827736705, 0.0003005161103138576, - 4.496683876631818e-5], - linf=[0.005596384769998769, 4.771160474496827e-5, - 0.005270322068908595, - 0.00011747787108790098, 0.00084326349695725, - 0.000795551892211168, - 0.001956482118303543, 0.0020739599893902436, - 0.00032606270109525326], - tspan=(0.0, 1.0)) - end + @trixi_testset "elixir_lbm_couette.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), + l2 = [0.0007899749117603378, 7.0995283148275575e-6, 0.0007454191223764233, + 1.6482025869100257e-5, 0.00012684365365448903, 0.0001198942846383015, + 0.00028436349827736705, 0.0003005161103138576, 4.496683876631818e-5], + linf = [0.005596384769998769, 4.771160474496827e-5, 0.005270322068908595, + 0.00011747787108790098, 0.00084326349695725, 0.000795551892211168, + 0.001956482118303543, 0.0020739599893902436, 0.00032606270109525326], + tspan = (0.0, 1.0)) + end - @trixi_testset "elixir_lbm_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), - l2=[0.0013628495945172754, 0.00021475256243322154, - 0.0012579141312268184, - 0.00036542734715110765, 0.00024127756258120715, - 0.00022899415795341014, - 0.0004225564518328741, 0.0004593854895507851, - 0.00044244398903669927], - linf=[0.025886626070758242, 0.00573859077176217, - 0.027568805277855102, 0.00946724671122974, - 0.004031686575556803, 0.0038728927083346437, - 0.020038695575169005, - 0.02061789496737146, 0.05568236920459335], - tspan=(0.0, 1.0)) - end + @trixi_testset "elixir_lbm_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), + l2 = [0.0013628495945172754, 0.00021475256243322154, 0.0012579141312268184, + 0.00036542734715110765, 0.00024127756258120715, 0.00022899415795341014, + 0.0004225564518328741, 0.0004593854895507851, 0.00044244398903669927], + linf = [0.025886626070758242, 0.00573859077176217, 0.027568805277855102, 0.00946724671122974, + 0.004031686575556803, 0.0038728927083346437, 0.020038695575169005, + 0.02061789496737146, 0.05568236920459335], + tspan = (0.0, 1.0)) + end - @trixi_testset "elixir_lbm_couette.jl with initial_condition_couette_steady" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), - l2=[9.321369073400123e-16, 1.6498793963435488e-6, - 5.211495843124065e-16, - 1.6520893954826173e-6, 1.0406056181388841e-5, - 8.801606429417205e-6, - 8.801710065560555e-6, 1.040614383799995e-5, - 2.6135657178357052e-15], - linf=[1.4432899320127035e-15, 2.1821189867266e-6, - 8.881784197001252e-16, - 2.2481261510165496e-6, 1.0692966335143494e-5, - 9.606391697600247e-6, - 9.62138334279633e-6, 1.0725969916147021e-5, - 3.3861802251067274e-15], - initial_condition=function initial_condition_couette_steady(x, - t, - equations::LatticeBoltzmannEquations2D) - # Initial state for a *steady* Couette flow setup. To be used in combination with - # [`boundary_condition_couette`](@ref) and [`boundary_condition_noslip_wall`](@ref). - @unpack L, u0, rho0 = equations + @trixi_testset "elixir_lbm_couette.jl with initial_condition_couette_steady" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), + l2 = [9.321369073400123e-16, 1.6498793963435488e-6, 5.211495843124065e-16, + 1.6520893954826173e-6, 1.0406056181388841e-5, 8.801606429417205e-6, + 8.801710065560555e-6, 1.040614383799995e-5, 2.6135657178357052e-15], + linf = [1.4432899320127035e-15, 2.1821189867266e-6, 8.881784197001252e-16, + 2.2481261510165496e-6, 1.0692966335143494e-5, 9.606391697600247e-6, + 9.62138334279633e-6, 1.0725969916147021e-5, 3.3861802251067274e-15], + initial_condition=function initial_condition_couette_steady(x, t, equations::LatticeBoltzmannEquations2D) + # Initial state for a *steady* Couette flow setup. To be used in combination with + # [`boundary_condition_couette`](@ref) and [`boundary_condition_noslip_wall`](@ref). + @unpack L, u0, rho0 = equations - rho = rho0 - v1 = u0 * x[2] / L - v2 = 0 + rho = rho0 + v1 = u0 * x[2] / L + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) - end, - tspan=(0.0, 1.0)) - end + return equilibrium_distribution(rho, v1, v2, equations) + end, + tspan = (0.0, 1.0)) + end - @trixi_testset "elixir_lbm_lid_driven_cavity.jl with stationary walls" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), - l2=[1.7198203373689985e-16, 1.685644347036533e-16, - 2.1604974801394525e-16, - 2.1527076266915764e-16, 4.2170298143732604e-17, - 5.160156233016299e-17, - 6.167794865198169e-17, 5.24166554417795e-17, - 6.694740573885739e-16], - linf=[5.967448757360216e-16, 6.522560269672795e-16, - 6.522560269672795e-16, - 6.245004513516506e-16, 2.1163626406917047e-16, - 2.185751579730777e-16, - 2.185751579730777e-16, 2.393918396847994e-16, - 1.887379141862766e-15], - boundary_conditions=boundary_condition_noslip_wall, - tspan=(0, 0.1)) - end + @trixi_testset "elixir_lbm_lid_driven_cavity.jl with stationary walls" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), + l2 = [1.7198203373689985e-16, 1.685644347036533e-16, 2.1604974801394525e-16, + 2.1527076266915764e-16, 4.2170298143732604e-17, 5.160156233016299e-17, + 6.167794865198169e-17, 5.24166554417795e-17, 6.694740573885739e-16], + linf = [5.967448757360216e-16, 6.522560269672795e-16, 6.522560269672795e-16, + 6.245004513516506e-16, 2.1163626406917047e-16, 2.185751579730777e-16, + 2.185751579730777e-16, 2.393918396847994e-16, 1.887379141862766e-15], + boundary_conditions=boundary_condition_noslip_wall, + tspan = (0, 0.1)) + end end end # module diff --git a/test/test_tree_2d_linearizedeuler.jl b/test/test_tree_2d_linearizedeuler.jl index 3f150448c55..540b3951212 100644 --- a/test/test_tree_2d_linearizedeuler.jl +++ b/test/test_tree_2d_linearizedeuler.jl @@ -7,19 +7,10 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Linearized Euler Equations 2D" begin - @trixi_testset "elixir_linearizedeuler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_convergence.jl"), - l2=[ - 0.00020601485381444888, - 0.00013380483421751216, - 0.0001338048342174503, - 0.00020601485381444888, - ], - linf=[ - 0.0011006084408365924, - 0.0005788678074691855, - 0.0005788678074701847, - 0.0011006084408365924, - ]) - end + @trixi_testset "elixir_linearizedeuler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_convergence.jl"), + l2 = [0.00020601485381444888, 0.00013380483421751216, 0.0001338048342174503, 0.00020601485381444888], + linf = [0.0011006084408365924, 0.0005788678074691855, 0.0005788678074701847, 0.0011006084408365924] + ) + end end diff --git a/test/test_tree_2d_mhd.jl b/test/test_tree_2d_mhd.jl index 1c64b01ba66..ad9e913eab9 100644 --- a/test/test_tree_2d_mhd.jl +++ b/test/test_tree_2d_mhd.jl @@ -8,253 +8,71 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "MHD" begin - @trixi_testset "elixir_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[ - 0.00011149543672225127, - 5.888242524520296e-6, - 5.888242524510072e-6, - 8.476931432519067e-6, - 1.3160738644036652e-6, - 1.2542675002588144e-6, - 1.2542675002747718e-6, - 1.8705223407238346e-6, - 4.651717010670585e-7, - ], - linf=[ - 0.00026806333988971254, - 1.6278838272418272e-5, - 1.627883827305665e-5, - 2.7551183488072617e-5, - 5.457878055614707e-6, - 8.130129322880819e-6, - 8.130129322769797e-6, - 1.2406302192291552e-5, - 2.373765544951732e-6, - ]) - end + @trixi_testset "elixir_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [0.00011149543672225127, 5.888242524520296e-6, 5.888242524510072e-6, 8.476931432519067e-6, 1.3160738644036652e-6, 1.2542675002588144e-6, 1.2542675002747718e-6, 1.8705223407238346e-6, 4.651717010670585e-7], + linf = [0.00026806333988971254, 1.6278838272418272e-5, 1.627883827305665e-5, 2.7551183488072617e-5, 5.457878055614707e-6, 8.130129322880819e-6, 8.130129322769797e-6, 1.2406302192291552e-5, 2.373765544951732e-6]) + end - @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[ - 1.7201098719531215e-6, - 8.692057393373005e-7, - 8.69205739320643e-7, - 1.2726508184718958e-6, - 1.040607127595208e-6, - 1.07029565814218e-6, - 1.0702956581404748e-6, - 1.3291748105236525e-6, - 4.6172239295786824e-7, - ], - linf=[ - 9.865325754310206e-6, - 7.352074675170961e-6, - 7.352074674185638e-6, - 1.0675656902672803e-5, - 5.112498347226158e-6, - 7.789533065905019e-6, - 7.789533065905019e-6, - 1.0933531593274037e-5, - 2.340244047768378e-6, - ], - volume_flux=(flux_derigs_etal, flux_nonconservative_powell)) - end + @trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [1.7201098719531215e-6, 8.692057393373005e-7, 8.69205739320643e-7, 1.2726508184718958e-6, 1.040607127595208e-6, 1.07029565814218e-6, 1.0702956581404748e-6, 1.3291748105236525e-6, 4.6172239295786824e-7], + linf = [9.865325754310206e-6, 7.352074675170961e-6, 7.352074674185638e-6, 1.0675656902672803e-5, 5.112498347226158e-6, 7.789533065905019e-6, 7.789533065905019e-6, 1.0933531593274037e-5, 2.340244047768378e-6], + volume_flux = (flux_derigs_etal, flux_nonconservative_powell)) + end - @trixi_testset "elixir_mhd_alfven_wave_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_mortar.jl"), - l2=[ - 3.7762324533854616e-6, - 1.5534623833573546e-6, - 1.4577234868196855e-6, - 1.7647724628707057e-6, - 1.4831911814574333e-6, - 1.456369119716533e-6, - 1.4115666913995062e-6, - 1.804758237422838e-6, - 8.320469738087189e-7, - ], - linf=[ - 3.670661330201774e-5, - 1.530289442645827e-5, - 1.3592183785327006e-5, - 1.5173897443654383e-5, - 9.43771379136038e-6, - 1.0906323046233624e-5, - 1.0603954940346938e-5, - 1.5900499596113726e-5, - 5.978772247650426e-6, - ], - tspan=(0.0, 1.0)) - end + @trixi_testset "elixir_mhd_alfven_wave_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_mortar.jl"), + l2 = [3.7762324533854616e-6, 1.5534623833573546e-6, 1.4577234868196855e-6, 1.7647724628707057e-6, 1.4831911814574333e-6, 1.456369119716533e-6, 1.4115666913995062e-6, 1.804758237422838e-6, 8.320469738087189e-7], + linf = [3.670661330201774e-5, 1.530289442645827e-5, 1.3592183785327006e-5, 1.5173897443654383e-5, 9.43771379136038e-6, 1.0906323046233624e-5, 1.0603954940346938e-5, 1.5900499596113726e-5, 5.978772247650426e-6], + tspan = (0.0, 1.0)) + end - @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2=[ - 0.03637302248881514, - 0.043002991956758996, - 0.042987505670836056, - 0.02574718055258975, - 0.1621856170457943, - 0.01745369341302589, - 0.017454552320664566, - 0.026873190440613117, - 5.336243933079389e-16, - ], - linf=[ - 0.23623816236321427, - 0.3137152204179957, - 0.30378397831730597, - 0.21500228807094865, - 0.9042495730546518, - 0.09398098096581875, - 0.09470282020962917, - 0.15277253978297378, - 4.307694418935709e-15, - ]) - end + @trixi_testset "elixir_mhd_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), + l2 = [0.03637302248881514, 0.043002991956758996, 0.042987505670836056, 0.02574718055258975, 0.1621856170457943, 0.01745369341302589, 0.017454552320664566, 0.026873190440613117, 5.336243933079389e-16], + linf = [0.23623816236321427, 0.3137152204179957, 0.30378397831730597, 0.21500228807094865, 0.9042495730546518, 0.09398098096581875, 0.09470282020962917, 0.15277253978297378, 4.307694418935709e-15]) + end - @trixi_testset "elixir_mhd_orszag_tang.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), - l2=[ - 0.21967600768935716, - 0.2643126515795721, - 0.31488287201980875, - 0.0, - 0.5160141621186931, - 0.23028914748088603, - 0.34413527376463915, - 0.0, - 0.003178793090381426, - ], - linf=[ - 1.2749969218080568, - 0.6737013368774057, - 0.8604154399895696, - 0.0, - 2.799342099887639, - 0.6473347557712643, - 0.9691773375490476, - 0.0, - 0.05729832038724348, - ], - tspan=(0.0, 0.09)) - end + @trixi_testset "elixir_mhd_orszag_tang.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), + l2 = [0.21967600768935716, 0.2643126515795721, 0.31488287201980875, 0.0, 0.5160141621186931, 0.23028914748088603, 0.34413527376463915, 0.0, 0.003178793090381426], + linf = [1.2749969218080568, 0.6737013368774057, 0.8604154399895696, 0.0, 2.799342099887639, 0.6473347557712643, 0.9691773375490476, 0.0, 0.05729832038724348], + tspan = (0.0, 0.09)) + end - @trixi_testset "elixir_mhd_orszag_tang.jl with flux_hll" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), - l2=[ - 0.10806619664693064, - 0.20199136742199922, - 0.22984589847526207, - 0.0, - 0.29950152196422647, - 0.15688413207147794, - 0.24293641543490646, - 0.0, - 0.003246181006326598, - ], - linf=[ - 0.560316034595759, - 0.5095520363866776, - 0.6536748458764621, - 0.0, - 0.9627447086204038, - 0.3981375420906146, - 0.673472146198816, - 0.0, - 0.04879208429337193, - ], - tspan=(0.0, 0.06), - surface_flux=(FluxHLL(min_max_speed_einfeldt), - flux_nonconservative_powell)) - end + @trixi_testset "elixir_mhd_orszag_tang.jl with flux_hll" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), + l2 = [0.10806619664693064, 0.20199136742199922, 0.22984589847526207, 0.0, 0.29950152196422647, 0.15688413207147794, 0.24293641543490646, 0.0, 0.003246181006326598], + linf = [0.560316034595759, 0.5095520363866776, 0.6536748458764621, 0.0, 0.9627447086204038, 0.3981375420906146, 0.673472146198816, 0.0, 0.04879208429337193], + tspan = (0.0, 0.06), surface_flux = (FluxHLL(min_max_speed_einfeldt), flux_nonconservative_powell)) + end - @trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[ - 7.144325530681224e-17, - 2.123397983547417e-16, - 5.061138912500049e-16, - 3.6588423152083e-17, - 8.449816179702522e-15, - 3.9171737639099993e-16, - 2.445565690318772e-16, - 3.6588423152083e-17, - 9.971153407737885e-17, - ], - linf=[ - 2.220446049250313e-16, - 8.465450562766819e-16, - 1.8318679906315083e-15, - 1.1102230246251565e-16, - 1.4210854715202004e-14, - 8.881784197001252e-16, - 4.440892098500626e-16, - 1.1102230246251565e-16, - 4.779017148551244e-16, - ], - maxiters=1, - initial_condition=initial_condition_constant, - atol=2.0e-13) - end + @trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2 = [7.144325530681224e-17, 2.123397983547417e-16, 5.061138912500049e-16, 3.6588423152083e-17, 8.449816179702522e-15, 3.9171737639099993e-16, 2.445565690318772e-16, 3.6588423152083e-17, 9.971153407737885e-17], + linf = [2.220446049250313e-16, 8.465450562766819e-16, 1.8318679906315083e-15, 1.1102230246251565e-16, 1.4210854715202004e-14, 8.881784197001252e-16, 4.440892098500626e-16, 1.1102230246251565e-16, 4.779017148551244e-16], + maxiters = 1, + initial_condition = initial_condition_constant, + atol = 2.0e-13) + end - @trixi_testset "elixir_mhd_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2=[ - 1.2623319195262743, - 1.8273050553090515, - 1.7004151198284634, - 0.0, - 2.2978570581460818, - 0.2147235065899803, - 0.23558337696054493, - 0.0, - 0.0032515115395693483, - ], - linf=[ - 11.003677581472843, - 14.70614192714736, - 15.687648666952708, - 0.0, - 17.098104835553823, - 1.3283750501377847, - 1.4365828094434892, - 0.0, - 0.07886241196068537, - ], - tspan=(0.0, 0.05)) - end + @trixi_testset "elixir_mhd_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), + l2 = [1.2623319195262743, 1.8273050553090515, 1.7004151198284634, 0.0, 2.2978570581460818, 0.2147235065899803, 0.23558337696054493, 0.0, 0.0032515115395693483], + linf = [11.003677581472843, 14.70614192714736, 15.687648666952708, 0.0, 17.098104835553823, 1.3283750501377847, 1.4365828094434892, 0.0, 0.07886241196068537], + tspan = (0.0, 0.05)) + end - @trixi_testset "elixir_mhd_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_blast_wave.jl"), - l2=[ - 0.17646728395490927, - 3.866230215339417, - 2.4867304651291255, - 0.0, - 355.4562971958441, - 2.359493623565687, - 1.4030741420730297, - 0.0, - 0.029613599942667133, - ], - linf=[ - 1.581630420824181, - 44.15725488910748, - 13.056964982196554, - 0.0, - 2244.875490238186, - 13.07679044647926, - 9.14612176426092, - 0.0, - 0.5154756722488522, - ], - tspan=(0.0, 0.003), - # Calling the AnalysisCallback before iteration 9 causes the interpolation - # of this IC to have negative density/pressure values, crashing the simulation. - coverage_override=(maxiters = 9,)) - end + @trixi_testset "elixir_mhd_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_blast_wave.jl"), + l2 = [0.17646728395490927, 3.866230215339417, 2.4867304651291255, 0.0, 355.4562971958441, 2.359493623565687, 1.4030741420730297, 0.0, 0.029613599942667133], + linf = [1.581630420824181, 44.15725488910748, 13.056964982196554, 0.0, 2244.875490238186, 13.07679044647926, 9.14612176426092, 0.0, 0.5154756722488522], + tspan = (0.0, 0.003), + # Calling the AnalysisCallback before iteration 9 causes the interpolation + # of this IC to have negative density/pressure values, crashing the simulation. + coverage_override = (maxiters=9,)) + end end end # module diff --git a/test/test_tree_2d_mhdmulti.jl b/test/test_tree_2d_mhdmulti.jl index 2f1bb15eaf0..09c26569d46 100644 --- a/test/test_tree_2d_mhdmulti.jl +++ b/test/test_tree_2d_mhdmulti.jl @@ -8,84 +8,62 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "MHD Multicomponent" begin - @trixi_testset "elixir_mhdmulti_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2=[0.04300299195675897, 0.042987505670835945, - 0.025747180552589767, 0.1621856170457937, - 0.017453693413025828, 0.0174545523206645, - 0.026873190440613162, 1.364647699274761e-15, - 0.012124340829605002, 0.024248681659210004], - linf=[0.31371522041799105, 0.3037839783173047, - 0.21500228807094351, 0.904249573054642, - 0.0939809809658183, 0.09470282020962761, 0.1527725397829759, - 8.245701827530042e-15, - 0.0787460541210726, 0.1574921082421452]) - end - @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2=[0.04301155595653799, 0.04299735787276207, - 0.025745530869947714, - 0.16206102676791553, 0.017454384272339165, - 0.01745523378100091, - 0.026879482381500154, 0.0002038008756963954, - 0.012094208262809778, - 0.024188416525619556], - linf=[0.3156206778985397, 0.30941696929809526, - 0.21167563519254176, - 0.9688251298546122, 0.09076254289155083, - 0.09160589769498295, - 0.15698032974768705, 0.006131914796912965, - 0.07839287555951036, - 0.1567857511190207], - volume_flux=(flux_derigs_etal, flux_nonconservative_powell), - surface_flux=(flux_derigs_etal, flux_nonconservative_powell)) - end + @trixi_testset "elixir_mhdmulti_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2 = [0.04300299195675897, 0.042987505670835945, 0.025747180552589767, 0.1621856170457937, + 0.017453693413025828, 0.0174545523206645, 0.026873190440613162, 1.364647699274761e-15, + 0.012124340829605002, 0.024248681659210004], + linf = [0.31371522041799105, 0.3037839783173047, 0.21500228807094351, 0.904249573054642, + 0.0939809809658183, 0.09470282020962761, 0.1527725397829759, 8.245701827530042e-15, + 0.0787460541210726, 0.1574921082421452]) + end - @trixi_testset "elixir_mhdmulti_es.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), - l2=[0.042511527162267, 0.04250603277530184, 0.02385422747993974, - 0.11555081362726903, - 0.016366641053738043, 0.01636681584592762, - 0.02581748418797907, 0.00023394429554818215, - 0.010834603551662698, 0.021669207103325396], - linf=[0.23454607703107877, 0.23464789247380322, - 0.11898832084115452, 0.5331209602648022, - 0.061744814466827336, 0.061767127585091286, - 0.09595041452184983, 0.004421037168524759, - 0.06186597801911198, 0.12373195603822396]) - end + @trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), + l2 = [0.04301155595653799, 0.04299735787276207, 0.025745530869947714, + 0.16206102676791553, 0.017454384272339165, 0.01745523378100091, + 0.026879482381500154, 0.0002038008756963954, 0.012094208262809778, + 0.024188416525619556], + linf = [0.3156206778985397, 0.30941696929809526, 0.21167563519254176, + 0.9688251298546122, 0.09076254289155083, 0.09160589769498295, + 0.15698032974768705, 0.006131914796912965, 0.07839287555951036, + 0.1567857511190207], + volume_flux = (flux_derigs_etal, flux_nonconservative_powell), + surface_flux = (flux_derigs_etal, flux_nonconservative_powell)) + end - @trixi_testset "elixir_mhdmulti_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), - l2=[0.0003808877028249613, 0.0003808877028249593, - 0.0005155994511260122, 0.000570394227652563, - 0.000439568811048544, 0.0004395688110485541, - 0.0005074093477702055, 0.0003859005258180428, - 7.4611207452221e-5, 0.000149222414904442, - 0.000298444829808884], - linf=[0.0013324014301672943, 0.0013324014301669181, - 0.002684449324758791, 0.0016236816790307085, - 0.0019172373117153363, 0.0019172373117148922, - 0.002664932274107224, 0.0011872396664042962, - 0.0002855492944235094, 0.0005710985888470188, - 0.0011421971776940376]) - end + @trixi_testset "elixir_mhdmulti_es.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), + l2 = [0.042511527162267, 0.04250603277530184, 0.02385422747993974, 0.11555081362726903, + 0.016366641053738043, 0.01636681584592762, 0.02581748418797907, 0.00023394429554818215, + 0.010834603551662698, 0.021669207103325396], + linf = [0.23454607703107877, 0.23464789247380322, 0.11898832084115452, 0.5331209602648022, + 0.061744814466827336, 0.061767127585091286, 0.09595041452184983, 0.004421037168524759, + 0.06186597801911198, 0.12373195603822396]) + end + + @trixi_testset "elixir_mhdmulti_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), + l2 = [0.0003808877028249613, 0.0003808877028249593, 0.0005155994511260122, 0.000570394227652563, + 0.000439568811048544, 0.0004395688110485541, 0.0005074093477702055, 0.0003859005258180428, + 7.4611207452221e-5, 0.000149222414904442, 0.000298444829808884], + linf = [0.0013324014301672943, 0.0013324014301669181, 0.002684449324758791, 0.0016236816790307085, + 0.0019172373117153363, 0.0019172373117148922, 0.002664932274107224, 0.0011872396664042962, + 0.0002855492944235094, 0.0005710985888470188, 0.0011421971776940376]) + end + + @trixi_testset "elixir_mhdmulti_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_rotor.jl"), + l2 = [0.6574605535168556, 0.6623234319361953, 0.0, 0.689806698245354, + 0.04883686128677976, 0.08382459729494686, 0.0, 0.0021114516459281177, + 0.15909290019096098, 0.07954645009548049], + linf = [9.362339085941425, 9.169838118652539, 0.0, 10.600957847359556, + 0.6628317732399827, 1.4185626901435056, 0.0, 0.06914316292003836, + 3.328770801731456, 1.664385400865728], + tspan = (0.0, 0.01)) +end - @trixi_testset "elixir_mhdmulti_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_rotor.jl"), - l2=[0.6574605535168556, 0.6623234319361953, 0.0, - 0.689806698245354, - 0.04883686128677976, 0.08382459729494686, 0.0, - 0.0021114516459281177, - 0.15909290019096098, 0.07954645009548049], - linf=[9.362339085941425, 9.169838118652539, 0.0, - 10.600957847359556, - 0.6628317732399827, 1.4185626901435056, 0.0, - 0.06914316292003836, - 3.328770801731456, 1.664385400865728], - tspan=(0.0, 0.01)) - end end end # module From ce72be08dc9085330faf09426e29c9e88728c8b3 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 23 Jun 2023 13:08:57 +0200 Subject: [PATCH 16/22] format equations --- src/equations/linearized_euler_2d.jl | 4 ++-- src/equations/shallow_water_1d.jl | 6 +++--- src/equations/shallow_water_2d.jl | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/equations/linearized_euler_2d.jl b/src/equations/linearized_euler_2d.jl index 3ebd0f736ba..d35e077e4e8 100644 --- a/src/equations/linearized_euler_2d.jl +++ b/src/equations/linearized_euler_2d.jl @@ -177,8 +177,8 @@ end norm_ = norm(normal_direction) - v_normal = - v_mean_global[1] * normal_direction[1] + v_mean_global[2] * normal_direction[2] + v_normal = v_mean_global[1] * normal_direction[1] + + v_mean_global[2] * normal_direction[2] # The v_normals are already scaled by the norm λ_min = v_normal - c_mean_global * norm_ diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index d8cf9d51b46..3a94db49f93 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -621,11 +621,11 @@ Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - - v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr)/(h_ll_sqrt + h_rr_sqrt) + + v_roe = (h_ll_sqrt * v_ll + h_rr_sqrt * v_rr) / (h_ll_sqrt + h_rr_sqrt) return v_roe, c_roe -end +end # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations1D) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index 321d923ffbe..f39f3de5d1d 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -966,15 +966,15 @@ slides 8 and 9. h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - + if orientation == 1 # x-direction - v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) + v_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr) / (h_ll_sqrt + h_rr_sqrt) else # y-direction - v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) + v_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr) / (h_ll_sqrt + h_rr_sqrt) end return v_roe, c_roe -end +end @inline function calc_wavespeed_roe(u_ll, u_rr, normal_direction::AbstractVector, equations::ShallowWaterEquations2D) @@ -990,14 +990,14 @@ end h_ll_sqrt = sqrt(h_ll) h_rr_sqrt = sqrt(h_rr) - - v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr)/(h_ll_sqrt + h_rr_sqrt) - v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr)/(h_ll_sqrt + h_rr_sqrt) + + v1_roe = (h_ll_sqrt * v1_ll + h_rr_sqrt * v1_rr) / (h_ll_sqrt + h_rr_sqrt) + v2_roe = (h_ll_sqrt * v2_ll + h_rr_sqrt * v2_rr) / (h_ll_sqrt + h_rr_sqrt) v_roe = (v1_roe * normal_direction[1] + v2_roe * normal_direction[2]) return v_roe, c_roe -end +end # Entropy function for the shallow water equations is the total energy @inline function entropy(cons, equations::ShallowWaterEquations2D) From f7b2b1e7248ddc0b4f7c4f7c7b9229b3c46878c9 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Sat, 24 Jun 2023 09:49:51 +0200 Subject: [PATCH 17/22] Add unit tests for HLL naive --- test/test_unit.jl | 97 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/test/test_unit.jl b/test/test_unit.jl index bb197d823eb..74744b523ad 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -586,8 +586,103 @@ isdir(outdir) && rm(outdir, recursive=true) @test_throws ArgumentError TimeSeriesCallback(semi, [1.0 1.0 1.0; 2.0 2.0 2.0]) end + @timed_testset "Consistency check for HLL flux (naive)" begin + flux_hll = FluxHLL(min_max_speed_naive) + + # Set up equations and dummy conservative variables state + equations = CompressibleEulerEquations1D(1.4) + u = SVector(1.1, 2.34, 5.5) + + orientations = [1] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = CompressibleEulerEquations2D(1.4) + u = SVector(1.1, -0.5, 2.34, 5.5) + + orientations = [1, 2] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = CompressibleEulerEquations3D(1.4) + u = SVector(1.1, -0.5, 2.34, 2.4, 5.5) + + orientations = [1, 2, 3] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = LinearizedEulerEquations2D(SVector(1.0, 1.0), 1.0, 1.0) + u = SVector(1.1, -0.5, 2.34, 5.5) + + orientations = [1, 2] + for orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + equations = ShallowWaterEquations1D(gravity_constant=9.81) + u = SVector(1, 0.5, 0.0) + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + + equations = ShallowWaterEquations2D(gravity_constant=9.81) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u = SVector(1, 0.5, 0.5, 0.0) + for normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + + equations = IdealGlmMhdEquations1D(1.4) + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2),] + + for u in u_values + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + end + + equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + orientations = [1, 2] + + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + + for u in u_values, orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + for u in u_values, normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + + equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) + normal_directions = [SVector(1.0, 0.0, 0.0), + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] + orientations = [1, 2, 3] + + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + + for u in u_values, orientation in orientations + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + end + + for u in u_values, normal_direction in normal_directions + @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + end + end + @timed_testset "Consistency check for HLL flux" begin - # Test HLL flux with min_max_speed_einfeldt flux_hll = FluxHLL(min_max_speed) # Set up equations and dummy conservative variables state From f1e7f5beb4cc8d630d5199cfb444e98a23330fe1 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Mon, 3 Jul 2023 09:58:18 +0200 Subject: [PATCH 18/22] Revert default hll flux --- examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl | 2 +- examples/dgmulti_2d/elixir_euler_bilinear.jl | 2 +- examples/dgmulti_2d/elixir_euler_curved.jl | 2 +- examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl | 2 +- .../dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl | 2 +- examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl | 2 +- examples/dgmulti_2d/elixir_euler_weakform.jl | 2 +- examples/dgmulti_2d/elixir_euler_weakform_periodic.jl | 2 +- examples/dgmulti_3d/elixir_euler_curved.jl | 2 +- examples/dgmulti_3d/elixir_euler_weakform.jl | 2 +- examples/dgmulti_3d/elixir_euler_weakform_periodic.jl | 2 +- examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl | 2 +- .../elixir_euler_source_terms_nonconforming_earth.jl | 2 +- .../elixir_euler_convergence.jl | 2 +- .../elixir_eulergravity_convergence.jl | 2 +- .../elixir_eulergravity_jeans_instability.jl | 2 +- .../elixir_eulergravity_sedov_blast_wave.jl | 2 +- examples/structured_1d_dgsem/elixir_euler_source_terms.jl | 2 +- .../elixir_euler_rayleigh_taylor_instability.jl | 2 +- examples/tree_1d_dgsem/elixir_euler_source_terms.jl | 2 +- examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl | 2 +- .../elixir_shallowwater_well_balanced_nonperiodic.jl | 2 +- examples/tree_3d_dgsem/elixir_euler_convergence.jl | 2 +- examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl | 2 +- examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl | 2 +- examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl | 2 +- examples/unstructured_2d_dgsem/elixir_euler_periodic.jl | 2 +- examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl | 2 +- .../unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl | 2 +- .../elixir_shallowwater_wall_bc_shockcapturing.jl | 2 +- src/equations/numerical_fluxes.jl | 4 ++-- test/test_special_elixirs.jl | 2 +- test/test_tree_1d_euler.jl | 2 +- test/test_tree_1d_shallowwater.jl | 4 ++-- test/test_tree_2d_shallowwater.jl | 2 +- test/test_unit.jl | 2 +- test/test_unstructured_2d.jl | 2 +- 37 files changed, 39 insertions(+), 39 deletions(-) diff --git a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl index f5c2a07bd24..3566185d110 100644 --- a/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_1d/elixir_euler_fdsbp_periodic.jl @@ -4,7 +4,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Line(), approximation_type = periodic_derivative_operator( derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), - surface_flux = FluxHLL(min_max_speed_naive), + surface_flux = flux_hll, volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations1D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_bilinear.jl b/examples/dgmulti_2d/elixir_euler_bilinear.jl index e9f02863c9b..bdd582610ea 100644 --- a/examples/dgmulti_2d/elixir_euler_bilinear.jl +++ b/examples/dgmulti_2d/elixir_euler_bilinear.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_curved.jl b/examples/dgmulti_2d/elixir_euler_curved.jl index 9e773ff7399..a3ba62f1cfb 100644 --- a/examples/dgmulti_2d/elixir_euler_curved.jl +++ b/examples/dgmulti_2d/elixir_euler_curved.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl index 81cd9224d18..d41ca2c5b34 100644 --- a/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_fdsbp_periodic.jl @@ -4,7 +4,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(element_type = Quad(), approximation_type = periodic_derivative_operator( derivative_order=1, accuracy_order=4, xmin=0.0, xmax=1.0, N=50), - surface_flux = FluxHLL(min_max_speed_naive), + surface_flux = flux_hll, volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl index e3ced751af4..f5adc7bf83c 100644 --- a/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/dgmulti_2d/elixir_euler_rayleigh_taylor_instability.jl @@ -61,7 +61,7 @@ end # numerical parameters dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) num_elements = 16 diff --git a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl index 150fb769138..c10b5e46a14 100644 --- a/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl +++ b/examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl @@ -1,7 +1,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tri(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_weakform.jl b/examples/dgmulti_2d/elixir_euler_weakform.jl index a43790a4d5f..486a30b37f1 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl index 0bb011bf540..c4c83fff642 100644 --- a/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_2d/elixir_euler_weakform_periodic.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tri(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations2D(1.4) diff --git a/examples/dgmulti_3d/elixir_euler_curved.jl b/examples/dgmulti_3d/elixir_euler_curved.jl index 56d870f6bf6..d8c4df5dd64 100644 --- a/examples/dgmulti_3d/elixir_euler_curved.jl +++ b/examples/dgmulti_3d/elixir_euler_curved.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Hex(), approximation_type=SBP(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)) equations = CompressibleEulerEquations3D(1.4) diff --git a/examples/dgmulti_3d/elixir_euler_weakform.jl b/examples/dgmulti_3d/elixir_euler_weakform.jl index 2a44a7b6c7b..b167377af51 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tet(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations3D(1.4) diff --git a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl index fd4a83a386f..6b17d4bba65 100644 --- a/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl +++ b/examples/dgmulti_3d/elixir_euler_weakform_periodic.jl @@ -2,7 +2,7 @@ using Trixi, OrdinaryDiffEq dg = DGMulti(polydeg = 3, element_type = Tet(), approximation_type = Polynomial(), - surface_integral = SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)), + surface_integral = SurfaceIntegralWeakForm(flux_hll), volume_integral = VolumeIntegralWeakForm()) equations = CompressibleEulerEquations3D(1.4) diff --git a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl index a99f9110aa8..b34c73d2a4e 100644 --- a/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/p4est_2d_dgsem/elixir_eulergravity_convergence.jl @@ -12,7 +12,7 @@ gamma = 2.0 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 -solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) +solver_euler = DGSEM(polydeg, flux_hll) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) diff --git a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl index fc5c7da5234..c5e349934a2 100644 --- a/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl +++ b/examples/p4est_3d_dgsem/elixir_euler_source_terms_nonconforming_earth.jl @@ -68,7 +68,7 @@ boundary_conditions = Dict( :outside => boundary_condition ) -surface_flux = FluxHLL(min_max_speed_naive) +surface_flux = flux_hll # Note that a free stream is not preserved if N < 2 * N_geo, where N is the # polydeg of the solver and N_geo is the polydeg of the mesh. # However, the FSP error is negligible in this example. diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl index f76ca4f2cdf..316f36adc9b 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_euler_convergence.jl @@ -8,7 +8,7 @@ equations = CompressibleEulerEquations2D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg=3, surface_flux=flux_hll) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl index 8277577f5b9..f2693c89583 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_convergence.jl @@ -12,7 +12,7 @@ gamma = 2.0 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 -solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) +solver_euler = DGSEM(polydeg, flux_hll) coordinates_min = (0.0, 0.0) coordinates_max = (2.0, 2.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl index a23915745df..1774e39513d 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_jeans_instability.jl @@ -68,7 +68,7 @@ gamma = 5/3 equations_euler = CompressibleEulerEquations2D(gamma) polydeg = 3 -solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) +solver_euler = DGSEM(polydeg, flux_hll) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) diff --git a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl index de8baf2ecdb..f7bb5bbb01c 100644 --- a/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl +++ b/examples/paper_self_gravitating_gas_dynamics/elixir_eulergravity_sedov_blast_wave.jl @@ -85,7 +85,7 @@ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, end boundary_conditions = boundary_condition_sedov_self_gravity -surface_flux = FluxHLL(min_max_speed_naive) +surface_flux = flux_hll volume_flux = flux_chandrashekar polydeg = 3 basis = LobattoLegendreBasis(polydeg) diff --git a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl index 05bf07f59c0..cbda7087052 100644 --- a/examples/structured_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/structured_1d_dgsem/elixir_euler_source_terms.jl @@ -12,7 +12,7 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. -# Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. +# Using flux_hll instead yields the expected EOC. solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = (0.0,) diff --git a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl index 499aea21d9b..bb5870ab9d5 100644 --- a/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl +++ b/examples/structured_2d_dgsem/elixir_euler_rayleigh_taylor_instability.jl @@ -61,7 +61,7 @@ end # numerical parameters volume_flux = flux_ranocha -solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), +solver = DGSEM(polydeg=3, surface_flux=flux_hll, volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) # The domain is [0, 0.25] x [0, 1] diff --git a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl index 193c6cedc5b..213206eb9e0 100644 --- a/examples/tree_1d_dgsem/elixir_euler_source_terms.jl +++ b/examples/tree_1d_dgsem/elixir_euler_source_terms.jl @@ -10,7 +10,7 @@ equations = CompressibleEulerEquations1D(1.4) initial_condition = initial_condition_convergence_test # Note that the expected EOC of 5 is not reached with this flux. -# Using FluxHLL(min_max_speed_naive) instead yields the expected EOC. +# Using flux_hll instead yields the expected EOC. solver = DGSEM(polydeg=4, surface_flux=flux_lax_friedrichs) coordinates_min = 0.0 diff --git a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl index 762ab1c90ca..42de0e18e51 100644 --- a/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_1d_dgsem/elixir_eulergravity_convergence.jl @@ -10,7 +10,7 @@ equations_euler = CompressibleEulerEquations1D(gamma) initial_condition = initial_condition_eoc_test_coupled_euler_gravity polydeg = 3 -solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) +solver_euler = DGSEM(polydeg, flux_hll) coordinates_min = 0.0 coordinates_max = 2.0 diff --git a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl index 4dff087390d..ef707b803e9 100644 --- a/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl +++ b/examples/tree_1d_dgsem/elixir_shallowwater_well_balanced_nonperiodic.jl @@ -26,7 +26,7 @@ boundary_condition = BoundaryConditionDirichlet(initial_condition) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), +solver = DGSEM(polydeg=4, surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### diff --git a/examples/tree_3d_dgsem/elixir_euler_convergence.jl b/examples/tree_3d_dgsem/elixir_euler_convergence.jl index 493fef8309b..2eeb280ae1f 100644 --- a/examples/tree_3d_dgsem/elixir_euler_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_euler_convergence.jl @@ -9,7 +9,7 @@ equations = CompressibleEulerEquations3D(2.0) initial_condition = initial_condition_eoc_test_coupled_euler_gravity -solver = DGSEM(polydeg=3, surface_flux=FluxHLL(min_max_speed_naive), +solver = DGSEM(polydeg=3, surface_flux=flux_hll, volume_integral=VolumeIntegralWeakForm()) coordinates_min = (0.0, 0.0, 0.0) diff --git a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl index 8e0625dea3a..336c09e9212 100644 --- a/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl +++ b/examples/tree_3d_dgsem/elixir_euler_sedov_blast_wave.jl @@ -87,7 +87,7 @@ function boundary_condition_sedov_self_gravity(u_inner, orientation, direction, end boundary_conditions = boundary_condition_sedov_self_gravity -surface_flux = FluxHLL(min_max_speed_naive) +surface_flux = flux_hll volume_flux = flux_ranocha polydeg = 3 basis = LobattoLegendreBasis(polydeg) diff --git a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl index 3935a219a96..6699ec9a4da 100644 --- a/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl +++ b/examples/tree_3d_dgsem/elixir_eulergravity_convergence.jl @@ -10,7 +10,7 @@ equations_euler = CompressibleEulerEquations3D(gamma) initial_condition = initial_condition_eoc_test_coupled_euler_gravity polydeg = 3 -solver_euler = DGSEM(polydeg, FluxHLL(min_max_speed_naive)) +solver_euler = DGSEM(polydeg, flux_hll) coordinates_min = (0.0, 0.0, 0.0) coordinates_max = (2.0, 2.0, 2.0) diff --git a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl index cb289848039..36e119ab794 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_free_stream.jl @@ -22,7 +22,7 @@ boundary_conditions = Dict( :Body => boundary_condition_free_stream, ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=6, surface_flux=FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg=6, surface_flux=flux_hll) ############################################################################### # Get the curved quad mesh from a file (downloads the file if not available locally) diff --git a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl index 5f248eb110d..796c99987a2 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_periodic.jl @@ -15,7 +15,7 @@ boundary_conditions = boundary_condition_periodic ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=6, surface_flux=FluxRotated(FluxHLL(min_max_speed_naive))) +solver = DGSEM(polydeg=6, surface_flux=FluxRotated(flux_hll)) ############################################################################### # Get the curved quad mesh from a file (downloads the file if not available locally) diff --git a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl index e300b39c01e..5bfe1ae4e0e 100644 --- a/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl +++ b/examples/unstructured_2d_dgsem/elixir_euler_wall_bc.jl @@ -36,7 +36,7 @@ boundary_conditions = Dict( :Bottom => boundary_condition_uniform_flow, ############################################################################### # Get the DG approximation space -solver = DGSEM(polydeg=4, surface_flux=FluxHLL(min_max_speed_naive)) +solver = DGSEM(polydeg=4, surface_flux=flux_hll) ############################################################################### # Get the curved quad mesh from a file diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl index 9a8a02feaed..044b2549b01 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_dirichlet.jl @@ -31,7 +31,7 @@ boundary_condition = Dict( :OuterCircle => boundary_condition_constant ) # Get the DG approximation space volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) -solver = DGSEM(polydeg=4, surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal), +solver = DGSEM(polydeg=4, surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal), volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) ############################################################################### diff --git a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl index ad1471a2d1a..4700724c520 100644 --- a/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl +++ b/examples/unstructured_2d_dgsem/elixir_shallowwater_wall_bc_shockcapturing.jl @@ -35,7 +35,7 @@ boundary_condition = Dict( :OuterCircle => boundary_condition_slip_wall ) ############################################################################### # Get the DG approximation space -surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), +surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal) volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal) polydeg = 6 diff --git a/src/equations/numerical_fluxes.jl b/src/equations/numerical_fluxes.jl index d729f50751f..0875df9f0f8 100644 --- a/src/equations/numerical_fluxes.jl +++ b/src/equations/numerical_fluxes.jl @@ -219,10 +219,10 @@ struct FluxHLL{MinMaxSpeed} min_max_speed::MinMaxSpeed end -FluxHLL() = FluxHLL(min_max_speed) +FluxHLL() = FluxHLL(min_max_speed_naive) """ - min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations) + min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations) min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations) Simple and fast estimate(!) of the minimal and maximal wave speed of the Riemann problem with diff --git a/test/test_special_elixirs.jl b/test/test_special_elixirs.jl index 35f5b5cfbf8..23017059eaa 100644 --- a/test/test_special_elixirs.jl +++ b/test/test_special_elixirs.jl @@ -200,7 +200,7 @@ coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", function entropy_at_final_time(k) # k is the wave number of the initial condition equations = CompressibleEulerEquations1D(1.4) mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=3, n_cells_max=10^4) - solver = DGSEM(3, FluxHLL(min_max_speed_naive), VolumeIntegralFluxDifferencing(flux_ranocha)) + solver = DGSEM(3, flux_hll, VolumeIntegralFluxDifferencing(flux_ranocha)) initial_condition = (x, t, equations) -> begin rho = 2 + sinpi(k * sum(x)) v1 = 0.1 diff --git a/test/test_tree_1d_euler.jl b/test/test_tree_1d_euler.jl index 1eda4649f65..5fb74b80bce 100644 --- a/test/test_tree_1d_euler.jl +++ b/test/test_tree_1d_euler.jl @@ -77,7 +77,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") l2 = [0.07852272782240548, 0.10209790867523805, 0.293873048809011], linf = [0.19244768908604093, 0.2515941686151897, 0.7258000837553769], maxiters = 10, - surface_flux = FluxHLL(min_max_speed_naive), + surface_flux = flux_hll, volume_flux = flux_ranocha) end diff --git a/test/test_tree_1d_shallowwater.jl b/test/test_tree_1d_shallowwater.jl index c66260c0018..1c3bac1fab6 100644 --- a/test/test_tree_1d_shallowwater.jl +++ b/test/test_tree_1d_shallowwater.jl @@ -49,7 +49,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), l2 = [0.0022758146627220154, 0.015864082886204556, 4.436491725585346e-5], linf = [0.008457195427364006, 0.057201667446161064, 9.098379777405796e-5], - tspan = (0.0, 0.025), surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal)) + tspan = (0.0, 0.025), surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) end @trixi_testset "elixir_shallowwater_source_terms_dirichlet.jl" begin @@ -63,7 +63,7 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), l2 = [0.0022956052733432287, 0.015540053559855601, 4.43649172558535e-5], linf = [0.008460440313118323, 0.05720939349382359, 9.098379777405796e-5], - surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), + surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), tspan = (0.0, 0.025)) end diff --git a/test/test_tree_2d_shallowwater.jl b/test/test_tree_2d_shallowwater.jl index 30893c5ed3a..f465a177a67 100644 --- a/test/test_tree_2d_shallowwater.jl +++ b/test/test_tree_2d_shallowwater.jl @@ -55,7 +55,7 @@ EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), l2 = [0.0018957692481057034, 0.016943229710439864, 0.01755623297390675, 6.274146767717414e-5], linf = [0.015156105797771602, 0.07964811135780492, 0.0839787097210376, 0.0001819675955490041], - tspan = (0.0, 0.025), surface_flux=(FluxHLL(min_max_speed_naive), flux_nonconservative_fjordholm_etal)) + tspan = (0.0, 0.025), surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) end end diff --git a/test/test_unit.jl b/test/test_unit.jl index 74744b523ad..2ab617b1486 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -382,7 +382,7 @@ isdir(outdir) && rm(outdir, recursive=true) @timed_testset "HLL flux with vanishing wave speed estimates (#502)" begin equations = CompressibleEulerEquations1D(1.4) u = SVector(1.0, 0.0, 0.0) - @test !any(isnan, FluxHLL(min_max_speed_naive)(u, u, 1, equations)) + @test !any(isnan, flux_hll(u, u, 1, equations)) end @timed_testset "DG L2 mortar container debug output" begin diff --git a/test/test_unstructured_2d.jl b/test/test_unstructured_2d.jl index 5b2ae286b00..d4b0d150ca1 100644 --- a/test/test_unstructured_2d.jl +++ b/test/test_unstructured_2d.jl @@ -130,7 +130,7 @@ isdir(outdir) && rm(outdir, recursive=true) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), l2 = [0.0011197139793938152, 0.015430259691310781, 0.017081031802719724, 5.089218476758271e-6], linf = [0.014300809338967824, 0.12783372461225184, 0.17625472321992852, 2.6407324614341476e-5], - surface_flux=(FluxHydrostaticReconstruction(FluxHLL(min_max_speed_naive), hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), + surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), tspan = (0.0, 0.025)) end From 5a03dfae586f38c005d7e9d7fca309914be68167 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 4 Jul 2023 15:08:21 +0200 Subject: [PATCH 19/22] Rename min_max_speed to min_max_speed_davis and reduce documentation --- ...hll.jl => elixir_euler_sedov_hll_Davis.jl} | 2 +- src/Trixi.jl | 2 +- src/equations/compressible_euler_1d.jl | 11 ++----- src/equations/compressible_euler_2d.jl | 17 ++++------ src/equations/compressible_euler_3d.jl | 17 ++++------ src/equations/ideal_glm_mhd_1d.jl | 22 ++----------- src/equations/ideal_glm_mhd_2d.jl | 27 ++++------------ src/equations/ideal_glm_mhd_3d.jl | 27 ++++------------ src/equations/linearized_euler_2d.jl | 20 +++++------- src/equations/numerical_fluxes.jl | 20 +++++++----- src/equations/shallow_water_1d.jl | 27 ++-------------- src/equations/shallow_water_2d.jl | 31 +++---------------- test/test_structured_1d.jl | 7 +++++ test/test_unit.jl | 4 +-- 14 files changed, 68 insertions(+), 166 deletions(-) rename examples/structured_1d_dgsem/{elixir_euler_sedov_hll.jl => elixir_euler_sedov_hll_Davis.jl} (98%) diff --git a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl b/examples/structured_1d_dgsem/elixir_euler_sedov_hll_Davis.jl similarity index 98% rename from examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl rename to examples/structured_1d_dgsem/elixir_euler_sedov_hll_Davis.jl index 230ba92d6b6..e9de319eaee 100644 --- a/examples/structured_1d_dgsem/elixir_euler_sedov_hll.jl +++ b/examples/structured_1d_dgsem/elixir_euler_sedov_hll_Davis.jl @@ -35,7 +35,7 @@ function initial_condition_sedov_blast_wave(x, t, equations::CompressibleEulerEq end initial_condition = initial_condition_sedov_blast_wave -surface_flux = flux_hll +surface_flux = FluxHLL(min_max_speed_davis) volume_flux = flux_ranocha basis = LobattoLegendreBasis(3) shock_indicator_variable = density_pressure diff --git a/src/Trixi.jl b/src/Trixi.jl index 078b7444dda..cc3ea09e875 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -164,7 +164,7 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle, hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, FluxLaxFriedrichs, max_abs_speed_naive, - FluxHLL, min_max_speed_naive, min_max_speed, min_max_speed_einfeldt, + FluxHLL, min_max_speed_naive, min_max_speed_davis, min_max_speed_einfeldt, FluxLMARS, FluxRotated, flux_shima_etal_turbo, flux_ranocha_turbo, diff --git a/src/equations/compressible_euler_1d.jl b/src/equations/compressible_euler_1d.jl index 6cfb7610ebb..76c60a24e5c 100644 --- a/src/equations/compressible_euler_1d.jl +++ b/src/equations/compressible_euler_1d.jl @@ -660,14 +660,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, equations::CompressibleEulerEquations1D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::CompressibleEulerEquations1D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations1D) rho_ll, v1_ll, p_ll = cons2prim(u_ll, equations) rho_rr, v1_rr, p_rr = cons2prim(u_rr, equations) diff --git a/src/equations/compressible_euler_2d.jl b/src/equations/compressible_euler_2d.jl index a72b9557b39..9ea6f9c7ce8 100644 --- a/src/equations/compressible_euler_2d.jl +++ b/src/equations/compressible_euler_2d.jl @@ -1065,15 +1065,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, - equations::CompressibleEulerEquations2D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::CompressibleEulerEquations2D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations2D) rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations) rho_rr, v1_rr, v2_rr, p_rr = cons2prim(u_rr, equations) @@ -1091,8 +1085,9 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, - equations::CompressibleEulerEquations2D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, + equations::CompressibleEulerEquations2D) rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations) rho_rr, v1_rr, v2_rr, p_rr = cons2prim(u_rr, equations) diff --git a/src/equations/compressible_euler_3d.jl b/src/equations/compressible_euler_3d.jl index ddc3e3b06be..a9e27142609 100644 --- a/src/equations/compressible_euler_3d.jl +++ b/src/equations/compressible_euler_3d.jl @@ -1108,15 +1108,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, - equations::CompressibleEulerEquations3D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::CompressibleEulerEquations3D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::CompressibleEulerEquations3D) rho_ll, v1_ll, v2_ll, v3_ll, p_ll = cons2prim(u_ll, equations) rho_rr, v1_rr, v2_rr, v3_rr, p_rr = cons2prim(u_rr, equations) @@ -1137,8 +1131,9 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, - equations::CompressibleEulerEquations3D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, + equations::CompressibleEulerEquations3D) rho_ll, v1_ll, v2_ll, v3_ll, p_ll = cons2prim(u_ll, equations) rho_rr, v1_rr, v2_rr, v3_rr, p_rr = cons2prim(u_rr, equations) diff --git a/src/equations/ideal_glm_mhd_1d.jl b/src/equations/ideal_glm_mhd_1d.jl index c2dbfe2215c..85030e8a5ad 100644 --- a/src/equations/ideal_glm_mhd_1d.jl +++ b/src/equations/ideal_glm_mhd_1d.jl @@ -293,14 +293,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::IdealGlmMhdEquations1D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations1D) rho_ll, rho_v1_ll, _ = u_ll rho_rr, rho_v1_rr, _ = u_rr @@ -325,17 +320,6 @@ Calculate minimum and maximum wave speeds for HLL-type fluxes as in - Li (2005) An HLLC Riemann solver for magneto-hydrodynamics [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020). - -This is the generalization to MHD from the works -- Bernd Einfeldt (1988) - On Godunov-type methods for gas dynamics. - [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) -- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) - On Godunov-type methods near low densities. - [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) - -originally developed for the compressible Euler equations. -A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ @inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations1D) diff --git a/src/equations/ideal_glm_mhd_2d.jl b/src/equations/ideal_glm_mhd_2d.jl index 156de15a379..95137a58164 100644 --- a/src/equations/ideal_glm_mhd_2d.jl +++ b/src/equations/ideal_glm_mhd_2d.jl @@ -635,14 +635,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::IdealGlmMhdEquations2D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -671,8 +666,9 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, - equations::IdealGlmMhdEquations2D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations2D) rho_ll, rho_v1_ll, rho_v2_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, _ = u_rr @@ -703,17 +699,6 @@ Calculate minimum and maximum wave speeds for HLL-type fluxes as in - Li (2005) An HLLC Riemann solver for magneto-hydrodynamics [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020). - -This is the generalization to MHD from the works -- Bernd Einfeldt (1988) - On Godunov-type methods for gas dynamics. - [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) -- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) - On Godunov-type methods near low densities. - [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) - -originally developed for the compressible Euler equations. -A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ @inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations2D) diff --git a/src/equations/ideal_glm_mhd_3d.jl b/src/equations/ideal_glm_mhd_3d.jl index 52227dbde8a..9a568f655a1 100644 --- a/src/equations/ideal_glm_mhd_3d.jl +++ b/src/equations/ideal_glm_mhd_3d.jl @@ -728,14 +728,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations3D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::IdealGlmMhdEquations3D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -772,8 +767,9 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, - equations::IdealGlmMhdEquations3D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, + equations::IdealGlmMhdEquations3D) rho_ll, rho_v1_ll, rho_v2_ll, rho_v3_ll, _ = u_ll rho_rr, rho_v1_rr, rho_v2_rr, rho_v3_rr, _ = u_rr @@ -810,17 +806,6 @@ Calculate minimum and maximum wave speeds for HLL-type fluxes as in - Li (2005) An HLLC Riemann solver for magneto-hydrodynamics [DOI: 10.1016/j.jcp.2004.08.020](https://doi.org/10.1016/j.jcp.2004.08.020) - -This is the generalization to MHD from the works - - Bernd Einfeldt (1988) - On Godunov-type methods for gas dynamics. - [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) - - Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) - On Godunov-type methods near low densities. - [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) - - originally developed for the compressible Euler equations. - A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ @inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::IdealGlmMhdEquations3D) diff --git a/src/equations/linearized_euler_2d.jl b/src/equations/linearized_euler_2d.jl index d35e077e4e8..7b3f15b06e6 100644 --- a/src/equations/linearized_euler_2d.jl +++ b/src/equations/linearized_euler_2d.jl @@ -146,23 +146,17 @@ end # Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes @inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, equations::LinearizedEulerEquations2D) - min_max_speed(u_ll, u_rr, orientation, equations) + min_max_speed_davis(u_ll, u_rr, orientation, equations) end @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::LinearizedEulerEquations2D) - min_max_speed(u_ll, u_rr, normal_direction, equations) + min_max_speed_davis(u_ll, u_rr, normal_direction, equations) end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, - equations::LinearizedEulerEquations2D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::LinearizedEulerEquations2D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::LinearizedEulerEquations2D) @unpack v_mean_global, c_mean_global = equations λ_min = v_mean_global[orientation] - c_mean_global @@ -171,8 +165,8 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, - equations::LinearizedEulerEquations2D) +@inline function min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, + equations::LinearizedEulerEquations2D) @unpack v_mean_global, c_mean_global = equations norm_ = norm(normal_direction) diff --git a/src/equations/numerical_fluxes.jl b/src/equations/numerical_fluxes.jl index 0875df9f0f8..9d9917235a6 100644 --- a/src/equations/numerical_fluxes.jl +++ b/src/equations/numerical_fluxes.jl @@ -214,6 +214,10 @@ Create an HLL (Harten, Lax, van Leer) numerical flux where the minimum and maxim wave speeds are estimated as `λ_min, λ_max = min_max_speed(u_ll, u_rr, orientation_or_normal_direction, equations)`, defaulting to [`min_max_speed_naive`](@ref). +Original paper: +- Amiram Harten, Peter D. Lax, Bram van Leer (1983) + On Upstream Differencing and Godunov-Type Schemes for Hyperbolic Conservation Laws + [DOI: 10.1137/1025002](https://doi.org/10.1137/1025002) """ struct FluxHLL{MinMaxSpeed} min_max_speed::MinMaxSpeed @@ -235,21 +239,21 @@ left and right states `u_ll, u_rr`, usually based only on the local wave speeds function min_max_speed_naive end """ - min_max_speed(u_ll, u_rr, orientation::Integer, equations) - min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, equations) + min_max_speed_davis(u_ll, u_rr, orientation::Integer, equations) + min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, equations) Simple and fast bounds of the minimal and maximal wave speed of the Riemann problem with left and right states `u_ll, u_rr`, usually based only on the local wave speeds associated to `u_ll` and `u_rr`. -- Amiram Harten, Peter D. Lax, Bram van Leer (1983) - On Upstream Differencing and Godunov-Type Schemes for Hyperbolic Conservation Laws - [DOI: 10.1137/1025002](https://doi.org/10.1137/1025002) +- S.F. Davis (1988) + Simplified Second-Order Godunov-Type Methods + [DOI: 10.1137/0909030](https://doi.org/10.1137/0909030) """ -function min_max_speed end +function min_max_speed_davis end """ - min_max_speed(u_ll, u_rr, orientation::Integer, equations) - min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, equations) + min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations) + min_max_speed_einfeldt(u_ll, u_rr, normal_direction::AbstractVector, equations) More advanced mininmal and maximal wave speed computation based on - Bernd Einfeldt (1988) diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index 3a94db49f93..ac30a98a8e9 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -474,15 +474,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations1D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations1D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations1D) h_ll = waterheight(u_ll, equations) v_ll = velocity(u_ll, equations) h_rr = waterheight(u_rr, equations) @@ -497,21 +491,6 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -""" - min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations1D) - -This is the generalization to SWE from the works -- Bernd Einfeldt (1988) - On Godunov-type methods for gas dynamics. - [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) -- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) - On Godunov-type methods near low densities. - [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) - -originally developed for the compressible Euler equations. -A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" @inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations1D) h_ll = waterheight(u_ll, equations) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index f39f3de5d1d..bde5b0e7a72 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -762,15 +762,9 @@ end return λ_min, λ_max end -""" - min_max_speed(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations2D) - -Implements the classic 2-wave HLL solver, see the [original paper](https://epubs.siam.org/doi/abs/10.1137/1025002) -or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" -@inline function min_max_speed(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations2D) +# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes +@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer, + equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) v1_ll, v2_ll = velocity(u_ll, equations) h_rr = waterheight(u_rr, equations) @@ -790,8 +784,8 @@ or this [lecture notes, Eq. (9.27)](https://metaphor.ethz.ch/x/2019/hs/401-4671- return λ_min, λ_max end -@inline function min_max_speed(u_ll, u_rr, normal_direction::AbstractVector, - equations::ShallowWaterEquations2D) +@inline function min_max_speed_davis(u_ll, u_rr, normal_direction::AbstractVector, + equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) v1_ll, v2_ll = velocity(u_ll, equations) h_rr = waterheight(u_rr, equations) @@ -811,21 +805,6 @@ end return λ_min, λ_max end -""" - min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquations2D) - -This is the generalization to SWE from the works -- Bernd Einfeldt (1988) - On Godunov-type methods for gas dynamics. - [DOI: 10.1137/0725021](https://doi.org/10.1137/0725021) -- Bernd Einfeldt, Claus-Dieter Munz, Philip L. Roe and Björn Sjögreen (1991) - On Godunov-type methods near low densities. - [DOI: 10.1016/0021-9991(91)90211-3](https://doi.org/10.1016/0021-9991(91)90211-3) - -originally developed for the compressible Euler equations. -A compact representation can be found in [this lecture notes, eq. (9.28)](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). -""" @inline function min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, equations::ShallowWaterEquations2D) h_ll = waterheight(u_ll, equations) diff --git a/test/test_structured_1d.jl b/test/test_structured_1d.jl index ec8c7a138d5..a48a1358a10 100644 --- a/test/test_structured_1d.jl +++ b/test/test_structured_1d.jl @@ -32,6 +32,13 @@ isdir(outdir) && rm(outdir, recursive=true) atol = 1.0e-5) end + @trixi_testset "elixir_euler_sedov_hll_Davis.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_hll_Davis.jl"), + l2 = [1.278661029299215, 0.0663853410742763, 0.9585741943783386], + linf = [3.1661064228547255, 0.16256363944708607, 2.667676158812806], + tspan = (0.0, 12.5)) + end + @trixi_testset "elixir_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), l2 = [3.67478226e-01, 3.49491179e-01, 8.08910759e-01], diff --git a/test/test_unit.jl b/test/test_unit.jl index 2ab617b1486..ba2a171393d 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -682,8 +682,8 @@ isdir(outdir) && rm(outdir, recursive=true) end end - @timed_testset "Consistency check for HLL flux" begin - flux_hll = FluxHLL(min_max_speed) + @timed_testset "Consistency check for HLL flux with Davis wave speed estimates" begin + flux_hll = FluxHLL(min_max_speed_davis) # Set up equations and dummy conservative variables state equations = CompressibleEulerEquations1D(1.4) From 7cfc22cd3fb864d742b672b66d4ddb3ce4af9465 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Thu, 6 Jul 2023 10:59:41 +0200 Subject: [PATCH 20/22] Update src/equations/shallow_water_1d.jl: Comments Co-authored-by: Hendrik Ranocha --- src/equations/shallow_water_1d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index ac30a98a8e9..612c0627d62 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -586,7 +586,7 @@ end calc_wavespeed_roe(u_ll, u_rr, direction::Integer, equations::ShallowWaterEquations1D) -Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` +Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt(g * h_roe)`. """ @inline function calc_wavespeed_roe(u_ll, u_rr, direction::Integer, equations::ShallowWaterEquations1D) From ef6d070a63118991967d19ebcfa1fa1a953b41ee Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Thu, 6 Jul 2023 11:35:01 +0200 Subject: [PATCH 21/22] Add published resource for Roe averages for SWE --- src/equations/shallow_water_1d.jl | 5 +++++ src/equations/shallow_water_2d.jl | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/equations/shallow_water_1d.jl b/src/equations/shallow_water_1d.jl index ac30a98a8e9..dcada5b662f 100644 --- a/src/equations/shallow_water_1d.jl +++ b/src/equations/shallow_water_1d.jl @@ -587,6 +587,11 @@ end equations::ShallowWaterEquations1D) Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` +See for instance equation (62) in +- Paul A. Ullrich, Christiane Jablonowski, and Bram van Leer (2010) + High-order finite-volume methods for the shallow-water equations on the sphere + [DOI: 10.1016/j.jcp.2010.04.044](https://doi.org/10.1016/j.jcp.2010.04.044) +Or equation (9.17) in [this lecture notes](https://metaphor.ethz.ch/x/2019/hs/401-4671-00L/literature/mishra_hyperbolic_pdes.pdf). """ @inline function calc_wavespeed_roe(u_ll, u_rr, direction::Integer, equations::ShallowWaterEquations1D) diff --git a/src/equations/shallow_water_2d.jl b/src/equations/shallow_water_2d.jl index bde5b0e7a72..d6e34e3e3ca 100644 --- a/src/equations/shallow_water_2d.jl +++ b/src/equations/shallow_water_2d.jl @@ -930,7 +930,11 @@ end equations::ShallowWaterEquations2D) Calculate Roe-averaged velocity `v_roe` and wavespeed `c_roe = sqrt{g h_roe}` depending on direction. -See for instance [this slides](https://faculty.washington.edu/rjl/classes/am574w2011/slides/am574lecture20nup3.pdf), +See for instance equation (62) in +- Paul A. Ullrich, Christiane Jablonowski, and Bram van Leer (2010) + High-order finite-volume methods for the shallow-water equations on the sphere + [DOI: 10.1016/j.jcp.2010.04.044](https://doi.org/10.1016/j.jcp.2010.04.044) +Or [this slides](https://faculty.washington.edu/rjl/classes/am574w2011/slides/am574lecture20nup3.pdf), slides 8 and 9. """ @inline function calc_wavespeed_roe(u_ll, u_rr, orientation::Integer, From f7413063ebe28beb5ee748e569a2782b541a55b4 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Thu, 6 Jul 2023 12:42:54 +0200 Subject: [PATCH 22/22] Add tests for rotation --- test/test_unit.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_unit.jl b/test/test_unit.jl index ba2a171393d..038fe3881fe 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -1021,7 +1021,7 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(-1.2, 0.3)] u_values = [SVector(1.0, 0.5, -0.7, 1.0), SVector(1.5, -0.2, 0.1, 5.0),] - fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber] + fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, FluxHLL(min_max_speed_davis)] for f_std in fluxes f_rot = FluxRotated(f_std) @@ -1040,7 +1040,7 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(-1.2, 0.3, 1.4)] u_values = [SVector(1.0, 0.5, -0.7, 0.1, 1.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0),] - fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, FluxLMARS(340)] + fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, FluxLMARS(340), FluxHLL(min_max_speed_davis)] for f_std in fluxes f_rot = FluxRotated(f_std) @@ -1058,7 +1058,7 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(-1.2, 0.3)] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] - fluxes = [flux_central, flux_hindenlang_gassner] + fluxes = [flux_central, flux_hindenlang_gassner, FluxHLL(min_max_speed_davis)] for f_std in fluxes f_rot = FluxRotated(f_std) @@ -1077,7 +1077,7 @@ isdir(outdir) && rm(outdir, recursive=true) SVector(-1.2, 0.3, 1.4)] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] - fluxes = [flux_central, flux_hindenlang_gassner] + fluxes = [flux_central, flux_hindenlang_gassner, FluxHLL(min_max_speed_davis)] for f_std in fluxes f_rot = FluxRotated(f_std)