Skip to content

Commit

Permalink
push soundSpeed.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
smarras79 committed Jul 17, 2024
1 parent f5c3e71 commit 61ff1c0
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/kernel/physics/soundSpeed.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
function soundSpeed(npoin, integrator)

#speed of sound
PhysConst = PhysicalConst{TFloat}()
ctmp = Float32(0.0)
c = Float32(0.0)
for i=1:npoin
ρ = integrator.u[i]
θ = integrator.u[3*npoin+i]
p = perfectGasLaw_ρθtoP(PhysConst; ρ=ρ, θ=θ)
c = sqrt(PhysConst.γ*p/ρ)
c = max(c, ctmp)
ctmp = c
end

return c

end

function computeCFL(npoin, dt, Δs, integrator, SD::NSD_2D)

#u
ieq = 2
idx = (ieq-1)*npoin
umax = maximum(integrator.u[idx+1:ieq*npoin])
#v
ieq = 3
idx = (ieq-1)*npoin
vmax = maximum(integrator.u[idx+1:ieq*npoin])

#velomax
velomax = max(umax, vmax)

#speed of sound
c = soundSpeed(npoin, integrator)

cfl_u = velomax*dt/Δs #Advective CFL
cfl_c = c*dt/Δs #Acoustic CFL

println(" # Advective CFL: ", cfl_u)
println(" # Acoustic CFL: ", cfl_c)

end

function computeCFL(npoin, dt, Δs, integrator, SD::NSD_3D)

#u
ieq = 2
idx = (ieq-1)*npoin
umax = maximum(integrator.u[idx+1:ieq*npoin])
#v
ieq = 3
idx = (ieq-1)*npoin
vmax = maximum(integrator.u[idx+1:ieq*npoin])
#w
ieq = 4
idx = (ieq-1)*npoin
vmax = maximum(integrator.u[idx+1:ieq*npoin])

#velomax
velomax = max(umax, vmax, wmax)

#speed of sound
c = soundSpeed(npoin, integrator)

cfl_u = velomax*dt/Δs #Advective CFL
cfl_c = c*dt/Δs #Acoustic CFL

println(" # Advective CFL: ", cfl_u)
println(" # Acoustic CFL: ", cfl_c)

end

0 comments on commit 61ff1c0

Please sign in to comment.