From f1c8ca66c09ba5c14584e0c58812e0168f4130a3 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Sat, 7 Jun 2025 22:29:37 +0200 Subject: [PATCH 1/5] fix --- src/schemes/fluid/entropically_damped_sph/system.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/schemes/fluid/entropically_damped_sph/system.jl b/src/schemes/fluid/entropically_damped_sph/system.jl index 0865f8227..39cf4796d 100644 --- a/src/schemes/fluid/entropically_damped_sph/system.jl +++ b/src/schemes/fluid/entropically_damped_sph/system.jl @@ -239,6 +239,10 @@ system_correction(system::EntropicallyDampedSPHSystem) = system.correction return v[end, particle] end +@inline function current_velocity(v, system::EntropicallyDampedSPHSystem) + return view(v, 1:ndims(system), :) +end + @inline system_state_equation(system::EntropicallyDampedSPHSystem) = nothing # WARNING! From 537f2fec5834cb7325044bf4fffa8711c24f3b11 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Wed, 11 Jun 2025 09:56:47 +0200 Subject: [PATCH 2/5] add tests --- test/systems/edac_system.jl | 3 +++ test/systems/wcsph_system.jl | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/systems/edac_system.jl b/test/systems/edac_system.jl index c49fe4806..761aabdfc 100644 --- a/test/systems/edac_system.jl +++ b/test/systems/edac_system.jl @@ -194,6 +194,9 @@ TrixiParticles.write_v0!(v0, system) @test v0 == vcat(velocity, pressure') + @test TrixiParticles.current_velocity(v0, system) == velocity + @test TrixiParticles.current_density(v0, system) == system.cache.density + @test TrixiParticles.current_pressure(v0, system) == pressure initial_condition = InitialCondition(; coordinates, velocity, mass, density, pressure=pressure_function) diff --git a/test/systems/wcsph_system.jl b/test/systems/wcsph_system.jl index 1b0387360..f2f20a724 100644 --- a/test/systems/wcsph_system.jl +++ b/test/systems/wcsph_system.jl @@ -267,6 +267,9 @@ TrixiParticles.write_v0!(v0, system) @test v0 == velocity + @test TrixiParticles.current_velocity(v0, system) == velocity + @test TrixiParticles.current_density(v0, system) == system.cache.density + @test TrixiParticles.current_pressure(v0, system) == system.pressure # ContinuityDensity system = WeaklyCompressibleSPHSystem(initial_condition, From 381172583efcf142339dd81f2fc37651434f1a03 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Wed, 11 Jun 2025 10:19:51 +0200 Subject: [PATCH 3/5] fix --- test/systems/edac_system.jl | 2 ++ test/systems/wcsph_system.jl | 3 +++ 2 files changed, 5 insertions(+) diff --git a/test/systems/edac_system.jl b/test/systems/edac_system.jl index 761aabdfc..424680abf 100644 --- a/test/systems/edac_system.jl +++ b/test/systems/edac_system.jl @@ -193,6 +193,8 @@ TrixiParticles.n_moving_particles(system)) TrixiParticles.write_v0!(v0, system) + system.cache.density .= density + @test v0 == vcat(velocity, pressure') @test TrixiParticles.current_velocity(v0, system) == velocity @test TrixiParticles.current_density(v0, system) == system.cache.density diff --git a/test/systems/wcsph_system.jl b/test/systems/wcsph_system.jl index f2f20a724..cf6020d06 100644 --- a/test/systems/wcsph_system.jl +++ b/test/systems/wcsph_system.jl @@ -266,6 +266,9 @@ TrixiParticles.n_moving_particles(system)) TrixiParticles.write_v0!(v0, system) + system.cache.density .= density + system.pressure .= zero(density) + @test v0 == velocity @test TrixiParticles.current_velocity(v0, system) == velocity @test TrixiParticles.current_density(v0, system) == system.cache.density From a21a5d9c8f6186049b63a4cfcef4fc4cc83f45c4 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Wed, 11 Jun 2025 11:00:52 +0200 Subject: [PATCH 4/5] only active particles --- src/schemes/fluid/entropically_damped_sph/system.jl | 6 +++--- src/schemes/fluid/weakly_compressible_sph/system.jl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/schemes/fluid/entropically_damped_sph/system.jl b/src/schemes/fluid/entropically_damped_sph/system.jl index 39cf4796d..80e87c2f7 100644 --- a/src/schemes/fluid/entropically_damped_sph/system.jl +++ b/src/schemes/fluid/entropically_damped_sph/system.jl @@ -240,7 +240,7 @@ system_correction(system::EntropicallyDampedSPHSystem) = system.correction end @inline function current_velocity(v, system::EntropicallyDampedSPHSystem) - return view(v, 1:ndims(system), :) + return view(v, 1:ndims(system), each_moving_particle(system)) end @inline system_state_equation(system::EntropicallyDampedSPHSystem) = nothing @@ -287,8 +287,8 @@ end return view(v, size(v, 1) - 1, :) end -@inline function current_pressure(v, ::EntropicallyDampedSPHSystem) - return view(v, size(v, 1), :) +@inline function current_pressure(v, system::EntropicallyDampedSPHSystem) + return view(v, size(v, 1), each_moving_particle(system)) end function update_quantities!(system::EntropicallyDampedSPHSystem, v, u, diff --git a/src/schemes/fluid/weakly_compressible_sph/system.jl b/src/schemes/fluid/weakly_compressible_sph/system.jl index 690803960..57cade516 100644 --- a/src/schemes/fluid/weakly_compressible_sph/system.jl +++ b/src/schemes/fluid/weakly_compressible_sph/system.jl @@ -261,7 +261,7 @@ end system::WeaklyCompressibleSPHSystem) # When using `ContinuityDensity`, the velocity is stored # in the first `ndims(system)` rows of `v`. - return view(v, 1:ndims(system), :) + return view(v, 1:ndims(system), each_moving_particle(system)) end @inline function current_density(v, system::WeaklyCompressibleSPHSystem) @@ -271,17 +271,17 @@ end @inline function current_density(v, ::SummationDensity, system::WeaklyCompressibleSPHSystem) # When using `SummationDensity`, the density is stored in the cache - return system.cache.density + return view(system.cache.density, each_moving_particle(system)) end @inline function current_density(v, ::ContinuityDensity, system::WeaklyCompressibleSPHSystem) # When using `ContinuityDensity`, the density is stored in the last row of `v` - return view(v, size(v, 1), :) + return view(v, size(v, 1), each_moving_particle(system)) end @inline function current_pressure(v, system::WeaklyCompressibleSPHSystem) - return system.pressure + return view(system.pressure, each_moving_particle(system)) end @inline system_sound_speed(system::WeaklyCompressibleSPHSystem) = system.state_equation.sound_speed From b4ff8f634f81074f265392f5527f28ceb36d1c53 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Wed, 11 Jun 2025 14:38:56 +0200 Subject: [PATCH 5/5] Revert "only active particles" This reverts commit a21a5d9c8f6186049b63a4cfcef4fc4cc83f45c4. --- src/schemes/fluid/entropically_damped_sph/system.jl | 6 +++--- src/schemes/fluid/weakly_compressible_sph/system.jl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/schemes/fluid/entropically_damped_sph/system.jl b/src/schemes/fluid/entropically_damped_sph/system.jl index 80e87c2f7..39cf4796d 100644 --- a/src/schemes/fluid/entropically_damped_sph/system.jl +++ b/src/schemes/fluid/entropically_damped_sph/system.jl @@ -240,7 +240,7 @@ system_correction(system::EntropicallyDampedSPHSystem) = system.correction end @inline function current_velocity(v, system::EntropicallyDampedSPHSystem) - return view(v, 1:ndims(system), each_moving_particle(system)) + return view(v, 1:ndims(system), :) end @inline system_state_equation(system::EntropicallyDampedSPHSystem) = nothing @@ -287,8 +287,8 @@ end return view(v, size(v, 1) - 1, :) end -@inline function current_pressure(v, system::EntropicallyDampedSPHSystem) - return view(v, size(v, 1), each_moving_particle(system)) +@inline function current_pressure(v, ::EntropicallyDampedSPHSystem) + return view(v, size(v, 1), :) end function update_quantities!(system::EntropicallyDampedSPHSystem, v, u, diff --git a/src/schemes/fluid/weakly_compressible_sph/system.jl b/src/schemes/fluid/weakly_compressible_sph/system.jl index 57cade516..690803960 100644 --- a/src/schemes/fluid/weakly_compressible_sph/system.jl +++ b/src/schemes/fluid/weakly_compressible_sph/system.jl @@ -261,7 +261,7 @@ end system::WeaklyCompressibleSPHSystem) # When using `ContinuityDensity`, the velocity is stored # in the first `ndims(system)` rows of `v`. - return view(v, 1:ndims(system), each_moving_particle(system)) + return view(v, 1:ndims(system), :) end @inline function current_density(v, system::WeaklyCompressibleSPHSystem) @@ -271,17 +271,17 @@ end @inline function current_density(v, ::SummationDensity, system::WeaklyCompressibleSPHSystem) # When using `SummationDensity`, the density is stored in the cache - return view(system.cache.density, each_moving_particle(system)) + return system.cache.density end @inline function current_density(v, ::ContinuityDensity, system::WeaklyCompressibleSPHSystem) # When using `ContinuityDensity`, the density is stored in the last row of `v` - return view(v, size(v, 1), each_moving_particle(system)) + return view(v, size(v, 1), :) end @inline function current_pressure(v, system::WeaklyCompressibleSPHSystem) - return view(system.pressure, each_moving_particle(system)) + return system.pressure end @inline system_sound_speed(system::WeaklyCompressibleSPHSystem) = system.state_equation.sound_speed