Skip to content

Commit 4fd1b32

Browse files
author
LasNikas
committed
fix gpu bugs
1 parent 2cdd9e9 commit 4fd1b32

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/schemes/boundary/open_boundary/method_of_characteristics.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,9 @@ end
237237
function average_velocity!(v, u, system, ::BoundaryModelLastiwka, ::BoundaryZone{InFlow},
238238
semi)
239239
avg_velocity = sum(each_moving_particle(system)) do particle
240-
return current_velocity(v, system, particle)
240+
return current_velocity(v, system, particle) / system.buffer.active_particle_count[]
241241
end
242242

243-
avg_velocity /= system.buffer.active_particle_count[]
244-
245243
@threaded semi for particle in each_moving_particle(system)
246244
# Set the velocity of the ghost node to the average velocity of the fluid domain
247245
@inbounds for dim in eachindex(avg_velocity)

src/schemes/boundary/open_boundary/mirroring.jl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ to retrieve first order kernel and particle consistency.
1010
"""
1111
struct FirstOrderMirroring{ELTYPE}
1212
firstorder_tolerance::ELTYPE
13-
function FirstOrderMirroring(; firstorder_tolerance::ELTYPE=1e-3) where {ELTYPE}
13+
function FirstOrderMirroring(; firstorder_tolerance::Real=1 / 1000.0f0)
1414
return new{typeof(firstorder_tolerance)}(firstorder_tolerance)
1515
end
1616
end
@@ -27,7 +27,7 @@ the corrected gradient as proposed by [Negi et al. (2022)](@cite Negi2022).
2727
"""
2828
struct SimpleMirroring{ELTYPE}
2929
firstorder_tolerance::ELTYPE
30-
function SimpleMirroring(; firstorder_tolerance::Real=1e-3)
30+
function SimpleMirroring(; firstorder_tolerance::Real=1 / 1000.0f0)
3131
return new{typeof(firstorder_tolerance)}(firstorder_tolerance)
3232
end
3333
end
@@ -62,14 +62,16 @@ struct BoundaryModelTafuni{MM}
6262
end
6363

6464
function BoundaryModelTafuni(;
65-
mirror_method=FirstOrderMirroring(; firstorder_tolerance=1e-3))
65+
mirror_method=FirstOrderMirroring(;
66+
firstorder_tolerance=1 /
67+
1000.0f0))
6668
return BoundaryModelTafuni(mirror_method)
6769
end
6870

6971
function update_boundary_quantities!(system, boundary_model::BoundaryModelTafuni,
7072
v, u, v_ode, u_ode, semi, t)
7173
(; reference_pressure, reference_density, reference_velocity, boundary_zone,
72-
cache) = system
74+
pressure, density, cache) = system
7375
(; prescribed_pressure, prescribed_density, prescribed_velocity) = cache
7476

7577
@trixi_timeit timer() "extrapolate and correct values" begin
@@ -205,21 +207,22 @@ function extrapolate_values!(system,
205207
# pressure
206208
if !(prescribed_pressure)
207209
first_order_scalar_interpolation!(pressure, particle, L_inv,
208-
interpolated_pressure_correction,
210+
interpolated_pressure_correction[],
209211
two_to_end, pos_diff, mirror_method)
210212
end
211213

212214
# density
213215
if !(prescribed_density)
214216
first_order_scalar_interpolation!(density, particle, L_inv,
215-
interpolated_density_correction,
217+
interpolated_density_correction[],
216218
two_to_end, pos_diff, mirror_method)
217219
end
218220

219221
# velocity
220222
if !(prescribed_velocity)
221223
first_order_velocity_interpolation!(v_open_boundary, system, particle,
222-
L_inv, interpolated_velocity_correction,
224+
L_inv,
225+
interpolated_velocity_correction[],
223226
two_to_end, pos_diff, mirror_method)
224227

225228
# Project the velocity on the normal direction of the boundary zone (only for inflow boundaries).
@@ -381,9 +384,9 @@ function zeroth_order_velocity_interpolation!(v, system, particle, shepard_coeff
381384
end
382385

383386
function first_order_scalar_interpolation!(values, particle, L_inv,
384-
extrapolated_values_correction,
387+
interpolated_values_correction,
385388
two_to_end, pos_diff, ::FirstOrderMirroring)
386-
f_s = L_inv * extrapolated_values_correction[]
389+
f_s = L_inv * interpolated_values_correction
387390
df_p = f_s[two_to_end] # f_s[2:end] as SVector
388391

389392
values[particle] = f_s[1] + dot(pos_diff, df_p)
@@ -392,9 +395,9 @@ function first_order_scalar_interpolation!(values, particle, L_inv,
392395
end
393396

394397
function first_order_scalar_interpolation!(values, particle, L_inv,
395-
extrapolated_values_correction,
398+
interpolated_values_correction,
396399
two_to_end, pos_diff, ::SimpleMirroring)
397-
f_s = L_inv * extrapolated_values_correction[]
400+
f_s = L_inv * interpolated_values_correction
398401

399402
values[particle] = f_s[1]
400403

@@ -405,7 +408,7 @@ function first_order_velocity_interpolation!(v, system, particle, L_inv,
405408
interpolated_velocity_correction,
406409
two_to_end, pos_diff, ::FirstOrderMirroring)
407410
@inbounds for dim in eachindex(pos_diff)
408-
f_v = L_inv * interpolated_velocity_correction[][dim, :]
411+
f_v = L_inv * interpolated_velocity_correction[dim, :]
409412
df_v = f_v[two_to_end] # f_v[2:end] as SVector
410413

411414
v[dim, particle] = f_v[1] + dot(pos_diff, df_v)
@@ -418,7 +421,7 @@ function first_order_velocity_interpolation!(v, system, particle, L_inv,
418421
interpolated_velocity_correction,
419422
two_to_end, pos_diff, ::SimpleMirroring)
420423
@inbounds for dim in eachindex(pos_diff)
421-
f_v = L_inv * interpolated_velocity_correction[][dim, :]
424+
f_v = L_inv * interpolated_velocity_correction[dim, :]
422425

423426
v[dim, particle] = f_v[1]
424427
end
@@ -496,11 +499,9 @@ function average_velocity!(v, u, system, boundary_zone::BoundaryZone{InFlow}, se
496499
active_coordinates(u, system)))
497500

498501
avg_velocity = sum(candidates) do particle
499-
return current_velocity(v, system, particle)
502+
return current_velocity(v, system, particle) / length(candidates)
500503
end
501504

502-
avg_velocity /= length(candidates)
503-
504505
@threaded semi for particle in each_moving_particle(system)
505506
# Set the velocity of the ghost node to the average velocity of the fluid domain
506507
@inbounds for dim in eachindex(avg_velocity)

0 commit comments

Comments
 (0)