From aa1d7c7be1353595d6a7c9af641f6f1bc8db543f Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 11:25:41 +0100 Subject: [PATCH 001/111] Added polytropic Euler equations. --- src/equations/polytropic_euler_2d.jl | 674 +++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 src/equations/polytropic_euler_2d.jl diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl new file mode 100644 index 00000000000..b622585f86b --- /dev/null +++ b/src/equations/polytropic_euler_2d.jl @@ -0,0 +1,674 @@ +# By default, Julia/LLVM does not use fused multiply-add operations (FMAs). +# Since these FMAs can increase the performance of many numerical algorithms, +# we need to opt-in explicitly. +# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details. +@muladd begin + + +@doc raw""" + PolytropicEulerEquations2D(gamma, kappa) + +The compressible Euler equations +```math +\partial t +\begin{pmatrix} +\rho \\ \rho v_1 \\ \rho v_2 +\end{pmatrix} ++ +\partial x +\begin{pmatrix} + \rho v_1 \\ \rho v_1^2 + \kappa\rho^\gamma \\ \rho v_1 v_2 +\end{pmatrix} ++ +\partial y +\begin{pmatrix} +\rho v_2 \\ \rho v_1 v_2 \\ \rho v_2^2 + \kappa\rho^\gamma +\end{pmatrix} += +\begin{pmatrix} +0 \\ 0 \\ 0 +\end{pmatrix} +``` +for an ideal gas with ratio of specific heats `gamma` +in two space dimensions. +Here, ``\rho`` is the density and ``v_1`` and`v_2` the velocities and +```math +p = \kappa\rho^\gamma +``` +the pressure, which we replaced using this relation. + +""" +struct PolytropicEulerEquations2D{RealT<:Real, RealT<:Real} <: AbstractPolytropicEulerEquations{2, 3} + gamma::RealT # ratio of specific heats + kappa::RealT # fluid scaling factor + inv_gamma_minus_one::RealT # = inv(gamma - 1); can be used to write slow divisions as fast multiplications + + function PolytropicEulerEquations2D(gamma, kappa) + new{typeof(gamma), typeof(kappa)}(gamma, kappa) + end +end + + +varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) = ("rho", "rho_v1", "rho_v2") +varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") + + +# Set initial conditions at physical location `x` for time `t` +""" + initial_condition_constant(x, t, equations::CompressibleEulerEquations2D) + +A constant initial condition to test free-stream preservation. +""" +function initial_condition_constant(x, t, equations::PolytropicEulerEquations2D) + rho = 1.0 + rho_v1 = 0.1 + rho_v2 = -0.2 + + return SVector(rho, rho_v1, rho_v2) +end + + +""" + initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + +A smooth initial condition used for convergence tests in combination with +[`source_terms_convergence_test`](@ref) +(and [`BoundaryConditionDirichlet(initial_condition_convergence_test)`](@ref) in non-periodic domains). +""" +function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + c = 2 + A = 0.1 + L = 2 + f = 1/L + ω = 2 * pi * f + ini = c + A * sin(ω * (x[1] + x[2] - t)) + + rho = ini + rho_v1 = ini + rho_v2 = ini + + return SVector(rho, rho_v1, rho_v2) +end + + +""" + initial_condition_density_wave(x, t, equations::PolytropicEulerEquations2D) + +A sine wave in the density with constant velocity and pressure; reduces the +compressible Euler equations to the linear advection equations. +This setup is the test case for stability of EC fluxes from paper +- Gregor J. Gassner, Magnus Svärd, Florian J. Hindenlang (2020) + Stability issues of entropy-stable and/or split-form high-order schemes + [arXiv: 2007.09026](https://arxiv.org/abs/2007.09026) +with the following parameters +- domain [-1, 1] +- mesh = 4x4 +- polydeg = 5 +""" +function initial_condition_density_wave(x, t, equations::PolytropicEulerEquations2D) + v1 = 0.1 + v2 = 0.2 + rho = 1 + 0.98 * sinpi(2 * (x[1] + x[2] - t * (v1 + v2))) + rho_v1 = rho * v1 + rho_v2 = rho * v2 + p = 20 + return SVector(rho, rho_v1, rho_v2) +end + + +""" + boundary_condition_slip_wall(u_inner, normal_direction, x, t, surface_flux_function, + equations::PolytropicEulerEquations2D) + +Determine the boundary numerical surface flux for a slip wall condition. +Imposes a zero normal velocity at the wall. +Density is taken from the internal solution state and pressure is computed as an +exact solution of a 1D Riemann problem. Further details about this boundary state +are available in the paper: +- J. J. W. van der Vegt and H. van der Ven (2002) + Slip flow boundary conditions in discontinuous Galerkin discretizations of + the Euler equations of gas dynamics + [PDF](https://reports.nlr.nl/bitstream/handle/10921/692/TP-2002-300.pdf?sequence=1) + +Details about the 1D pressure Riemann solution can be found in Section 6.3.3 of the book +- Eleuterio F. Toro (2009) + Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction + 3rd edition + [DOI: 10.1007/b79761](https://doi.org/10.1007/b79761) + +Should be used together with [`UnstructuredMesh2D`](@ref). +""" +@inline function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, + x, t, + surface_flux_function, + equations::PolytropicEulerEquations2D) + + 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 = rotate_to_x(u_inner, normal, equations) + p_local = equations.kappa*rho^equations.gamma + + # compute the primitive variables + rho_local, v_normal, v_tangent = cons2prim(u_local, equations) + + # Get the solution of the pressure Riemann problem + # See Section 6.3.3 of + # Eleuterio F. Toro (2009) + # Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction + # [DOI: 10.1007/b79761](https://doi.org/10.1007/b79761) + if v_normal <= 0.0 + sound_speed = sqrt(equations.gamma * p_local / rho_local) # local sound speed + p_star = p_local * (1.0 + 0.5 * (equations.gamma - 1) * v_normal / sound_speed)^(2.0 * equations.gamma * equations.inv_gamma_minus_one) + else # v_normal > 0.0 + A = 2.0 / ((equations.gamma + 1) * rho_local) + B = p_local * (equations.gamma - 1) / (equations.gamma + 1) + p_star = p_local + 0.5 * v_normal / A * (v_normal + sqrt(v_normal^2 + 4.0 * A * (p_local + B))) + end + + # For the slip wall we directly set the flux as the normal velocity is zero + return SVector(zero(eltype(u_inner)), + p_star * normal[1], + p_star * normal[2]) * norm_ +end + +""" + boundary_condition_slip_wall(u_inner, orientation, direction, x, t, + surface_flux_function, equations::PolytropicEulerEquations2D) + +Should be used together with [`TreeMesh`](@ref). +""" +@inline function boundary_condition_slip_wall(u_inner, orientation, + direction, x, t, + surface_flux_function, + equations::PolytropicEulerEquations2D) + # get the appropriate normal vector from the orientation + if orientation == 1 + normal = SVector(1, 0) + else # orientation == 2 + normal = SVector(0, 1) + end + + # compute and return the flux using `boundary_condition_slip_wall` routine above + return boundary_condition_slip_wall(u_inner, normal, x, t, surface_flux_function, equations) +end + +""" + boundary_condition_slip_wall(u_inner, normal_direction, direction, x, t, + surface_flux_function, equations::PolytropicEulerEquations2D) + +Should be used together with [`StructuredMesh`](@ref). +""" +@inline function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, + direction, x, t, + surface_flux_function, + equations::PolytropicEulerEquations2D) + # flip sign of normal to make it outward pointing, then flip the sign of the normal flux back + # to be inward pointing on the -x and -y sides due to the orientation convention used by StructuredMesh + if isodd(direction) + boundary_flux = -boundary_condition_slip_wall(u_inner, -normal_direction, + x, t, surface_flux_function, equations) + else + boundary_flux = boundary_condition_slip_wall(u_inner, normal_direction, + x, t, surface_flux_function, equations) + end + + return boundary_flux +end + + +# Calculate 1D flux for a single point +@inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + v1 = rho_v1 / rho + v2 = rho_v2 / rho + p = equations.kappa*rho^equations.gamma + if orientation == 1 + f1 = rho_v1 + f2 = rho_v1 * v1 + p + f3 = rho_v1 * v2 + else + f1 = rho_v2 + f2 = rho_v2 * v1 + f3 = rho_v2 * v2 + p + end + return SVector(f1, f2, f3) +end + +# Calculate 1D flux for a single point in the normal direction +# Note, this directional vector is not normalized +@inline function flux(u, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) + rho_e = last(u) + rho, v1, v2 = cons2prim(u, equations) + p = equations.kappa*rho^equations.gamma + + v_normal = v1 * normal_direction[1] + v2 * normal_direction[2] + rho_v_normal = rho * v_normal + f1 = rho_v_normal + f2 = rho_v_normal * v1 + p * normal_direction[1] + f3 = rho_v_normal * v2 + p * normal_direction[2] + return SVector(f1, f2, f3) +end + + +""" + flux_hllc(u_ll, u_rr, orientation, equations::PolytropicEulerEquations2D) + +Computes the HLLC flux (HLL with Contact) for compressible Euler equations developed by E.F. Toro +[Lecture slides](http://www.prague-sum.com/download/2012/Toro_2-HLLC-RiemannSolver.pdf) +Signal speeds: [DOI: 10.1137/S1064827593260140](https://doi.org/10.1137/S1064827593260140) +""" +function flux_hllc(u_ll, u_rr, orientation::Integer, equations::PolytropicEulerEquations2D) + # Calculate primitive variables and speed of sound + rho_ll, rho_v1_ll, rho_v2_ll = u_ll + rho_rr, rho_v1_rr, rho_v2_rr = u_rr + + v1_ll = rho_v1_ll / rho_ll + v2_ll = rho_v2_ll / rho_ll + p_ll = equations.kappa * rho_ll^equations.gamma + e_ll = p_ll * rho_ll / (equations.gamma - 1) + rho_e_ll = rho_ll * e_ll + c_ll = sqrt(equations.gamma*p_ll/rho_ll) + + v1_rr = rho_v1_rr / rho_rr + v2_rr = rho_v2_rr / rho_rr + p_rr = equations.kappa * rho_rr^equations.gamma + e_rr = p_rr * rho_rr / (equations.gamma - 1) + rho_e_rr = rho_rr * e_rr + c_rr = sqrt(equations.gamma*p_rr/rho_rr) + + # Obtain left and right fluxes + f_ll = flux(u_ll, orientation, equations) + f_rr = flux(u_rr, orientation, equations) + + # Compute Roe averages + sqrt_rho_ll = sqrt(rho_ll) + sqrt_rho_rr = sqrt(rho_rr) + sum_sqrt_rho = sqrt_rho_ll + sqrt_rho_rr + if orientation == 1 # x-direction + vel_L = v1_ll + vel_R = v1_rr + ekin_roe = (sqrt_rho_ll * v2_ll + sqrt_rho_rr * v2_rr)^2 + elseif orientation == 2 # y-direction + vel_L = v2_ll + vel_R = v2_rr + ekin_roe = (sqrt_rho_ll * v1_ll + sqrt_rho_rr * v1_rr)^2 + end + vel_roe = (sqrt_rho_ll * vel_L + sqrt_rho_rr * vel_R) / sum_sqrt_rho + ekin_roe = 0.5 * (vel_roe^2 + ekin_roe / sum_sqrt_rho^2) + H_ll = (rho_e_ll + p_ll) / rho_ll + H_rr = (rho_e_rr + p_rr) / rho_rr + H_roe = (sqrt_rho_ll * H_ll + sqrt_rho_rr * H_rr) / sum_sqrt_rho + c_roe = sqrt((equations.gamma - 1) * (H_roe - ekin_roe)) + Ssl = min(vel_L - c_ll, vel_roe - c_roe) + Ssr = max(vel_R + c_rr, vel_roe + c_roe) + sMu_L = Ssl - vel_L + sMu_R = Ssr - vel_R + + if Ssl >= 0.0 + f1 = f_ll[1] + f2 = f_ll[2] + f3 = f_ll[3] + elseif Ssr <= 0.0 + f1 = f_rr[1] + f2 = f_rr[2] + f3 = f_rr[3] + else + SStar = (p_rr - p_ll + rho_ll*vel_L*sMu_L - rho_rr*vel_R*sMu_R) / (rho_ll*sMu_L - rho_rr*sMu_R) + if Ssl <= 0.0 <= SStar + densStar = rho_ll*sMu_L / (Ssl-SStar) + enerStar = e_ll + (SStar - vel_L) * (SStar + p_ll / (rho_ll * sMu_L)) + UStar1 = densStar + UStar4 = densStar*enerStar + if orientation == 1 # x-direction + UStar2 = densStar*SStar + UStar3 = densStar*v2_ll + elseif orientation == 2 # y-direction + UStar2 = densStar*v1_ll + UStar3 = densStar*SStar + end + f1 = f_ll[1]+Ssl*(UStar1 - rho_ll) + f2 = f_ll[2]+Ssl*(UStar2 - rho_v1_ll) + f3 = f_ll[3]+Ssl*(UStar3 - rho_v2_ll) + else + densStar = rho_rr*sMu_R / (Ssr-SStar) + enerStar = e_rr + (SStar - vel_R) * (SStar + p_rr / (rho_rr * sMu_R)) + UStar1 = densStar + UStar4 = densStar*enerStar + if orientation == 1 # x-direction + UStar2 = densStar*SStar + UStar3 = densStar*v2_rr + elseif orientation == 2 # y-direction + UStar2 = densStar*v1_rr + UStar3 = densStar*SStar + end + f1 = f_rr[1]+Ssr*(UStar1 - rho_rr) + f2 = f_rr[2]+Ssr*(UStar2 - rho_v1_rr) + f3 = f_rr[3]+Ssr*(UStar3 - rho_v2_rr) + end + end + return SVector(f1, f2, f3) + end + + + +""" + flux_ranocha(u_ll, u_rr, orientation_or_normal_direction, + equations::PolytropicEulerEquations2D) + +Entropy conserving and kinetic energy preserving two-point flux by +- Hendrik Ranocha (2018) + Generalised Summation-by-Parts Operators and Entropy Stability of Numerical Methods + for Hyperbolic Balance Laws + [PhD thesis, TU Braunschweig](https://cuvillier.de/en/shop/publications/7743) +See also +- Hendrik Ranocha (2020) + Entropy Conserving and Kinetic Energy Preserving Numerical Methods for + the Euler Equations Using Summation-by-Parts Operators + [Proceedings of ICOSAHOM 2018](https://doi.org/10.1007/978-3-030-39647-3_42) +""" +@inline function flux_ranocha(u_ll, u_rr, orientation::Integer, equations::PolytropicEulerEquations2D) + # Unpack left and right state + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa*rho_ll^equations.gamma + p_rr = equations.kappa*rho_rr^equations.gamma + + # Compute the necessary mean values + rho_mean = ln_mean(rho_ll, rho_rr) + # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` + # in exact arithmetic since + # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) + # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) + inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) + v1_avg = 0.5 * (v1_ll + v1_rr) + v2_avg = 0.5 * (v2_ll + v2_rr) + p_avg = 0.5 * (p_ll + p_rr) + velocity_square_avg = 0.5 * (v1_ll*v1_rr + v2_ll*v2_rr) + + # Calculate fluxes depending on orientation + if orientation == 1 + f1 = rho_mean * v1_avg + f2 = f1 * v1_avg + p_avg + f3 = f1 * v2_avg + else + f1 = rho_mean * v2_avg + f2 = f1 * v1_avg + f3 = f1 * v2_avg + p_avg + end + + return SVector(f1, f2, f3) +end + + +@inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) + # Unpack left and right state + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa*rho_ll^equations.gamma + p_rr = equations.kappa*rho_rr^equations.gamma + v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # Compute the necessary mean values + rho_mean = ln_mean(rho_ll, rho_rr) + # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` + # in exact arithmetic since + # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) + # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) + inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) + v1_avg = 0.5 * (v1_ll + v1_rr) + v2_avg = 0.5 * (v2_ll + v2_rr) + p_avg = 0.5 * (p_ll + p_rr) + + # Calculate fluxes depending on normal_direction + f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) + f2 = f1 * v1_avg + p_avg * normal_direction[1] + f3 = f1 * v2_avg + p_avg * normal_direction[2] + + return SVector(f1, f2, f3) +end + + +# Calculate 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::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa*rho_ll^equations.gamma + p_rr = equations.kappa*rho_rr^equations.gamma + + # Get the velocity value in the appropriate direction + if orientation == 1 + v_ll = v1_ll + v_rr = v1_rr + else # orientation == 2 + v_ll = v2_ll + v_rr = v2_rr + end + # Calculate sound speeds + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + λ_max = max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) +end + + +@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa*rho_ll^equations.gamma + p_rr = equations.kappa*rho_rr^equations.gamma + + # Calculate normal velocities and sound speed + # left + v_ll = ( v1_ll * normal_direction[1] + + v2_ll * normal_direction[2] ) + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + # right + v_rr = ( v1_rr * normal_direction[1] + + v2_rr * normal_direction[2] ) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + 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 +@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, + equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa*rho_ll^equations.gamma + p_rr = equations.kappa*rho_rr^equations.gamma + + if orientation == 1 # x-direction + λ_min = v1_ll - sqrt(equations.gamma * p_ll / rho_ll) + λ_max = v1_rr + sqrt(equations.gamma * p_rr / rho_rr) + else # y-direction + λ_min = v2_ll - sqrt(equations.gamma * p_ll / rho_ll) + λ_max = v2_rr + sqrt(equations.gamma * p_rr / rho_rr) + end + + return λ_min, λ_max +end + +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa*rho_ll^equations.gamma + p_rr = equations.kappa*rho_rr^equations.gamma + + 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] + + norm_ = norm(normal_direction) + # The v_normals are already scaled by the norm + λ_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ + λ_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ + + 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::PolytropicEulerEquations2D) + # cos and sin of the angle between the x-axis and the normalized normal_vector are + # the normalized vector's x and y coordinates respectively (see unit circle). + c = normal_vector[1] + s = normal_vector[2] + + # Apply the 2D rotation matrix with normal and tangent directions of the form + # [ 1 0 0 + # 0 n_1 t_1 + # 0 n_2 t_2 ] + # where t_1 = -n_2 and t_2 = n_1 + + return SVector(u[1], + c * u[2] + s * u[3], + -s * u[2] + c * u[3]) +end + + +# Called inside `FluxRotated` in `numerical_fluxes.jl` so the direction +# has been normalized prior to this back-rotation of the state vector +@inline function rotate_from_x(u, normal_vector, equations::PolytropicEulerEquations2D) + # cos and sin of the angle between the x-axis and the normalized normal_vector are + # the normalized vector's x and y coordinates respectively (see unit circle). + c = normal_vector[1] + s = normal_vector[2] + + # Apply the 2D back-rotation matrix with normal and tangent directions of the form + # [ 1 0 0 + # 0 n_1 t_1 + # 0 n_2 t_2 ] + # where t_1 = -n_2 and t_2 = n_1 + + return SVector(u[1], + c * u[2] - s * u[3], + s * u[2] + c * u[3]) +end + + +@inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) + rho, v1, v2 = cons2prim(u, equations) + c = sqrt(equations.gamma * equations.kappa*rho^(equations.gamma-1)) + + return abs(v1) + c, abs(v2) + c +end + + +# Convert conservative variables to primitive +@inline function cons2prim(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + + v1 = rho_v1 / rho + v2 = rho_v2 / rho + + return SVector(rho, v1, v2) +end + + +# Convert conservative variables to entropy +@inline function cons2entropy(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + + v1 = rho_v1 / rho + v2 = rho_v2 / rho + v_square = v1^2 + v2^2 + p = equations.kappa * rho^equations.gamma + s = rho/2*v_square + rho*equations.kappa*rho^(equations.gamma-1)/(equations.gamma-1) + rho_p = rho / p + + w1 = (equations.gamma - s) * (equations.gamma - 1) - 0.5 * rho_p * v_square + w2 = rho_p * v1 + w3 = rho_p * v2 + + return SVector(w1, w2, w3) +end + +# TODO: Do we need this? (SC) +# @inline function entropy2cons(w, equations::PolytropicEulerEquations2D) +# # See Hughes, Franca, Mallet (1986) A new finite element formulation for CFD +# # [DOI: 10.1016/0045-7825(86)90127-1](https://doi.org/10.1016/0045-7825(86)90127-1) +# @unpack gamma, kappa = equations + +# # convert to entropy `-rho * s` used by Hughes, France, Mallet (1986) +# # instead of `-rho * s / (gamma - 1)` +# V1, V2, V3, V5 = w .* (gamma-1) + +# # s = specific entropy, eq. (53) +# s = gamma - V1 + (V2^2 + V3^2)/(2*V5) + +# # eq. (52) +# rho_iota = ((gamma-1) / (-V5)^gamma)^(equations.inv_gamma_minus_one)*exp(-s * equations.inv_gamma_minus_one) + +# # eq. (51) +# rho = -rho_iota * V5 +# rho_v1 = rho_iota * V2 +# rho_v2 = rho_iota * V3 +# rho_e = rho_iota * (1-(V2^2 + V3^2)/(2*V5)) +# return SVector(rho, rho_v1, rho_v2, rho_e) +# end + + + + +# Convert primitive to conservative variables +@inline function prim2cons(prim, equations::PolytropicEulerEquations2D) + rho, v1, v2 = prim + rho_v1 = rho * v1 + rho_v2 = rho * v2 + return SVector(rho, rho_v1, rho_v2) +end + + +@inline function density(u, equations::PolytropicEulerEquations2D) + rho = u[1] + return rho +end + + +@inline function pressure(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + p = equations.kappa*rho^equations.gamma + return p +end + + +@inline function density_pressure(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + rho_times_p = equations.kappa*rho^(equations.gamma+1) + return rho_times_p +end + + +# Calculate thermodynamic entropy for a conservative state `cons` +@inline function entropy_thermodynamic(cons, equations::PolytropicEulerEquations2D) + # Pressure + p = equations.kappa*cons[1]^equations.gamma + + # Thermodynamic entropy + s = log(p) - equations.gamma*log(cons[1]) + + return s +end + + +# Calculate mathematical entropy for a conservative state `cons` +@inline function entropy_math(cons, equations::PolytropicEulerEquations2D) + # Mathematical entropy + S = -entropy_thermodynamic(cons, equations) * cons[1] * (equations.gamma - 1) + + return S +end + + +# Default entropy is the mathematical entropy +@inline entropy(cons, equations::PolytropicEulerEquations2D) = entropy_math(cons, equations) + +end # @muladd From b4ef0cd63fb096ae359bf6dbe4077ce03b2fb9be Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 11:25:55 +0100 Subject: [PATCH 002/111] Added polytropic Euler equations. --- src/Trixi.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index b45edbbecd4..d5a061adfd0 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -136,7 +136,8 @@ export AcousticPerturbationEquations2D, LatticeBoltzmannEquations2D, LatticeBoltzmannEquations3D, ShallowWaterEquations1D, ShallowWaterEquations2D, ShallowWaterTwoLayerEquations1D, ShallowWaterTwoLayerEquations2D, - LinearizedEulerEquations2D + LinearizedEulerEquations2D, + PolytropicEulerEquations2D export LaplaceDiffusion1D, LaplaceDiffusion2D, CompressibleNavierStokesDiffusion2D, CompressibleNavierStokesDiffusion3D From 2974c7678a52e38a3a15526b26a5f50876664035 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 11:26:10 +0100 Subject: [PATCH 003/111] Added polytropic Euler equations. --- src/equations/equations.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/equations/equations.jl b/src/equations/equations.jl index c1669531def..c77652a3fd4 100644 --- a/src/equations/equations.jl +++ b/src/equations/equations.jl @@ -322,6 +322,10 @@ abstract type AbstractCompressibleEulerMulticomponentEquations{NDIMS, NVARS, NCO include("compressible_euler_multicomponent_1d.jl") include("compressible_euler_multicomponent_2d.jl") +# PolytropicEulerEquations +abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <: AbstractEquations{NDIMS, NVARS} end +include("polytropic_euler_2d.jl") + # Retrieve number of components from equation instance for the multicomponent case @inline ncomponents(::AbstractCompressibleEulerMulticomponentEquations{NDIMS, NVARS, NCOMP}) where {NDIMS, NVARS, NCOMP} = NCOMP """ From b0252bb51ba2cc7a9c0b2ca1e6bbdd8c3b150f26 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 11:49:51 +0100 Subject: [PATCH 004/111] Minor clean up in polytropic equations. --- src/equations/polytropic_euler_2d.jl | 48 ++++++---------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index b622585f86b..5034356a501 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -69,49 +69,21 @@ end """ - initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + initial_condition_linear_wave(x, t, equations::PolytropicEulerEquations2D) -A smooth initial condition used for convergence tests in combination with -[`source_terms_convergence_test`](@ref) -(and [`BoundaryConditionDirichlet(initial_condition_convergence_test)`](@ref) in non-periodic domains). -""" -function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) - c = 2 - A = 0.1 - L = 2 - f = 1/L - ω = 2 * pi * f - ini = c + A * sin(ω * (x[1] + x[2] - t)) - - rho = ini - rho_v1 = ini - rho_v2 = ini - - return SVector(rho, rho_v1, rho_v2) -end - - -""" - initial_condition_density_wave(x, t, equations::PolytropicEulerEquations2D) - -A sine wave in the density with constant velocity and pressure; reduces the -compressible Euler equations to the linear advection equations. -This setup is the test case for stability of EC fluxes from paper -- Gregor J. Gassner, Magnus Svärd, Florian J. Hindenlang (2020) - Stability issues of entropy-stable and/or split-form high-order schemes - [arXiv: 2007.09026](https://arxiv.org/abs/2007.09026) -with the following parameters -- domain [-1, 1] -- mesh = 4x4 -- polydeg = 5 +A linear density wave that travel into the negative x-direction. """ function initial_condition_density_wave(x, t, equations::PolytropicEulerEquations2D) - v1 = 0.1 - v2 = 0.2 - rho = 1 + 0.98 * sinpi(2 * (x[1] + x[2] - t * (v1 + v2))) + v1 = 0.0 + if x[1] > 0.0 + rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma) + v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa) + end + v2 = 0.0 + rho_v1 = rho * v1 rho_v2 = rho * v2 - p = 20 + return SVector(rho, rho_v1, rho_v2) end From 472e8249644574fd7493e43a1d1a44be909e1593 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 11:58:38 +0100 Subject: [PATCH 005/111] Added example for the compressible polytropic Euler equations in 2d on a structured mesh. --- .../elixir_euler_polytropic.jl | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 examples/structured_2d_dgsem/elixir_euler_polytropic.jl diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic.jl b/examples/structured_2d_dgsem/elixir_euler_polytropic.jl new file mode 100644 index 00000000000..7b3fee4ee79 --- /dev/null +++ b/examples/structured_2d_dgsem/elixir_euler_polytropic.jl @@ -0,0 +1,100 @@ +using OrdinaryDiffEq +using Trixi2Vtk +using Trixi + +############################################################################### +# semidiscretization of the polytropic Euler equations +gamma = 1.001 +kappa = 1.0 # We might need to play around with this constant. +equations = PolytropicEulerEquations2D(gamma, kappa) + + +function initial_condition_constant(x, t, equations::PolytropicEulerEquations2D) + rho = 1.0 + v1 = 0.2 + v2 = 0.1 + + return prim2cons(SVector(rho, v1, v2), equations) +end +initial_condition = initial_condition_constant + + +function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) + rho = 1.0 + v1 = 0.0 + if x[1] > 0.0 + rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma) + v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa) + end + v2 = 0.0 + + return prim2cons(SVector(rho, v1, v2), equations) +end + + +initial_condition = initial_condition_wave + +volume_flux = flux_ranocha +solver = DGSEM(polydeg=2, surface_flux=flux_hll, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + +coordinates_min = (-2.0, -1.0) +coordinates_max = ( 2.0, 1.0) + +cells_per_dimension = (64, 32) + +boundary_conditions = ( + x_neg=boundary_condition_periodic, + x_pos=boundary_condition_periodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + ) + +mesh = StructuredMesh(cells_per_dimension, + coordinates_min, + coordinates_max) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions=boundary_conditions) + + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 3.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 200 +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=1, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) + +stepsize_callback = StepsizeCallback(cfl=1.7) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_solution, + stepsize_callback) + + +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); +summary_callback() # print the timer summary + + +# # Convert the snapshots into vtk format. +trixi2vtk("out/solution_*.h5") From 24777ed1a03863662646e74d4bae60ba73a51ffa Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 12:24:13 +0100 Subject: [PATCH 006/111] Cleaned up example elicir for polytropic Euler in 2d. --- .../elixir_euler_polytropic.jl | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic.jl b/examples/structured_2d_dgsem/elixir_euler_polytropic.jl index 7b3fee4ee79..61850fadfd4 100644 --- a/examples/structured_2d_dgsem/elixir_euler_polytropic.jl +++ b/examples/structured_2d_dgsem/elixir_euler_polytropic.jl @@ -1,24 +1,16 @@ + using OrdinaryDiffEq -using Trixi2Vtk using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.001 -kappa = 1.0 # We might need to play around with this constant. -equations = PolytropicEulerEquations2D(gamma, kappa) - - -function initial_condition_constant(x, t, equations::PolytropicEulerEquations2D) - rho = 1.0 - v1 = 0.2 - v2 = 0.1 - - return prim2cons(SVector(rho, v1, v2), equations) -end -initial_condition = initial_condition_constant +gamma = 1.001 # Isotropic simulation. gamma = 1.0 would lead to a singularity. +# gamma = 2.0 # Adiabatic monatomic gas in 2d. +kappa = 1.0 # Scaling factor for the pressure. +equations = PolytropicEulerEquations2D(gamma, kappa) +# Linear pressure wave in the negative x-direction. function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) rho = 1.0 v1 = 0.0 @@ -30,8 +22,6 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) return prim2cons(SVector(rho, v1, v2), equations) end - - initial_condition = initial_condition_wave volume_flux = flux_ranocha @@ -61,7 +51,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 3.0) +tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() @@ -71,7 +61,7 @@ analysis_callback = AnalysisCallback(semi, interval=analysis_interval) alive_callback = AliveCallback(analysis_interval=analysis_interval) -save_solution = SaveSolutionCallback(interval=1, +save_solution = SaveSolutionCallback(interval=50, save_initial_solution=true, save_final_solution=true, solution_variables=cons2prim) @@ -83,18 +73,16 @@ callbacks = CallbackSet(summary_callback, save_solution, stepsize_callback) - 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); -summary_callback() # print the timer summary - -# # Convert the snapshots into vtk format. -trixi2vtk("out/solution_*.h5") +# Print the timer summary +summary_callback() From d3c431e74493d99fb4ecd378b53090667fbc91f1 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 12:33:01 +0100 Subject: [PATCH 007/111] Added polytrropic Euler in 2d in tests. --- test/test_structured_2d.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 2aea5adca48..c56464f1f62 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -206,6 +206,12 @@ isdir(outdir) && rm(outdir, recursive=true) tspan = (0.0, 0.3)) end + @trixi_testset "elixir_euler_polytropic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_polytropic.jl"), + l2 = [0.004995041733939986, 0.004997681632536576, 9.723735592127134e-17], + linf = [0.009993486548832253, 0.010048540255715076, 6.86525156020157e-16]) + 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], From c072eca6a74fbbb3f63dbdbccafaed97a8b29895 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 13 Jun 2023 14:27:25 +0100 Subject: [PATCH 008/111] Remoed unused routines. --- src/equations/polytropic_euler_2d.jl | 440 --------------------------- 1 file changed, 440 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 5034356a501..fc349a9b583 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -53,162 +53,6 @@ varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) = ("rho", "rho_v1", varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") -# Set initial conditions at physical location `x` for time `t` -""" - initial_condition_constant(x, t, equations::CompressibleEulerEquations2D) - -A constant initial condition to test free-stream preservation. -""" -function initial_condition_constant(x, t, equations::PolytropicEulerEquations2D) - rho = 1.0 - rho_v1 = 0.1 - rho_v2 = -0.2 - - return SVector(rho, rho_v1, rho_v2) -end - - -""" - initial_condition_linear_wave(x, t, equations::PolytropicEulerEquations2D) - -A linear density wave that travel into the negative x-direction. -""" -function initial_condition_density_wave(x, t, equations::PolytropicEulerEquations2D) - v1 = 0.0 - if x[1] > 0.0 - rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma) - v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa) - end - v2 = 0.0 - - rho_v1 = rho * v1 - rho_v2 = rho * v2 - - return SVector(rho, rho_v1, rho_v2) -end - - -""" - boundary_condition_slip_wall(u_inner, normal_direction, x, t, surface_flux_function, - equations::PolytropicEulerEquations2D) - -Determine the boundary numerical surface flux for a slip wall condition. -Imposes a zero normal velocity at the wall. -Density is taken from the internal solution state and pressure is computed as an -exact solution of a 1D Riemann problem. Further details about this boundary state -are available in the paper: -- J. J. W. van der Vegt and H. van der Ven (2002) - Slip flow boundary conditions in discontinuous Galerkin discretizations of - the Euler equations of gas dynamics - [PDF](https://reports.nlr.nl/bitstream/handle/10921/692/TP-2002-300.pdf?sequence=1) - -Details about the 1D pressure Riemann solution can be found in Section 6.3.3 of the book -- Eleuterio F. Toro (2009) - Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction - 3rd edition - [DOI: 10.1007/b79761](https://doi.org/10.1007/b79761) - -Should be used together with [`UnstructuredMesh2D`](@ref). -""" -@inline function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, - x, t, - surface_flux_function, - equations::PolytropicEulerEquations2D) - - 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 = rotate_to_x(u_inner, normal, equations) - p_local = equations.kappa*rho^equations.gamma - - # compute the primitive variables - rho_local, v_normal, v_tangent = cons2prim(u_local, equations) - - # Get the solution of the pressure Riemann problem - # See Section 6.3.3 of - # Eleuterio F. Toro (2009) - # Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction - # [DOI: 10.1007/b79761](https://doi.org/10.1007/b79761) - if v_normal <= 0.0 - sound_speed = sqrt(equations.gamma * p_local / rho_local) # local sound speed - p_star = p_local * (1.0 + 0.5 * (equations.gamma - 1) * v_normal / sound_speed)^(2.0 * equations.gamma * equations.inv_gamma_minus_one) - else # v_normal > 0.0 - A = 2.0 / ((equations.gamma + 1) * rho_local) - B = p_local * (equations.gamma - 1) / (equations.gamma + 1) - p_star = p_local + 0.5 * v_normal / A * (v_normal + sqrt(v_normal^2 + 4.0 * A * (p_local + B))) - end - - # For the slip wall we directly set the flux as the normal velocity is zero - return SVector(zero(eltype(u_inner)), - p_star * normal[1], - p_star * normal[2]) * norm_ -end - -""" - boundary_condition_slip_wall(u_inner, orientation, direction, x, t, - surface_flux_function, equations::PolytropicEulerEquations2D) - -Should be used together with [`TreeMesh`](@ref). -""" -@inline function boundary_condition_slip_wall(u_inner, orientation, - direction, x, t, - surface_flux_function, - equations::PolytropicEulerEquations2D) - # get the appropriate normal vector from the orientation - if orientation == 1 - normal = SVector(1, 0) - else # orientation == 2 - normal = SVector(0, 1) - end - - # compute and return the flux using `boundary_condition_slip_wall` routine above - return boundary_condition_slip_wall(u_inner, normal, x, t, surface_flux_function, equations) -end - -""" - boundary_condition_slip_wall(u_inner, normal_direction, direction, x, t, - surface_flux_function, equations::PolytropicEulerEquations2D) - -Should be used together with [`StructuredMesh`](@ref). -""" -@inline function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector, - direction, x, t, - surface_flux_function, - equations::PolytropicEulerEquations2D) - # flip sign of normal to make it outward pointing, then flip the sign of the normal flux back - # to be inward pointing on the -x and -y sides due to the orientation convention used by StructuredMesh - if isodd(direction) - boundary_flux = -boundary_condition_slip_wall(u_inner, -normal_direction, - x, t, surface_flux_function, equations) - else - boundary_flux = boundary_condition_slip_wall(u_inner, normal_direction, - x, t, surface_flux_function, equations) - end - - return boundary_flux -end - - -# Calculate 1D flux for a single point -@inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - v1 = rho_v1 / rho - v2 = rho_v2 / rho - p = equations.kappa*rho^equations.gamma - if orientation == 1 - f1 = rho_v1 - f2 = rho_v1 * v1 + p - f3 = rho_v1 * v2 - else - f1 = rho_v2 - f2 = rho_v2 * v1 - f3 = rho_v2 * v2 + p - end - return SVector(f1, f2, f3) -end - # Calculate 1D flux for a single point in the normal direction # Note, this directional vector is not normalized @inline function flux(u, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) @@ -225,156 +69,6 @@ end end -""" - flux_hllc(u_ll, u_rr, orientation, equations::PolytropicEulerEquations2D) - -Computes the HLLC flux (HLL with Contact) for compressible Euler equations developed by E.F. Toro -[Lecture slides](http://www.prague-sum.com/download/2012/Toro_2-HLLC-RiemannSolver.pdf) -Signal speeds: [DOI: 10.1137/S1064827593260140](https://doi.org/10.1137/S1064827593260140) -""" -function flux_hllc(u_ll, u_rr, orientation::Integer, equations::PolytropicEulerEquations2D) - # Calculate primitive variables and speed of sound - rho_ll, rho_v1_ll, rho_v2_ll = u_ll - rho_rr, rho_v1_rr, rho_v2_rr = u_rr - - v1_ll = rho_v1_ll / rho_ll - v2_ll = rho_v2_ll / rho_ll - p_ll = equations.kappa * rho_ll^equations.gamma - e_ll = p_ll * rho_ll / (equations.gamma - 1) - rho_e_ll = rho_ll * e_ll - c_ll = sqrt(equations.gamma*p_ll/rho_ll) - - v1_rr = rho_v1_rr / rho_rr - v2_rr = rho_v2_rr / rho_rr - p_rr = equations.kappa * rho_rr^equations.gamma - e_rr = p_rr * rho_rr / (equations.gamma - 1) - rho_e_rr = rho_rr * e_rr - c_rr = sqrt(equations.gamma*p_rr/rho_rr) - - # Obtain left and right fluxes - f_ll = flux(u_ll, orientation, equations) - f_rr = flux(u_rr, orientation, equations) - - # Compute Roe averages - sqrt_rho_ll = sqrt(rho_ll) - sqrt_rho_rr = sqrt(rho_rr) - sum_sqrt_rho = sqrt_rho_ll + sqrt_rho_rr - if orientation == 1 # x-direction - vel_L = v1_ll - vel_R = v1_rr - ekin_roe = (sqrt_rho_ll * v2_ll + sqrt_rho_rr * v2_rr)^2 - elseif orientation == 2 # y-direction - vel_L = v2_ll - vel_R = v2_rr - ekin_roe = (sqrt_rho_ll * v1_ll + sqrt_rho_rr * v1_rr)^2 - end - vel_roe = (sqrt_rho_ll * vel_L + sqrt_rho_rr * vel_R) / sum_sqrt_rho - ekin_roe = 0.5 * (vel_roe^2 + ekin_roe / sum_sqrt_rho^2) - H_ll = (rho_e_ll + p_ll) / rho_ll - H_rr = (rho_e_rr + p_rr) / rho_rr - H_roe = (sqrt_rho_ll * H_ll + sqrt_rho_rr * H_rr) / sum_sqrt_rho - c_roe = sqrt((equations.gamma - 1) * (H_roe - ekin_roe)) - Ssl = min(vel_L - c_ll, vel_roe - c_roe) - Ssr = max(vel_R + c_rr, vel_roe + c_roe) - sMu_L = Ssl - vel_L - sMu_R = Ssr - vel_R - - if Ssl >= 0.0 - f1 = f_ll[1] - f2 = f_ll[2] - f3 = f_ll[3] - elseif Ssr <= 0.0 - f1 = f_rr[1] - f2 = f_rr[2] - f3 = f_rr[3] - else - SStar = (p_rr - p_ll + rho_ll*vel_L*sMu_L - rho_rr*vel_R*sMu_R) / (rho_ll*sMu_L - rho_rr*sMu_R) - if Ssl <= 0.0 <= SStar - densStar = rho_ll*sMu_L / (Ssl-SStar) - enerStar = e_ll + (SStar - vel_L) * (SStar + p_ll / (rho_ll * sMu_L)) - UStar1 = densStar - UStar4 = densStar*enerStar - if orientation == 1 # x-direction - UStar2 = densStar*SStar - UStar3 = densStar*v2_ll - elseif orientation == 2 # y-direction - UStar2 = densStar*v1_ll - UStar3 = densStar*SStar - end - f1 = f_ll[1]+Ssl*(UStar1 - rho_ll) - f2 = f_ll[2]+Ssl*(UStar2 - rho_v1_ll) - f3 = f_ll[3]+Ssl*(UStar3 - rho_v2_ll) - else - densStar = rho_rr*sMu_R / (Ssr-SStar) - enerStar = e_rr + (SStar - vel_R) * (SStar + p_rr / (rho_rr * sMu_R)) - UStar1 = densStar - UStar4 = densStar*enerStar - if orientation == 1 # x-direction - UStar2 = densStar*SStar - UStar3 = densStar*v2_rr - elseif orientation == 2 # y-direction - UStar2 = densStar*v1_rr - UStar3 = densStar*SStar - end - f1 = f_rr[1]+Ssr*(UStar1 - rho_rr) - f2 = f_rr[2]+Ssr*(UStar2 - rho_v1_rr) - f3 = f_rr[3]+Ssr*(UStar3 - rho_v2_rr) - end - end - return SVector(f1, f2, f3) - end - - - -""" - flux_ranocha(u_ll, u_rr, orientation_or_normal_direction, - equations::PolytropicEulerEquations2D) - -Entropy conserving and kinetic energy preserving two-point flux by -- Hendrik Ranocha (2018) - Generalised Summation-by-Parts Operators and Entropy Stability of Numerical Methods - for Hyperbolic Balance Laws - [PhD thesis, TU Braunschweig](https://cuvillier.de/en/shop/publications/7743) -See also -- Hendrik Ranocha (2020) - Entropy Conserving and Kinetic Energy Preserving Numerical Methods for - the Euler Equations Using Summation-by-Parts Operators - [Proceedings of ICOSAHOM 2018](https://doi.org/10.1007/978-3-030-39647-3_42) -""" -@inline function flux_ranocha(u_ll, u_rr, orientation::Integer, equations::PolytropicEulerEquations2D) - # Unpack left and right state - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa*rho_ll^equations.gamma - p_rr = equations.kappa*rho_rr^equations.gamma - - # Compute the necessary mean values - rho_mean = ln_mean(rho_ll, rho_rr) - # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` - # in exact arithmetic since - # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) - # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) - inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) - v1_avg = 0.5 * (v1_ll + v1_rr) - v2_avg = 0.5 * (v2_ll + v2_rr) - p_avg = 0.5 * (p_ll + p_rr) - velocity_square_avg = 0.5 * (v1_ll*v1_rr + v2_ll*v2_rr) - - # Calculate fluxes depending on orientation - if orientation == 1 - f1 = rho_mean * v1_avg - f2 = f1 * v1_avg + p_avg - f3 = f1 * v2_avg - else - f1 = rho_mean * v2_avg - f2 = f1 * v1_avg - f3 = f1 * v2_avg + p_avg - end - - return SVector(f1, f2, f3) -end - - @inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) # Unpack left and right state rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) @@ -404,69 +98,6 @@ end end -# Calculate 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::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa*rho_ll^equations.gamma - p_rr = equations.kappa*rho_rr^equations.gamma - - # Get the velocity value in the appropriate direction - if orientation == 1 - v_ll = v1_ll - v_rr = v1_rr - else # orientation == 2 - v_ll = v2_ll - v_rr = v2_rr - end - # Calculate sound speeds - c_ll = sqrt(equations.gamma * p_ll / rho_ll) - c_rr = sqrt(equations.gamma * p_rr / rho_rr) - - λ_max = max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) -end - - -@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa*rho_ll^equations.gamma - p_rr = equations.kappa*rho_rr^equations.gamma - - # Calculate normal velocities and sound speed - # left - v_ll = ( v1_ll * normal_direction[1] - + v2_ll * normal_direction[2] ) - c_ll = sqrt(equations.gamma * p_ll / rho_ll) - # right - v_rr = ( v1_rr * normal_direction[1] - + v2_rr * normal_direction[2] ) - c_rr = sqrt(equations.gamma * p_rr / rho_rr) - - 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 -@inline function min_max_speed_naive(u_ll, u_rr, orientation::Integer, - equations::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa*rho_ll^equations.gamma - p_rr = equations.kappa*rho_rr^equations.gamma - - if orientation == 1 # x-direction - λ_min = v1_ll - sqrt(equations.gamma * p_ll / rho_ll) - λ_max = v1_rr + sqrt(equations.gamma * p_rr / rho_rr) - else # y-direction - λ_min = v2_ll - sqrt(equations.gamma * p_ll / rho_ll) - λ_max = v2_rr + sqrt(equations.gamma * p_rr / rho_rr) - end - - return λ_min, λ_max -end - @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) @@ -486,46 +117,6 @@ end 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::PolytropicEulerEquations2D) - # cos and sin of the angle between the x-axis and the normalized normal_vector are - # the normalized vector's x and y coordinates respectively (see unit circle). - c = normal_vector[1] - s = normal_vector[2] - - # Apply the 2D rotation matrix with normal and tangent directions of the form - # [ 1 0 0 - # 0 n_1 t_1 - # 0 n_2 t_2 ] - # where t_1 = -n_2 and t_2 = n_1 - - return SVector(u[1], - c * u[2] + s * u[3], - -s * u[2] + c * u[3]) -end - - -# Called inside `FluxRotated` in `numerical_fluxes.jl` so the direction -# has been normalized prior to this back-rotation of the state vector -@inline function rotate_from_x(u, normal_vector, equations::PolytropicEulerEquations2D) - # cos and sin of the angle between the x-axis and the normalized normal_vector are - # the normalized vector's x and y coordinates respectively (see unit circle). - c = normal_vector[1] - s = normal_vector[2] - - # Apply the 2D back-rotation matrix with normal and tangent directions of the form - # [ 1 0 0 - # 0 n_1 t_1 - # 0 n_2 t_2 ] - # where t_1 = -n_2 and t_2 = n_1 - - return SVector(u[1], - c * u[2] - s * u[3], - s * u[2] + c * u[3]) -end - - @inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) rho, v1, v2 = cons2prim(u, equations) c = sqrt(equations.gamma * equations.kappa*rho^(equations.gamma-1)) @@ -612,35 +203,4 @@ end end -@inline function density_pressure(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - rho_times_p = equations.kappa*rho^(equations.gamma+1) - return rho_times_p -end - - -# Calculate thermodynamic entropy for a conservative state `cons` -@inline function entropy_thermodynamic(cons, equations::PolytropicEulerEquations2D) - # Pressure - p = equations.kappa*cons[1]^equations.gamma - - # Thermodynamic entropy - s = log(p) - equations.gamma*log(cons[1]) - - return s -end - - -# Calculate mathematical entropy for a conservative state `cons` -@inline function entropy_math(cons, equations::PolytropicEulerEquations2D) - # Mathematical entropy - S = -entropy_thermodynamic(cons, equations) * cons[1] * (equations.gamma - 1) - - return S -end - - -# Default entropy is the mathematical entropy -@inline entropy(cons, equations::PolytropicEulerEquations2D) = entropy_math(cons, equations) - end # @muladd From 3dde9669d1e8363d662ed6f5720e18b3b15c5ecb Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:31:22 +0100 Subject: [PATCH 009/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index fc349a9b583..e6176944c7a 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -8,7 +8,7 @@ @doc raw""" PolytropicEulerEquations2D(gamma, kappa) -The compressible Euler equations +The polytropic Euler equations ```math \partial t \begin{pmatrix} From bd1cb982b69cebf5683f654a21b0d94132af0ddd Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:31:44 +0100 Subject: [PATCH 010/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index e6176944c7a..c19b08464c3 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -58,7 +58,7 @@ varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2" @inline function flux(u, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) rho_e = last(u) rho, v1, v2 = cons2prim(u, equations) - p = equations.kappa*rho^equations.gamma + p = pressure(u, equations) v_normal = v1 * normal_direction[1] + v2 * normal_direction[2] rho_v_normal = rho * v_normal From 1233184d183e6e4b8fdfd3a4ef6c2489a9bc333c Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:32:05 +0100 Subject: [PATCH 011/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index c19b08464c3..949de353c90 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -154,32 +154,6 @@ end return SVector(w1, w2, w3) end -# TODO: Do we need this? (SC) -# @inline function entropy2cons(w, equations::PolytropicEulerEquations2D) -# # See Hughes, Franca, Mallet (1986) A new finite element formulation for CFD -# # [DOI: 10.1016/0045-7825(86)90127-1](https://doi.org/10.1016/0045-7825(86)90127-1) -# @unpack gamma, kappa = equations - -# # convert to entropy `-rho * s` used by Hughes, France, Mallet (1986) -# # instead of `-rho * s / (gamma - 1)` -# V1, V2, V3, V5 = w .* (gamma-1) - -# # s = specific entropy, eq. (53) -# s = gamma - V1 + (V2^2 + V3^2)/(2*V5) - -# # eq. (52) -# rho_iota = ((gamma-1) / (-V5)^gamma)^(equations.inv_gamma_minus_one)*exp(-s * equations.inv_gamma_minus_one) - -# # eq. (51) -# rho = -rho_iota * V5 -# rho_v1 = rho_iota * V2 -# rho_v2 = rho_iota * V3 -# rho_e = rho_iota * (1-(V2^2 + V3^2)/(2*V5)) -# return SVector(rho, rho_v1, rho_v2, rho_e) -# end - - - # Convert primitive to conservative variables @inline function prim2cons(prim, equations::PolytropicEulerEquations2D) From 366ff394a3c3b25db2c7173a488585be7a3ffbd8 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:32:17 +0100 Subject: [PATCH 012/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 949de353c90..9b73fbe8c78 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -143,7 +143,7 @@ end v1 = rho_v1 / rho v2 = rho_v2 / rho v_square = v1^2 + v2^2 - p = equations.kappa * rho^equations.gamma + p = pressure(u, equations) s = rho/2*v_square + rho*equations.kappa*rho^(equations.gamma-1)/(equations.gamma-1) rho_p = rho / p From 4d45e135b90c6079b4d23d57f81a3a38df893b20 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 20 Jun 2023 14:36:06 +0100 Subject: [PATCH 013/111] Added compressible Euler equations in news. --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 9b46ba565fe..eeace90dd2f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,7 @@ for human readability. #### Added - Experimental support for 3D parabolic diffusion terms has been added. +- Implementation of compressible Euler equations in 2D #### Changed From 2a2663433abff4737e10462561ea16d45f656d3d Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 20 Jun 2023 14:45:34 +0100 Subject: [PATCH 014/111] Auto-reformatted equations. --- src/equations/equations.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/equations/equations.jl b/src/equations/equations.jl index 1b1d97d4b36..1051afe0233 100644 --- a/src/equations/equations.jl +++ b/src/equations/equations.jl @@ -365,7 +365,8 @@ include("compressible_euler_multicomponent_1d.jl") include("compressible_euler_multicomponent_2d.jl") # PolytropicEulerEquations -abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <: AbstractEquations{NDIMS, NVARS} end +abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <: + AbstractEquations{NDIMS, NVARS} end include("polytropic_euler_2d.jl") # Retrieve number of components from equation instance for the multicomponent case From f51d90e3031fb042759bda015bee9b9d99959579 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 20 Jun 2023 14:46:04 +0100 Subject: [PATCH 015/111] Auto-reformatted docs for polytropic equations. --- src/equations/polytropic_euler_2d.jl | 340 +++++++++++++-------------- 1 file changed, 166 insertions(+), 174 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 9b73fbe8c78..4e00a437679 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -3,178 +3,170 @@ # we need to opt-in explicitly. # See https://ranocha.de/blog/Optimizing_EC_Trixi for further details. @muladd begin - - -@doc raw""" - PolytropicEulerEquations2D(gamma, kappa) - -The polytropic Euler equations -```math -\partial t -\begin{pmatrix} -\rho \\ \rho v_1 \\ \rho v_2 -\end{pmatrix} -+ -\partial x -\begin{pmatrix} - \rho v_1 \\ \rho v_1^2 + \kappa\rho^\gamma \\ \rho v_1 v_2 -\end{pmatrix} -+ -\partial y -\begin{pmatrix} -\rho v_2 \\ \rho v_1 v_2 \\ \rho v_2^2 + \kappa\rho^\gamma -\end{pmatrix} -= -\begin{pmatrix} -0 \\ 0 \\ 0 -\end{pmatrix} -``` -for an ideal gas with ratio of specific heats `gamma` -in two space dimensions. -Here, ``\rho`` is the density and ``v_1`` and`v_2` the velocities and -```math -p = \kappa\rho^\gamma -``` -the pressure, which we replaced using this relation. - -""" -struct PolytropicEulerEquations2D{RealT<:Real, RealT<:Real} <: AbstractPolytropicEulerEquations{2, 3} - gamma::RealT # ratio of specific heats - kappa::RealT # fluid scaling factor - inv_gamma_minus_one::RealT # = inv(gamma - 1); can be used to write slow divisions as fast multiplications - - function PolytropicEulerEquations2D(gamma, kappa) - new{typeof(gamma), typeof(kappa)}(gamma, kappa) - end -end - - -varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) = ("rho", "rho_v1", "rho_v2") -varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") - - -# Calculate 1D flux for a single point in the normal direction -# Note, this directional vector is not normalized -@inline function flux(u, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) - rho_e = last(u) - rho, v1, v2 = cons2prim(u, equations) - p = pressure(u, equations) - - v_normal = v1 * normal_direction[1] + v2 * normal_direction[2] - rho_v_normal = rho * v_normal - f1 = rho_v_normal - f2 = rho_v_normal * v1 + p * normal_direction[1] - f3 = rho_v_normal * v2 + p * normal_direction[2] - return SVector(f1, f2, f3) -end - - -@inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) - # Unpack left and right state - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa*rho_ll^equations.gamma - p_rr = equations.kappa*rho_rr^equations.gamma - v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] - v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] - - # Compute the necessary mean values - rho_mean = ln_mean(rho_ll, rho_rr) - # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` - # in exact arithmetic since - # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) - # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) - inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) - v1_avg = 0.5 * (v1_ll + v1_rr) - v2_avg = 0.5 * (v2_ll + v2_rr) - p_avg = 0.5 * (p_ll + p_rr) - - # Calculate fluxes depending on normal_direction - f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) - f2 = f1 * v1_avg + p_avg * normal_direction[1] - f3 = f1 * v2_avg + p_avg * normal_direction[2] - - return SVector(f1, f2, f3) -end - - -@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, - equations::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa*rho_ll^equations.gamma - p_rr = equations.kappa*rho_rr^equations.gamma - - 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] - - norm_ = norm(normal_direction) - # The v_normals are already scaled by the norm - λ_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ - λ_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ - - return λ_min, λ_max -end - - -@inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) - c = sqrt(equations.gamma * equations.kappa*rho^(equations.gamma-1)) - - return abs(v1) + c, abs(v2) + c -end - - -# Convert conservative variables to primitive -@inline function cons2prim(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - - v1 = rho_v1 / rho - v2 = rho_v2 / rho - - return SVector(rho, v1, v2) -end - - -# Convert conservative variables to entropy -@inline function cons2entropy(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - - v1 = rho_v1 / rho - v2 = rho_v2 / rho - v_square = v1^2 + v2^2 - p = pressure(u, equations) - s = rho/2*v_square + rho*equations.kappa*rho^(equations.gamma-1)/(equations.gamma-1) - rho_p = rho / p - - w1 = (equations.gamma - s) * (equations.gamma - 1) - 0.5 * rho_p * v_square - w2 = rho_p * v1 - w3 = rho_p * v2 - - return SVector(w1, w2, w3) -end - - -# Convert primitive to conservative variables -@inline function prim2cons(prim, equations::PolytropicEulerEquations2D) - rho, v1, v2 = prim - rho_v1 = rho * v1 - rho_v2 = rho * v2 - return SVector(rho, rho_v1, rho_v2) -end - - -@inline function density(u, equations::PolytropicEulerEquations2D) - rho = u[1] - return rho -end - - -@inline function pressure(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - p = equations.kappa*rho^equations.gamma - return p -end - - + @doc raw""" + PolytropicEulerEquations2D(gamma, kappa) + + The polytropic Euler equations + ```math + \partial t + \begin{pmatrix} + \rho \\ \rho v_1 \\ \rho v_2 + \end{pmatrix} + + + \partial x + \begin{pmatrix} + \rho v_1 \\ \rho v_1^2 + \kappa\rho^\gamma \\ \rho v_1 v_2 + \end{pmatrix} + + + \partial y + \begin{pmatrix} + \rho v_2 \\ \rho v_1 v_2 \\ \rho v_2^2 + \kappa\rho^\gamma + \end{pmatrix} + = + \begin{pmatrix} + 0 \\ 0 \\ 0 + \end{pmatrix} + ``` + for an ideal gas with ratio of specific heats `gamma` + in two space dimensions. + Here, ``\rho`` is the density and ``v_1`` and`v_2` the velocities and + ```math + p = \kappa\rho^\gamma + ``` + the pressure, which we replaced using this relation. + + """ + struct PolytropicEulerEquations2D{RealT <: Real, RealT <: Real} <: + AbstractPolytropicEulerEquations{2, 3} + gamma::RealT # ratio of specific heats + kappa::RealT # fluid scaling factor + inv_gamma_minus_one::RealT # = inv(gamma - 1); can be used to write slow divisions as fast multiplications + + function PolytropicEulerEquations2D(gamma, kappa) + new{typeof(gamma), typeof(kappa)}(gamma, kappa) + end + end + + function varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) + ("rho", "rho_v1", "rho_v2") + end + varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") + + # Calculate 1D flux for a single point in the normal direction + # Note, this directional vector is not normalized + @inline function flux(u, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + rho_e = last(u) + rho, v1, v2 = cons2prim(u, equations) + p = pressure(u, equations) + + v_normal = v1 * normal_direction[1] + v2 * normal_direction[2] + rho_v_normal = rho * v_normal + f1 = rho_v_normal + f2 = rho_v_normal * v1 + p * normal_direction[1] + f3 = rho_v_normal * v2 + p * normal_direction[2] + return SVector(f1, f2, f3) + end + + @inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + # Unpack left and right state + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa * rho_ll^equations.gamma + p_rr = equations.kappa * rho_rr^equations.gamma + v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # Compute the necessary mean values + rho_mean = ln_mean(rho_ll, rho_rr) + # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` + # in exact arithmetic since + # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) + # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) + inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) + v1_avg = 0.5 * (v1_ll + v1_rr) + v2_avg = 0.5 * (v2_ll + v2_rr) + p_avg = 0.5 * (p_ll + p_rr) + + # Calculate fluxes depending on normal_direction + f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) + f2 = f1 * v1_avg + p_avg * normal_direction[1] + f3 = f1 * v2_avg + p_avg * normal_direction[2] + + return SVector(f1, f2, f3) + end + + @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa * rho_ll^equations.gamma + p_rr = equations.kappa * rho_rr^equations.gamma + + 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] + + norm_ = norm(normal_direction) + # The v_normals are already scaled by the norm + λ_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ + λ_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ + + return λ_min, λ_max + end + + @inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) + rho, v1, v2 = cons2prim(u, equations) + c = sqrt(equations.gamma * equations.kappa * rho^(equations.gamma - 1)) + + return abs(v1) + c, abs(v2) + c + end + + # Convert conservative variables to primitive + @inline function cons2prim(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + + v1 = rho_v1 / rho + v2 = rho_v2 / rho + + return SVector(rho, v1, v2) + end + + # Convert conservative variables to entropy + @inline function cons2entropy(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + + v1 = rho_v1 / rho + v2 = rho_v2 / rho + v_square = v1^2 + v2^2 + p = pressure(u, equations) + s = rho / 2 * v_square + + rho * equations.kappa * rho^(equations.gamma - 1) / (equations.gamma - 1) + rho_p = rho / p + + w1 = (equations.gamma - s) * (equations.gamma - 1) - 0.5 * rho_p * v_square + w2 = rho_p * v1 + w3 = rho_p * v2 + + return SVector(w1, w2, w3) + end + + # Convert primitive to conservative variables + @inline function prim2cons(prim, equations::PolytropicEulerEquations2D) + rho, v1, v2 = prim + rho_v1 = rho * v1 + rho_v2 = rho * v2 + return SVector(rho, rho_v1, rho_v2) + end + + @inline function density(u, equations::PolytropicEulerEquations2D) + rho = u[1] + return rho + end + + @inline function pressure(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + p = equations.kappa * rho^equations.gamma + return p + end end # @muladd From 4a5d33f4ebc0f980355bf37e412a4f3e30786056 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Thu, 22 Jun 2023 15:32:24 +0100 Subject: [PATCH 016/111] Added example elixir for polytropic and isothermal coupling. --- .../elixir_euler_polytropic_coupled.jl | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl new file mode 100644 index 00000000000..f9a3bd7bf95 --- /dev/null +++ b/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl @@ -0,0 +1,155 @@ + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# Couple polytropic Euler systems. +# +# In a rectangular domain we solve two different sets of equations for the +# left and the right half. Those are the isotropic equations (left) +# and polytropic equations (right). +# The coupling hapens on two interfaces. One is located at the center of the +# domain such that the right half is coupled through its left boundary +# and the left half is coupled through its right boundary. The other coupling +# makes sure that the domain is periodic. Here the right boundary of the right +# domain is coupled to the left boundary of the left domain. +# The vertical boundaries are simply periodic. +# As test case we send a linear wave through the domain and observe a change +# in the dispersion relation when the wave enters the isotropic domain. + +############################################################################### +# define the initial conditions + +function initial_condition_wave_isotropic(x, t, equations::PolytropicEulerEquations2D) + gamma = 1.001 + kappa = 1.0 + + rho = 1.0 + v1 = 0.0 + v2 = 0.0 + + return prim2cons(SVector(rho, v1, v2), equations) +end + +function initial_condition_wave_polytropic(x, t, equations::PolytropicEulerEquations2D) + gamma = 2.0 + kappa = 1.0 + + rho = 1.0 + v1 = 0.0 + if x[1] > 0.0 + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa) + end + v2 = 0.0 + + return prim2cons(SVector(rho, v1, v2), equations) +end + +############################################################################### +# semidiscretization of the linear advection equation + +function Trixi.wrap_array(u_ode::AbstractVector, mesh::Trixi.AbstractMesh, equations, + dg::DGSEM, cache) + Trixi.wrap_array_native(u_ode, mesh, equations, dg, cache) +end + +# Define the equations involved. +gamma1 = 1.001 +kappa1 = 1.0 +equations1 = PolytropicEulerEquations2D(gamma_A, kappa_A) +gamma2 = 2.0 +kappa2 = 1.0 +equations2 = PolytropicEulerEquations2D(gamma_B, kappa_B) + +# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux +volume_flux = flux_ranocha +solver = DGSEM(polydeg = 2, surface_flux = flux_hll, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) + +coordinates_min1 = (-2.0, -1.0) # minimum coordinates (min(x), min(y)) +coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y)) +coordinates_min2 = (0.0, -1.0) # minimum coordinates (min(x), min(y)) +coordinates_max2 = (2.0, 1.0) # maximum coordinates (max(x), max(y)) + +cells_per_dimension = (32, 32) + +mesh1 = StructuredMesh(cells_per_dimension, + coordinates_min1, + coordinates_max1) +mesh2 = StructuredMesh(cells_per_dimension, + coordinates_min2, + coordinates_max2) + +# A semidiscretization collects data structures and functions for the spatial discretization. +semi1 = SemidiscretizationHyperbolic(mesh1, equations1, + initial_condition_wave_isotropic, solver, + boundary_conditions = (x_neg = BoundaryConditionCoupled(2, + (:end, + :i_forward), + Float64), + x_pos = BoundaryConditionCoupled(2, + (:begin, + :i_forward), + Float64), + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic)) + +semi2 = SemidiscretizationHyperbolic(mesh2, equations2, + initial_condition_wave_polytropic, solver, + boundary_conditions = (x_neg = BoundaryConditionCoupled(1, + (:end, + :i_forward), + Float64), + 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) + +############################################################################### +# ODE solvers, callbacks etc. + +# Create ODE problem with time span from 0.0 to 30.0 +ode = semidiscretize(semi, (0.0, 3.0)) + +# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup +# and resets the timers +summary_callback = SummaryCallback() + +resid_tol = 5.0e-12 +steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) + +# 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_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2) + +# The SaveSolutionCallback allows to save the solution to a file in regular intervals +save_solution = SaveSolutionCallback(interval = 5, + solution_variables = cons2prim) + +# The StepsizeCallback handles the re-calculcation of the maximum Δt after each time step +stepsize_callback = StepsizeCallback(cfl = 1.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) + +############################################################################### +# 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); + +# Print the timer summary +summary_callback() + From 003aafda2ee1320f30dc741613d2bdb468b42a12 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Thu, 22 Jun 2023 15:33:16 +0100 Subject: [PATCH 017/111] Corrected typos. --- .../elixir_euler_polytropic_coupled.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl index f9a3bd7bf95..7da0378a62c 100644 --- a/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl @@ -6,7 +6,7 @@ using Trixi # Couple polytropic Euler systems. # # In a rectangular domain we solve two different sets of equations for the -# left and the right half. Those are the isotropic equations (left) +# left and the right half. Those are the isothermal equations (left) # and polytropic equations (right). # The coupling hapens on two interfaces. One is located at the center of the # domain such that the right half is coupled through its left boundary @@ -15,12 +15,12 @@ using Trixi # domain is coupled to the left boundary of the left domain. # The vertical boundaries are simply periodic. # As test case we send a linear wave through the domain and observe a change -# in the dispersion relation when the wave enters the isotropic domain. +# in the dispersion relation when the wave enters the isothermal domain. ############################################################################### # define the initial conditions -function initial_condition_wave_isotropic(x, t, equations::PolytropicEulerEquations2D) +function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquations2D) gamma = 1.001 kappa = 1.0 @@ -83,7 +83,7 @@ mesh2 = StructuredMesh(cells_per_dimension, # A semidiscretization collects data structures and functions for the spatial discretization. semi1 = SemidiscretizationHyperbolic(mesh1, equations1, - initial_condition_wave_isotropic, solver, + initial_condition_wave_thermal, solver, boundary_conditions = (x_neg = BoundaryConditionCoupled(2, (:end, :i_forward), From f14ea5da474dc98f59fd9e1f209afd02a1a9a907 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 09:38:34 +0100 Subject: [PATCH 018/111] Update examples/structured_2d_dgsem/elixir_euler_polytropic.jl Co-authored-by: Michael Schlottke-Lakemper --- examples/structured_2d_dgsem/elixir_euler_polytropic.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic.jl b/examples/structured_2d_dgsem/elixir_euler_polytropic.jl index 61850fadfd4..0f3f3312665 100644 --- a/examples/structured_2d_dgsem/elixir_euler_polytropic.jl +++ b/examples/structured_2d_dgsem/elixir_euler_polytropic.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.001 # Isotropic simulation. gamma = 1.0 would lead to a singularity. +gamma = 1.001 # Quasi-isotropic simulation. gamma = 1.0 would lead to a singularity. # gamma = 2.0 # Adiabatic monatomic gas in 2d. kappa = 1.0 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) From dc403ecd09c62db51b23b226bfd95611e0eff131 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 09:39:04 +0100 Subject: [PATCH 019/111] Update NEWS.md Co-authored-by: Michael Schlottke-Lakemper --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index eeace90dd2f..e04ae614129 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,7 +9,7 @@ for human readability. #### Added - Experimental support for 3D parabolic diffusion terms has been added. -- Implementation of compressible Euler equations in 2D +- Implementation of the polytropic Euler equations in 2D #### Changed From 75a026c4f9e5d4a280c348fc79e0e82dc885d1c5 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 3 Jul 2023 09:50:18 +0100 Subject: [PATCH 020/111] Renamed elixir_euler_polytropic.jl to elixir_euler_polytropic.jl. --- ...{elixir_euler_polytropic.jl => elixir_eulerpolytropic_wave.jl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/structured_2d_dgsem/{elixir_euler_polytropic.jl => elixir_eulerpolytropic_wave.jl} (100%) diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl similarity index 100% rename from examples/structured_2d_dgsem/elixir_euler_polytropic.jl rename to examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl From fb6617d7c6eab6088bfca4e74e0259e9d59e3d1f Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 3 Jul 2023 09:51:34 +0100 Subject: [PATCH 021/111] Renamed Euler polytropic elixir in test. --- test/test_structured_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 498c98501a3..5a88059a563 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -218,8 +218,8 @@ isdir(outdir) && rm(outdir, recursive=true) tspan = (0.0, 0.3)) end - @trixi_testset "elixir_euler_polytropic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_polytropic.jl"), + @trixi_testset "elixir_eulerpolytropic_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_wave.jl"), l2 = [0.004995041733939986, 0.004997681632536576, 9.723735592127134e-17], linf = [0.009993486548832253, 0.010048540255715076, 6.86525156020157e-16]) end From 6515f416ec33bde39868da5f8d93b409a2e7bd4b Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 3 Jul 2023 09:52:26 +0100 Subject: [PATCH 022/111] Renamed coupled polytropic example elixir. --- ...er_polytropic_coupled.jl => elixir_eulerpolytropic_coupled.jl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/structured_2d_dgsem/{elixir_euler_polytropic_coupled.jl => elixir_eulerpolytropic_coupled.jl} (100%) diff --git a/examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl similarity index 100% rename from examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl rename to examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl From 9edd2b57e44d58e03a7a9f25afe404f0f9631385 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 3 Jul 2023 10:00:18 +0100 Subject: [PATCH 023/111] Reformatted the boundary conditions for the couple polytropic example elixir. --- .../elixir_eulerpolytropic_coupled.jl | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 7da0378a62c..092c6fa81e5 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -81,30 +81,23 @@ mesh2 = StructuredMesh(cells_per_dimension, coordinates_min2, coordinates_max2) +boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, (:end, :i_forward), Float64) +boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64) +boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, (:end, :i_forward), Float64) +boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64) + # A semidiscretization collects data structures and functions for the spatial discretization. semi1 = SemidiscretizationHyperbolic(mesh1, equations1, initial_condition_wave_thermal, solver, - boundary_conditions = (x_neg = BoundaryConditionCoupled(2, - (:end, - :i_forward), - Float64), - x_pos = BoundaryConditionCoupled(2, - (:begin, - :i_forward), - Float64), + boundary_conditions = (x_neg = boundary_conditions_x_neg1, + x_pos = boundary_conditions_x_pos1, y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic)) semi2 = SemidiscretizationHyperbolic(mesh2, equations2, initial_condition_wave_polytropic, solver, - boundary_conditions = (x_neg = BoundaryConditionCoupled(1, - (:end, - :i_forward), - Float64), - x_pos = BoundaryConditionCoupled(1, - (:begin, - :i_forward), - Float64), + boundary_conditions = (x_neg = boundary_conditions_x_neg2 + x_pos = boundary_conditions_x_pos2 y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic)) From 3c2a1256cbab1a8c00937fe60b32599af7bc9505 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 3 Jul 2023 10:07:23 +0100 Subject: [PATCH 024/111] Removed redundant inv_gamma_minus_one variable. --- src/equations/polytropic_euler_2d.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 4e00a437679..78f7f23abaf 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -40,7 +40,6 @@ AbstractPolytropicEulerEquations{2, 3} gamma::RealT # ratio of specific heats kappa::RealT # fluid scaling factor - inv_gamma_minus_one::RealT # = inv(gamma - 1); can be used to write slow divisions as fast multiplications function PolytropicEulerEquations2D(gamma, kappa) new{typeof(gamma), typeof(kappa)}(gamma, kappa) From ba8d163861a19ad68d16ec7fbe1b83fa96ae6fd3 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:08:29 +0100 Subject: [PATCH 025/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 78f7f23abaf..f15735af32c 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -36,8 +36,7 @@ the pressure, which we replaced using this relation. """ - struct PolytropicEulerEquations2D{RealT <: Real, RealT <: Real} <: - AbstractPolytropicEulerEquations{2, 3} + struct PolytropicEulerEquations2D{RealT <: Real} <: AbstractPolytropicEulerEquations{2, 3} gamma::RealT # ratio of specific heats kappa::RealT # fluid scaling factor From e409677c4cbda001f9c91926279b56b5a78efc3b Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:08:56 +0100 Subject: [PATCH 026/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index f15735af32c..d2a48422ee0 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -41,7 +41,8 @@ kappa::RealT # fluid scaling factor function PolytropicEulerEquations2D(gamma, kappa) - new{typeof(gamma), typeof(kappa)}(gamma, kappa) + gamma_, kappa_ = promote(gamma, kappa) + new{typeof(gamma), typeof(kappa)}(gamma_, kappa_) end end From d3109acc4e52c1b9f1f79f22042027023479737b Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:09:37 +0100 Subject: [PATCH 027/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index d2a48422ee0..e9f1523f100 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -55,7 +55,6 @@ # Note, this directional vector is not normalized @inline function flux(u, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) - rho_e = last(u) rho, v1, v2 = cons2prim(u, equations) p = pressure(u, equations) From a49e2a41df2ca32f009c114fe8171d68076ee33f Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:10:21 +0100 Subject: [PATCH 028/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index e9f1523f100..a622571d5ea 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -107,10 +107,10 @@ norm_ = norm(normal_direction) # The v_normals are already scaled by the norm - λ_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ - λ_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ + lambda_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ + lambda_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ - return λ_min, λ_max + return lambda_min, lambda_max end @inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) From 4d5959c8f0332e9c1e16e053ee2bd6f3631fcc43 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:08:47 +0100 Subject: [PATCH 029/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl Yes. That was necessary in an old version for Trixi.jl. Co-authored-by: Michael Schlottke-Lakemper --- .../structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 092c6fa81e5..f5b14d22dd3 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -49,11 +49,6 @@ end ############################################################################### # semidiscretization of the linear advection equation -function Trixi.wrap_array(u_ode::AbstractVector, mesh::Trixi.AbstractMesh, equations, - dg::DGSEM, cache) - Trixi.wrap_array_native(u_ode, mesh, equations, dg, cache) -end - # Define the equations involved. gamma1 = 1.001 kappa1 = 1.0 From 8d3c371f68fa0832e8241023491263c7f09b6404 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:10:29 +0100 Subject: [PATCH 030/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl Co-authored-by: Michael Schlottke-Lakemper --- examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index f5b14d22dd3..305d3056335 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -109,9 +109,6 @@ ode = semidiscretize(semi, (0.0, 3.0)) # and resets the timers summary_callback = SummaryCallback() -resid_tol = 5.0e-12 -steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0) - # 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) From 1e08200fd161a048af608112a06a856fe0a3e4b7 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:11:45 +0100 Subject: [PATCH 031/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl Co-authored-by: Michael Schlottke-Lakemper --- examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 305d3056335..55507653364 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -102,7 +102,7 @@ semi = SemidiscretizationCoupled(semi1, semi2) ############################################################################### # ODE solvers, callbacks etc. -# Create ODE problem with time span from 0.0 to 30.0 +# Create ODE problem ode = semidiscretize(semi, (0.0, 3.0)) # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup From c53fecfc0294cbb0dc81620280e8d8c9d8e4e672 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:12:22 +0100 Subject: [PATCH 032/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl Co-authored-by: Michael Schlottke-Lakemper --- .../structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 55507653364..7d1d5589d28 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -52,10 +52,10 @@ end # Define the equations involved. gamma1 = 1.001 kappa1 = 1.0 -equations1 = PolytropicEulerEquations2D(gamma_A, kappa_A) +equations1 = PolytropicEulerEquations2D(gamma1, kappa1) gamma2 = 2.0 kappa2 = 1.0 -equations2 = PolytropicEulerEquations2D(gamma_B, kappa_B) +equations2 = PolytropicEulerEquations2D(gamma2, kappa2) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux volume_flux = flux_ranocha From f74d681ccc338569d37df603ac68b643063e7b1b Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 3 Jul 2023 15:59:54 +0100 Subject: [PATCH 033/111] Removed flux Ranocha for polytropic equations. --- .../elixir_eulerpolytropic_wave.jl | 6 +- src/equations/polytropic_euler_2d.jl | 56 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 0f3f3312665..14f6a139599 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -24,9 +24,9 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) end initial_condition = initial_condition_wave -volume_flux = flux_ranocha -solver = DGSEM(polydeg=2, surface_flux=flux_hll, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +#volume_flux = flux_ranocha +solver = DGSEM(polydeg=2, surface_flux=flux_hll)#, +# volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -1.0) coordinates_max = ( 2.0, 1.0) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index a622571d5ea..7bf6ce6ede4 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -66,34 +66,34 @@ return SVector(f1, f2, f3) end - @inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, - equations::PolytropicEulerEquations2D) - # Unpack left and right state - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa * rho_ll^equations.gamma - p_rr = equations.kappa * rho_rr^equations.gamma - v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] - v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] - - # Compute the necessary mean values - rho_mean = ln_mean(rho_ll, rho_rr) - # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` - # in exact arithmetic since - # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) - # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) - inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) - v1_avg = 0.5 * (v1_ll + v1_rr) - v2_avg = 0.5 * (v2_ll + v2_rr) - p_avg = 0.5 * (p_ll + p_rr) - - # Calculate fluxes depending on normal_direction - f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) - f2 = f1 * v1_avg + p_avg * normal_direction[1] - f3 = f1 * v2_avg + p_avg * normal_direction[2] - - return SVector(f1, f2, f3) - end + # @inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, + # equations::PolytropicEulerEquations2D) + # # Unpack left and right state + # rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + # rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + # p_ll = equations.kappa * rho_ll^equations.gamma + # p_rr = equations.kappa * rho_rr^equations.gamma + # v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + # v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # # Compute the necessary mean values + # rho_mean = ln_mean(rho_ll, rho_rr) + # # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` + # # in exact arithmetic since + # # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) + # # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) + # inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) + # v1_avg = 0.5 * (v1_ll + v1_rr) + # v2_avg = 0.5 * (v2_ll + v2_rr) + # p_avg = 0.5 * (p_ll + p_rr) + + # # Calculate fluxes depending on normal_direction + # f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) + # f2 = f1 * v1_avg + p_avg * normal_direction[1] + # f3 = f1 * v2_avg + p_avg * normal_direction[2] + + # return SVector(f1, f2, f3) + # end @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) From d8e25601d226736cebbb05819acb6da5f5cbd009 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 3 Jul 2023 16:25:33 +0100 Subject: [PATCH 034/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 7bf6ce6ede4..bc4f67b1133 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -42,7 +42,7 @@ function PolytropicEulerEquations2D(gamma, kappa) gamma_, kappa_ = promote(gamma, kappa) - new{typeof(gamma), typeof(kappa)}(gamma_, kappa_) + new{typeof(gamma_)}(gamma_, kappa_) end end From a55c6be94d3065cb91eba374228c8ba001808984 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:45:38 +0100 Subject: [PATCH 035/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Hendrik Ranocha --- src/equations/polytropic_euler_2d.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index bc4f67b1133..b363c661cc1 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -3,6 +3,8 @@ # we need to opt-in explicitly. # See https://ranocha.de/blog/Optimizing_EC_Trixi for further details. @muladd begin +#! format: noindent + @doc raw""" PolytropicEulerEquations2D(gamma, kappa) From 3ab5f003046466020c246f0a8ab5ffd98cf7e4e1 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:49:47 +0100 Subject: [PATCH 036/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Hendrik Ranocha --- src/equations/polytropic_euler_2d.jl | 29 ---------------------------- 1 file changed, 29 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index b363c661cc1..46559ca720a 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -68,35 +68,6 @@ return SVector(f1, f2, f3) end - # @inline function flux_ranocha(u_ll, u_rr, normal_direction::AbstractVector, - # equations::PolytropicEulerEquations2D) - # # Unpack left and right state - # rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - # rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - # p_ll = equations.kappa * rho_ll^equations.gamma - # p_rr = equations.kappa * rho_rr^equations.gamma - # v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] - # v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] - - # # Compute the necessary mean values - # rho_mean = ln_mean(rho_ll, rho_rr) - # # Algebraically equivalent to `inv_ln_mean(rho_ll / p_ll, rho_rr / p_rr)` - # # in exact arithmetic since - # # log((ϱₗ/pₗ) / (ϱᵣ/pᵣ)) / (ϱₗ/pₗ - ϱᵣ/pᵣ) - # # = pₗ pᵣ log((ϱₗ pᵣ) / (ϱᵣ pₗ)) / (ϱₗ pᵣ - ϱᵣ pₗ) - # inv_rho_p_mean = p_ll * p_rr * inv_ln_mean(rho_ll * p_rr, rho_rr * p_ll) - # v1_avg = 0.5 * (v1_ll + v1_rr) - # v2_avg = 0.5 * (v2_ll + v2_rr) - # p_avg = 0.5 * (p_ll + p_rr) - - # # Calculate fluxes depending on normal_direction - # f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) - # f2 = f1 * v1_avg + p_avg * normal_direction[1] - # f3 = f1 * v2_avg + p_avg * normal_direction[2] - - # return SVector(f1, f2, f3) - # end - @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) From 8c7cdf21b6e080925e3c03b3b693d9c729031c4b Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 4 Jul 2023 10:31:55 +0100 Subject: [PATCH 037/111] Added Andrew's flux implementation flux_winters_etal. --- src/Trixi.jl | 1 + src/auxiliary/math.jl | 66 ++++++++++++++++++++++++++++ src/equations/polytropic_euler_2d.jl | 59 ++++++++++++++++++++++--- 3 files changed, 120 insertions(+), 6 deletions(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 94e4a2861bc..064e6d8ced0 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -161,6 +161,7 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle, flux_kennedy_gruber, flux_shima_etal, flux_ec, flux_fjordholm_etal, flux_nonconservative_fjordholm_etal, flux_es_fjordholm_etal, flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal, + flux_winters_etal, hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, FluxLaxFriedrichs, max_abs_speed_naive, diff --git a/src/auxiliary/math.jl b/src/auxiliary/math.jl index 27c1bed5ca4..3952e7d5207 100644 --- a/src/auxiliary/math.jl +++ b/src/auxiliary/math.jl @@ -207,4 +207,70 @@ Return `x` if `x` is negative, else zero. In other words, return @inline function negative_part(x) return min(x, zero(x)) end + +""" + stolarsky_mean(x, y) + +Compute an instance of a weighted Stolarsky mean of the form + + stolarsky_mean(x, y, gamma) = (gamma - 1)/gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) + +where `gamma > 1`. + +Problem: The formula above has a removable singularity at `x == y`. Thus, +some care must be taken to implement it correctly without problems or loss +of accuracy when `x ≈ y`. Here, we use the approach proposed by +Winters et al. (2020). +Set f = (y - x) / (y + x) and g = gamma (for compact notation). +Then, we use the expansions + + ((1+f)^g - (1-f)^g) / g = 2*f + (g-1)(g-2)/3 * f^3 + (g-1)(g-2)(g-3)(g-4)/60 * f^5 + O(f^7) + +and + + ((1+f)^(g-1) - (1-f)^(g-1)) / (g-1) = 2*f + (g-2)(g-3)/3 * f^3 + (g-2)(g-3)(g-4)(g-5)/60 * f^5 + O(f^7) + +Inserting the first few terms of these expansions and performing polynomial long division +we find that + + stolarsky_mean(x, y, gamma) ≈ (y + x) / 2 * (1 + (g-2)/3 * f^2 - (g+1)(g-2)(g-3)/45 * f^4 + (g+1)(g-2)(g-3)(2g(g-2)-9)/945 * f^6) + +Since divisions are usually more expensive on modern hardware than +multiplications (Agner Fog), we try to avoid computing two divisions. Thus, +we use + + f^2 = (y - x)^2 / (x + y)^2 + = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y) + +Given ε = 1.0e-4, we use the following algorithm. + + if f^2 < ε + # use the expansion above + else + # use the direct formula (gamma - 1)/gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) + end + +# References +- Andrew R. Winters, Christof Czernik, Moritz B. Schily & Gregor J. Gassner (2020) + Entropy stable numerical approximations for the isothermal and polytropic + Euler equations + [DOI: 10.1007/s10543-019-00789-w](https://doi.org/10.1007/s10543-019-00789-w) +- Agner Fog. + Lists of instruction latencies, throughputs and micro-operation breakdowns + for Intel, AMD, and VIA CPUs. + [https://www.agner.org/optimize/instruction_tables.pdf](https://www.agner.org/optimize/instruction_tables.pdf) +""" +@inline function stolarsky_mean(x, y, gamma) + epsilon_f2 = 1.0e-4 + f2 = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y) # f2 = f^2 + if f2 < epsilon_f2 + # convenience coefficients + c1 = (gamma - 2) / 3 + c2 = -(gamma + 1) * (gamma - 2)* (gamma - 3) / 45 + c3 = (gamma + 1) * (gamma - 2) * (gamma - 3)* (2 * gamma * (gamma - 2) - 9) / 945 + return 0.5 * (x + y) * @evalpoly(f2, 1, c1, c2, c3) + else + return (gamma - 1)/gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) + end +end end # @muladd diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 46559ca720a..233b4a92663 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -68,6 +68,50 @@ return SVector(f1, f2, f3) end + + """ + flux_winters_etal(u_ll, u_rr, normal_direction, + equations::PolytropicEulerEquations2D) + + Entropy conserving two-point flux for isothermal or polytropic gases. + Requires a special weighted Stolarsky mean for the evaluation of the density + denoted here as `stolarsky_mean`. Note, for isothermal gases where `gamma = 1` + this `stolarsky_mean` becomes the [`ln_mean`](@ref). + + For details see Section 3.2 of the following reference + - Andrew R. Winters, Christof Czernik, Moritz B. Schily & Gregor J. Gassner (2020) + Entropy stable numerical approximations for the isothermal and polytropic + Euler equations + [DOI: 10.1007/s10543-019-00789-w](https://doi.org/10.1007/s10543-019-00789-w) + """ + @inline function flux_winters_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + # Unpack left and right state + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa * rho_ll^equations.gamma + p_rr = equations.kappa * rho_rr^equations.gamma + v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # Compute the necessary mean values + if equations.gamma == 1.0 # isothermal gas + rho_mean = ln_mean(rho_ll, rho_rr) + else # equations.gamma > 1 # polytropic gas + rho_mean = stolarsky_mean(rho_ll, rho_rr, equations.gamma) + end + v1_avg = 0.5 * (v1_ll + v1_rr) + v2_avg = 0.5 * (v2_ll + v2_rr) + p_avg = 0.5 * (p_ll + p_rr) + + # Calculate fluxes depending on normal_direction + f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) + f2 = f1 * v1_avg + p_avg * normal_direction[1] + f3 = f1 * v2_avg + p_avg * normal_direction[2] + + return SVector(f1, f2, f3) + end + @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) @@ -111,13 +155,16 @@ v2 = rho_v2 / rho v_square = v1^2 + v2^2 p = pressure(u, equations) - s = rho / 2 * v_square + - rho * equations.kappa * rho^(equations.gamma - 1) / (equations.gamma - 1) - rho_p = rho / p + # Form of the internal energy depends on gas type + if equations.gamma == 1.0 # isothermal gas + internal_energy = equations.kappa * log(rho) + else # equations.gamma > 1 # polytropic gas + internal_energy = equations.kappa * rho^equations.gamma / (equations.gamma - 1.0) + end - w1 = (equations.gamma - s) * (equations.gamma - 1) - 0.5 * rho_p * v_square - w2 = rho_p * v1 - w3 = rho_p * v2 + w1 = internal_energy + p / rho - 0.5 * v_square + w2 = v1 + w3 = v2 return SVector(w1, w2, w3) end From 989b2ce612d431ac7e24703f8be2340094a93296 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 5 Jul 2023 15:47:32 +0100 Subject: [PATCH 038/111] Added couped polytropic tests. --- test/test_structured_2d.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 5a88059a563..ff169867018 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -220,8 +220,14 @@ isdir(outdir) && rm(outdir, recursive=true) @trixi_testset "elixir_eulerpolytropic_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_wave.jl"), - l2 = [0.004995041733939986, 0.004997681632536576, 9.723735592127134e-17], - linf = [0.009993486548832253, 0.010048540255715076, 6.86525156020157e-16]) + l2 = [0.004995041733948277, 0.004997681632536703, 1.0470037668370186e-16], + linf = [0.009993486548883546, 0.010048540255675103, 7.678654693030116e-16]) + end + + @trixi_testset "elixir_eulerpolytropic_coupled.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_coupled.jl"), + l2 = [0.0036724498044657687, 0.003679081320994357, 5.528989074383132e-17, 0.004396618502845242, 0.009680572117143958, 6.110025166619439e-17] + linf = [0.007162343826079498, 0.007189011428420566, 3.256422271459761e-16, 0.009842450719342977, 0.0187716097506127, 3.940688927378186e-16]) end @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin From 26b246d4bdd26e588daae066d33d7f1962bb8479 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 5 Jul 2023 15:47:55 +0100 Subject: [PATCH 039/111] Added Winter's fluxes for coupled polytropic elixir. --- .../elixir_eulerpolytropic_coupled.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 7d1d5589d28..6d4f1e5306c 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -58,7 +58,7 @@ kappa2 = 1.0 equations2 = PolytropicEulerEquations2D(gamma2, kappa2) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux -volume_flux = flux_ranocha +volume_flux = flux_winters_etal solver = DGSEM(polydeg = 2, surface_flux = flux_hll, volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) @@ -83,7 +83,7 @@ boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (:begin, :i_forward), F # A semidiscretization collects data structures and functions for the spatial discretization. semi1 = SemidiscretizationHyperbolic(mesh1, equations1, - initial_condition_wave_thermal, solver, + initial_condition_wave_isothermal, solver, boundary_conditions = (x_neg = boundary_conditions_x_neg1, x_pos = boundary_conditions_x_pos1, y_neg = boundary_condition_periodic, @@ -91,8 +91,8 @@ semi1 = SemidiscretizationHyperbolic(mesh1, equations1, semi2 = SemidiscretizationHyperbolic(mesh2, equations2, initial_condition_wave_polytropic, solver, - boundary_conditions = (x_neg = boundary_conditions_x_neg2 - x_pos = boundary_conditions_x_pos2 + boundary_conditions = (x_neg = boundary_conditions_x_neg2, + x_pos = boundary_conditions_x_pos2, y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic)) @@ -103,7 +103,7 @@ semi = SemidiscretizationCoupled(semi1, semi2) # ODE solvers, callbacks etc. # Create ODE problem -ode = semidiscretize(semi, (0.0, 3.0)) +ode = semidiscretize(semi, (0.0, 1.0)) # At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup # and resets the timers From dd21d6e820e5ccf8a9651c3281bbd73a0a155fa4 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 5 Jul 2023 15:48:18 +0100 Subject: [PATCH 040/111] Added flux_winters_etal. --- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 14f6a139599..39a69b6e77e 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -24,9 +24,9 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) end initial_condition = initial_condition_wave -#volume_flux = flux_ranocha -solver = DGSEM(polydeg=2, surface_flux=flux_hll)#, -# volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +volume_flux = flux_winters_etal +solver = DGSEM(polydeg=2, surface_flux=flux_hll, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -1.0) coordinates_max = ( 2.0, 1.0) From 430bc4ab6d42ef4999a1727d57fd1913b98a5b60 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Fri, 7 Jul 2023 13:28:58 +0100 Subject: [PATCH 041/111] Added convergence test for polytropic Euler. --- .../elixir_polytropiceuler_convergence.jl | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 examples/structured_2d_dgsem/elixir_polytropiceuler_convergence.jl diff --git a/examples/structured_2d_dgsem/elixir_polytropiceuler_convergence.jl b/examples/structured_2d_dgsem/elixir_polytropiceuler_convergence.jl new file mode 100644 index 00000000000..06ad7725f0f --- /dev/null +++ b/examples/structured_2d_dgsem/elixir_polytropiceuler_convergence.jl @@ -0,0 +1,72 @@ + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# semidiscretization of the polytropic Euler equations + +gamma = 1.001 # Quasi-isotropic simulation. gamma = 1.0 would lead to a singularity. +# gamma = 2.0 # Adiabatic monatomic gas in 2d. +kappa = 1.0 # Scaling factor for the pressure. +equations = PolytropicEulerEquations2D(gamma, kappa) + +initial_condition = initial_condition_convergence_test + +volume_flux = flux_winters_etal +solver = DGSEM(polydeg=2, surface_flux=flux_hll, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + +coordinates_min = (0.0, 0.0) +coordinates_max = (1.0, 1.0) + +cells_per_dimension = (64, 64) + +boundary_conditions = ( + x_neg=boundary_condition_periodic, + x_pos=boundary_condition_periodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + ) + +mesh = StructuredMesh(cells_per_dimension, +coordinates_min, +coordinates_max) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions=boundary_conditions) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval=analysis_interval, + extra_analysis_errors=(:l2_error_primitive, + :linf_error_primitive)) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true, + solution_variables=cons2prim) + +stepsize_callback = StepsizeCallback(cfl=1.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); +summary_callback() # print the timer summary From d8de77cfa3fc5b97bd3a400e2c8c8a289c091e6b Mon Sep 17 00:00:00 2001 From: SimonCan Date: Fri, 7 Jul 2023 13:29:56 +0100 Subject: [PATCH 042/111] Renamed polytropic uler convergence Elixir. --- ...euler_convergence.jl => elixir_eulerpolytropic_convergence.jl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/structured_2d_dgsem/{elixir_polytropiceuler_convergence.jl => elixir_eulerpolytropic_convergence.jl} (100%) diff --git a/examples/structured_2d_dgsem/elixir_polytropiceuler_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl similarity index 100% rename from examples/structured_2d_dgsem/elixir_polytropiceuler_convergence.jl rename to examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl From 3f56b6cc9a730c83f8556fbbae4349141d93ccf3 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Fri, 7 Jul 2023 13:30:17 +0100 Subject: [PATCH 043/111] Added convergence test initial condition. --- src/equations/polytropic_euler_2d.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 233b4a92663..6bde2fa8674 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -187,4 +187,18 @@ p = equations.kappa * rho^equations.gamma return p end + + """ + initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + + Manufactured smooth initial condition used for convergence tests. + """ + function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] + # domain must be set to [0, 1] x [0, 1] + h = 8 + cos(2 * pi * x) * sin(2 * pi * y) * cos(2 * pi * t) + + return prim2cons(SVector(h, h/2, 3*h/2), equations) + end + end # @muladd From 5d5072d19e2552bd53e761bd55facfc3e7747db7 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Fri, 7 Jul 2023 13:44:42 +0100 Subject: [PATCH 044/111] Corrected variable names in convergence test for polytropic equations. --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 6bde2fa8674..b25d2290c53 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -196,7 +196,7 @@ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] # domain must be set to [0, 1] x [0, 1] - h = 8 + cos(2 * pi * x) * sin(2 * pi * y) * cos(2 * pi * t) + h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) return prim2cons(SVector(h, h/2, 3*h/2), equations) end From a28707ae1f95e44d63f1e6c62535c0083a0cedb1 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:08:17 +0100 Subject: [PATCH 045/111] Update src/auxiliary/math.jl Co-authored-by: Hendrik Ranocha --- src/auxiliary/math.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auxiliary/math.jl b/src/auxiliary/math.jl index 3952e7d5207..059399688b3 100644 --- a/src/auxiliary/math.jl +++ b/src/auxiliary/math.jl @@ -209,7 +209,7 @@ Return `x` if `x` is negative, else zero. In other words, return end """ - stolarsky_mean(x, y) + stolarsky_mean(x, y, gamma) Compute an instance of a weighted Stolarsky mean of the form From db830d3a893b3912bec28c57e1e87fc8cace2c2b Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 10:21:39 +0100 Subject: [PATCH 046/111] Added isotropic Eulre wave test case. --- .../elixir_eulerisotropic_wave.jl | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl diff --git a/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl new file mode 100644 index 00000000000..577618b938c --- /dev/null +++ b/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl @@ -0,0 +1,87 @@ + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# semidiscretization of the polytropic Euler equations + +gamma = 1.0 +kappa = 1.0 # Scaling factor for the pressure. +equations = PolytropicEulerEquations2D(gamma, kappa) + +# Linear pressure wave in the negative x-direction. +function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) + rho = 1.0 + v1 = 0.0 + if x[1] > 0.0 + rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma) + v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa) + end + v2 = 0.0 + + return prim2cons(SVector(rho, v1, v2), equations) +end +initial_condition = initial_condition_wave + +volume_flux = flux_winters_etal +solver = DGSEM(polydeg=2, surface_flux=flux_hll, + volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + +coordinates_min = (-2.0, -1.0) +coordinates_max = ( 2.0, 1.0) + +cells_per_dimension = (64, 32) + +boundary_conditions = ( + x_neg=boundary_condition_periodic, + x_pos=boundary_condition_periodic, + y_neg=boundary_condition_periodic, + y_pos=boundary_condition_periodic, + ) + +mesh = StructuredMesh(cells_per_dimension, + coordinates_min, + coordinates_max) + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, + boundary_conditions=boundary_conditions) + + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 200 +analysis_callback = AnalysisCallback(semi, 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) + +stepsize_callback = StepsizeCallback(cfl=1.7) + +callbacks = CallbackSet(summary_callback, + analysis_callback, alive_callback, + save_solution, + stepsize_callback) + +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); + +# Print the timer summary +summary_callback() From a3afce107a0e95fadae21fee9b1bc083b2172a21 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 10:57:42 +0100 Subject: [PATCH 047/111] Removed isotropic option in purely polytropic test case. --- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 39a69b6e77e..011858fd9e6 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -5,8 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.001 # Quasi-isotropic simulation. gamma = 1.0 would lead to a singularity. -# gamma = 2.0 # Adiabatic monatomic gas in 2d. +gamma = 2.0 # Adiabatic monatomic gas in 2d. kappa = 1.0 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) From 3a24980951b50c62bb41e442af019f7251c1360e Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 10:58:24 +0100 Subject: [PATCH 048/111] Implmented Andrew's efficient way of computing coefficients. --- src/auxiliary/math.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auxiliary/math.jl b/src/auxiliary/math.jl index 059399688b3..8779530f096 100644 --- a/src/auxiliary/math.jl +++ b/src/auxiliary/math.jl @@ -265,9 +265,9 @@ Given ε = 1.0e-4, we use the following algorithm. f2 = (x * (x - 2 * y) + y * y) / (x * (x + 2 * y) + y * y) # f2 = f^2 if f2 < epsilon_f2 # convenience coefficients - c1 = (gamma - 2) / 3 - c2 = -(gamma + 1) * (gamma - 2)* (gamma - 3) / 45 - c3 = (gamma + 1) * (gamma - 2) * (gamma - 3)* (2 * gamma * (gamma - 2) - 9) / 945 + c1 = (1 / 3) * (gamma - 2) + c2 = -(1 / 15) * (gamma + 1) * (gamma - 3) * c1 + c3 = -(1 / 21) * (2 * gamma *(gamma - 2) - 9) * c2 return 0.5 * (x + y) * @evalpoly(f2, 1, c1, c2, c3) else return (gamma - 1)/gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) From 7c32006adb1ae06787f7d10f68274cd8f67eefbc Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 10:58:52 +0100 Subject: [PATCH 049/111] Added isotropic Euler wave as test case. --- test/test_structured_2d.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index ff169867018..e788f006e92 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -218,15 +218,21 @@ isdir(outdir) && rm(outdir, recursive=true) tspan = (0.0, 0.3)) end + @trixi_testset "elixir_eulerisotropic_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerisotropic_wave.jl"), + l2 = [0.004998778491726375, 0.004998916000294413, 9.644873288246357e-17], + linf = [0.01000110367383511, 0.010051165098399165, 5.866026685895555e-16]) + end + @trixi_testset "elixir_eulerpolytropic_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_wave.jl"), - l2 = [0.004995041733948277, 0.004997681632536703, 1.0470037668370186e-16], - linf = [0.009993486548883546, 0.010048540255675103, 7.678654693030116e-16]) + l2 = [0.004163502792026258, 0.007467178084006138, 7.739975153896063e-17], + linf = [0.010509124387702351, 0.017663038621826756, 6.2937880869984e-16]) end @trixi_testset "elixir_eulerpolytropic_coupled.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_coupled.jl"), - l2 = [0.0036724498044657687, 0.003679081320994357, 5.528989074383132e-17, 0.004396618502845242, 0.009680572117143958, 6.110025166619439e-17] + l2 = [0.0036724498044657687, 0.003679081320994357, 5.528989074383132e-17, 0.004396618502845242, 0.009680572117143958, 6.110025166619439e-17], linf = [0.007162343826079498, 0.007189011428420566, 3.256422271459761e-16, 0.009842450719342977, 0.0187716097506127, 3.940688927378186e-16]) end From 37dcd27c6083fc368f4885db791e8c2d101d80fd Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 11:35:16 +0100 Subject: [PATCH 050/111] Reformatted polytrropic_2d. --- src/equations/polytropic_euler_2d.jl | 378 +++++++++++++-------------- 1 file changed, 189 insertions(+), 189 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index b25d2290c53..e220361b19c 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -5,200 +5,200 @@ @muladd begin #! format: noindent - @doc raw""" - PolytropicEulerEquations2D(gamma, kappa) - - The polytropic Euler equations - ```math - \partial t - \begin{pmatrix} - \rho \\ \rho v_1 \\ \rho v_2 - \end{pmatrix} - + - \partial x - \begin{pmatrix} - \rho v_1 \\ \rho v_1^2 + \kappa\rho^\gamma \\ \rho v_1 v_2 - \end{pmatrix} - + - \partial y - \begin{pmatrix} - \rho v_2 \\ \rho v_1 v_2 \\ \rho v_2^2 + \kappa\rho^\gamma - \end{pmatrix} - = - \begin{pmatrix} - 0 \\ 0 \\ 0 - \end{pmatrix} - ``` - for an ideal gas with ratio of specific heats `gamma` - in two space dimensions. - Here, ``\rho`` is the density and ``v_1`` and`v_2` the velocities and - ```math - p = \kappa\rho^\gamma - ``` - the pressure, which we replaced using this relation. - - """ - struct PolytropicEulerEquations2D{RealT <: Real} <: AbstractPolytropicEulerEquations{2, 3} - gamma::RealT # ratio of specific heats - kappa::RealT # fluid scaling factor - - function PolytropicEulerEquations2D(gamma, kappa) - gamma_, kappa_ = promote(gamma, kappa) - new{typeof(gamma_)}(gamma_, kappa_) - end +@doc raw""" + PolytropicEulerEquations2D(gamma, kappa) + +The polytropic Euler equations +```math +\partial t +\begin{pmatrix} +\rho \\ \rho v_1 \\ \rho v_2 +\end{pmatrix} ++ +\partial x +\begin{pmatrix} + \rho v_1 \\ \rho v_1^2 + \kappa\rho^\gamma \\ \rho v_1 v_2 +\end{pmatrix} ++ +\partial y +\begin{pmatrix} +\rho v_2 \\ \rho v_1 v_2 \\ \rho v_2^2 + \kappa\rho^\gamma +\end{pmatrix} += +\begin{pmatrix} +0 \\ 0 \\ 0 +\end{pmatrix} +``` +for an ideal gas with ratio of specific heats `gamma` +in two space dimensions. +Here, ``\rho`` is the density and ``v_1`` and`v_2` the velocities and +```math +p = \kappa\rho^\gamma +``` +the pressure, which we replaced using this relation. + +""" +struct PolytropicEulerEquations2D{RealT <: Real} <: + AbstractPolytropicEulerEquations{2, 3} + gamma::RealT # ratio of specific heats + kappa::RealT # fluid scaling factor + + function PolytropicEulerEquations2D(gamma, kappa) + gamma_, kappa_ = promote(gamma, kappa) + new{typeof(gamma_)}(gamma_, kappa_) end +end - function varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) - ("rho", "rho_v1", "rho_v2") - end - varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") - - # Calculate 1D flux for a single point in the normal direction - # Note, this directional vector is not normalized - @inline function flux(u, normal_direction::AbstractVector, - equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) - p = pressure(u, equations) - - v_normal = v1 * normal_direction[1] + v2 * normal_direction[2] - rho_v_normal = rho * v_normal - f1 = rho_v_normal - f2 = rho_v_normal * v1 + p * normal_direction[1] - f3 = rho_v_normal * v2 + p * normal_direction[2] - return SVector(f1, f2, f3) - end +function varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) + ("rho", "rho_v1", "rho_v2") +end +varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") - - """ - flux_winters_etal(u_ll, u_rr, normal_direction, +# Calculate 1D flux for a single point in the normal direction +# Note, this directional vector is not normalized +@inline function flux(u, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) - - Entropy conserving two-point flux for isothermal or polytropic gases. - Requires a special weighted Stolarsky mean for the evaluation of the density - denoted here as `stolarsky_mean`. Note, for isothermal gases where `gamma = 1` - this `stolarsky_mean` becomes the [`ln_mean`](@ref). - - For details see Section 3.2 of the following reference - - Andrew R. Winters, Christof Czernik, Moritz B. Schily & Gregor J. Gassner (2020) - Entropy stable numerical approximations for the isothermal and polytropic - Euler equations - [DOI: 10.1007/s10543-019-00789-w](https://doi.org/10.1007/s10543-019-00789-w) - """ - @inline function flux_winters_etal(u_ll, u_rr, normal_direction::AbstractVector, - equations::PolytropicEulerEquations2D) - # Unpack left and right state - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa * rho_ll^equations.gamma - p_rr = equations.kappa * rho_rr^equations.gamma - v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] - v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] - - # Compute the necessary mean values - if equations.gamma == 1.0 # isothermal gas - rho_mean = ln_mean(rho_ll, rho_rr) - else # equations.gamma > 1 # polytropic gas - rho_mean = stolarsky_mean(rho_ll, rho_rr, equations.gamma) - end - v1_avg = 0.5 * (v1_ll + v1_rr) - v2_avg = 0.5 * (v2_ll + v2_rr) - p_avg = 0.5 * (p_ll + p_rr) - - # Calculate fluxes depending on normal_direction - f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) - f2 = f1 * v1_avg + p_avg * normal_direction[1] - f3 = f1 * v2_avg + p_avg * normal_direction[2] - - return SVector(f1, f2, f3) + rho, v1, v2 = cons2prim(u, equations) + p = pressure(u, equations) + + v_normal = v1 * normal_direction[1] + v2 * normal_direction[2] + rho_v_normal = rho * v_normal + f1 = rho_v_normal + f2 = rho_v_normal * v1 + p * normal_direction[1] + f3 = rho_v_normal * v2 + p * normal_direction[2] + return SVector(f1, f2, f3) +end + +""" +flux_winters_etal(u_ll, u_rr, normal_direction, + equations::PolytropicEulerEquations2D) + +Entropy conserving two-point flux for isothermal or polytropic gases. +Requires a special weighted Stolarsky mean for the evaluation of the density +denoted here as `stolarsky_mean`. Note, for isothermal gases where `gamma = 1` +this `stolarsky_mean` becomes the [`ln_mean`](@ref). + +For details see Section 3.2 of the following reference +- Andrew R. Winters, Christof Czernik, Moritz B. Schily & Gregor J. Gassner (2020) +Entropy stable numerical approximations for the isothermal and polytropic +Euler equations +[DOI: 10.1007/s10543-019-00789-w](https://doi.org/10.1007/s10543-019-00789-w) +""" +@inline function flux_winters_etal(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + # Unpack left and right state + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa * rho_ll^equations.gamma + p_rr = equations.kappa * rho_rr^equations.gamma + v_dot_n_ll = v1_ll * normal_direction[1] + v2_ll * normal_direction[2] + v_dot_n_rr = v1_rr * normal_direction[1] + v2_rr * normal_direction[2] + + # Compute the necessary mean values + if equations.gamma == 1.0 # isothermal gas + rho_mean = ln_mean(rho_ll, rho_rr) + else # equations.gamma > 1 # polytropic gas + rho_mean = stolarsky_mean(rho_ll, rho_rr, equations.gamma) end - - @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, - equations::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = equations.kappa * rho_ll^equations.gamma - p_rr = equations.kappa * rho_rr^equations.gamma - - 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] - - norm_ = norm(normal_direction) - # The v_normals are already scaled by the norm - lambda_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ - lambda_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ - - return lambda_min, lambda_max - end - - @inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) - c = sqrt(equations.gamma * equations.kappa * rho^(equations.gamma - 1)) - - return abs(v1) + c, abs(v2) + c - end - - # Convert conservative variables to primitive - @inline function cons2prim(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - - v1 = rho_v1 / rho - v2 = rho_v2 / rho - - return SVector(rho, v1, v2) - end - - # Convert conservative variables to entropy - @inline function cons2entropy(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - - v1 = rho_v1 / rho - v2 = rho_v2 / rho - v_square = v1^2 + v2^2 - p = pressure(u, equations) - # Form of the internal energy depends on gas type - if equations.gamma == 1.0 # isothermal gas - internal_energy = equations.kappa * log(rho) - else # equations.gamma > 1 # polytropic gas - internal_energy = equations.kappa * rho^equations.gamma / (equations.gamma - 1.0) - end - - w1 = internal_energy + p / rho - 0.5 * v_square - w2 = v1 - w3 = v2 - - return SVector(w1, w2, w3) - end - - # Convert primitive to conservative variables - @inline function prim2cons(prim, equations::PolytropicEulerEquations2D) - rho, v1, v2 = prim - rho_v1 = rho * v1 - rho_v2 = rho * v2 - return SVector(rho, rho_v1, rho_v2) - end - - @inline function density(u, equations::PolytropicEulerEquations2D) - rho = u[1] - return rho - end - - @inline function pressure(u, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - p = equations.kappa * rho^equations.gamma - return p - end - - """ - initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) - - Manufactured smooth initial condition used for convergence tests. - """ - function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) - # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] - # domain must be set to [0, 1] x [0, 1] - h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) - - return prim2cons(SVector(h, h/2, 3*h/2), equations) + v1_avg = 0.5 * (v1_ll + v1_rr) + v2_avg = 0.5 * (v2_ll + v2_rr) + p_avg = 0.5 * (p_ll + p_rr) + + # Calculate fluxes depending on normal_direction + f1 = rho_mean * 0.5 * (v_dot_n_ll + v_dot_n_rr) + f2 = f1 * v1_avg + p_avg * normal_direction[1] + f3 = f1 * v2_avg + p_avg * normal_direction[2] + + return SVector(f1, f2, f3) +end + +@inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = equations.kappa * rho_ll^equations.gamma + p_rr = equations.kappa * rho_rr^equations.gamma + + 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] + + norm_ = norm(normal_direction) + # The v_normals are already scaled by the norm + lambda_min = v_normal_ll - sqrt(equations.gamma * p_ll / rho_ll) * norm_ + lambda_max = v_normal_rr + sqrt(equations.gamma * p_rr / rho_rr) * norm_ + + return lambda_min, lambda_max +end + +@inline function max_abs_speeds(u, equations::PolytropicEulerEquations2D) + rho, v1, v2 = cons2prim(u, equations) + c = sqrt(equations.gamma * equations.kappa * rho^(equations.gamma - 1)) + + return abs(v1) + c, abs(v2) + c +end + +# Convert conservative variables to primitive +@inline function cons2prim(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + + v1 = rho_v1 / rho + v2 = rho_v2 / rho + + return SVector(rho, v1, v2) +end + +# Convert conservative variables to entropy +@inline function cons2entropy(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + + v1 = rho_v1 / rho + v2 = rho_v2 / rho + v_square = v1^2 + v2^2 + p = pressure(u, equations) + # Form of the internal energy depends on gas type + if equations.gamma == 1.0 # isothermal gas + internal_energy = equations.kappa * log(rho) + else # equations.gamma > 1 # polytropic gas + internal_energy = equations.kappa * rho^equations.gamma / + (equations.gamma - 1.0) end + w1 = internal_energy + p / rho - 0.5 * v_square + w2 = v1 + w3 = v2 + + return SVector(w1, w2, w3) +end + +# Convert primitive to conservative variables +@inline function prim2cons(prim, equations::PolytropicEulerEquations2D) + rho, v1, v2 = prim + rho_v1 = rho * v1 + rho_v2 = rho * v2 + return SVector(rho, rho_v1, rho_v2) +end + +@inline function density(u, equations::PolytropicEulerEquations2D) + rho = u[1] + return rho +end + +@inline function pressure(u, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + p = equations.kappa * rho^equations.gamma + return p +end + +""" +initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + +Manufactured smooth initial condition used for convergence tests. +""" +function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] + # domain must be set to [0, 1] x [0, 1] + h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) + + return prim2cons(SVector(h, h / 2, 3 * h / 2), equations) +end end # @muladd From bface631fa115daa8110bb0ff896da3332a0dfbf Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:37:34 +0100 Subject: [PATCH 051/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl Co-authored-by: Michael Schlottke-Lakemper --- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 011858fd9e6..01c8ddb647d 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -24,7 +24,7 @@ end initial_condition = initial_condition_wave volume_flux = flux_winters_etal -solver = DGSEM(polydeg=2, surface_flux=flux_hll, +solver = DGSEM(polydeg=3, surface_flux=flux_hll, volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -1.0) From 4b9babdc05f99ef828a0bed87da1a13df9ba6f6d Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:42:45 +0100 Subject: [PATCH 052/111] Update src/auxiliary/math.jl Co-authored-by: Andrew Winters --- src/auxiliary/math.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auxiliary/math.jl b/src/auxiliary/math.jl index 8779530f096..4c81cab845a 100644 --- a/src/auxiliary/math.jl +++ b/src/auxiliary/math.jl @@ -270,7 +270,7 @@ Given ε = 1.0e-4, we use the following algorithm. c3 = -(1 / 21) * (2 * gamma *(gamma - 2) - 9) * c2 return 0.5 * (x + y) * @evalpoly(f2, 1, c1, c2, c3) else - return (gamma - 1)/gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) + return (gamma - 1) / gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) end end end # @muladd From 7be52e34eef60ce53534b26ec705eb1ed0397266 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 11:59:56 +0100 Subject: [PATCH 053/111] Reformatted example elixir for polytropic/isothermal equations. --- .../elixir_eulerisotropic_wave.jl | 62 +++++++++---------- .../elixir_eulerpolytropic_convergence.jl | 52 +++++++--------- .../elixir_eulerpolytropic_coupled.jl | 5 +- .../elixir_eulerpolytropic_wave.jl | 62 +++++++++---------- 4 files changed, 84 insertions(+), 97 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl index 577618b938c..a02168639f1 100644 --- a/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerisotropic_wave.jl @@ -11,41 +11,38 @@ equations = PolytropicEulerEquations2D(gamma, kappa) # Linear pressure wave in the negative x-direction. function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) - rho = 1.0 - v1 = 0.0 - if x[1] > 0.0 - rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma) - v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa) - end - v2 = 0.0 - - return prim2cons(SVector(rho, v1, v2), equations) + rho = 1.0 + v1 = 0.0 + if x[1] > 0.0 + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa) + end + v2 = 0.0 + + return prim2cons(SVector(rho, v1, v2), equations) end initial_condition = initial_condition_wave volume_flux = flux_winters_etal -solver = DGSEM(polydeg=2, surface_flux=flux_hll, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 2, surface_flux = flux_hll, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -1.0) -coordinates_max = ( 2.0, 1.0) +coordinates_max = (2.0, 1.0) cells_per_dimension = (64, 32) -boundary_conditions = ( - x_neg=boundary_condition_periodic, - x_pos=boundary_condition_periodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - ) +boundary_conditions = (x_neg = boundary_condition_periodic, + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -56,32 +53,31 @@ 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=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.7) +stepsize_callback = StepsizeCallback(cfl = 1.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, 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); # Print the timer summary summary_callback() diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 06ad7725f0f..9c5ac97c2d0 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -5,68 +5,64 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.001 # Quasi-isotropic simulation. gamma = 1.0 would lead to a singularity. -# gamma = 2.0 # Adiabatic monatomic gas in 2d. +gamma = 2.0 kappa = 1.0 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) initial_condition = initial_condition_convergence_test volume_flux = flux_winters_etal -solver = DGSEM(polydeg=2, surface_flux=flux_hll, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 2, surface_flux = flux_hll, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) cells_per_dimension = (64, 64) -boundary_conditions = ( - x_neg=boundary_condition_periodic, - x_pos=boundary_condition_periodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - ) +boundary_conditions = (x_neg = boundary_condition_periodic, + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) mesh = StructuredMesh(cells_per_dimension, -coordinates_min, -coordinates_max) - + coordinates_min, + coordinates_max) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 1.0) +tspan = (0.0, 0.1) 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.7) +stepsize_callback = StepsizeCallback(cfl = 1.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/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 6d4f1e5306c..e85d1871e71 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -21,7 +21,7 @@ using Trixi # define the initial conditions function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquations2D) - gamma = 1.001 + gamma = 1.0 kappa = 1.0 rho = 1.0 @@ -50,7 +50,7 @@ end # semidiscretization of the linear advection equation # Define the equations involved. -gamma1 = 1.001 +gamma1 = 1.0 kappa1 = 1.0 equations1 = PolytropicEulerEquations2D(gamma1, kappa1) gamma2 = 2.0 @@ -137,4 +137,3 @@ sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), # Print the timer summary summary_callback() - diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 011858fd9e6..ae6eb31a1a9 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -11,41 +11,38 @@ equations = PolytropicEulerEquations2D(gamma, kappa) # Linear pressure wave in the negative x-direction. function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) - rho = 1.0 - v1 = 0.0 - if x[1] > 0.0 - rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma) - v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa) - end - v2 = 0.0 - - return prim2cons(SVector(rho, v1, v2), equations) + rho = 1.0 + v1 = 0.0 + if x[1] > 0.0 + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa) + end + v2 = 0.0 + + return prim2cons(SVector(rho, v1, v2), equations) end initial_condition = initial_condition_wave volume_flux = flux_winters_etal -solver = DGSEM(polydeg=2, surface_flux=flux_hll, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) +solver = DGSEM(polydeg = 2, surface_flux = flux_hll, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (-2.0, -1.0) -coordinates_max = ( 2.0, 1.0) +coordinates_max = (2.0, 1.0) cells_per_dimension = (64, 32) -boundary_conditions = ( - x_neg=boundary_condition_periodic, - x_pos=boundary_condition_periodic, - y_neg=boundary_condition_periodic, - y_pos=boundary_condition_periodic, - ) +boundary_conditions = (x_neg = boundary_condition_periodic, + x_pos = boundary_condition_periodic, + y_neg = boundary_condition_periodic, + y_pos = boundary_condition_periodic) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions=boundary_conditions) - + boundary_conditions = boundary_conditions) ############################################################################### # ODE solvers, callbacks etc. @@ -56,32 +53,31 @@ 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=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.7) +stepsize_callback = StepsizeCallback(cfl = 1.7) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, 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); # Print the timer summary summary_callback() From 99a487b923cbf1007643b51f0bdb94e7cf3fe9d7 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 12:14:45 +0100 Subject: [PATCH 054/111] Updated errors for elixir_eulerpolytropic_coupled.jl. --- test/test_structured_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index e788f006e92..848aa00cf38 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -232,8 +232,8 @@ isdir(outdir) && rm(outdir, recursive=true) @trixi_testset "elixir_eulerpolytropic_coupled.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_coupled.jl"), - l2 = [0.0036724498044657687, 0.003679081320994357, 5.528989074383132e-17, 0.004396618502845242, 0.009680572117143958, 6.110025166619439e-17], - linf = [0.007162343826079498, 0.007189011428420566, 3.256422271459761e-16, 0.009842450719342977, 0.0187716097506127, 3.940688927378186e-16]) + l2 = [0.0036722668603851854, 0.0036770945693062585, 6.219512805736816e-17, 0.004396173729156031, 0.00968163194407191, 5.328567457283904e-17], + linf = [0.007166777740855723, 0.007189858933515634, 3.334601450120292e-16, 0.009841506991455362, 0.018773251247021595, 3.152557652220928e-16]) end @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin From ed59ee82015ebdc41aad47965b57b171a771dc78 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 10 Jul 2023 12:25:13 +0100 Subject: [PATCH 055/111] Added polytropic convergence test and renamed isothermal file. --- test/test_structured_2d.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 848aa00cf38..ae880adeb8d 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -218,8 +218,14 @@ isdir(outdir) && rm(outdir, recursive=true) tspan = (0.0, 0.3)) end - @trixi_testset "elixir_eulerisotropic_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerisotropic_wave.jl"), + @trixi_testset "elixir_eulerpolytropic_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_convergence.jl"), + l2 = [0.9265197650552958, 5.854697965606039, 14.85499224304319], + linf = [2.6651435738539053, 12.237661077904363, 36.79422185045536] + end + + @trixi_testset "elixir_eulerisothermal_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerisothermal_wave.jl"), l2 = [0.004998778491726375, 0.004998916000294413, 9.644873288246357e-17], linf = [0.01000110367383511, 0.010051165098399165, 5.866026685895555e-16]) end From 5c6d4225af0f03dea6efaf975ace4a0a4c8b1883 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 14:13:37 +0100 Subject: [PATCH 056/111] Corrected gamma and kappa. --- .../elixir_eulerpolytropic_coupled.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index e85d1871e71..68a0dfc918d 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -21,8 +21,8 @@ using Trixi # define the initial conditions function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquations2D) - gamma = 1.0 - kappa = 1.0 + equations.gamma = 1.0 + equations.kappa = 1.0 rho = 1.0 v1 = 0.0 @@ -32,14 +32,14 @@ function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquat end function initial_condition_wave_polytropic(x, t, equations::PolytropicEulerEquations2D) - gamma = 2.0 - kappa = 1.0 + equations.gamma = 2.0 + equations.kappa = 1.0 rho = 1.0 v1 = 0.0 if x[1] > 0.0 - rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma) - v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa) + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / equations.kappa)^(1 / equations.gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / equations.kappa) end v2 = 0.0 From 66d481c38b9972d4449d79155d286cdb3f2094fd Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 15:09:24 +0100 Subject: [PATCH 057/111] Added source terms for EOC. --- .../structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 9c5ac97c2d0..7f5d4ef07d6 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -30,7 +30,8 @@ mesh = StructuredMesh(cells_per_dimension, coordinates_max) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions) + boundary_conditions = boundary_conditions, + source_terms = source_terms_eoc_test_euler) ############################################################################### # ODE solvers, callbacks etc. From 104d226ae653de8cbb09d25d8b829af77419875a Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 15:09:39 +0100 Subject: [PATCH 058/111] Added source term for ECO. --- src/equations/polytropic_euler_2d.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index e220361b19c..93f948031fa 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -202,3 +202,30 @@ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEqua return prim2cons(SVector(h, h / 2, 3 * h / 2), equations) end end # @muladd + + +""" +source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) + +""" +@inline function source_terms_eoc_test_polytropic(u, x, t, + equations::PolytropicEulerEquations2D) + # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). + h_t = -2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * t) + h_x = -2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) + h_y = 2 * pi * cos(2 * pi * x[1]) * cos(2 * pi * x[2]) * cos(2 * pi * t) + + c2 = equations.p_avg / equations.rho + + if gamma == 1 + b = c2 + else + b = equations.kappa * equations.gamma * equations.rho^(equations.gamma-1) + end + + r_1 = h_t + h_x / 2 + 3 / 2 * h_y + r_2 = h_t / 2 + h_x / 4 + b * equations.rho_x + 3 / 4 * h_y + r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * equations.rho_y + + return SVector(r_1, r_2, r_3) +end From d2056d44272536d89a4223cf5092b59ef78bf25d Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 15:36:32 +0100 Subject: [PATCH 059/111] Minor corrections. --- .../structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 7f5d4ef07d6..55eaeb80d1c 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -31,7 +31,7 @@ mesh = StructuredMesh(cells_per_dimension, semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, boundary_conditions = boundary_conditions, - source_terms = source_terms_eoc_test_euler) + source_terms = source_terms_eoc_test_polytropic) ############################################################################### # ODE solvers, callbacks etc. From 6c437ebceb9719a36235ba68bf51cfbddaa865a6 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 15:37:21 +0100 Subject: [PATCH 060/111] Added source terms. --- src/Trixi.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 064e6d8ced0..db556952e9f 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -195,7 +195,8 @@ export source_terms_harmonic export initial_condition_poisson_nonperiodic, source_terms_poisson_nonperiodic, boundary_condition_poisson_nonperiodic export initial_condition_eoc_test_coupled_euler_gravity, - source_terms_eoc_test_coupled_euler_gravity, source_terms_eoc_test_euler + source_terms_eoc_test_coupled_euler_gravity, source_terms_eoc_test_euler, + source_terms_eoc_test_polytropic export cons2cons, cons2prim, prim2cons, cons2macroscopic, cons2state, cons2mean, cons2entropy, entropy2cons From 41061cb002d4ac3b0287c0abf977ce69a8611763 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 15:38:06 +0100 Subject: [PATCH 061/111] Corrected primary variables. --- src/equations/polytropic_euler_2d.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 93f948031fa..0091f91f5e7 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -201,7 +201,6 @@ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEqua return prim2cons(SVector(h, h / 2, 3 * h / 2), equations) end -end # @muladd """ @@ -210,17 +209,19 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) """ @inline function source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) + rho, v1, v2 = cons2prim(u, equations) + # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). h_t = -2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * t) h_x = -2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) h_y = 2 * pi * cos(2 * pi * x[1]) * cos(2 * pi * x[2]) * cos(2 * pi * t) - c2 = equations.p_avg / equations.rho + c2 = pressure(u, equations) / rho - if gamma == 1 + if equations.gamma == 1 b = c2 else - b = equations.kappa * equations.gamma * equations.rho^(equations.gamma-1) + b = equations.kappa * equations.gamma * rho^(equations.gamma-1) end r_1 = h_t + h_x / 2 + 3 / 2 * h_y @@ -229,3 +230,5 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) return SVector(r_1, r_2, r_3) end + +end # @muladd \ No newline at end of file From c1e6f93462d2c9a17907935e52f33466c2208098 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 20:32:13 +0100 Subject: [PATCH 062/111] Removed redundant kappa and gamme redefinitions. --- .../structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 68a0dfc918d..025a380b9d6 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -21,9 +21,6 @@ using Trixi # define the initial conditions function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquations2D) - equations.gamma = 1.0 - equations.kappa = 1.0 - rho = 1.0 v1 = 0.0 v2 = 0.0 @@ -32,9 +29,6 @@ function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquat end function initial_condition_wave_polytropic(x, t, equations::PolytropicEulerEquations2D) - equations.gamma = 2.0 - equations.kappa = 1.0 - rho = 1.0 v1 = 0.0 if x[1] > 0.0 From 500d7395fb9cd64212f1e98f84027e8dbba5d624 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 11 Jul 2023 20:57:40 +0100 Subject: [PATCH 063/111] Improved style by using gamma and kappa from equations. --- examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl | 4 ++-- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl b/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl index a02168639f1..29508cd94b8 100644 --- a/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl @@ -14,8 +14,8 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) rho = 1.0 v1 = 0.0 if x[1] > 0.0 - rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma) - v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa) + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / eqiations.kappa)^(1 / eqiations.gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / eqiations.kappa) end v2 = 0.0 diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index ae6eb31a1a9..7ae68825883 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -14,8 +14,8 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) rho = 1.0 v1 = 0.0 if x[1] > 0.0 - rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma) - v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa) + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / eqiations.kappa)^(1 / eqiations.gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / eqiations.kappa) end v2 = 0.0 From e6b41ea5bef2d3d4317c3b01eab5de28f51b59c1 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Thu, 13 Jul 2023 17:45:30 +0100 Subject: [PATCH 064/111] Improved convergence test for polytropic. --- .../elixir_eulerpolytropic_convergence.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 55eaeb80d1c..07ff1c55361 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -5,20 +5,20 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 2.0 +gamma = 1.0 kappa = 1.0 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) initial_condition = initial_condition_convergence_test volume_flux = flux_winters_etal -solver = DGSEM(polydeg = 2, surface_flux = flux_hll, +solver = DGSEM(polydeg = 3, surface_flux = flux_hll, volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) -cells_per_dimension = (64, 64) +cells_per_dimension = (8, 8) boundary_conditions = (x_neg = boundary_condition_periodic, x_pos = boundary_condition_periodic, @@ -36,7 +36,7 @@ semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 0.1) +tspan = (0.0, 0.01) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() @@ -53,7 +53,7 @@ save_solution = SaveSolutionCallback(interval = 100, save_final_solution = true, solution_variables = cons2prim) -stepsize_callback = StepsizeCallback(cfl = 1.7) +stepsize_callback = StepsizeCallback(cfl = 0.1) callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, From 1c68e4bd913be1b18a98006cd92c6c4fb44fd480 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Thu, 13 Jul 2023 17:45:56 +0100 Subject: [PATCH 065/111] Corrected convergence test residual for polytropic equations. --- src/equations/polytropic_euler_2d.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 0091f91f5e7..f6c0be2920b 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -199,7 +199,7 @@ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEqua # domain must be set to [0, 1] x [0, 1] h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) - return prim2cons(SVector(h, h / 2, 3 * h / 2), equations) + return SVector(h, h / 2, 3 * h / 2) end @@ -216,17 +216,20 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) h_x = -2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) h_y = 2 * pi * cos(2 * pi * x[1]) * cos(2 * pi * x[2]) * cos(2 * pi * t) + rho_x = h_x + rho_y = h_y + c2 = pressure(u, equations) / rho if equations.gamma == 1 b = c2 else - b = equations.kappa * equations.gamma * rho^(equations.gamma-1) + b = equations.kappa * equations.gamma * h^(equations.gamma-1) end r_1 = h_t + h_x / 2 + 3 / 2 * h_y - r_2 = h_t / 2 + h_x / 4 + b * equations.rho_x + 3 / 4 * h_y - r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * equations.rho_y + r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y + r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y return SVector(r_1, r_2, r_3) end From aee57daa4af9936c4f987d95fb694ca1f396e31d Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Fri, 14 Jul 2023 16:28:29 +0200 Subject: [PATCH 066/111] Allow use of flux_lax_friedrichs --- .../elixir_eulerpolytropic_convergence.jl | 13 ++-- src/equations/polytropic_euler_2d.jl | 70 ++++++++++++++++++- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 07ff1c55361..1b1b00e5a5d 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -14,29 +14,24 @@ initial_condition = initial_condition_convergence_test volume_flux = flux_winters_etal solver = DGSEM(polydeg = 3, surface_flux = flux_hll, volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) +# solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) -cells_per_dimension = (8, 8) - -boundary_conditions = (x_neg = boundary_condition_periodic, - x_pos = boundary_condition_periodic, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic) +cells_per_dimension = (4, 4) mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max) semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - boundary_conditions = boundary_conditions, - source_terms = source_terms_eoc_test_polytropic) + source_terms = source_terms_convergence_test) ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 0.01) +tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index f6c0be2920b..ecd38b2a006 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -69,6 +69,27 @@ varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2" return SVector(f1, f2, f3) end +# Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the +# maximum velocity magnitude plus the maximum speed of sound +@inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) + rho, rho_v1, rho_v2 = u + v1 = rho_v1 / rho + v2 = rho_v2 / rho + p = pressure(u, equations) + + if orientation == 1 + f1 = rho_v1 + f2 = rho_v1 * v1 + p + f3 = rho_v1 * v2 + else # orientation == 2 + f1 = rho_v2 + f2 = rho_v2 * v1 + f3 = rho_v2 * v2 + p + end + + return SVector(f1, f2, f3) +end + """ flux_winters_etal(u_ll, u_rr, normal_direction, equations::PolytropicEulerEquations2D) @@ -112,6 +133,49 @@ Euler equations return SVector(f1, f2, f3) end +@inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer, + equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = pressure(u_ll, equations) + p_rr = pressure(u_rr, equations) + + # Get the velocity value in the appropriate direction + if orientation == 1 + v_ll = v1_ll + v_rr = v1_rr + else # orientation == 2 + v_ll = v2_ll + v_rr = v2_rr + end + + # Calculate sound speeds + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + λ_max = max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) +end + +@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, + equations::PolytropicEulerEquations2D) + rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) + rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) + p_ll = pressure(u_ll, equations) + p_rr = pressure(u_rr, equations) + + # Calculate normal velocities and sound speed + # left + v_ll = (v1_ll * normal_direction[1] + + v2_ll * normal_direction[2]) + c_ll = sqrt(equations.gamma * p_ll / rho_ll) + # right + v_rr = (v1_rr * normal_direction[1] + + v2_rr * normal_direction[2]) + c_rr = sqrt(equations.gamma * p_rr / rho_rr) + + return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction) +end + @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) @@ -207,8 +271,8 @@ end source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) """ -@inline function source_terms_eoc_test_polytropic(u, x, t, - equations::PolytropicEulerEquations2D) +@inline function source_terms_convergence_test(u, x, t, + equations::PolytropicEulerEquations2D) rho, v1, v2 = cons2prim(u, equations) # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). @@ -234,4 +298,4 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) return SVector(r_1, r_2, r_3) end -end # @muladd \ No newline at end of file +end # @muladd From 843166b9a46f13402875a44570103b210815d64b Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Fri, 14 Jul 2023 16:30:53 +0200 Subject: [PATCH 067/111] Fix comment --- src/equations/polytropic_euler_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index ecd38b2a006..4e8ac923cbe 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -69,8 +69,6 @@ varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2" return SVector(f1, f2, f3) end -# Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the -# maximum velocity magnitude plus the maximum speed of sound @inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) rho, rho_v1, rho_v2 = u v1 = rho_v1 / rho @@ -133,6 +131,8 @@ Euler equations return SVector(f1, f2, f3) end +# Calculate 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::PolytropicEulerEquations2D) rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) From 5924fb337a61448cf4a43f8be4936dabe22487d9 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Sat, 15 Jul 2023 17:28:41 +0100 Subject: [PATCH 068/111] Added flux calculation for polytropic Euler. --- src/equations/polytropic_euler_2d.jl | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index f6c0be2920b..dbe6e577bf1 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -54,6 +54,23 @@ function varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) end varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") +# Calculate 2D flux for a single point +@inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) + rho, v1, v2 = cons2prim(u, equations) + p = pressure(u, equations) + + if orientation == 1 + f1 = rho * v1 + f2 = rho * v1^2 + p + f3 = rho * v1 * v2 + else + f1 = rho * v2 + f2 = rho * v2 * v1 + f3 = rho * v2^2 + p + end + return SVector(f1, f2, f3) +end + # Calculate 1D flux for a single point in the normal direction # Note, this directional vector is not normalized @inline function flux(u, normal_direction::AbstractVector, @@ -209,9 +226,8 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) """ @inline function source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) - # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). + h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) h_t = -2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * t) h_x = -2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) h_y = 2 * pi * cos(2 * pi * x[1]) * cos(2 * pi * x[2]) * cos(2 * pi * t) @@ -219,19 +235,15 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) rho_x = h_x rho_y = h_y - c2 = pressure(u, equations) / rho - - if equations.gamma == 1 - b = c2 - else - b = equations.kappa * equations.gamma * h^(equations.gamma-1) - end + b = equations.kappa * equations.gamma * h^(equations.gamma-1) r_1 = h_t + h_x / 2 + 3 / 2 * h_y r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y return SVector(r_1, r_2, r_3) + + # return SVector(0.0, 0.0, 0.0) end end # @muladd \ No newline at end of file From 571b2cd5f48e650c83e7f4c118279939078e8e8e Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:19:14 +0100 Subject: [PATCH 069/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index faac70dc763..3a9411b8807 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -305,7 +305,7 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) r_1 = h_t + h_x / 2 + 3 / 2 * h_y r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y - r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y + r_3 = 3 / 2 * h_t + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y return SVector(r_1, r_2, r_3) From a70e736982763d77cee669d616f38fbae5e15ccf Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:22:23 +0100 Subject: [PATCH 070/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl Co-authored-by: Andrew Winters --- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 7ae68825883..1f85c274805 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -14,8 +14,8 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) rho = 1.0 v1 = 0.0 if x[1] > 0.0 - rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / eqiations.kappa)^(1 / eqiations.gamma) - v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / eqiations.kappa) + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / equations.kappa)^(1 / equations.gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / equations.kappa) end v2 = 0.0 From 99527f0d056518109eee85891275644a7664615f Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 17 Jul 2023 22:24:34 +0100 Subject: [PATCH 071/111] Moved initial condition and source term before flux function. --- src/equations/polytropic_euler_2d.jl | 82 ++++++++++++++-------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 3a9411b8807..006c1d7e4c1 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -54,6 +54,46 @@ function varnames(::typeof(cons2cons), ::PolytropicEulerEquations2D) end varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") +""" +initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + +Manufactured smooth initial condition used for convergence tests. +""" +function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] + # domain must be set to [0, 1] x [0, 1] + h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) + + return SVector(h, h / 2, 3 * h / 2) +end + + +""" +source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) + +""" +@inline function source_terms_convergence_test(u, x, t, + equations::PolytropicEulerEquations2D) + rho, v1, v2 = cons2prim(u, equations) + + # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). + h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) + h_t = -2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * t) + h_x = -2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) + h_y = 2 * pi * cos(2 * pi * x[1]) * cos(2 * pi * x[2]) * cos(2 * pi * t) + + rho_x = h_x + rho_y = h_y + + b = equations.kappa * equations.gamma * h^(equations.gamma-1) + + r_1 = h_t + h_x / 2 + 3 / 2 * h_y + r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y + r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y + + return SVector(r_1, r_2, r_3) +end + # Calculate 2D flux for a single point @inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) rho, v1, v2 = cons2prim(u, equations) @@ -270,46 +310,4 @@ end return p end -""" -initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) - -Manufactured smooth initial condition used for convergence tests. -""" -function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) - # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] - # domain must be set to [0, 1] x [0, 1] - h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) - - return SVector(h, h / 2, 3 * h / 2) -end - - -""" -source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) - -""" -@inline function source_terms_convergence_test(u, x, t, - equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) - - # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). - h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) - h_t = -2 * pi * cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * sin(2 * pi * t) - h_x = -2 * pi * sin(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) - h_y = 2 * pi * cos(2 * pi * x[1]) * cos(2 * pi * x[2]) * cos(2 * pi * t) - - rho_x = h_x - rho_y = h_y - - b = equations.kappa * equations.gamma * h^(equations.gamma-1) - - r_1 = h_t + h_x / 2 + 3 / 2 * h_y - r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y - r_3 = 3 / 2 * h_t + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y - - return SVector(r_1, r_2, r_3) - - # return SVector(0.0, 0.0, 0.0) -end - end # @muladd From b7d665cfacda8931e0e308e9955bf549d66daec9 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:26:36 +0100 Subject: [PATCH 072/111] Update examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl Co-authored-by: Andrew Winters --- examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl b/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl index 29508cd94b8..c8b40a152ab 100644 --- a/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl @@ -14,8 +14,8 @@ function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D) rho = 1.0 v1 = 0.0 if x[1] > 0.0 - rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / eqiations.kappa)^(1 / eqiations.gamma) - v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / eqiations.kappa) + rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / equations.kappa)^(1 / equations.gamma) + v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / equations.kappa) end v2 = 0.0 From 799d165dbfc9422b76934ab3edb73b77faae37a7 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:28:01 +0100 Subject: [PATCH 073/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 3a9411b8807..0952a497205 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -290,7 +290,6 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) """ @inline function source_terms_convergence_test(u, x, t, equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) # Residual from Winters (2019) [0.1007/s10543-019-00789-w] eq. (5.2). h = 8 + cos(2 * pi * x[1]) * sin(2 * pi * x[2]) * cos(2 * pi * t) From 66d5161869744cdcd17f1a3d8402ec6e2766efe3 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Mon, 17 Jul 2023 22:28:22 +0100 Subject: [PATCH 074/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 0952a497205..b54cd99798e 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -86,24 +86,6 @@ end return SVector(f1, f2, f3) end -@inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) - rho, rho_v1, rho_v2 = u - v1 = rho_v1 / rho - v2 = rho_v2 / rho - p = pressure(u, equations) - - if orientation == 1 - f1 = rho_v1 - f2 = rho_v1 * v1 + p - f3 = rho_v1 * v2 - else # orientation == 2 - f1 = rho_v2 - f2 = rho_v2 * v1 - f3 = rho_v2 * v2 + p - end - - return SVector(f1, f2, f3) -end """ flux_winters_etal(u_ll, u_rr, normal_direction, From 6465fd5f6aa59cd0b2c7abe0a20b3fd280a90c7a Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 17 Jul 2023 22:29:20 +0100 Subject: [PATCH 075/111] Change kappa and gamma in some polytropic Euler elixirs. --- .../structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl | 4 ++-- .../structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 2 +- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 1b1b00e5a5d..a97c207a139 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -5,8 +5,8 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.0 -kappa = 1.0 # Scaling factor for the pressure. +gamma = 1.4 +kappa = 0.5 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) initial_condition = initial_condition_convergence_test diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 025a380b9d6..47726add336 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -48,7 +48,7 @@ gamma1 = 1.0 kappa1 = 1.0 equations1 = PolytropicEulerEquations2D(gamma1, kappa1) gamma2 = 2.0 -kappa2 = 1.0 +kappa2 = 0.5 equations2 = PolytropicEulerEquations2D(gamma2, kappa2) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 7ae68825883..01d9d2f4fac 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the polytropic Euler equations gamma = 2.0 # Adiabatic monatomic gas in 2d. -kappa = 1.0 # Scaling factor for the pressure. +kappa = 0.5 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) # Linear pressure wave in the negative x-direction. From 1391c8c228e8a5356dc5f51cb0c0ac15f09b40b3 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 17 Jul 2023 22:33:56 +0100 Subject: [PATCH 076/111] Correcte source for Euler polytropic convergence test. --- .../structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl | 4 ++-- src/equations/polytropic_euler_2d.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index a97c207a139..1b1b00e5a5d 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -5,8 +5,8 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.4 -kappa = 0.5 # Scaling factor for the pressure. +gamma = 1.0 +kappa = 1.0 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) initial_condition = initial_condition_convergence_test diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index b1ec23983f2..4e77a97be94 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -89,7 +89,7 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) r_1 = h_t + h_x / 2 + 3 / 2 * h_y r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y - r_3 = h_t / 2 + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y + r_3 = 3 / 2 * h_t + 3 / 4 * h_x + 9 / 4 * h_y + b * rho_y return SVector(r_1, r_2, r_3) end From 0080a50178fe554b696e5aac3bf51b0f8f3c3413 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Mon, 17 Jul 2023 22:34:40 +0100 Subject: [PATCH 077/111] Changed parameters gamma and kappa in Euler polytropic convergence test to other than 1.0. --- .../structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index 1b1b00e5a5d..a97c207a139 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -5,8 +5,8 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.0 -kappa = 1.0 # Scaling factor for the pressure. +gamma = 1.4 +kappa = 0.5 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) initial_condition = initial_condition_convergence_test From 2a56cfc739369cc5eeb0c4b5b1932f5371596ace Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 12:19:10 +0100 Subject: [PATCH 078/111] Reformatted polytropic Euler. --- src/equations/polytropic_euler_2d.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 4e77a97be94..3a937fab09a 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -67,7 +67,6 @@ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEqua return SVector(h, h / 2, 3 * h / 2) end - """ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) @@ -85,7 +84,7 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) rho_x = h_x rho_y = h_y - b = equations.kappa * equations.gamma * h^(equations.gamma-1) + b = equations.kappa * equations.gamma * h^(equations.gamma - 1) r_1 = h_t + h_x / 2 + 3 / 2 * h_y r_2 = h_t / 2 + h_x / 4 + b * rho_x + 3 / 4 * h_y @@ -126,7 +125,6 @@ end return SVector(f1, f2, f3) end - """ flux_winters_etal(u_ll, u_rr, normal_direction, equations::PolytropicEulerEquations2D) @@ -205,11 +203,13 @@ end # Calculate normal velocities and sound speed # left v_ll = (v1_ll * normal_direction[1] - + v2_ll * normal_direction[2]) + + + v2_ll * normal_direction[2]) c_ll = sqrt(equations.gamma * p_ll / rho_ll) # right v_rr = (v1_rr * normal_direction[1] - + v2_rr * normal_direction[2]) + + + v2_rr * normal_direction[2]) c_rr = sqrt(equations.gamma * p_rr / rho_rr) return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction) @@ -291,5 +291,4 @@ end p = equations.kappa * rho^equations.gamma return p end - end # @muladd From bb9cdce5d37ae3ee92a938af00094be1869910a6 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 12:30:39 +0100 Subject: [PATCH 079/111] Spelling errors. --- .../structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 47726add336..3dd25ba6743 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -8,7 +8,7 @@ using Trixi # In a rectangular domain we solve two different sets of equations for the # left and the right half. Those are the isothermal equations (left) # and polytropic equations (right). -# The coupling hapens on two interfaces. One is located at the center of the +# The coupling happens on two interfaces. One is located at the center of the # domain such that the right half is coupled through its left boundary # and the left half is coupled through its right boundary. The other coupling # makes sure that the domain is periodic. Here the right boundary of the right @@ -112,7 +112,7 @@ analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_c save_solution = SaveSolutionCallback(interval = 5, solution_variables = cons2prim) -# The StepsizeCallback handles the re-calculcation of the maximum Δt after each time step +# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step stepsize_callback = StepsizeCallback(cfl = 1.0) # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver From ffea2c469c3c6cb6c0af055f3c5c00a436711e67 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 13:26:16 +0100 Subject: [PATCH 080/111] Reformatted. --- src/auxiliary/math.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/auxiliary/math.jl b/src/auxiliary/math.jl index e4102bf84d2..38ea0bda8c8 100644 --- a/src/auxiliary/math.jl +++ b/src/auxiliary/math.jl @@ -271,10 +271,11 @@ Given ε = 1.0e-4, we use the following algorithm. # convenience coefficients c1 = (1 / 3) * (gamma - 2) c2 = -(1 / 15) * (gamma + 1) * (gamma - 3) * c1 - c3 = -(1 / 21) * (2 * gamma *(gamma - 2) - 9) * c2 + c3 = -(1 / 21) * (2 * gamma * (gamma - 2) - 9) * c2 return 0.5 * (x + y) * @evalpoly(f2, 1, c1, c2, c3) else - return (gamma - 1) / gamma * (y^gamma - x^gamma) / (y^(gamma-1) - x^(gamma-1)) + return (gamma - 1) / gamma * (y^gamma - x^gamma) / + (y^(gamma - 1) - x^(gamma - 1)) end end end # @muladd From 85bb9a03774b6897034f62490f10fa2aed7a9d19 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 14:39:58 +0100 Subject: [PATCH 081/111] Added elixir for testing entropy conservation for polytropic Euler equations. --- ...lixir_eulerpolytropic_ec_shockcapturing.jl | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 examples/structured_2d_dgsem/elixir_eulerpolytropic_ec_shockcapturing.jl diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_ec_shockcapturing.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_ec_shockcapturing.jl new file mode 100644 index 00000000000..de15f6b2bc3 --- /dev/null +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_ec_shockcapturing.jl @@ -0,0 +1,80 @@ + +using OrdinaryDiffEq +using Trixi + +############################################################################### +# semidiscretization of the polytropic Euler equations + +gamma = 1.4 +kappa = 0.5 # Scaling factor for the pressure. +equations = PolytropicEulerEquations2D(gamma, kappa) + +initial_condition = initial_condition_weak_blast_wave + +############################################################################### +# Get the DG approximation space + +volume_flux = flux_winters_etal +solver = DGSEM(polydeg=4, surface_flux=flux_winters_etal, + 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 + + 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)) + + return SVector(x, y) +end + +cells_per_dimension = (16, 16) + +# Create curved mesh with 16 x 16 elements +mesh = StructuredMesh(cells_per_dimension, mapping) + +############################################################################### +# create the semi discretization object + +semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 2.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() + +analysis_interval = 100 +analysis_callback = AnalysisCallback(semi, interval=analysis_interval) + +alive_callback = AliveCallback(analysis_interval=analysis_interval) + +save_solution = SaveSolutionCallback(interval=100, + save_initial_solution=true, + save_final_solution=true) + +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); +summary_callback() # print the timer summary From 124d34926cfa59b7742280377fc72302537938cf Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 14:40:26 +0100 Subject: [PATCH 082/111] Added weak blast wave as initial condition for the polytropic Euler equations. --- src/equations/polytropic_euler_2d.jl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 3a937fab09a..496af3b3779 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -93,6 +93,31 @@ source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) return SVector(r_1, r_2, r_3) end +""" + initial_condition_weak_blast_wave(x, t, equations::PolytropicEulerEquations2D) + +A weak blast wave adapted from +- Sebastian Hennemann, Gregor J. Gassner (2020) + A provably entropy stable subcell shock capturing approach for high order split form DG + [arXiv: 2008.12044](https://arxiv.org/abs/2008.12044) +""" +function initial_condition_weak_blast_wave(x, t, equations::PolytropicEulerEquations2D) + # Adapted MHD version of the weak blast wave from Hennemann & Gassner JCP paper 2020 (Sec. 6.3) + # Set up polar coordinates + inicenter = (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) + + # 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) + + return prim2cons(SVector(rho, v1, v2,), equations) +end + # Calculate 2D flux for a single point @inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) rho, v1, v2 = cons2prim(u, equations) From 0163ebb9f2c9577fefb0d640e71fc4b532ce77d9 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 14:48:56 +0100 Subject: [PATCH 083/111] Added entropy conservation test. --- test/test_structured_2d.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index d887d44130a..7c6e0f41055 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -226,6 +226,12 @@ isdir(outdir) && rm(outdir, recursive=true) linf = [2.6651435738539053, 12.237661077904363, 36.79422185045536] end + @trixi_testset "elixir_eulerpolytropic_ec_shockcaptrugin.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec_shockcaptrugin.jl"), + l2 = [0.03647890611450939, 0.025284915444045052, 0.025340697771609126], + linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336] + end + @trixi_testset "elixir_eulerisothermal_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerisothermal_wave.jl"), l2 = [0.004998778491726375, 0.004998916000294413, 9.644873288246357e-17], From 2cd0c8236dddf84864a1888dd9f15d03a3fdc765 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 15:12:19 +0100 Subject: [PATCH 084/111] Typo in tests. --- test/test_structured_2d.jl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 7c6e0f41055..cb607cfc144 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -223,13 +223,13 @@ isdir(outdir) && rm(outdir, recursive=true) @trixi_testset "elixir_eulerpolytropic_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_convergence.jl"), l2 = [0.9265197650552958, 5.854697965606039, 14.85499224304319], - linf = [2.6651435738539053, 12.237661077904363, 36.79422185045536] + linf = [2.6651435738539053, 12.237661077904363, 36.79422185045536]) end @trixi_testset "elixir_eulerpolytropic_ec_shockcaptrugin.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec_shockcaptrugin.jl"), l2 = [0.03647890611450939, 0.025284915444045052, 0.025340697771609126], - linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336] + linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336]) end @trixi_testset "elixir_eulerisothermal_wave.jl" begin @@ -244,12 +244,6 @@ isdir(outdir) && rm(outdir, recursive=true) linf = [0.010509124387702351, 0.017663038621826756, 6.2937880869984e-16]) end - @trixi_testset "elixir_eulerpolytropic_coupled.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_coupled.jl"), - l2 = [0.0036722668603851854, 0.0036770945693062585, 6.219512805736816e-17, 0.004396173729156031, 0.00968163194407191, 5.328567457283904e-17], - linf = [0.007166777740855723, 0.007189858933515634, 3.334601450120292e-16, 0.009841506991455362, 0.018773251247021595, 3.152557652220928e-16]) - 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], From 689f20457c685c96716c9a01b1afaf0d15026d9f Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 16:14:40 +0100 Subject: [PATCH 085/111] Auto reformat. --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 496af3b3779..0e0f07601c1 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -115,7 +115,7 @@ function initial_condition_weak_blast_wave(x, t, equations::PolytropicEulerEquat v1 = r > 0.5 ? 0.0 : 0.1882 * cos(phi) v2 = r > 0.5 ? 0.0 : 0.1882 * sin(phi) - return prim2cons(SVector(rho, v1, v2,), equations) + return prim2cons(SVector(rho, v1, v2), equations) end # Calculate 2D flux for a single point From 582fe33e82b0e7c932cc6222d9f1208e3055e183 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 16:16:50 +0100 Subject: [PATCH 086/111] Corrected polytropic Euler test reults. --- test/test_structured_2d.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index cb607cfc144..6f9af3334e6 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -222,26 +222,26 @@ isdir(outdir) && rm(outdir, recursive=true) @trixi_testset "elixir_eulerpolytropic_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_convergence.jl"), - l2 = [0.9265197650552958, 5.854697965606039, 14.85499224304319], - linf = [2.6651435738539053, 12.237661077904363, 36.79422185045536]) + l2 = [0.0016688820596537988, 0.0025921681885685425, 0.003280950351435014], + linf = [0.010994679664394269, 0.01331197845637, 0.020080117011346488]) end - @trixi_testset "elixir_eulerpolytropic_ec_shockcaptrugin.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec_shockcaptrugin.jl"), + @trixi_testset "elixir_eulerpolytropic_ec_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec_shockcapturing.jl"), l2 = [0.03647890611450939, 0.025284915444045052, 0.025340697771609126], linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336]) end @trixi_testset "elixir_eulerisothermal_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerisothermal_wave.jl"), - l2 = [0.004998778491726375, 0.004998916000294413, 9.644873288246357e-17], - linf = [0.01000110367383511, 0.010051165098399165, 5.866026685895555e-16]) + l2 = [0.004998778491726366, 0.004998916000294425, 9.259136963058664e-17], + linf = [0.010001103673834888, 0.010051165098399503, 7.623942913643681e-16]) end @trixi_testset "elixir_eulerpolytropic_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_wave.jl"), - l2 = [0.004163502792026258, 0.007467178084006138, 7.739975153896063e-17], - linf = [0.010509124387702351, 0.017663038621826756, 6.2937880869984e-16]) + l2 = [0.23642682112204072, 0.2090426439033139, 9.864611225329867e-17], + linf = [0.48482503683499933, 0.25335087381569504, 7.552785191845908e-16]) end @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin From abf33062eba8c36653a991d29811cf99d641768c Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 17:34:46 +0100 Subject: [PATCH 087/111] Renamed entropy test for Euler polytropic. --- ...lytropic_ec_shockcapturing.jl => elixir_eulerpolytropic_ec.jl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/structured_2d_dgsem/{elixir_eulerpolytropic_ec_shockcapturing.jl => elixir_eulerpolytropic_ec.jl} (100%) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_ec_shockcapturing.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_ec.jl similarity index 100% rename from examples/structured_2d_dgsem/elixir_eulerpolytropic_ec_shockcapturing.jl rename to examples/structured_2d_dgsem/elixir_eulerpolytropic_ec.jl From c7169767a471634fb68edcfbdf724317fead56d3 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 18 Jul 2023 17:35:27 +0100 Subject: [PATCH 088/111] Renamed elixir for shock test. --- test/test_structured_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 6f9af3334e6..c105ec519a3 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -226,8 +226,8 @@ isdir(outdir) && rm(outdir, recursive=true) linf = [0.010994679664394269, 0.01331197845637, 0.020080117011346488]) end - @trixi_testset "elixir_eulerpolytropic_ec_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec_shockcapturing.jl"), + @trixi_testset "elixir_eulerpolytropic_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec.jl"), l2 = [0.03647890611450939, 0.025284915444045052, 0.025340697771609126], linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336]) end From 59ff85c6ce0f426df0a030f7e5c3e1a9ff466fe1 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 19 Jul 2023 10:54:59 +0100 Subject: [PATCH 089/111] Added coupled Euler polytropic to the tests. --- test/test_structured_2d.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index c105ec519a3..6d44f5715c6 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -244,6 +244,12 @@ isdir(outdir) && rm(outdir, recursive=true) linf = [0.48482503683499933, 0.25335087381569504, 7.552785191845908e-16]) end + @trixi_testset "elixir_eulerpolytropic_coupled.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_coupled.jl"), + l2 = [0.0036722668603851824, 0.0036770945693063266, 7.328907398530868e-17, 0.0043961737291559905, 0.009681631944071874, 5.5383635487039e-17], + linf = [0.007166777740855057, 0.007189858933514897, 3.8972436848752724e-16, 0.00984150699145514, 0.018773251247021745, 2.8709391713585104e-16]) + 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], From 2c8ee14f62837498fb785356fa899527987e0d2e Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 19 Jul 2023 10:55:15 +0100 Subject: [PATCH 090/111] Removed redundant flux function. --- src/equations/polytropic_euler_2d.jl | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 0e0f07601c1..da618a1a930 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -118,23 +118,6 @@ function initial_condition_weak_blast_wave(x, t, equations::PolytropicEulerEquat return prim2cons(SVector(rho, v1, v2), equations) end -# Calculate 2D flux for a single point -@inline function flux(u, orientation::Integer, equations::PolytropicEulerEquations2D) - rho, v1, v2 = cons2prim(u, equations) - p = pressure(u, equations) - - if orientation == 1 - f1 = rho * v1 - f2 = rho * v1^2 + p - f3 = rho * v1 * v2 - else - f1 = rho * v2 - f2 = rho * v2 * v1 - f3 = rho * v2^2 + p - end - return SVector(f1, f2, f3) -end - # Calculate 1D flux for a single point in the normal direction # Note, this directional vector is not normalized @inline function flux(u, normal_direction::AbstractVector, From 093ebd00375b77f6e78e7f529287a3e88aa62783 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 19 Jul 2023 10:55:41 +0100 Subject: [PATCH 091/111] Changed example parameters for coupled polytropic Euler. --- .../structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl index 3dd25ba6743..5be631e6867 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl @@ -44,11 +44,11 @@ end # semidiscretization of the linear advection equation # Define the equations involved. -gamma1 = 1.0 +gamma1 = 1.4 kappa1 = 1.0 equations1 = PolytropicEulerEquations2D(gamma1, kappa1) gamma2 = 2.0 -kappa2 = 0.5 +kappa2 = 1.0 equations2 = PolytropicEulerEquations2D(gamma2, kappa2) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux From 0a9876cf579a873cd506400c6bf1e0186ed269a3 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 19 Jul 2023 10:58:08 +0100 Subject: [PATCH 092/111] Removed max-speed calculations, as they are not being used. --- src/equations/polytropic_euler_2d.jl | 47 ---------------------------- 1 file changed, 47 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index da618a1a930..c9445e6f0f4 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -176,53 +176,6 @@ Euler equations return SVector(f1, f2, f3) end -# Calculate 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::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = pressure(u_ll, equations) - p_rr = pressure(u_rr, equations) - - # Get the velocity value in the appropriate direction - if orientation == 1 - v_ll = v1_ll - v_rr = v1_rr - else # orientation == 2 - v_ll = v2_ll - v_rr = v2_rr - end - - # Calculate sound speeds - c_ll = sqrt(equations.gamma * p_ll / rho_ll) - c_rr = sqrt(equations.gamma * p_rr / rho_rr) - - λ_max = max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) -end - -@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, - equations::PolytropicEulerEquations2D) - rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) - rho_rr, v1_rr, v2_rr = cons2prim(u_rr, equations) - p_ll = pressure(u_ll, equations) - p_rr = pressure(u_rr, equations) - - # Calculate normal velocities and sound speed - # left - v_ll = (v1_ll * normal_direction[1] - + - v2_ll * normal_direction[2]) - c_ll = sqrt(equations.gamma * p_ll / rho_ll) - # right - v_rr = (v1_rr * normal_direction[1] - + - v2_rr * normal_direction[2]) - c_rr = sqrt(equations.gamma * p_rr / rho_rr) - - return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction) -end - @inline function min_max_speed_naive(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) rho_ll, v1_ll, v2_ll = cons2prim(u_ll, equations) From 9ee900e06d8898d463ab51af6c8dae87a2f40925 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 19 Jul 2023 11:40:14 +0100 Subject: [PATCH 093/111] Removed coupled polytropic elixir, since this PR is on the polytropic equations only. --- .../elixir_eulerpolytropic_coupled.jl | 133 ------------------ test/test_structured_2d.jl | 6 - 2 files changed, 139 deletions(-) delete mode 100644 examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl deleted file mode 100644 index 5be631e6867..00000000000 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl +++ /dev/null @@ -1,133 +0,0 @@ - -using OrdinaryDiffEq -using Trixi - -############################################################################### -# Couple polytropic Euler systems. -# -# In a rectangular domain we solve two different sets of equations for the -# left and the right half. Those are the isothermal equations (left) -# and polytropic equations (right). -# The coupling happens on two interfaces. One is located at the center of the -# domain such that the right half is coupled through its left boundary -# and the left half is coupled through its right boundary. The other coupling -# makes sure that the domain is periodic. Here the right boundary of the right -# domain is coupled to the left boundary of the left domain. -# The vertical boundaries are simply periodic. -# As test case we send a linear wave through the domain and observe a change -# in the dispersion relation when the wave enters the isothermal domain. - -############################################################################### -# define the initial conditions - -function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquations2D) - rho = 1.0 - v1 = 0.0 - v2 = 0.0 - - return prim2cons(SVector(rho, v1, v2), equations) -end - -function initial_condition_wave_polytropic(x, t, equations::PolytropicEulerEquations2D) - rho = 1.0 - v1 = 0.0 - if x[1] > 0.0 - rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / equations.kappa)^(1 / equations.gamma) - v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / equations.kappa) - end - v2 = 0.0 - - return prim2cons(SVector(rho, v1, v2), equations) -end - -############################################################################### -# semidiscretization of the linear advection equation - -# Define the equations involved. -gamma1 = 1.4 -kappa1 = 1.0 -equations1 = PolytropicEulerEquations2D(gamma1, kappa1) -gamma2 = 2.0 -kappa2 = 1.0 -equations2 = PolytropicEulerEquations2D(gamma2, kappa2) - -# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux -volume_flux = flux_winters_etal -solver = DGSEM(polydeg = 2, surface_flux = flux_hll, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) - -coordinates_min1 = (-2.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y)) -coordinates_min2 = (0.0, -1.0) # minimum coordinates (min(x), min(y)) -coordinates_max2 = (2.0, 1.0) # maximum coordinates (max(x), max(y)) - -cells_per_dimension = (32, 32) - -mesh1 = StructuredMesh(cells_per_dimension, - coordinates_min1, - coordinates_max1) -mesh2 = StructuredMesh(cells_per_dimension, - coordinates_min2, - coordinates_max2) - -boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, (:end, :i_forward), Float64) -boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64) -boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, (:end, :i_forward), Float64) -boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64) - -# A semidiscretization collects data structures and functions for the spatial discretization. -semi1 = SemidiscretizationHyperbolic(mesh1, equations1, - initial_condition_wave_isothermal, solver, - boundary_conditions = (x_neg = boundary_conditions_x_neg1, - x_pos = boundary_conditions_x_pos1, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic)) - -semi2 = SemidiscretizationHyperbolic(mesh2, equations2, - initial_condition_wave_polytropic, solver, - boundary_conditions = (x_neg = boundary_conditions_x_neg2, - x_pos = boundary_conditions_x_pos2, - y_neg = boundary_condition_periodic, - y_pos = boundary_condition_periodic)) - -# Create a semidiscretization that bundles semi1 and semi2 -semi = SemidiscretizationCoupled(semi1, semi2) - -############################################################################### -# ODE solvers, callbacks etc. - -# Create ODE problem -ode = semidiscretize(semi, (0.0, 1.0)) - -# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup -# and resets the timers -summary_callback = SummaryCallback() - -# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results -analysis_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 = 5, - solution_variables = cons2prim) - -# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step -stepsize_callback = StepsizeCallback(cfl = 1.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) - -############################################################################### -# 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); - -# Print the timer summary -summary_callback() diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index 6d44f5715c6..c105ec519a3 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -244,12 +244,6 @@ isdir(outdir) && rm(outdir, recursive=true) linf = [0.48482503683499933, 0.25335087381569504, 7.552785191845908e-16]) end - @trixi_testset "elixir_eulerpolytropic_coupled.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_coupled.jl"), - l2 = [0.0036722668603851824, 0.0036770945693063266, 7.328907398530868e-17, 0.0043961737291559905, 0.009681631944071874, 5.5383635487039e-17], - linf = [0.007166777740855057, 0.007189858933514897, 3.8972436848752724e-16, 0.00984150699145514, 0.018773251247021745, 2.8709391713585104e-16]) - 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], From acfdf21bed0750bbee508bd2b6b91bc1746f6056 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 25 Jul 2023 13:55:34 +0100 Subject: [PATCH 094/111] Correcte entropy variables for polytropic Euler. This fixes the entropy conservation issue. --- src/equations/polytropic_euler_2d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index c9445e6f0f4..e3bcff1b6ac 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -223,7 +223,7 @@ end if equations.gamma == 1.0 # isothermal gas internal_energy = equations.kappa * log(rho) else # equations.gamma > 1 # polytropic gas - internal_energy = equations.kappa * rho^equations.gamma / + internal_energy = equations.kappa * rho^(equations.gamma - 1) / (equations.gamma - 1.0) end From b98194fa4df3f54f20fc3b10aad81b7e74078e8b Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:07:42 +0100 Subject: [PATCH 095/111] Update examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl Co-authored-by: Andrew Winters --- .../structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl index a97c207a139..4fc9281e7a0 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_convergence.jl @@ -14,7 +14,6 @@ initial_condition = initial_condition_convergence_test volume_flux = flux_winters_etal solver = DGSEM(polydeg = 3, surface_flux = flux_hll, volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) -# solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) coordinates_min = (0.0, 0.0) coordinates_max = (1.0, 1.0) From 56dbd5e8892c22699dedb342d1bb803ecd87acac Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:11:22 +0100 Subject: [PATCH 096/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index e3bcff1b6ac..8707f0f9378 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -10,17 +10,17 @@ The polytropic Euler equations ```math -\partial t +\frac{\partial}{\partial t} \begin{pmatrix} \rho \\ \rho v_1 \\ \rho v_2 \end{pmatrix} + -\partial x +\frac{\partial}{\partial x} \begin{pmatrix} \rho v_1 \\ \rho v_1^2 + \kappa\rho^\gamma \\ \rho v_1 v_2 \end{pmatrix} + -\partial y +\frac{\partial}{\partial y} \begin{pmatrix} \rho v_2 \\ \rho v_1 v_2 \\ \rho v_2^2 + \kappa\rho^\gamma \end{pmatrix} From b1ed0d4c9e716ce9075a0cea79cf17c7c1d92b28 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:17:40 +0100 Subject: [PATCH 097/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 8707f0f9378..bbb8a8cfd2a 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -36,7 +36,6 @@ Here, ``\rho`` is the density and ``v_1`` and`v_2` the velocities and p = \kappa\rho^\gamma ``` the pressure, which we replaced using this relation. - """ struct PolytropicEulerEquations2D{RealT <: Real} <: AbstractPolytropicEulerEquations{2, 3} From 77bd3b75c9a4a805812000252fa39870d7872f3c Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:17:57 +0100 Subject: [PATCH 098/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index bbb8a8cfd2a..d6a45d9b313 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -67,8 +67,10 @@ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEqua end """ -source_terms_eoc_test_polytropic(u, x, t, equations::PolytropicEulerEquations2D) + source_terms_convergence_test(u, x, t, equations::PolytropicEulerEquations2D) +Source terms used for convergence tests in combination with +[`initial_condition_convergence_test`](@ref). """ @inline function source_terms_convergence_test(u, x, t, equations::PolytropicEulerEquations2D) From 255c007622a2b443c1abaa69582b6dae5b2a1c57 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:18:13 +0100 Subject: [PATCH 099/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index d6a45d9b313..7b7806ff31a 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -54,9 +54,10 @@ end varnames(::typeof(cons2prim), ::PolytropicEulerEquations2D) = ("rho", "v1", "v2") """ -initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) + initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) -Manufactured smooth initial condition used for convergence tests. +Manufactured smooth initial condition used for convergence tests +in combination with [`source_terms_convergence_test`](@ref). """ function initial_condition_convergence_test(x, t, equations::PolytropicEulerEquations2D) # manufactured initial condition from Winters (2019) [0.1007/s10543-019-00789-w] From 6a783579bad5d4c43aa35571b0419a425ae457db Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:18:32 +0100 Subject: [PATCH 100/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 7b7806ff31a..1e73991e1c5 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -136,8 +136,8 @@ end end """ -flux_winters_etal(u_ll, u_rr, normal_direction, - equations::PolytropicEulerEquations2D) + flux_winters_etal(u_ll, u_rr, normal_direction, + equations::PolytropicEulerEquations2D) Entropy conserving two-point flux for isothermal or polytropic gases. Requires a special weighted Stolarsky mean for the evaluation of the density From 3fec3213aeade69d1fc32e8b3eadc4dea15f67ac Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:18:58 +0100 Subject: [PATCH 101/111] Update src/equations/polytropic_euler_2d.jl Co-authored-by: Andrew Winters --- src/equations/polytropic_euler_2d.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/equations/polytropic_euler_2d.jl b/src/equations/polytropic_euler_2d.jl index 1e73991e1c5..d4902bbafb2 100644 --- a/src/equations/polytropic_euler_2d.jl +++ b/src/equations/polytropic_euler_2d.jl @@ -146,9 +146,9 @@ this `stolarsky_mean` becomes the [`ln_mean`](@ref). For details see Section 3.2 of the following reference - Andrew R. Winters, Christof Czernik, Moritz B. Schily & Gregor J. Gassner (2020) -Entropy stable numerical approximations for the isothermal and polytropic -Euler equations -[DOI: 10.1007/s10543-019-00789-w](https://doi.org/10.1007/s10543-019-00789-w) + Entropy stable numerical approximations for the isothermal and polytropic + Euler equations + [DOI: 10.1007/s10543-019-00789-w](https://doi.org/10.1007/s10543-019-00789-w) """ @inline function flux_winters_etal(u_ll, u_rr, normal_direction::AbstractVector, equations::PolytropicEulerEquations2D) From d12f324193e87a92c3da138705539fa6b5781f4c Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 1 Aug 2023 18:30:31 +0100 Subject: [PATCH 102/111] Format of comment. --- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index 6125fa4c5f7..ad6d7e05fd3 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -6,7 +6,7 @@ using Trixi # semidiscretization of the polytropic Euler equations gamma = 2.0 # Adiabatic monatomic gas in 2d. -kappa = 0.5 # Scaling factor for the pressure. +kappa = 0.5 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa) # Linear pressure wave in the negative x-direction. From 640aabb93779a344d7ff63fe6f10dd122df57535 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:20:41 +0100 Subject: [PATCH 103/111] Update src/Trixi.jl Co-authored-by: Michael Schlottke-Lakemper --- src/Trixi.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 764629f3916..f67e609e06c 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -203,8 +203,7 @@ export source_terms_harmonic export initial_condition_poisson_nonperiodic, source_terms_poisson_nonperiodic, boundary_condition_poisson_nonperiodic export initial_condition_eoc_test_coupled_euler_gravity, - source_terms_eoc_test_coupled_euler_gravity, source_terms_eoc_test_euler, - source_terms_eoc_test_polytropic + source_terms_eoc_test_coupled_euler_gravity, source_terms_eoc_test_euler export cons2cons, cons2prim, prim2cons, cons2macroscopic, cons2state, cons2mean, cons2entropy, entropy2cons From 8561a38c18a80eed683fcd676d9228077cdcd914 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 15 Aug 2023 11:25:20 +0100 Subject: [PATCH 104/111] Updated polytropic wave test results after removing stage limiter. --- test/test_structured_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index c105ec519a3..e2e16729c3c 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -240,8 +240,8 @@ isdir(outdir) && rm(outdir, recursive=true) @trixi_testset "elixir_eulerpolytropic_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_wave.jl"), - l2 = [0.23642682112204072, 0.2090426439033139, 9.864611225329867e-17], - linf = [0.48482503683499933, 0.25335087381569504, 7.552785191845908e-16]) + l2 = [0.23642682112204072, 0.20904264390331334, 8.174982691297391e-17], + linf = [0.4848250368349989, 0.253350873815695, 4.984552457753618e-16]) end @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin From f650a5a216e2247fd1ffc7bf5b10857d1cc0f817 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 15 Aug 2023 11:25:43 +0100 Subject: [PATCH 105/111] Removed stqage limiter. --- examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl index ad6d7e05fd3..fd332b20aef 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl @@ -69,13 +69,10 @@ callbacks = CallbackSet(summary_callback, save_solution, stepsize_callback) -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), +sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback save_everystep = false, callback = callbacks); From 0e95b0593abbf10d39289f9fe79ee12a716febaf Mon Sep 17 00:00:00 2001 From: SimonCan Date: Tue, 19 Sep 2023 12:56:08 +0100 Subject: [PATCH 106/111] Reformatted Trixi.jl. --- src/Trixi.jl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 8adf374ac41..8ea27871402 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -167,19 +167,19 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle, flux_fjordholm_etal, flux_nonconservative_fjordholm_etal, flux_es_fjordholm_etal, flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal, flux_chan_etal, flux_nonconservative_chan_etal, flux_winters_etal - hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, +hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, # TODO: TrixiShallowWater: move anything with "chen_noelle" to new file - hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle, - flux_hll_chen_noelle, - FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, - FluxLaxFriedrichs, max_abs_speed_naive, - FluxHLL, min_max_speed_naive, min_max_speed_davis, min_max_speed_einfeldt, - min_max_speed_chen_noelle, - FluxLMARS, - FluxRotated, - flux_shima_etal_turbo, flux_ranocha_turbo, - FluxHydrostaticReconstruction, - FluxUpwind +hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle, +flux_hll_chen_noelle, +FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, +FluxLaxFriedrichs, max_abs_speed_naive, +FluxHLL, min_max_speed_naive, min_max_speed_davis, min_max_speed_einfeldt, +min_max_speed_chen_noelle, +FluxLMARS, +FluxRotated, +flux_shima_etal_turbo, flux_ranocha_turbo, +FluxHydrostaticReconstruction, +FluxUpwind export splitting_steger_warming, splitting_vanleer_haenel, splitting_coirier_vanleer, splitting_lax_friedrichs From 5eaa88d24b5aa6173caa45ce38556b0177a3f7e5 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 4 Oct 2023 11:46:13 +0100 Subject: [PATCH 107/111] Corrected removed exports in Trixi.jl. --- src/Trixi.jl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Trixi.jl b/src/Trixi.jl index 8ea27871402..4169700898a 100644 --- a/src/Trixi.jl +++ b/src/Trixi.jl @@ -166,20 +166,20 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle, flux_kennedy_gruber, flux_shima_etal, flux_ec, flux_fjordholm_etal, flux_nonconservative_fjordholm_etal, flux_es_fjordholm_etal, flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal, - flux_chan_etal, flux_nonconservative_chan_etal, flux_winters_etal -hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, + flux_chan_etal, flux_nonconservative_chan_etal, flux_winters_etal, + hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal, # TODO: TrixiShallowWater: move anything with "chen_noelle" to new file -hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle, -flux_hll_chen_noelle, -FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, -FluxLaxFriedrichs, max_abs_speed_naive, -FluxHLL, min_max_speed_naive, min_max_speed_davis, min_max_speed_einfeldt, -min_max_speed_chen_noelle, -FluxLMARS, -FluxRotated, -flux_shima_etal_turbo, flux_ranocha_turbo, -FluxHydrostaticReconstruction, -FluxUpwind + hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle, + flux_hll_chen_noelle, + FluxPlusDissipation, DissipationGlobalLaxFriedrichs, DissipationLocalLaxFriedrichs, + FluxLaxFriedrichs, max_abs_speed_naive, + FluxHLL, min_max_speed_naive, min_max_speed_davis, min_max_speed_einfeldt, + min_max_speed_chen_noelle, + FluxLMARS, + FluxRotated, + flux_shima_etal_turbo, flux_ranocha_turbo, + FluxHydrostaticReconstruction, + FluxUpwind export splitting_steger_warming, splitting_vanleer_haenel, splitting_coirier_vanleer, splitting_lax_friedrichs From ea115cf0a76d4e66964e554ca3eab43cf17d3bed Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 4 Oct 2023 15:52:06 +0100 Subject: [PATCH 108/111] Fix for broadcasting. --- src/solvers/dgmulti/dg.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/solvers/dgmulti/dg.jl b/src/solvers/dgmulti/dg.jl index bc76aa1a9d2..87f09808313 100644 --- a/src/solvers/dgmulti/dg.jl +++ b/src/solvers/dgmulti/dg.jl @@ -302,7 +302,9 @@ function calc_volume_integral!(du, u, mesh::DGMultiMesh, @threaded for e in eachelement(mesh, dg, cache) flux_values = local_values_threaded[Threads.threadid()] for i in eachdim(mesh) - flux_values .= flux.(view(u_values, :, e), i, equations) + for j in eachindex(flux_values) + flux_values[j] = flux(u_values[j, e], i, equations) + end for j in eachdim(mesh) apply_to_each_field(mul_by_accum!(weak_differentiation_matrices[j], dxidxhatj[i, j][1, e]), From 61bc4db0017ee8f7a69bd912501343bf96ad4b3a Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 18 Oct 2023 15:11:22 +0100 Subject: [PATCH 109/111] Renamed elixir for isothermal wave. --- ...othermal_wave.jl => elixir_eulerpolytropic_isothermal_wave.jl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/structured_2d_dgsem/{elixir_eulerisothermal_wave.jl => elixir_eulerpolytropic_isothermal_wave.jl} (100%) diff --git a/examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_isothermal_wave.jl similarity index 100% rename from examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl rename to examples/structured_2d_dgsem/elixir_eulerpolytropic_isothermal_wave.jl From 68e5fc7dfa6b97d5538561bad93aab7ad91294d0 Mon Sep 17 00:00:00 2001 From: Simon Candelaresi <10759273+SimonCan@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:11:54 +0100 Subject: [PATCH 110/111] Update test/test_structured_2d.jl Co-authored-by: Michael Schlottke-Lakemper --- test/test_structured_2d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index e2e16729c3c..6d528abc7af 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -232,8 +232,8 @@ isdir(outdir) && rm(outdir, recursive=true) linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336]) end - @trixi_testset "elixir_eulerisothermal_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerisothermal_wave.jl"), + @trixi_testset "elixir_eulerpolytropic_isothermal_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_isothermal_wave.jl"), l2 = [0.004998778491726366, 0.004998916000294425, 9.259136963058664e-17], linf = [0.010001103673834888, 0.010051165098399503, 7.623942913643681e-16]) end From 462bf61ccf5d8b1998cc734ea3cb57431c735ac0 Mon Sep 17 00:00:00 2001 From: SimonCan Date: Wed, 18 Oct 2023 22:56:02 +0100 Subject: [PATCH 111/111] Added comment about isothermal system in elixir. --- .../elixir_eulerpolytropic_isothermal_wave.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structured_2d_dgsem/elixir_eulerpolytropic_isothermal_wave.jl b/examples/structured_2d_dgsem/elixir_eulerpolytropic_isothermal_wave.jl index c8b40a152ab..4ab90957579 100644 --- a/examples/structured_2d_dgsem/elixir_eulerpolytropic_isothermal_wave.jl +++ b/examples/structured_2d_dgsem/elixir_eulerpolytropic_isothermal_wave.jl @@ -5,7 +5,7 @@ using Trixi ############################################################################### # semidiscretization of the polytropic Euler equations -gamma = 1.0 +gamma = 1.0 # With gamma = 1 the system is isothermal. kappa = 1.0 # Scaling factor for the pressure. equations = PolytropicEulerEquations2D(gamma, kappa)