Skip to content

Commit

Permalink
Fixed formulation, same as before tbh
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedSalih3d committed Apr 6, 2024
1 parent 2bda11c commit 719ba19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
15 changes: 8 additions & 7 deletions example/Dambreak2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ function ComputeInteractions!(SimMetaData, SimConstants, Position, KernelThreade
ρᵢⱼᴴ = InverseHydrostaticEquationOfState(ρ₀, Pᵢⱼᴴ, Cb⁻¹)
Pⱼᵢᴴ = -Pᵢⱼᴴ
ρⱼᵢᴴ = InverseHydrostaticEquationOfState(ρ₀, Pⱼᵢᴴ, Cb⁻¹)

ρⱼᵢ = ρⱼ - ρᵢ
ddt_symmetric_term = δᵩ * h * c₀ * 2 * invd²η² * dot(-xᵢⱼ, ∇ᵢWᵢⱼ)
Dᵢ = ddt_symmetric_term * (m₀/ρⱼ) * ( ρⱼᵢ - ρᵢⱼᴴ) * MotionLimiter[i]
Dⱼ = ddt_symmetric_term * (m₀/ρᵢ) * (-ρⱼᵢ - ρⱼᵢᴴ) * MotionLimiter[j]

Ψᵢⱼ = 2( ρⱼᵢ - ρᵢⱼᴴ) * (-xᵢⱼ)/(dᵢⱼ^2 + η²)
Ψⱼᵢ = 2(-ρⱼᵢ - ρⱼᵢᴴ) * ( xᵢⱼ)/(dᵢⱼ^2 + η²)

MLcond = MotionLimiter[i] * MotionLimiter[j]
Dᵢ = δᵩ * h * c₀ * (m₀/ρⱼ) * dot(Ψᵢⱼ , ∇ᵢWᵢⱼ) * MLcond
Dⱼ = δᵩ * h * c₀ * (m₀/ρᵢ) * dot(Ψⱼᵢ , -∇ᵢWᵢⱼ) * MLcond
else
Dᵢ = 0.0
Dⱼ = 0.0
Expand Down Expand Up @@ -154,8 +158,6 @@ end
# IndexCounter = findfirst(isequal(0), ParticleRanges) - 2
# end

@timeit SimMetaData.HourGlass "09 Final LimitDensityAtBoundary" LimitDensityAtBoundary!(Density, SimConstants.ρ₀, MotionLimiter)

@timeit SimMetaData.HourGlass "03 ResetArrays" ResetArrays!(Kernel, KernelGradient, dρdtI, Acceleration); ResetArrays!.(KernelThreaded, KernelGradientThreaded, dρdtIThreaded, AccelerationThreaded)

Pressure!(SimParticles.Pressure,SimParticles.Density,SimConstants)
Expand Down Expand Up @@ -311,7 +313,6 @@ function RunSimulation(;FluidCSV::String,
end
end


let
Dimensions = 2
FloatType = Float64
Expand Down
17 changes: 10 additions & 7 deletions example/StillWedge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ function ComputeInteractions!(SimMetaData, SimConstants, Position, KernelThreade
ρᵢⱼᴴ = InverseHydrostaticEquationOfState(ρ₀, Pᵢⱼᴴ, Cb⁻¹)
Pⱼᵢᴴ = -Pᵢⱼᴴ
ρⱼᵢᴴ = InverseHydrostaticEquationOfState(ρ₀, Pⱼᵢᴴ, Cb⁻¹)

ρⱼᵢ = ρⱼ - ρᵢ
ddt_symmetric_term = δᵩ * h * c₀ * 2 * invd²η² * dot(-xᵢⱼ, ∇ᵢWᵢⱼ)
Dᵢ = ddt_symmetric_term * (m₀/ρⱼ) * ( ρⱼᵢ - ρᵢⱼᴴ) * MotionLimiter[i]
Dⱼ = ddt_symmetric_term * (m₀/ρᵢ) * (-ρⱼᵢ - ρⱼᵢᴴ) * MotionLimiter[i]

Ψᵢⱼ = 2( ρⱼᵢ - ρᵢⱼᴴ) * (-xᵢⱼ)/(dᵢⱼ^2 + η²)
Ψⱼᵢ = 2(-ρⱼᵢ - ρⱼᵢᴴ) * ( xᵢⱼ)/(dᵢⱼ^2 + η²)

MLcond = MotionLimiter[i] * MotionLimiter[j]
Dᵢ = δᵩ * h * c₀ * (m₀/ρⱼ) * dot(Ψᵢⱼ , ∇ᵢWᵢⱼ) * MLcond
Dⱼ = δᵩ * h * c₀ * (m₀/ρᵢ) * dot(Ψⱼᵢ , -∇ᵢWᵢⱼ) * MLcond
else
Dᵢ = 0.0
Dⱼ = 0.0
Expand Down Expand Up @@ -168,7 +172,7 @@ end
ρₙ⁺[i] = Density[i] + dρdtI[i] * dt₂
end

# @timeit SimMetaData.HourGlass "06 Half LimitDensityAtBoundary" LimitDensityAtBoundary!(ρₙ⁺, SimConstants.ρ₀, MotionLimiter)
@timeit SimMetaData.HourGlass "06 Half LimitDensityAtBoundary" LimitDensityAtBoundary!(ρₙ⁺, SimConstants.ρ₀, MotionLimiter)

@timeit SimMetaData.HourGlass "07 ResetArrays" ResetArrays!(Kernel, KernelGradient, dρdtI, Acceleration); ResetArrays!.(KernelThreaded, KernelGradientThreaded, dρdtIThreaded, AccelerationThreaded)

Expand All @@ -177,7 +181,7 @@ end
@timeit SimMetaData.HourGlass "08A Reduction" reduce_sum!(dρdtI, dρdtIThreaded)
@timeit SimMetaData.HourGlass "08B Reduction" reduce_sum!(Acceleration, AccelerationThreaded)

# @timeit SimMetaData.HourGlass "09 Final LimitDensityAtBoundary" LimitDensityAtBoundary!(Density, SimConstants.ρ₀, MotionLimiter)
@timeit SimMetaData.HourGlass "09 Final LimitDensityAtBoundary" LimitDensityAtBoundary!(Density, SimConstants.ρ₀, MotionLimiter)

@timeit SimMetaData.HourGlass "10 Final Density" DensityEpsi!(Density, dρdtI, ρₙ⁺, dt)

Expand Down Expand Up @@ -309,7 +313,6 @@ function RunSimulation(;FluidCSV::String,
end
end


let
Dimensions = 2
FloatType = Float64
Expand Down

0 comments on commit 719ba19

Please sign in to comment.