Skip to content

Commit f7826d7

Browse files
authored
Merge branch 'main' into validate-open-boundaries
2 parents 4d9c5c7 + 5ad3e6e commit f7826d7

8 files changed

Lines changed: 176 additions & 45 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ FastPow = "0.1"
5050
FileIO = "1"
5151
ForwardDiff = "1"
5252
GPUArraysCore = "0.2"
53-
JSON = "0.21"
53+
JSON = "1"
5454
KernelAbstractions = "0.9"
5555
MuladdMacro = "0.2"
5656
OrdinaryDiffEq = "6.91"

src/TrixiParticles.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using ForwardDiff: ForwardDiff
1515
using GPUArraysCore: AbstractGPUArray
1616
using JSON: JSON
1717
using KernelAbstractions: KernelAbstractions, @kernel, @index
18-
using LinearAlgebra: norm, dot, I, tr, inv, pinv, det
18+
using LinearAlgebra: norm, normalize, cross, dot, I, tr, inv, pinv, det
1919
using MuladdMacro: @muladd
2020
using Polyester: Polyester, @batch
2121
using Printf: @printf, @sprintf

src/general/interpolation.jl

Lines changed: 89 additions & 39 deletions
Large diffs are not rendered by default.

src/schemes/fluid/shifting_techniques.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ end
596596
distance, grad_kernel, correction)
597597
end
598598

599+
# The function above misuses the pressure acceleration function by passing a Matrix as `p_a`.
600+
# This doesn't work with `tensile_instability_control`, so we disable TIC in this case.
601+
@inline function tensile_instability_control(m_a, m_b, rho_a, rho_b, p_a::SMatrix, p_b, W_a)
602+
return pressure_acceleration_continuity_density(m_a, m_b, rho_a, rho_b, p_a, A_b, W_a)
603+
end
604+
599605
function continuity_equation_shifting!(dv, shifting::TransportVelocityAdami{true},
600606
particle_system, neighbor_system,
601607
particle, neighbor, grad_kernel, rho_a, rho_b, m_b)

test/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ TrixiTest = "0a316866-cbd0-4425-8bcb-08103b2c1f26"
1717

1818
[compat]
1919
CSV = "0.10"
20-
CairoMakie = "0.13, 0.15"
20+
CairoMakie = "0.15"
2121
DataFrames = "1.6"
2222
GLM = "1.9"
2323
Glob = "1.3"
24-
JSON = "0.21"
24+
JSON = "1"
2525
OrdinaryDiffEq = "6.49"
2626
Plots = "1"
2727
Polyester = "0.7"

test/general/interpolation.jl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107

108108
boundary_model = BoundaryModelDummyParticles(bnd.density, bnd.mass,
109109
state_equation=state_equation,
110+
viscosity=viscosity,
110111
AdamiPressureExtrapolation(),
111112
smoothing_kernel, smoothing_length)
112113

@@ -552,6 +553,42 @@
552553
end
553554
end
554555
end
556+
557+
@testset verbose=true "Include Wall Velocity" begin
558+
# Define vertical interpolation line
559+
start_svector = SVector(0.0, 0.0)
560+
end_svector = SVector(0.0, 1.0)
561+
points_coords_ = range(start_svector, end_svector, length=10)
562+
points_coords = collect(reinterpret(reshape, eltype(start_svector),
563+
points_coords_))
564+
565+
# Linear velocity field for fluid and boundary
566+
v_fluid = InitialCondition(;
567+
coordinates=fluid_system.initial_condition.coordinates,
568+
density=1000.0, particle_spacing,
569+
velocity=(pos) -> SVector(0.0, pos[2])).velocity
570+
v_boundary = InitialCondition(; coordinates=boundary_system.coordinates,
571+
density=1000.0, particle_spacing,
572+
velocity=(pos) -> SVector(0.0, pos[2])).velocity
573+
574+
boundary_system.boundary_model.cache.wall_velocity .= v_boundary
575+
576+
v_ode = vcat(v_fluid, fluid.density')
577+
u_ode = fluid_system.initial_condition.coordinates
578+
579+
v_wall_velocity = interpolate_points(points_coords, semi_boundary,
580+
include_wall_velocity=true,
581+
fluid_system, v_ode, u_ode).velocity
582+
583+
v_no_wall_velocity = interpolate_points(points_coords, semi_boundary,
584+
include_wall_velocity=false,
585+
fluid_system, v_ode, u_ode).velocity
586+
587+
@test isapprox(v_wall_velocity[2, 1], 0.0; atol=eps())
588+
@test isapprox(v_no_wall_velocity[2, 1], 0.1; atol=eps())
589+
@test any(isapprox.(v_wall_velocity[:, 3:end], v_no_wall_velocity[:, 3:end],
590+
atol=eps()))
591+
end
555592
end
556593

557594
@testset verbose=true "3D" begin
@@ -621,6 +658,7 @@
621658

622659
boundary_model = BoundaryModelDummyParticles(bnd.density, bnd.mass,
623660
state_equation=state_equation,
661+
viscosity=viscosity,
624662
AdamiPressureExtrapolation(),
625663
smoothing_kernel, smoothing_length)
626664

@@ -883,5 +921,41 @@
883921
compare_interpolation_result(result, expected_res)
884922
end
885923
end
924+
925+
@testset verbose=true "Include Wall Velocity" begin
926+
# Define vertical interpolation line
927+
start_svector = SVector(0.0, 0.0, 0.0)
928+
end_svector = SVector(0.0, 1.0, 0.0)
929+
points_coords_ = range(start_svector, end_svector, length=10)
930+
points_coords = collect(reinterpret(reshape, eltype(start_svector),
931+
points_coords_))
932+
933+
# Linear velocity field for fluid and boundary
934+
v_fluid = InitialCondition(;
935+
coordinates=fluid_system.initial_condition.coordinates,
936+
density=1000.0, particle_spacing,
937+
velocity=(pos) -> SVector(0.0, pos[2], 0.0)).velocity
938+
v_boundary = InitialCondition(; coordinates=boundary_system.coordinates,
939+
density=1000.0, particle_spacing,
940+
velocity=(pos) -> SVector(0.0, pos[2], 0.0)).velocity
941+
942+
boundary_system.boundary_model.cache.wall_velocity .= v_boundary
943+
944+
v_ode = vcat(v_fluid, fluid.density')
945+
u_ode = fluid_system.initial_condition.coordinates
946+
947+
v_wall_velocity = interpolate_points(points_coords, semi_boundary,
948+
include_wall_velocity=true,
949+
fluid_system, v_ode, u_ode).velocity
950+
951+
v_no_wall_velocity = interpolate_points(points_coords, semi_boundary,
952+
include_wall_velocity=false,
953+
fluid_system, v_ode, u_ode).velocity
954+
955+
@test isapprox(v_wall_velocity[2, 1], 0.0; atol=eps())
956+
@test isapprox(v_no_wall_velocity[2, 1], 0.1; atol=eps())
957+
@test any(isapprox.(v_wall_velocity[:, 3:end], v_no_wall_velocity[:, 3:end],
958+
atol=eps()))
959+
end
886960
end
887961
end;

test/systems/iisph_system.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
time_step=0.001)
254254

255255
u0 = zeros(TrixiParticles.u_nvariables(system),
256-
TrixiParticles.n_moving_particles(system))
256+
TrixiParticles.n_integrated_particles(system))
257257
TrixiParticles.write_u0!(u0, system)
258258

259259
@test u0 == coordinates
@@ -279,7 +279,7 @@
279279
time_step=0.001)
280280

281281
v0 = zeros(TrixiParticles.v_nvariables(system),
282-
TrixiParticles.n_moving_particles(system))
282+
TrixiParticles.n_integrated_particles(system))
283283
TrixiParticles.write_v0!(v0, system)
284284

285285
@test v0 == velocity

test/systems/systems.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ include("boundary_system.jl")
55
include("open_boundary_system.jl")
66
include("dem_system.jl")
77
include("packing_system.jl")
8+
include("iisph_system.jl")

0 commit comments

Comments
 (0)