Skip to content

Commit

Permalink
Further breakthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedSalih3d committed Apr 6, 2024
1 parent 7c5ad66 commit 2bda11c
Show file tree
Hide file tree
Showing 3 changed files with 1,529 additions and 24 deletions.
11 changes: 6 additions & 5 deletions example/Dambreak2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ function ComputeInteractions!(SimMetaData, SimConstants, Position, KernelThreade
ρⱼᵢᴴ = InverseHydrostaticEquationOfState(ρ₀, Pⱼᵢᴴ, Cb⁻¹)

ρⱼᵢ = ρⱼ - ρᵢ
MLcond = MotionLimiter[i] * MotionLimiter[j]
ddt_symmetric_term = δᵩ * h * c₀ * 2 * invd²η² * dot(-xᵢⱼ, ∇ᵢWᵢⱼ) #* MLcond
Dᵢ = ddt_symmetric_term * (m₀/ρⱼ) * ( ρⱼᵢ - ρᵢⱼᴴ) * MLcond
Dⱼ = ddt_symmetric_term * (m₀/ρᵢ) * (-ρⱼᵢ - ρⱼᵢᴴ) * MLcond
ddt_symmetric_term = δᵩ * h * c₀ * 2 * invd²η² * dot(-xᵢⱼ, ∇ᵢWᵢⱼ)
Dᵢ = ddt_symmetric_term * (m₀/ρⱼ) * ( ρⱼᵢ - ρᵢⱼᴴ) * MotionLimiter[i]
Dⱼ = ddt_symmetric_term * (m₀/ρᵢ) * (-ρⱼᵢ - ρⱼᵢᴴ) * MotionLimiter[j]
else
Dᵢ = 0.0
Dⱼ = 0.0
Expand Down Expand Up @@ -155,6 +154,8 @@ 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 @@ -331,7 +332,7 @@ let

@profview RunSimulation(
FluidCSV = "./input/dam_break_2d/DamBreak2d_Dp0.02_Fluid_OneLayer.csv",
BoundCSV = "./input/dam_break_2d/DamBreak2d_Dp0.02_Bound_OneLayer.csv",
BoundCSV = "./input/dam_break_2d/DamBreak2d_Dp0.02_Bound_ThreeLayers.csv",
SimMetaData = SimMetaDataDamBreak,
SimConstants = SimConstantsDamBreak,
SimLogger = SimLogger
Expand Down
26 changes: 7 additions & 19 deletions example/StillWedge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ function ComputeInteractions!(SimMetaData, SimConstants, Position, KernelThreade
ρⱼᵢᴴ = InverseHydrostaticEquationOfState(ρ₀, Pⱼᵢᴴ, Cb⁻¹)

ρⱼᵢ = ρⱼ - ρᵢ
MLcond = MotionLimiter[i] * MotionLimiter[j]
ddt_symmetric_term = δᵩ * h * c₀ * 2 * invd²η² * dot(-xᵢⱼ, ∇ᵢWᵢⱼ) #* MLcond
Dᵢ = ddt_symmetric_term * (m₀/ρⱼ) * ( ρⱼᵢ - ρᵢⱼᴴ) * MLcond
Dⱼ = ddt_symmetric_term * (m₀/ρᵢ) * (-ρⱼᵢ - ρⱼᵢᴴ) * MLcond
ddt_symmetric_term = δᵩ * h * c₀ * 2 * invd²η² * dot(-xᵢⱼ, ∇ᵢWᵢⱼ)
Dᵢ = ddt_symmetric_term * (m₀/ρⱼ) * ( ρⱼᵢ - ρᵢⱼᴴ) * MotionLimiter[i]
Dⱼ = ddt_symmetric_term * (m₀/ρᵢ) * (-ρⱼᵢ - ρⱼᵢᴴ) * MotionLimiter[i]
else
Dᵢ = 0.0
Dⱼ = 0.0
Expand Down Expand Up @@ -169,7 +168,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 @@ -178,7 +177,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 @@ -318,9 +317,9 @@ let
SimMetaDataWedge = SimulationMetaData{Dimensions,FloatType}(
SimulationName="Test",
SaveLocation="E:/SecondApproach/TESTING_CPU",
SimulationTime=4,
SimulationTime=1,
OutputEach=0.01,
FlagDensityDiffusion=false,
FlagDensityDiffusion=true,
FlagOutputKernelValues=false,
FlagLog=true
)
Expand All @@ -329,20 +328,9 @@ let

SimLogger = SimulationLogger(SimMetaDataWedge.SaveLocation)

#Remove '@profview' if you do not want VS Code timers
# println(@report_opt target_modules=(@__MODULE__,) RunSimulation(
# FluidCSV = "./input/still_wedge/StillWedge_Dp0.02_Fluid.csv",
# BoundCSV = "./input/still_wedge/StillWedge_Dp0.02_Bound.csv",
# SimMetaData = SimMetaDataWedge,
# SimConstants = SimConstantsWedge,
# SimLogger = SimLogger,
# ))

@profview RunSimulation(
FluidCSV = "./input/still_wedge/StillWedge_Dp0.02_Fluid.csv",
BoundCSV = "./input/still_wedge/StillWedge_Dp0.02_Bound.csv",
# FluidCSV = "./input/dam_break_2d/DamBreak2d_Dp0.02_Fluid.csv",
# BoundCSV = "./input/dam_break_2d/DamBreak2d_Dp0.02_Bound.csv",
SimMetaData = SimMetaDataWedge,
SimConstants = SimConstantsWedge,
SimLogger = SimLogger
Expand Down
Loading

0 comments on commit 2bda11c

Please sign in to comment.