Skip to content

Commit 0150a1f

Browse files
author
LasNikas
committed
1 parent 0ed7dd5 commit 0150a1f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/schemes/boundary/open_boundary/boundary_zones.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ function BoundaryZone(; plane, plane_normal, density, particle_spacing,
196196
reference_values = (reference_velocity=velocity_ref, reference_pressure=pressure_ref,
197197
reference_density=density_ref)
198198

199+
coordinates_svector = reinterpret(reshape, SVector{NDIMS, ELTYPE}, ic.coordinates)
200+
201+
if prescribed_pressure
202+
ic.pressure .= pressure_ref.(coordinates_svector, 0)
203+
end
204+
if prescribed_density
205+
ic.density .= density_ref.(coordinates_svector, 0)
206+
ic.mass .= ic.density * ic.particle_spacing^NDIMS
207+
end
208+
if prescribed_velocity
209+
ic.velocity .= stack(velocity_ref.(coordinates_svector, 0))
210+
end
211+
199212
return BoundaryZone(ic, spanning_set_, zone_origin, zone_width,
200213
flow_direction, plane_normal_, reference_values,
201214
average_inflow_velocity, prescribed_density, prescribed_pressure,

test/schemes/boundary/open_boundary/characteristic_variables.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# Prescribed quantities
1616
reference_velocity = (pos, t) -> SVector(t, 0.0)
1717
reference_pressure = (pos, t) -> 50_000.0 * t
18-
reference_density = (pos, t) -> 1000.0 * t
18+
# Add small offset to avoid "ArgumentError: density must be positive and larger than `eps()`"
19+
reference_density = (pos, t) -> 1000.0 * (t + sqrt(eps()))
1920

2021
# Plane points of open boundary
2122
plane_points_1 = [[0.0, 0.0], [0.5, -0.5], [1.0, 0.5]]

0 commit comments

Comments
 (0)