Skip to content

Commit

Permalink
Added custom CFL function.
Browse files Browse the repository at this point in the history
  • Loading branch information
b-fg committed Nov 14, 2024
1 parent 775c6bc commit 01cbf94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ end
Integrate the `Flow` one time step using the [Boundary Data Immersion Method](https://eprints.soton.ac.uk/369635/)
and the `AbstractPoisson` pressure solver to project the velocity onto an incompressible flow.
"""
@fastmath function mom_step!(a::Flow{N},b::AbstractPoisson) where N
@fastmath function mom_step!(a::Flow{N},b::AbstractPoisson; CFL_f=CFL) where N
a.u⁰ .= a.u; scale_u!(a,0)
# predictor u → u'
U = BCTuple(a.U,@view(a.Δt[1:end-1]),N)
Expand All @@ -165,7 +165,7 @@ and the `AbstractPoisson` pressure solver to project the velocity onto an incomp
accelerate!(a.f,a.Δt,a.g,a.U)
BDIM!(a); scale_u!(a,0.5); BC!(a.u,U,a.exitBC,a.perdir)
project!(a,b,0.5); BC!(a.u,U,a.exitBC,a.perdir)
push!(a.Δt,CFL(a))
push!(a.Δt,CFL_f(a))
end
scale_u!(a,scale) = @loop a.u[Ii] *= scale over Ii inside_u(size(a.p))

Expand Down
8 changes: 4 additions & 4 deletions src/WaterLily.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ Integrate the simulation `sim` up to dimensionless time `t_end`.
If `remeasure=true`, the body is remeasured at every time step.
Can be set to `false` for static geometries to speed up simulation.
"""
function sim_step!(sim::Simulation,t_end;remeasure=true,max_steps=typemax(Int),verbose=false)
function sim_step!(sim::Simulation,t_end;remeasure=true,max_steps=typemax(Int),verbose=false,CFL_f=CFL)
steps₀ = length(sim.flow.Δt)
while sim_time(sim) < t_end && length(sim.flow.Δt) - steps₀ < max_steps
sim_step!(sim; remeasure)
sim_step!(sim; remeasure, CFL_f)
verbose && println("tU/L=",round(sim_time(sim),digits=4),
", Δt=",round(sim.flow.Δt[end],digits=3))
end
end
function sim_step!(sim::Simulation;remeasure=true)
function sim_step!(sim::Simulation;remeasure=true,CFL_f=CFL)
remeasure && measure!(sim)
mom_step!(sim.flow,sim.pois)
mom_step!(sim.flow,sim.pois; CFL_f)
end

"""
Expand Down

0 comments on commit 01cbf94

Please sign in to comment.