Skip to content

Commit

Permalink
Merge pull request #131 from weymouth/flow_time
Browse files Browse the repository at this point in the history
Added time(::Flow) and fixed shift function float types
  • Loading branch information
b-fg authored Jun 20, 2024
2 parents 1882eae + 000898b commit eb3a04a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/Flow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ struct Flow{D, T, Sf<:AbstractArray{T}, Vf<:AbstractArray{T}, Tf<:AbstractArray{
end
end

"""
time(a::Flow)
Current flow time.
"""
time(a::Flow) = sum(@view(a.Δt[1:end-1]))

function BDIM!(a::Flow)
dt = a.Δt[end]
@loop a.f[Ii] = a.u⁰[Ii]+dt*a.f[Ii]-a.V[Ii] over Ii in CartesianIndices(a.f)
Expand Down
2 changes: 1 addition & 1 deletion src/WaterLily.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct Simulation
end
end

time(sim::Simulation) = sum(@view(sim.flow.Δt[1:end-1]))
time(sim::Simulation) = time(sim.flow)
"""
sim_time(sim::Simulation)
Expand Down
2 changes: 1 addition & 1 deletion src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@ function interp(x::SVector{D}, arr::AbstractArray{T,D}) where {D,T}
end
function interp(x::SVector{D}, varr::AbstractArray) where {D}
# Shift to align with each staggered grid component and interpolate
@inline shift(i) = SVector{D}(ifelse(i==j,0.5f0,0f0) for j in 1:D)
@inline shift(i) = SVector{D}(ifelse(i==j,0.5,0.0) for j in 1:D)
return SVector{D}(interp(x+shift(i),@view(varr[..,i])) for i in 1:D)
end

0 comments on commit eb3a04a

Please sign in to comment.