@@ -162,18 +162,19 @@ bidirectional_flow = BoundaryZone(; boundary_face=face_vertices, face_normal,
162162!!! warning "Experimental Implementation"
163163 This is an experimental feature and may change in any future releases.
164164"""
165- struct BoundaryZone{IC, S, ZO, ZW, FD, FN, ELTYPE , R, C}
165+ struct BoundaryZone{NDIMS, ELTYPE, IC, S , R, C}
166166 initial_condition :: IC
167167 spanning_set :: S
168- zone_origin :: ZO
169- zone_width :: ZW
170- flow_direction :: FD
171- face_normal :: FN
168+ zone_origin :: SVector{NDIMS, ELTYPE}
169+ zone_width :: ELTYPE
170+ flow_direction :: SVector{NDIMS, ELTYPE}
171+ face_normal :: SVector{NDIMS, ELTYPE}
172172 rest_pressure :: ELTYPE # Only required for `BoundaryModelDynamicalPressureZhang`
173173 reference_values :: R
174174 cache :: C
175175 # Note that the following can't be static type parameters, as all boundary zones in a system
176176 # must have the same type, so that we can loop over them in a type-stable way.
177+ is_bidirectional :: Bool
177178 average_inflow_velocity :: Bool
178179 prescribed_density :: Bool
179180 prescribed_pressure :: Bool
@@ -202,7 +203,7 @@ function BoundaryZone(; boundary_face, face_normal, density, particle_spacing,
202203 NDIMS = ndims (ic)
203204 ELTYPE = eltype (ic)
204205 if ! (reference_velocity isa Function || isnothing (reference_velocity) ||
205- (reference_velocity isa Vector && length (reference_velocity) == NDIMS))
206+ (reference_velocity isa AbstractVector && length (reference_velocity) == NDIMS))
206207 throw (ArgumentError (" `reference_velocity` must be either a function mapping " *
207208 " each particle's coordinates and time to its velocity, " *
208209 " or, for a constant fluid velocity, a vector of length $NDIMS for a $(NDIMS) D problem holding this velocity" ))
@@ -281,16 +282,18 @@ function BoundaryZone(; boundary_face, face_normal, density, particle_spacing,
281282 cache = (;
282283 create_cache_boundary_zone (ic, boundary_face, face_normal_, sample_points)... )
283284
285+ is_bidirectional = boundary_type isa BidirectionalFlow
286+
284287 return BoundaryZone (ic, spanning_set_, zone_origin, zone_width,
285288 flow_direction, face_normal_, rest_pressure, reference_values,
286- cache, average_inflow_velocity, prescribed_density ,
287- prescribed_pressure, prescribed_velocity)
289+ cache, is_bidirectional, average_inflow_velocity ,
290+ prescribed_density, prescribed_pressure, prescribed_velocity)
288291end
289292
290293function boundary_type_name (boundary_zone:: BoundaryZone )
291- (; flow_direction, face_normal) = boundary_zone
294+ (; flow_direction, face_normal, is_bidirectional ) = boundary_zone
292295
293- if isnothing (flow_direction)
296+ if is_bidirectional
294297 return " bidirectional_flow"
295298 elseif signbit (dot (flow_direction, face_normal))
296299 return " outflow"
@@ -378,7 +381,7 @@ function set_up_boundary_zone(boundary_face, face_normal, density, particle_spac
378381 # Unit vector pointing in downstream direction
379382 flow_direction = - face_normal
380383 elseif boundary_type isa BidirectionalFlow
381- flow_direction = nothing
384+ flow_direction = zero (face_normal)
382385 end
383386
384387 # Sample particles in boundary zone
@@ -565,7 +568,7 @@ function wrap_reference_function(constant_vector::AbstractVector,
565568 return @inline ((coords, t)-> SVector {NDIMS, ELTYPE} (constant_vector))
566569end
567570
568- function reference_pressure (boundary_zone, v, system, particle, pos, t)
571+ @inline function reference_pressure (boundary_zone, v, system, particle, pos, t)
569572 (; prescribed_pressure) = boundary_zone
570573 (; pressure_reference_values) = system. cache
571574
@@ -579,7 +582,7 @@ function reference_pressure(boundary_zone, v, system, particle, pos, t)
579582 end
580583end
581584
582- function reference_density (boundary_zone, v, system, particle, pos, t)
585+ @inline function reference_density (boundary_zone, v, system, particle, pos, t)
583586 (; prescribed_density) = boundary_zone
584587 (; density_reference_values) = system. cache
585588
@@ -593,7 +596,7 @@ function reference_density(boundary_zone, v, system, particle, pos, t)
593596 end
594597end
595598
596- function reference_velocity (boundary_zone, v, system, particle, pos, t)
599+ @inline function reference_velocity (boundary_zone, v, system, particle, pos, t)
597600 (; prescribed_velocity) = boundary_zone
598601 (; velocity_reference_values) = system. cache
599602
0 commit comments