Skip to content

Commit

Permalink
Remove soundspeed from openboundary system (#605)
Browse files Browse the repository at this point in the history
* remove soundspeed from OBS

* fix test

* fix tests

* fix tests

* remove system soundspeed from obs
  • Loading branch information
svchb authored Sep 26, 2024
1 parent c17a6ae commit ff9ef7a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/fluid/pipe_flow_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ end
inflow = InFlow(; plane=([0.0, 0.0], [0.0, domain_size[2]]), flow_direction,
open_boundary_layers, density=fluid_density, particle_spacing)

open_boundary_in = OpenBoundarySPHSystem(inflow; sound_speed, fluid_system,
open_boundary_in = OpenBoundarySPHSystem(inflow; fluid_system,
boundary_model=BoundaryModelLastiwka(),
buffer_size=n_buffer_particles,
reference_density=fluid_density,
Expand All @@ -98,7 +98,7 @@ outflow = OutFlow(; plane=([domain_size[1], 0.0], [domain_size[1], domain_size[2
flow_direction, open_boundary_layers, density=fluid_density,
particle_spacing)

open_boundary_out = OpenBoundarySPHSystem(outflow; sound_speed, fluid_system,
open_boundary_out = OpenBoundarySPHSystem(outflow; fluid_system,
boundary_model=BoundaryModelLastiwka(),
buffer_size=n_buffer_particles,
reference_density=fluid_density,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ struct BoundaryModelLastiwka end

@inline function update_quantities!(system, boundary_model::BoundaryModelLastiwka,
v, u, v_ode, u_ode, semi, t)
(; density, pressure, cache, flow_direction, sound_speed,
(; density, pressure, cache, flow_direction,
reference_velocity, reference_pressure, reference_density) = system

sound_speed = system_sound_speed(system.fluid_system)

# Update quantities based on the characteristic variables
@threaded system for particle in each_moving_particle(system)
particle_position = current_coords(u, system, particle)
Expand Down Expand Up @@ -112,7 +114,7 @@ end

function evaluate_characteristics!(system, neighbor_system::FluidSystem,
v, u, v_ode, u_ode, semi, t)
(; volume, sound_speed, cache, flow_direction, density, pressure,
(; volume, cache, flow_direction, density, pressure,
reference_velocity, reference_pressure, reference_density) = system
(; characteristics) = cache

Expand All @@ -123,6 +125,7 @@ function evaluate_characteristics!(system, neighbor_system::FluidSystem,

system_coords = current_coordinates(u, system)
neighbor_coords = current_coordinates(u_neighbor_system, neighbor_system)
sound_speed = system_sound_speed(system.fluid_system)

# Loop over all fluid neighbors within the kernel cutoff
foreach_point_neighbor(system, neighbor_system, system_coords, neighbor_coords,
Expand Down
8 changes: 3 additions & 5 deletions src/schemes/boundary/open_boundary/system.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@doc raw"""
OpenBoundarySPHSystem(boundary_zone::Union{InFlow, OutFlow}; sound_speed,
OpenBoundarySPHSystem(boundary_zone::Union{InFlow, OutFlow};
fluid_system::FluidSystem, buffer_size::Integer,
boundary_model,
reference_velocity=nothing,
Expand All @@ -12,7 +12,6 @@ Open boundary system for in- and outflow particles.
- `boundary_zone`: Use [`InFlow`](@ref) for an inflow and [`OutFlow`](@ref) for an outflow boundary.
# Keywords
- `sound_speed`: Speed of sound.
- `fluid_system`: The corresponding fluid system
- `boundary_model`: Boundary model (see [Open Boundary Models](@ref open_boundary_models))
- `buffer_size`: Number of buffer particles.
Expand All @@ -39,7 +38,6 @@ struct OpenBoundarySPHSystem{BM, BZ, NDIMS, ELTYPE <: Real, IC, FS, ARRAY1D, RV,
density :: ARRAY1D # Array{ELTYPE, 1}: [particle]
volume :: ARRAY1D # Array{ELTYPE, 1}: [particle]
pressure :: ARRAY1D # Array{ELTYPE, 1}: [particle]
sound_speed :: ELTYPE
boundary_zone :: BZ
flow_direction :: SVector{NDIMS, ELTYPE}
reference_velocity :: RV
Expand All @@ -50,7 +48,7 @@ struct OpenBoundarySPHSystem{BM, BZ, NDIMS, ELTYPE <: Real, IC, FS, ARRAY1D, RV,
cache :: C

function OpenBoundarySPHSystem(boundary_zone::Union{InFlow, OutFlow};
sound_speed, fluid_system::FluidSystem,
fluid_system::FluidSystem,
buffer_size::Integer, boundary_model,
reference_velocity=nothing,
reference_pressure=nothing,
Expand Down Expand Up @@ -109,7 +107,7 @@ struct OpenBoundarySPHSystem{BM, BZ, NDIMS, ELTYPE <: Real, IC, FS, ARRAY1D, RV,
typeof(reference_velocity_), typeof(reference_pressure_),
typeof(reference_density_), typeof(buffer),
typeof(cache)}(initial_condition, fluid_system, boundary_model, mass,
density, volume, pressure, sound_speed, boundary_zone,
density, volume, pressure, boundary_zone,
flow_direction_, reference_velocity_, reference_pressure_,
reference_density_, buffer, false, cache)
end
Expand Down
1 change: 0 additions & 1 deletion src/visualization/write2vtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ function write2vtk!(vtk, v, u, t, system::OpenBoundarySPHSystem; write_meta_data

if write_meta_data
vtk["boundary_zone"] = type2string(system.boundary_zone)
vtk["sound_speed"] = system.sound_speed
vtk["width"] = round(system.boundary_zone.zone_width, digits=3)
vtk["flow_direction"] = system.flow_direction
vtk["velocity_function"] = type2string(system.reference_velocity)
Expand Down
4 changes: 2 additions & 2 deletions test/general/buffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

inflow = InFlow(; plane=([0.0, 0.0], [0.0, 1.0]), particle_spacing=0.2,
open_boundary_layers=2, density=1.0, flow_direction=[1.0, 0.0])
system = OpenBoundarySPHSystem(inflow; sound_speed=1.0, fluid_system=FluidSystemMock3(),
system = OpenBoundarySPHSystem(inflow; fluid_system=FluidSystemMock3(),
reference_density=0.0, reference_pressure=0.0,
reference_velocity=[0, 0],
boundary_model=BoundaryModelLastiwka(), buffer_size=0)
system_buffer = OpenBoundarySPHSystem(inflow; sound_speed=1.0, buffer_size=5,
system_buffer = OpenBoundarySPHSystem(inflow; buffer_size=5,
reference_density=0.0, reference_pressure=0.0,
reference_velocity=[0, 0],
boundary_model=BoundaryModelLastiwka(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
density_calculator=ContinuityDensity(),
smoothing_length, sound_speed)

boundary_system = OpenBoundarySPHSystem(boundary_zone; sound_speed,
boundary_system = OpenBoundarySPHSystem(boundary_zone;
fluid_system, buffer_size=0,
boundary_model=BoundaryModelLastiwka(),
reference_velocity,
Expand Down
10 changes: 5 additions & 5 deletions test/systems/open_boundary_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"or, for a constant fluid velocity, a vector of length 2 for a 2D problem holding this velocity"

reference_velocity = 1.0
@test_throws ArgumentError(error_str) OpenBoundarySPHSystem(inflow; sound_speed=1.0,
@test_throws ArgumentError(error_str) OpenBoundarySPHSystem(inflow;
boundary_model=BoundaryModelLastiwka(),
buffer_size=0,
fluid_system=FluidSystemMock2(),
Expand All @@ -28,7 +28,7 @@
"a vector holding the pressure of each particle, or a scalar"

reference_pressure = [1.0, 1.0]
@test_throws ArgumentError(error_str) OpenBoundarySPHSystem(inflow; sound_speed=1.0,
@test_throws ArgumentError(error_str) OpenBoundarySPHSystem(inflow;
boundary_model=BoundaryModelLastiwka(),
buffer_size=0,
fluid_system=FluidSystemMock2(),
Expand All @@ -42,7 +42,7 @@
"a vector holding the density of each particle, or a scalar"

reference_density = [1.0, 1.0]
@test_throws ArgumentError(error_str) OpenBoundarySPHSystem(inflow; sound_speed=1.0,
@test_throws ArgumentError(error_str) OpenBoundarySPHSystem(inflow;
boundary_model=BoundaryModelLastiwka(),
buffer_size=0,
fluid_system=FluidSystemMock2(),
Expand All @@ -54,7 +54,7 @@
@testset "`show`" begin
inflow = InFlow(; 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)
system = OpenBoundarySPHSystem(inflow; sound_speed=1.0, buffer_size=0,
system = OpenBoundarySPHSystem(inflow; buffer_size=0,
boundary_model=BoundaryModelLastiwka(),
reference_density=0.0,
reference_pressure=0.0,
Expand Down Expand Up @@ -83,7 +83,7 @@

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)
system = OpenBoundarySPHSystem(outflow; sound_speed=1.0, buffer_size=0,
system = OpenBoundarySPHSystem(outflow; buffer_size=0,
boundary_model=BoundaryModelLastiwka(),
reference_density=0.0,
reference_pressure=0.0,
Expand Down

0 comments on commit ff9ef7a

Please sign in to comment.