Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoArtiano committed Sep 23, 2024
1 parent 96d60c1 commit 04c304d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions examples/elixir_potential_euler_dry_bubble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using TrixiAtmo: flux_LMARS, source_terms_bubble, flux_theta
using Plots

function initial_condition_warm_bubble(x, t,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
g = equations.g
c_p = equations.c_p
c_v = equations.c_v
Expand Down Expand Up @@ -45,7 +45,7 @@ end
###############################################################################
# semidiscretization of the compressible Euler equations

equations = CompressiblePotentialEulerEquations2D()
equations = CompressibleEulerPotentialTemperatureEquations2D()

boundary_conditions = (x_neg = boundary_condition_periodic,
x_pos = boundary_condition_periodic,
Expand All @@ -65,7 +65,7 @@ solver = DGSEM(basis, surface_flux, volume_integral)
coordinates_min = (0.0, 0.0)
coordinates_max = (20_000.0, 10_000.0)

cells_per_dimension = (32, 16)
cells_per_dimension = (64, 32)
mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max,
periodicity = (true, false))
initial_condition = initial_condition_warm_bubble
Expand Down
2 changes: 1 addition & 1 deletion src/TrixiAtmo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ include("solvers/solvers.jl")
include("semidiscretization/semidiscretization_hyperbolic_2d_manifold_in_3d.jl")

export CompressibleMoistEulerEquations2D
export CompressiblePotentialEulerEquations2D
export CompressibleEulerPotentialTemperatureEquations2D

export flux_chandrashekar, flux_LMARS, flux_theta

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Trixi: varnames, cons2cons, cons2prim, cons2entropy, entropy

@muladd begin
#! format: noindent
struct CompressiblePotentialEulerEquations2D{RealT <: Real} <:
AbstractCompressiblePotentialEulerEquations{2, 4}
struct CompressibleEulerPotentialTemperatureEquations2D{RealT <: Real} <:
AbstractCompressibleEulerPotentialTemperatureEquations{2, 4}
p_0::RealT
c_p::RealT
c_v::RealT
Expand All @@ -15,27 +15,27 @@ struct CompressiblePotentialEulerEquations2D{RealT <: Real} <:
a::RealT
end

function CompressiblePotentialEulerEquations2D(; g = 9.81, RealT = Float64)
function CompressibleEulerPotentialTemperatureEquations2D(; g = 9.81, RealT = Float64)
p_0 = 100_000.0
c_p = 1004.0
c_v = 717.0
R = c_p - c_v
gamma = c_p / c_v
a = 340.0
return CompressiblePotentialEulerEquations2D{RealT}(p_0, c_p, c_v, g, R, gamma, a)
return CompressibleEulerPotentialTemperatureEquations2D{RealT}(p_0, c_p, c_v, g, R, gamma, a)
end

function varnames(::typeof(cons2cons), ::CompressiblePotentialEulerEquations2D)
function varnames(::typeof(cons2cons), ::CompressibleEulerPotentialTemperatureEquations2D)
("rho", "rho_v1", "rho_v2", "rho_theta")
end

varnames(::typeof(cons2prim), ::CompressiblePotentialEulerEquations2D) = ("rho", "v1",
varnames(::typeof(cons2prim), ::CompressibleEulerPotentialTemperatureEquations2D) = ("rho", "v1",
"v2", "p1")

# 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::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, rho_v1, rho_v2, rho_theta = u
v1 = rho_v1 / rho
v2 = rho_v2 / rho
Expand All @@ -49,7 +49,7 @@ varnames(::typeof(cons2prim), ::CompressiblePotentialEulerEquations2D) = ("rho",
end

@inline function flux(u, orientation::Integer,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, rho_v1, rho_v2, rho_theta = u
v1 = rho_v1 / rho
v2 = rho_v2 / rho
Expand All @@ -76,7 +76,7 @@ end
@inline function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector,
x, t,
surface_flux_function,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
@unpack gamma = equations
norm_ = norm(normal_direction)
# Normalize the vector without using `normalize` since we need to multiply by the `norm_` later
Expand Down Expand Up @@ -116,7 +116,7 @@ end
@inline function boundary_condition_slip_wall(u_inner, normal_direction::AbstractVector,
direction, x, t,
surface_flux_function,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
# 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)
Expand All @@ -133,15 +133,15 @@ end
end

@inline function source_terms_bubble(u, x, t,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, _, _, _ = u
return SVector(zero(eltype(u)), zero(eltype(u)), -equations.g * rho,
zero(eltype(u)))
end

# Rotate momentum flux. The same as in compressible Euler.
@inline function rotate_to_x(u, normal_vector::AbstractVector,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
# 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]
Expand All @@ -166,7 +166,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(u_ll, u_rr, normal_direction::AbstractVector,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
@unpack a = equations
# Unpack left and right state
rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations)
Expand Down Expand Up @@ -197,7 +197,7 @@ end

## Entropy (total energy) conservative flux for the Compressible Euler with the Potential Formulation
@inline function flux_theta(u_ll, u_rr, normal_direction::AbstractVector,
equations::CompressiblePotentialEulerEquations2D)
equations::CompressibleEulerPotentialTemperatureEquations2D)
# Unpack left and right state
rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations)
rho_rr, v1_rr, v2_rr, p_rr = cons2prim(u_rr, equations)
Expand All @@ -224,15 +224,15 @@ end
return SVector(f1, f2, f3, f4)
end

@inline function prim2cons(prim, equations::CompressiblePotentialEulerEquations2D)
@inline function prim2cons(prim, equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, v1, v2, p = prim
rho_v1 = rho * v1
rho_v2 = rho * v2
rho_theta = (p / equations.p_0)^(1 / equations.gamma) * equations.p_0 / equations.R
return SVector(rho, rho_v1, rho_v2, rho_theta)
end

@inline function cons2prim(u, equations::CompressiblePotentialEulerEquations2D)
@inline function cons2prim(u, equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, rho_v1, rho_v2, rho_theta = u
v1 = rho_v1 / rho
v2 = rho_v2 / rho
Expand All @@ -241,11 +241,11 @@ end
return SVector(rho, v1, v2, p)
end

@inline function cons2cons(u, equations::CompressiblePotentialEulerEquations2D)
@inline function cons2cons(u, equations::CompressibleEulerPotentialTemperatureEquations2D)
return u
end

@inline function cons2entropy(u, equations::CompressiblePotentialEulerEquations2D)
@inline function cons2entropy(u, equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, rho_v1, rho_v2, rho_theta = u

k = equations.p_0 * (equations.R / equations.p_0)^equations.gamma
Expand All @@ -257,7 +257,7 @@ end
return SVector(w1, w2, w3, w4)
end

@inline function entropy_math(cons, equations::CompressiblePotentialEulerEquations2D)
@inline function entropy_math(cons, equations::CompressibleEulerPotentialTemperatureEquations2D)
# Mathematical entropy
p = equations.p_0 * (equations.R * cons[4] / equations.p_0)^equations.gamma

Expand All @@ -267,19 +267,19 @@ end
end

# Default entropy is the mathematical entropy
@inline function entropy(cons, equations::CompressiblePotentialEulerEquations2D)
@inline function entropy(cons, equations::CompressibleEulerPotentialTemperatureEquations2D)
entropy_math(cons, equations)
end

@inline function energy_total(cons, equations::CompressiblePotentialEulerEquations2D)
@inline function energy_total(cons, equations::CompressibleEulerPotentialTemperatureEquations2D)
entropy(cons, equations)
end

@inline function energy_kinetic(cons, equations::CompressiblePotentialEulerEquations2D)
@inline function energy_kinetic(cons, equations::CompressibleEulerPotentialTemperatureEquations2D)
return 0.5 * (cons[2]^2 + cons[3]^2) / (cons[1])
end

@inline function max_abs_speeds(u, equations::CompressiblePotentialEulerEquations2D)
@inline function max_abs_speeds(u, equations::CompressibleEulerPotentialTemperatureEquations2D)
rho, v1, v2, p = cons2prim(u, equations)
c = sqrt(equations.gamma * p / rho)

Expand Down
2 changes: 1 addition & 1 deletion src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ abstract type AbstractCompressibleMoistEulerEquations{NDIMS, NVARS} <:
abstract type AbstractCompressiblePotentialEulerEquations{NDIMS, NVARS} <:
AbstractEquations{NDIMS, NVARS} end
include("compressible_moist_euler_2d_lucas.jl")
include("compressible_potential_euler_2d.jl")
include("compressible_euler_potential_temperature_2d.jl")

0 comments on commit 04c304d

Please sign in to comment.