Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/SPHCellList.jl
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,11 @@ using LinearAlgebra
kernel_acc, kernel_grad_acc = compute_kernel_output_local(SimMetaData, kernel_acc, kernel_grad_acc, SimKernel, q, ∇ᵢWᵢⱼ)

MotionLimiterCondition = MotionLimiterValue(eltype(ρᵢ), ParticleType[i]) * MotionLimiterValue(eltype(ρᵢ), ParticleType[j])
shift_c_acc += (m₀ / ρᵢ) * ∇ᵢWᵢⱼ
shift_r_acc += (m₀ / ρⱼ) * dot(-xᵢⱼ, ∇ᵢWᵢⱼ) * MotionLimiterCondition
kernel_value = @fastpow Wᵢⱼ(SimKernel, q)
w_ref = @fastpow Wᵢⱼ(SimKernel, dx * h⁻¹)
correction = one(T) + T(0.2) * (kernel_value / w_ref)^T(4)
shift_weight = (m₀ / ρᵢ) * (m₀ / (ρᵢ + ρⱼ)) * correction * kernel_value
shift_c_acc += shift_weight * xᵢⱼ * MotionLimiterCondition
end

return dρdt_acc, acc_acc, kernel_acc, kernel_grad_acc, shift_c_acc, shift_r_acc
Expand Down Expand Up @@ -562,8 +565,11 @@ using LinearAlgebra
acc_acc += dvdt⁺ + visc_term

MotionLimiterCondition = MotionLimiterValue(eltype(ρᵢ), ParticleType[i]) * MotionLimiterValue(eltype(ρᵢ), ParticleType[j])
shift_c_acc += (m₀ / ρᵢ) * ∇ᵢWᵢⱼ
shift_r_acc += (m₀ / ρⱼ) * dot(-xᵢⱼ, ∇ᵢWᵢⱼ) * MotionLimiterCondition
kernel_value = @fastpow Wᵢⱼ(SimKernel, q)
w_ref = @fastpow Wᵢⱼ(SimKernel, dx * h⁻¹)
correction = one(T) + T(0.2) * (kernel_value / w_ref)^T(4)
shift_weight = (m₀ / ρᵢ) * (m₀ / (ρᵢ + ρⱼ)) * correction * kernel_value
shift_c_acc += shift_weight * xᵢⱼ * MotionLimiterCondition
end

return dρdt_acc, acc_acc, shift_c_acc, shift_r_acc
Expand Down
2 changes: 2 additions & 0 deletions src/SimulationConstantsConfiguration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SimulationConstants is a parameterized struct representing the constants and par
- `dt::T`: Initial time step. Default is 1e-5.
- `δᵩ::T`: Coefficient for density diffusion. Default is 0.1.
- `CFL::T`: CFL (Courant-Friedrichs-Lewy) number (positive). Default is 0.2.
- `ShiftCFL::T`: CFL value used for shifting (positive). Default is 0.2.
- `η²::T`: Eta squared (positive). Default is computed as `(0.01 * H)^2`.

# Example
Expand All @@ -44,6 +45,7 @@ constants = SimulationConstants(ρ₀=1017, dx=0.03, α=0.02)
γ⁻¹::T = 1/γ ; @assert γ⁻¹ > 0 "Inverse adiabatic index (γ⁻¹) must be positive"
δᵩ::T = 0.1 ; @assert δᵩ > 0 "Density variation (δᵩ) must be positive"
CFL::T = 0.2 ; @assert CFL > 0 "CFL condition (CFL) must be positive"
ShiftCFL::T = 0.2 ; @assert ShiftCFL > 0 "Shift CFL condition (ShiftCFL) must be positive"
Cb::T = (c₀^2 * ρ₀)/γ ; @assert Cb >= 0 "Cb (pressure coefficient) must be positive"
Cb⁻¹::T = inv(Cb) ; @assert Cb⁻¹>= 0 "Inverse Cb (inverse pressure coefficient) must be positive"
ν₀::T = 1e-6 ; @assert ν₀ >= 0 "Kinematic viscosity must be positive"
Expand Down
15 changes: 6 additions & 9 deletions src/TimeStepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,18 @@ function FullTimeStep(::SimulationMetaData{D,T,S,K,B,L}, SimKernel, SimConstants
@unpack Position, Velocity, Acceleration = SimParticles
ParticleType = SimParticles.Type
AccelerationScalarType = eltype(eltype(Acceleration))
A = 2# Value between 1 to 6 advised
A_FST = 0; # zero for internal flows
A_FSM = length(first(Position)); #2d, 3d val different
max_velocity = zero(eltype(eltype(Velocityₙ⁺)))
@inbounds for i in eachindex(Velocityₙ⁺)
max_velocity = max(max_velocity, norm(Velocityₙ⁺[i]))
end
shift_scale = -SimConstants.ShiftCFL * (max_velocity / SimConstants.c₀) * (2 * SimKernel.h)^2
@inbounds @simd ivdep for i in eachindex(Position)
MotionLimiterFactor = MotionLimiterValue(AccelerationScalarType, ParticleType[i])
GravityFactor = GravityFactorValue(AccelerationScalarType, ParticleType[i])
Acceleration[i] += ConstructGravitySVector(Acceleration[i], SimConstants.g * GravityFactor)
Velocity[i] += Acceleration[i] * dt * MotionLimiterFactor

A_FSC = (∇◌rᵢ[i] - A_FST)/(A_FSM - A_FST)
if A_FSC < 0
δxᵢ = zero(eltype(Position))
else
δxᵢ = -A_FSC * A * SimKernel.h * norm(Velocityₙ⁺[i]) * dt * ∇Cᵢ[i]
end
δxᵢ = shift_scale * ∇Cᵢ[i]

Position[i] += (Velocityₙ⁺[i] * dt + δxᵢ) * MotionLimiterFactor
end
Expand Down