diff --git a/examples/elixir_euler_potential_temperature_dry_bubble.jl b/examples/elixir_euler_potential_temperature_dry_bubble.jl index 55167c6..0ec083a 100644 --- a/examples/elixir_euler_potential_temperature_dry_bubble.jl +++ b/examples/elixir_euler_potential_temperature_dry_bubble.jl @@ -1,7 +1,7 @@ using OrdinaryDiffEq using Trixi using TrixiAtmo -using TrixiAtmo: flux_LMARS, source_terms_gravity, flux_theta +using TrixiAtmo: FluxLMARS, source_terms_gravity, flux_theta function initial_condition_warm_bubble(x, t, equations::CompressibleEulerPotentialTemperatureEquations2D) @@ -54,7 +54,7 @@ boundary_conditions = (x_neg = boundary_condition_periodic, polydeg = 3 basis = LobattoLegendreBasis(polydeg) -surface_flux = flux_LMARS(340.0) +surface_flux = FluxLMARS(340.0) volume_flux = flux_theta volume_integral = VolumeIntegralFluxDifferencing(volume_flux) diff --git a/examples/elixir_moist_euler_dry_bubble.jl b/examples/elixir_moist_euler_dry_bubble.jl index d7ecaa9..1256a9c 100644 --- a/examples/elixir_moist_euler_dry_bubble.jl +++ b/examples/elixir_moist_euler_dry_bubble.jl @@ -1,7 +1,7 @@ using OrdinaryDiffEq using Trixi using TrixiAtmo -using TrixiAtmo: flux_LMARS, source_terms_geopotential, cons2drypot +using TrixiAtmo: FluxLMARS, source_terms_geopotential, cons2drypot ############################################################################### # semidiscretization of the compressible moist Euler equations @@ -61,7 +61,7 @@ source_term = source_terms_geopotential polydeg = 4 basis = LobattoLegendreBasis(polydeg) -surface_flux = flux_LMARS(360.0) +surface_flux = FluxLMARS(360.0) volume_flux = flux_chandrashekar volume_integral = VolumeIntegralFluxDifferencing(volume_flux) diff --git a/examples/elixir_moist_euler_moist_bubble.jl b/examples/elixir_moist_euler_moist_bubble.jl index 209ece8..956c4a2 100644 --- a/examples/elixir_moist_euler_moist_bubble.jl +++ b/examples/elixir_moist_euler_moist_bubble.jl @@ -1,7 +1,7 @@ using OrdinaryDiffEq using Trixi, TrixiAtmo using TrixiAtmo: cons2aeqpot, saturation_pressure, source_terms_moist_bubble, - flux_LMARS + FluxLMARS using NLsolve: nlsolve ############################################################################### @@ -242,7 +242,7 @@ source_term = source_terms_moist_bubble polydeg = 4 basis = LobattoLegendreBasis(polydeg) -surface_flux = flux_LMARS(360.0) +surface_flux = FluxLMARS(360.0) volume_flux = flux_chandrashekar volume_integral = VolumeIntegralFluxDifferencing(volume_flux) diff --git a/examples/elixir_moist_euler_nonhydrostatic_gravity_waves.jl b/examples/elixir_moist_euler_nonhydrostatic_gravity_waves.jl index d384599..dd8de4f 100644 --- a/examples/elixir_moist_euler_nonhydrostatic_gravity_waves.jl +++ b/examples/elixir_moist_euler_nonhydrostatic_gravity_waves.jl @@ -3,7 +3,7 @@ using Trixi, TrixiAtmo using TrixiAtmo: CompressibleMoistEulerEquations2D, source_terms_geopotential, source_terms_phase_change, source_terms_nonhydrostatic_rayleigh_sponge, - cons2drypot, flux_LMARS + cons2drypot, FluxLMARS ############################################################################### # semidiscretization of the compressible moist Euler equation @@ -55,7 +55,7 @@ boundary_conditions = (x_neg = boundary_condition_periodic, polydeg = 4 basis = LobattoLegendreBasis(polydeg) -surface_flux = flux_LMARS(360.0) +surface_flux = FluxLMARS(360.0) volume_flux = flux_chandrashekar volume_integral = VolumeIntegralFluxDifferencing(volume_flux) diff --git a/src/TrixiAtmo.jl b/src/TrixiAtmo.jl index cdce0a3..e4f64c3 100644 --- a/src/TrixiAtmo.jl +++ b/src/TrixiAtmo.jl @@ -26,7 +26,7 @@ include("semidiscretization/semidiscretization_hyperbolic_2d_manifold_in_3d.jl") export CompressibleMoistEulerEquations2D export CompressibleEulerPotentialTemperatureEquations2D -export flux_chandrashekar, flux_LMARS, flux_theta +export flux_chandrashekar, FluxLMARS, flux_theta export examples_dir diff --git a/src/equations/compressible_euler_potential_temperature_2d.jl b/src/equations/compressible_euler_potential_temperature_2d.jl index 21ed1d0..6aa3ad8 100644 --- a/src/equations/compressible_euler_potential_temperature_2d.jl +++ b/src/equations/compressible_euler_potential_temperature_2d.jl @@ -1,6 +1,6 @@ using Trixi using Trixi: ln_mean, stolarsky_mean -import Trixi: varnames, cons2cons, cons2prim, cons2entropy, entropy +import Trixi: varnames, cons2cons, cons2prim, cons2entropy, entropy, FluxLMARS @muladd begin #! format: noindent @@ -168,7 +168,7 @@ end # Coordinate Monthly Weather Review Vol. 141.7, pages 2526–2544, 2013, # https://journals.ametsoc.org/view/journals/mwre/141/7/mwr-d-12-00129.1.xml. -@inline function (flux_lmars::flux_LMARS)(u_ll, u_rr, normal_direction::AbstractVector, +@inline function (flux_lmars::FluxLMARS)(u_ll, u_rr, normal_direction::AbstractVector, equations::CompressibleEulerPotentialTemperatureEquations2D) a = flux_lmars.speed_of_sound # Unpack left and right state diff --git a/src/equations/compressible_moist_euler_2d_lucas.jl b/src/equations/compressible_moist_euler_2d_lucas.jl index 7a440d2..4bf1676 100644 --- a/src/equations/compressible_moist_euler_2d_lucas.jl +++ b/src/equations/compressible_moist_euler_2d_lucas.jl @@ -5,7 +5,7 @@ using Trixi using Trixi: ln_mean, inv_ln_mean import Trixi: varnames, flux_chandrashekar, boundary_condition_slip_wall, cons2prim, cons2entropy, max_abs_speed_naive, max_abs_speeds, - entropy, energy_total, flux + entropy, energy_total, flux, FluxLMARS @muladd begin #! format: noindent @@ -118,13 +118,13 @@ end if v_normal <= 0.0 sound_speed = sqrt(gamma * p_local / rho_local) # local sound speed p_star = p_local * - (1.0 + 0.5 * (gamma - 1) * v_normal / sound_speed)^(2.0 * gamma * + (1.0 + 0.5f0 * (gamma - 1) * v_normal / sound_speed)^(2.0 * gamma * inv(gamma - 1)) else # v_normal > 0.0 A = 2.0 / ((gamma + 1) * rho_local) B = p_local * (gamma - 1) / (gamma + 1) p_star = p_local + - 0.5 * v_normal / A * + 0.5f0 * v_normal / A * (v_normal + sqrt(v_normal^2 + 4.0 * A * (p_local + B))) end @@ -368,11 +368,11 @@ end # positive even power with default value 2 gamma = 2.0 # relaxation coefficient > 0 - alpha = 0.5 + alpha = 0.5f0 tau_s = zero(eltype(u)) if z > z_s - tau_s = alpha * sin(0.5 * (z - z_s) * inv(z_top - z_s))^(gamma) + tau_s = alpha * sin(0.5f0 * (z - z_s) * inv(z_top - z_s))^(gamma) end return SVector(zero(eltype(u)), @@ -398,7 +398,7 @@ end v2 = rho_v2 / rho # Inner energy - rho_e = (rho_E - 0.5 * (rho_v1 * v1 + rho_v2 * v2)) + rho_e = (rho_E - 0.5f0 * (rho_v1 * v1 + rho_v2 * v2)) # Absolute temperature T = (rho_e - L_00 * rho_qv) / (rho_qd * c_vd + rho_qv * c_vv + rho_ql * c_pl) @@ -451,7 +451,7 @@ end # Coordinate Monthly Weather Review Vol. 141.7, pages 2526–2544, 2013, # https://journals.ametsoc.org/view/journals/mwre/141/7/mwr-d-12-00129.1.xml. -@inline function (flux_lmars::flux_LMARS)(u_ll, u_rr, normal_direction::AbstractVector, +@inline function (flux_lmars::FluxLMARS)(u_ll, u_rr, normal_direction::AbstractVector, equations::CompressibleMoistEulerEquations2D) a = flux_lmars.speed_of_sound # Unpack left and right state @@ -473,9 +473,9 @@ end # Compute the necessary interface flux components norm_ = norm(normal_direction) - rho = 0.5 * (rho_ll + rho_rr) - p_interface = 0.5 * (p_ll + p_rr) - beta * 0.5 * a * rho * (v_rr - v_ll) / norm_ - v_interface = 0.5 * (v_ll + v_rr) - beta * 1 / (2 * a * rho) * (p_rr - p_ll) * norm_ + rho = 0.5f0 * (rho_ll + rho_rr) + p_interface = 0.5f0 * (p_ll + p_rr) - beta * 0.5f0 * a * rho * (v_rr - v_ll) / norm_ + v_interface = 0.5f0 * (v_ll + v_rr) - beta * 1 / (2 * a * rho) * (p_rr - p_ll) * norm_ if (v_interface > 0) f1, f2, f3, f4, f5, f6 = u_ll * v_interface @@ -548,7 +548,7 @@ end g_v = L_00 + (c_pv - s_v) * T g_l = (c_pl - s_l) * T - w1 = g_d - 0.5 * v_square + w1 = g_d - 0.5f0 * v_square w2 = v1 w3 = v2 w4 = -1 @@ -565,7 +565,7 @@ end rho_v2 = rho * v2 rho_qv = rho * qv rho_ql = rho * ql - rho_E = p * equations.inv_gamma_minus_one + 0.5 * (rho_v1 * v1 + rho_v2 * v2) + rho_E = p * equations.inv_gamma_minus_one + 0.5f0 * (rho_v1 * v1 + rho_v2 * v2) return SVector(rho, rho_v1, rho_v2, rho_E, rho_qv, rho_ql) end @@ -669,7 +669,7 @@ end v2 = rho_v2 / rho # inner energy - rho_e = (rho_E - 0.5 * (rho_v1 * v1 + rho_v2 * v2)) + rho_e = (rho_E - 0.5f0 * (rho_v1 * v1 + rho_v2 * v2)) # Absolute Temperature T = (rho_e - L_00 * rho_qv) / (rho_qd * c_vd + rho_qv * c_vv + rho_ql * c_pl) @@ -715,7 +715,7 @@ end v2 = rho_v2 / rho # inner energy - rho_e = (rho_E - 0.5 * (rho_v1 * v1 + rho_v2 * v2)) + rho_e = (rho_E - 0.5f0 * (rho_v1 * v1 + rho_v2 * v2)) # Absolute Temperature T = (rho_e - L_00 * rho_qv) / (rho_qd * c_vd + rho_qv * c_vv + rho_ql * c_pl) @@ -949,8 +949,8 @@ end v2_rr = rho_v2_rr / rho_rr # inner energy - rho_e_ll = (rho_E_ll - 0.5 * (rho_v1_ll * v1_ll + rho_v2_ll * v2_ll)) - rho_e_rr = (rho_E_rr - 0.5 * (rho_v1_rr * v1_rr + rho_v2_rr * v2_rr)) + rho_e_ll = (rho_E_ll - 0.5f0 * (rho_v1_ll * v1_ll + rho_v2_ll * v2_ll)) + rho_e_rr = (rho_E_rr - 0.5f0 * (rho_v1_rr * v1_rr + rho_v2_rr * v2_rr)) # Absolute Temperature T_ll = (rho_e_ll - L_00 * rho_qv_ll) / @@ -976,18 +976,18 @@ end inv_T_mean = inv_ln_mean(inv(T_ll), inv(T_rr)) end - v1_avg = 0.5 * (v1_ll + v1_rr) - v2_avg = 0.5 * (v2_ll + v2_rr) - v1_square_avg = 0.5 * (v1_ll^2 + v1_rr^2) - v2_square_avg = 0.5 * (v2_ll^2 + v2_rr^2) - rho_qd_avg = 0.5 * (rho_qd_ll + rho_qd_rr) - rho_qv_avg = 0.5 * (rho_qv_ll + rho_qv_rr) - rho_ql_avg = 0.5 * (rho_ql_ll + rho_ql_rr) - inv_T_avg = 0.5 * (inv(T_ll) + inv(T_rr)) + v1_avg = 0.5f0 * (v1_ll + v1_rr) + v2_avg = 0.5f0 * (v2_ll + v2_rr) + v1_square_avg = 0.5f0 * (v1_ll^2 + v1_rr^2) + v2_square_avg = 0.5f0 * (v2_ll^2 + v2_rr^2) + rho_qd_avg = 0.5f0 * (rho_qd_ll + rho_qd_rr) + rho_qv_avg = 0.5f0 * (rho_qv_ll + rho_qv_rr) + rho_ql_avg = 0.5f0 * (rho_ql_ll + rho_ql_rr) + inv_T_avg = 0.5f0 * (inv(T_ll) + inv(T_rr)) v_dot_n_avg = normal_direction[1] * v1_avg + normal_direction[2] * v2_avg p_int = inv(inv_T_avg) * (R_d * rho_qd_avg + R_v * rho_qv_avg + R_q * rho_ql_avg) - K_avg = 0.5 * (v1_square_avg + v2_square_avg) + K_avg = 0.5f0 * (v1_square_avg + v2_square_avg) f_1d = rho_qd_mean * v_dot_n_avg f_1v = rho_qv_mean * v_dot_n_avg diff --git a/src/equations/equations.jl b/src/equations/equations.jl index 016d5a9..3df151f 100644 --- a/src/equations/equations.jl +++ b/src/equations/equations.jl @@ -5,10 +5,10 @@ abstract type AbstractCompressibleMoistEulerEquations{NDIMS, NVARS} <: abstract type AbstractCompressibleEulerPotentialTemperatureEquations{NDIMS, NVARS} <: AbstractEquations{NDIMS, NVARS} end -struct flux_LMARS{SpeedOfSound} - # Estimate for the speed of sound - speed_of_sound::SpeedOfSound -end +# struct flux_LMARS{SpeedOfSound} +# # Estimate for the speed of sound +# speed_of_sound::SpeedOfSound +# end include("compressible_moist_euler_2d_lucas.jl") include("compressible_euler_potential_temperature_2d.jl") diff --git a/test/test_trixi_consistency.jl b/test/test_trixi_consistency.jl index 72e047f..3596d9c 100644 --- a/test/test_trixi_consistency.jl +++ b/test/test_trixi_consistency.jl @@ -49,7 +49,7 @@ isdir(outdir) && rm(outdir, recursive = true) trixi_include(trixi_elixir, equations = equations_moist, volume_flux = flux_chandrashekar, - surface_flux = flux_LMARS(360.0), + surface_flux = FluxLMARS(360.0), maxiters = maxiters) errors_atmo = Main.analysis_callback(Main.sol)