Skip to content

Commit 1118a07

Browse files
authored
Merge pull request #199 from WaterLily-jl/fix_conv_diff
Fix FP64 operations on `conv_diff`
2 parents 6bb77c2 + 6f0db2b commit 1118a07

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Flow.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@inline (a,I::CartesianIndex{d},f::AbstractArray{T,d}) where {T,d} = @inbounds f[I]-f[I-δ(a,I)]
22
@inline (a,I::CartesianIndex{m},u::AbstractArray{T,n}) where {T,n,m} = @inbounds u[I+δ(a,I),a]-u[I,a]
3-
@inline ϕ(a,I,f) = @inbounds (f[I]+f[I-δ(a,I)])*0.5
3+
@inline ϕ(a,I,f) = @inbounds (f[I]+f[I-δ(a,I)])/2
44
@fastmath quick(u,c,d) = median((5c+2d-u)/6,c,median(10c-9u,c,d))
55
@fastmath vanLeer(u,c,d) = (cmin(u,d) || cmax(u,d)) ? c : c+(d-c)*(c-u)/(d-u)
66
@inline ϕu(a,I,f,u,λ=quick) = @inbounds u>0 ? u*λ(f[I-2δ(a,I)],f[I-δ(a,I)],f[I]) : u*λ(f[I+δ(a,I)],f[I],f[I-δ(a,I)])
@@ -34,7 +34,7 @@ function median(a,b,c)
3434
end
3535

3636
function conv_diff!(r,u,Φ;ν=0.1,perdir=())
37-
r .= 0.
37+
r .= zero(eltype(r))
3838
N,n = size_u(u)
3939
for i 1:n, j 1:n
4040
# if it is periodic direction
@@ -109,7 +109,7 @@ struct Flow{D, T, Sf<:AbstractArray{T}, Vf<:AbstractArray{T}, Tf<:AbstractArray{
109109
fv, p, σ = zeros(T, Nd) |> f, zeros(T, Ng) |> f, zeros(T, Ng) |> f
110110
V, μ₀, μ₁ = zeros(T, Nd) |> f, ones(T, Nd) |> f, zeros(T, Ng..., D, D) |> f
111111
BC!(μ₀,ntuple(zero, D),false,perdir)
112-
new{D,T,typeof(p),typeof(u),typeof(μ₁)}(u,u⁰,fv,p,σ,V,μ₀,μ₁,uBC,T[Δt],ν,g,exitBC,perdir)
112+
new{D,T,typeof(p),typeof(u),typeof(μ₁)}(u,u⁰,fv,p,σ,V,μ₀,μ₁,uBC,T[Δt],T(ν),g,exitBC,perdir)
113113
end
114114
end
115115

0 commit comments

Comments
 (0)