Skip to content

Commit 58707b1

Browse files
authored
Merge branch 'main' into threaded-copy-coupled
2 parents b58a762 + 5398b22 commit 58707b1

5 files changed

+280
-29
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Trixi"
22
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
33
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"]
4-
version = "0.7.16-pre"
4+
version = "0.7.17-pre"
55

66
[deps]
77
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"

src/equations/linear_scalar_advection_1d.jl

+14-10
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ A constant initial condition to test free-stream preservation.
3434
"""
3535
function initial_condition_constant(x, t, equation::LinearScalarAdvectionEquation1D)
3636
# Store translated coordinate for easy use of exact solution
37+
RealT = eltype(x)
3738
x_trans = x - equation.advection_velocity * t
3839

39-
return SVector(2.0)
40+
return SVector(RealT(2))
4041
end
4142

4243
"""
@@ -49,13 +50,14 @@ in non-periodic domains).
4950
function initial_condition_convergence_test(x, t,
5051
equation::LinearScalarAdvectionEquation1D)
5152
# Store translated coordinate for easy use of exact solution
53+
RealT = eltype(x)
5254
x_trans = x - equation.advection_velocity * t
5355

54-
c = 1.0
55-
A = 0.5
56+
c = 1
57+
A = 0.5f0
5658
L = 2
57-
f = 1 / L
58-
omega = 2 * pi * f
59+
f = 1.0f0 / L
60+
omega = 2 * convert(RealT, pi) * f
5961
scalar = c + A * sin(omega * sum(x_trans))
6062
return SVector(scalar)
6163
end
@@ -161,7 +163,7 @@ function flux_engquist_osher(u_ll, u_rr, orientation::Int,
161163
u_L = u_ll[1]
162164
u_R = u_rr[1]
163165

164-
return SVector(0.5 * (flux(u_L, orientation, equation) +
166+
return SVector(0.5f0 * (flux(u_L, orientation, equation) +
165167
flux(u_R, orientation, equation) -
166168
abs(equation.advection_velocity[orientation]) * (u_R - u_L)))
167169
end
@@ -200,14 +202,16 @@ end
200202

201203
@inline function splitting_lax_friedrichs(u, ::Val{:plus}, orientation::Integer,
202204
equations::LinearScalarAdvectionEquation1D)
205+
RealT = eltype(u)
203206
a = equations.advection_velocity[1]
204-
return a > 0 ? flux(u, orientation, equations) : zero(u)
207+
return a > 0 ? flux(u, orientation, equations) : SVector(zero(RealT))
205208
end
206209

207210
@inline function splitting_lax_friedrichs(u, ::Val{:minus}, orientation::Integer,
208211
equations::LinearScalarAdvectionEquation1D)
212+
RealT = eltype(u)
209213
a = equations.advection_velocity[1]
210-
return a < 0 ? flux(u, orientation, equations) : zero(u)
214+
return a < 0 ? flux(u, orientation, equations) : SVector(zero(RealT))
211215
end
212216

213217
# Convert conservative variables to primitive
@@ -217,11 +221,11 @@ end
217221
@inline cons2entropy(u, equation::LinearScalarAdvectionEquation1D) = u
218222

219223
# Calculate entropy for a conservative state `cons`
220-
@inline entropy(u::Real, ::LinearScalarAdvectionEquation1D) = 0.5 * u^2
224+
@inline entropy(u::Real, ::LinearScalarAdvectionEquation1D) = 0.5f0 * u^2
221225
@inline entropy(u, equation::LinearScalarAdvectionEquation1D) = entropy(u[1], equation)
222226

223227
# Calculate total energy for a conservative state `cons`
224-
@inline energy_total(u::Real, ::LinearScalarAdvectionEquation1D) = 0.5 * u^2
228+
@inline energy_total(u::Real, ::LinearScalarAdvectionEquation1D) = 0.5f0 * u^2
225229
@inline function energy_total(u, equation::LinearScalarAdvectionEquation1D)
226230
energy_total(u[1], equation)
227231
end

src/equations/linear_scalar_advection_2d.jl

+11-9
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ varnames(::typeof(cons2prim), ::LinearScalarAdvectionEquation2D) = ("scalar",)
3434
function x_trans_periodic_2d(x, domain_length = SVector(10, 10), center = SVector(0, 0))
3535
x_normalized = x .- center
3636
x_shifted = x_normalized .% domain_length
37-
x_offset = ((x_shifted .< -0.5 * domain_length) -
38-
(x_shifted .> 0.5 * domain_length)) .* domain_length
37+
x_offset = ((x_shifted .< -0.5f0 * domain_length) -
38+
(x_shifted .> 0.5f0 * domain_length)) .* domain_length
3939
return center + x_shifted + x_offset
4040
end
4141

@@ -47,9 +47,10 @@ A constant initial condition to test free-stream preservation.
4747
"""
4848
function initial_condition_constant(x, t, equation::LinearScalarAdvectionEquation2D)
4949
# Store translated coordinate for easy use of exact solution
50+
RealT = eltype(x)
5051
x_trans = x_trans_periodic_2d(x - equation.advection_velocity * t)
5152

52-
return SVector(2.0)
53+
return SVector(RealT(2))
5354
end
5455

5556
"""
@@ -60,13 +61,14 @@ A smooth initial condition used for convergence tests.
6061
function initial_condition_convergence_test(x, t,
6162
equation::LinearScalarAdvectionEquation2D)
6263
# Store translated coordinate for easy use of exact solution
64+
RealT = eltype(x)
6365
x_trans = x - equation.advection_velocity * t
6466

65-
c = 1.0
66-
A = 0.5
67+
c = 1
68+
A = 0.5f0
6769
L = 2
68-
f = 1 / L
69-
omega = 2 * pi * f
70+
f = 1.0f0 / L
71+
omega = 2 * convert(RealT, pi) * f
7072
scalar = c + A * sin(omega * sum(x_trans))
7173
return SVector(scalar)
7274
end
@@ -280,11 +282,11 @@ end
280282
@inline cons2entropy(u, equation::LinearScalarAdvectionEquation2D) = u
281283

282284
# Calculate entropy for a conservative state `cons`
283-
@inline entropy(u::Real, ::LinearScalarAdvectionEquation2D) = 0.5 * u^2
285+
@inline entropy(u::Real, ::LinearScalarAdvectionEquation2D) = 0.5f0 * u^2
284286
@inline entropy(u, equation::LinearScalarAdvectionEquation2D) = entropy(u[1], equation)
285287

286288
# Calculate total energy for a conservative state `cons`
287-
@inline energy_total(u::Real, ::LinearScalarAdvectionEquation2D) = 0.5 * u^2
289+
@inline energy_total(u::Real, ::LinearScalarAdvectionEquation2D) = 0.5f0 * u^2
288290
@inline function energy_total(u, equation::LinearScalarAdvectionEquation2D)
289291
energy_total(u[1], equation)
290292
end

src/equations/linear_scalar_advection_3d.jl

+11-9
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ A constant initial condition to test free-stream preservation.
3838
"""
3939
function initial_condition_constant(x, t, equation::LinearScalarAdvectionEquation3D)
4040
# Store translated coordinate for easy use of exact solution
41+
RealT = eltype(x)
4142
x_trans = x - equation.advection_velocity * t
4243

43-
return SVector(2.0)
44+
return SVector(RealT(2))
4445
end
4546

4647
"""
@@ -51,13 +52,14 @@ A smooth initial condition used for convergence tests.
5152
function initial_condition_convergence_test(x, t,
5253
equation::LinearScalarAdvectionEquation3D)
5354
# Store translated coordinate for easy use of exact solution
55+
RealT = eltype(x)
5456
x_trans = x - equation.advection_velocity * t
5557

56-
c = 1.0
57-
A = 0.5
58+
c = 1
59+
A = 0.5f0
5860
L = 2
59-
f = 1 / L
60-
omega = 2 * pi * f
61+
f = 1.0f0 / L
62+
omega = 2 * convert(RealT, pi) * f
6163
scalar = c + A * sin(omega * sum(x_trans))
6264
return SVector(scalar)
6365
end
@@ -82,10 +84,10 @@ A sine wave in the conserved variable.
8284
"""
8385
function initial_condition_sin(x, t, equation::LinearScalarAdvectionEquation3D)
8486
# Store translated coordinate for easy use of exact solution
87+
RealT = eltype(x)
8588
x_trans = x - equation.advection_velocity * t
8689

87-
scalar = sin(2 * pi * x_trans[1]) * sin(2 * pi * x_trans[2]) *
88-
sin(2 * pi * x_trans[3])
90+
scalar = sinpi(2 * x_trans[1]) * sinpi(2 * x_trans[2]) * sinpi(2 * x_trans[3])
8991
return SVector(scalar)
9092
end
9193

@@ -199,11 +201,11 @@ end
199201
@inline cons2entropy(u, equation::LinearScalarAdvectionEquation3D) = u
200202

201203
# Calculate entropy for a conservative state `cons`
202-
@inline entropy(u::Real, ::LinearScalarAdvectionEquation3D) = 0.5 * u^2
204+
@inline entropy(u::Real, ::LinearScalarAdvectionEquation3D) = 0.5f0 * u^2
203205
@inline entropy(u, equation::LinearScalarAdvectionEquation3D) = entropy(u[1], equation)
204206

205207
# Calculate total energy for a conservative state `cons`
206-
@inline energy_total(u::Real, ::LinearScalarAdvectionEquation3D) = 0.5 * u^2
208+
@inline energy_total(u::Real, ::LinearScalarAdvectionEquation3D) = 0.5f0 * u^2
207209
@inline function energy_total(u, equation::LinearScalarAdvectionEquation3D)
208210
energy_total(u[1], equation)
209211
end

0 commit comments

Comments
 (0)