Skip to content

Commit

Permalink
implement suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
LasNikas committed Jul 18, 2024
1 parent cb44385 commit 05e811a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/schemes/boundary/dummy_particles/dummy_particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
smoothing_length; viscosity=nothing,
state_equation=nothing, correction=nothing)
`boundary_model` for `BoundarySPHSystem`.
Boundary model for `BoundarySPHSystem`.
# Arguments
- `initial_density`: Vector holding the initial density of each boundary particle.
Expand Down
2 changes: 1 addition & 1 deletion src/schemes/boundary/monaghan_kajtar/monaghan_kajtar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
BoundaryModelMonaghanKajtar(K, beta, boundary_particle_spacing, mass;
viscosity=nothing)
`boundary_model` for `BoundarySPHSystem`.
Boundary model for `BoundarySPHSystem`.
# Arguments
- `K`: Scaling factor for repulsive force.
Expand Down
10 changes: 6 additions & 4 deletions src/schemes/boundary/open_boundary/method_of_characteristics.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@doc raw"""
BoundaryModelLastiwka()
`boundary_model` for `OpenBoundarySPHSystem`.
Boundary model for `OpenBoundarySPHSystem`.
This model uses the characteristic variables to propagate the appropriate values
to the outlet or inlet and have been proposed by Lastiwka et al. (2009). For more information
about the method see [description below](@ref method_of_characteristics).
Expand All @@ -12,6 +12,7 @@ struct BoundaryModelLastiwka end
v, u, v_ode, u_ode, semi, t)
(; density, pressure, cache, flow_direction, sound_speed,
reference_velocity, reference_pressure, reference_density) = system
@autoinfiltrate

# Update quantities based on the characteristic variables
@threaded system for particle in each_moving_particle(system)
Expand All @@ -21,15 +22,16 @@ struct BoundaryModelLastiwka end
J2 = cache.characteristics[2, particle]
J3 = cache.characteristics[3, particle]

rho_ref = reference_value(reference_density, density, system, particle,
rho_ref = reference_value(reference_density, density[particle], system, particle,
particle_position, t)
density[particle] = rho_ref + ((-J1 + 0.5 * (J2 + J3)) / sound_speed^2)

p_ref = reference_value(reference_pressure, pressure, system, particle,
p_ref = reference_value(reference_pressure, pressure[particle], system, particle,
particle_position, t)
pressure[particle] = p_ref + 0.5 * (J2 + J3)

v_ref = reference_value(reference_velocity, v, system, particle,
v_current = current_velocity(v, system, particle)
v_ref = reference_value(reference_velocity, v_current, system, particle,
particle_position, t)
rho = density[particle]
v_ = v_ref + ((J2 - J3) / (2 * sound_speed * rho)) * flow_direction
Expand Down
10 changes: 2 additions & 8 deletions src/schemes/boundary/open_boundary/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,9 @@ function reference_value(value::Function, quantity, system, particle, position,
return value(position, t)
end

# These methods are used when extrapolating quantities from the domain
# This method is used when extrapolating quantities from the domain
# instead of using the method of characteristics
function reference_value(value::Nothing, quantity::Vector, system, particle, position, t)
return quantity[particle]
end

function reference_value(value::Nothing, quantity::PtrArray, system, particle, position, t)
return current_velocity(quantity, system, particle)
end
reference_value(value::Nothing, quantity, system, particle, position, t) = quantity

function check_reference_values!(boundary_model::BoundaryModelLastiwka,
reference_density, reference_pressure, reference_velocity)
Expand Down
38 changes: 22 additions & 16 deletions test/systems/open_boundary_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
buffer_size=0,
fluid_system=FluidSystemMock2(),
reference_density=0,
reference_velocity=[
1.0,
1.0,
],
reference_velocity=[1.0,
1.0],
reference_pressure)

error_str = "`reference_density` must be either a function mapping " *
Expand All @@ -49,10 +47,8 @@
buffer_size=0,
fluid_system=FluidSystemMock2(),
reference_density,
reference_velocity=[
1.0,
1.0,
],
reference_velocity=[1.0,
1.0],
reference_pressure=0)
end
@testset "`show`" begin
Expand Down Expand Up @@ -81,12 +77,17 @@
│ boundary model: ……………………………………… BoundaryModelLastiwka │
│ boundary: ……………………………………………………… InFlow │
│ flow direction: ……………………………………… [1.0, 0.0] │
│ prescribed velocity: ………………………… #f3
│ prescribed pressure: ………………………… #f2
│ prescribed density: …………………………… #f1
│ prescribed velocity: ………………………… #f
│ prescribed pressure: ………………………… #f
│ prescribed density: …………………………… #f
│ width: ……………………………………………………………… 0.2 │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘"""
@test repr("text/plain", system) == show_box

result = repr("text/plain", system)
# Remove numbers like `#f1#83`
result = replace(result, r"#f\d#.*|" => "#f |")

@test result == show_box

outflow = OutFlow(; plane=([0.0, 0.0], [0.0, 1.0]), particle_spacing=0.05,
flow_direction=(1.0, 0.0), density=1.0, open_boundary_layers=4)
Expand All @@ -109,11 +110,16 @@
│ boundary model: ……………………………………… BoundaryModelLastiwka │
│ boundary: ……………………………………………………… OutFlow │
│ flow direction: ……………………………………… [1.0, 0.0] │
│ prescribed velocity: ………………………… #f3
│ prescribed pressure: ………………………… #f2
│ prescribed density: …………………………… #f1
│ prescribed velocity: ………………………… #f
│ prescribed pressure: ………………………… #f
│ prescribed density: …………………………… #f
│ width: ……………………………………………………………… 0.2 │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘"""
@test repr("text/plain", system) == show_box

result = repr("text/plain", system)
# Remove numbers like `#f1#83`
result = replace(result, r"#f\d#.*|" => "#f |")

@test result == show_box
end
end

0 comments on commit 05e811a

Please sign in to comment.