Skip to content

Commit 1425637

Browse files
author
LasNikas
committed
implement suggestions
1 parent 70105bb commit 1425637

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/schemes/boundary/open_boundary/mirroring.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
FirstOrderMirroring(; firstorder_tolerance::=1f-3)
2+
FirstOrderMirroring(; firstorder_tolerance=1f-3)
33
44
Fluid properties are extrapolated onto ghost nodes using the method proposed by [Liu and Liu (2006)](@cite Liu2006),
55
to extend the gradient into the boundary zone.
@@ -10,6 +10,7 @@ to extend the gradient into the boundary zone.
1010
"""
1111
struct FirstOrderMirroring{ELTYPE}
1212
firstorder_tolerance::ELTYPE
13+
1314
function FirstOrderMirroring(; firstorder_tolerance::Real=1.0f-3)
1415
return new{typeof(firstorder_tolerance)}(firstorder_tolerance)
1516
end
@@ -202,21 +203,21 @@ function extrapolate_values!(system,
202203
if abs(det(correction_matrix[])) >= mirror_method.firstorder_tolerance
203204
L_inv = inv(correction_matrix[])
204205

205-
# pressure
206+
# Pressure
206207
if !prescribed_pressure
207208
first_order_scalar_extrapolation!(pressure, particle, L_inv,
208209
interpolated_pressure_correction[],
209210
two_to_end, pos_diff, mirror_method)
210211
end
211212

212-
# density
213+
# Density
213214
if !prescribed_density
214215
first_order_scalar_extrapolation!(density, particle, L_inv,
215216
interpolated_density_correction[],
216217
two_to_end, pos_diff, mirror_method)
217218
end
218219

219-
# velocity
220+
# Velocity
220221
if !prescribed_velocity
221222
first_order_velocity_extrapolation!(v_open_boundary, particle, L_inv,
222223
interpolated_velocity_correction[],
@@ -231,7 +232,7 @@ function extrapolate_values!(system,
231232
end
232233

233234
# No else: `correction_matrix[][1, 1] <= eps()` means no fluid neighbors
234-
# and thus no reliable interpolation, so boundary values remain at their current state
235+
# and thus no reliable interpolation, so boundary values remain at their current state.
235236
elseif correction_matrix[][1, 1] > eps()
236237
# Determinant is small, fallback to zero-th order mirroring
237238
shepard_coefficient = correction_matrix[][1, 1]

test/schemes/boundary/open_boundary/mirroring.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@
261261
@testset verbose=true "Mirroring Methods" begin
262262
function mirror(pressure_function, mirror_method;
263263
particle_spacing=0.05, domain_size=(2.0, 1.0))
264+
# Initialize a fluid block with pressure according to `pressure_function`
265+
# and a adjacent inflow and outflow open boundaries to test the pressure extrapolation.
264266
domain_fluid = RectangularShape(particle_spacing,
265267
round.(Int, domain_size ./ particle_spacing),
266268
(0.0, 0.0), density=1000.0,
@@ -283,8 +285,8 @@
283285
boundary_model=BoundaryModelTafuni(),
284286
buffer_size=0)
285287

288+
# Temporary semidiscretization just to extrapolate the pressure into the outflow system
286289
semi = Semidiscretization(fluid_system, open_boundary_out)
287-
288290
TrixiParticles.initialize_neighborhood_searches!(semi)
289291

290292
v_open_boundary = zero(outflow.initial_condition.velocity)
@@ -307,6 +309,7 @@
307309
boundary_model=BoundaryModelTafuni(),
308310
buffer_size=0)
309311

312+
# Temporary semidiscretization just to extrapolate the pressure into the outflow system
310313
semi = Semidiscretization(fluid_system, open_boundary_in)
311314
TrixiParticles.initialize_neighborhood_searches!(semi)
312315

@@ -324,6 +327,10 @@
324327
end
325328

326329
function interpolate_pressure(mirror_method, pressure_func; particle_spacing=0.05)
330+
# First call the function above to initialize fluid with pressure according to the function
331+
# and then extrapolate pressure to the inflow and outflow boundary systems.
332+
# Then, in this function, we apply an SPH interpolation on this extrapolated pressure field
333+
# to get a continuous representation of the extrapolated pressure field to validate.
327334
fluid_system, open_boundary_in, open_boundary_out,
328335
v_fluid = mirror(pressure_func, mirror_method)
329336

@@ -341,7 +348,7 @@
341348
smoothing_length = 1.2 * particle_spacing
342349
smoothing_kernel = WendlandC2Kernel{2}()
343350

344-
# Use a fluid system to interpolate the pressure
351+
# Use a temporary fluid system just to interpolate the pressure
345352
interpolation_system = WeaklyCompressibleSPHSystem(entire_domain,
346353
ContinuityDensity(),
347354
nothing, smoothing_kernel,

0 commit comments

Comments
 (0)