Skip to content

Commit 1e1f643

Browse files
jlchanranocha
andauthored
Add 1d version of flux_hllc with normal::AbstractVector (#2276)
* add 1d hllc flux with normal::AbstractVector argument * add test for 1D hllc flux with normal::AbstractVector * accomodate non-unit normals * format --------- Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent ec7c664 commit 1e1f643

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/equations/compressible_euler_1d.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,26 @@ function flux_hllc(u_ll, u_rr, orientation::Integer,
816816
return SVector(f1, f2, f3)
817817
end
818818

819+
# While `normal_direction` isn't strictly necessary in 1D, certain solvers assume that
820+
# the normal component is incorporated into the numerical flux.
821+
#
822+
# The HLLC flux along a 1D "normal" can be evaluated by scaling the velocity/momentum by
823+
# the normal for the 1D HLLC flux, then scaling the resulting momentum flux again.
824+
# Moreover, the 2D HLLC flux reduces to this if the normal vector is [n, 0].
825+
function flux_hllc(u_ll, u_rr, normal_direction::AbstractVector,
826+
equations::CompressibleEulerEquations1D)
827+
norm_ = abs(normal_direction[1])
828+
normal_direction_unit = normal_direction[1] * inv(norm_)
829+
830+
# scale the momentum by the normal direction
831+
f = flux_hllc(SVector(u_ll[1], normal_direction_unit * u_ll[2], u_ll[3]),
832+
SVector(u_rr[1], normal_direction_unit * u_rr[2], u_rr[3]), 1,
833+
equations)
834+
835+
# rescale the momentum flux by the normal direction and normalize
836+
return SVector(f[1], normal_direction_unit * f[2], f[3]) * norm_
837+
end
838+
819839
"""
820840
min_max_speed_einfeldt(u_ll, u_rr, orientation, equations::CompressibleEulerEquations1D)
821841

test/test_unit.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,25 @@ end
12241224
flux(u, normal_direction, equations)
12251225
end
12261226

1227+
# check consistency between 1D and 2D HLLC fluxes
1228+
u_1d = SVector(1.1, -0.5, 5.5)
1229+
u_2d = SVector(u_1d[1], u_1d[2], 0.0, u_1d[3])
1230+
normal_1d = SVector(-0.3)
1231+
normal_2d = SVector(normal_1d[1], 0.0)
1232+
equations_1d = CompressibleEulerEquations1D(1.4)
1233+
equations_2d = CompressibleEulerEquations2D(1.4)
1234+
flux_1d = flux_hllc(u_1d, u_1d, normal_1d, equations_1d)
1235+
flux_2d = flux_hllc(u_2d, u_2d, normal_2d, equations_2d)
1236+
@test flux_1d flux(u_1d, normal_1d, equations_1d)
1237+
@test flux_1d flux_2d[[1, 2, 4]]
1238+
1239+
# test when u_ll is not the same as u_rr
1240+
u_rr_1d = SVector(2.1, 0.3, 0.1)
1241+
u_rr_2d = SVector(u_rr_1d[1], u_rr_1d[2], 0.0, u_rr_1d[3])
1242+
flux_1d = flux_hllc(u_1d, u_rr_1d, normal_1d, equations_1d)
1243+
flux_2d = flux_hllc(u_2d, u_rr_2d, normal_2d, equations_2d)
1244+
@test flux_1d flux_2d[[1, 2, 4]]
1245+
12271246
equations = CompressibleEulerEquations3D(1.4)
12281247
u = SVector(1.1, -0.5, 2.34, 2.4, 5.5)
12291248

0 commit comments

Comments
 (0)