Skip to content

Commit

Permalink
Only sum inside pressure contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
weymouth committed Dec 16, 2023
1 parent 7cd9fcc commit bd88748
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Metrics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Surface normal integral of field `p` over the `body`.
"""
function ∮nds(p::AbstractArray{T,N},df::AbstractArray{T},body::AbstractBody,t=0) where {T,N}
@loop df[I,:] = p[I]*nds(body,loc(0,I,T),t) over I inside(p)
reshape(sum(df,dims=1:N),N) |> Array
[sum(@inbounds(df[inside(p),i])) for i 1:N] |> Array
end
@inline function nds(body::AbstractBody,x,t)
d,n,_ = measure(body,x,t)
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ using StaticArrays
function get_flow(N,f)
a = Flow((N,N),(1.,0.);f,T=Float32)
@inside a.p[I] = loc(0, I)[2]
sdf(x,t) = sum(abs2,x.-(N÷2+0.5))-N÷4
sdf(x,t) = sum(abs2,x.-(N/2))-N÷4
map(x,t) = x.-SVector(t,0)
body = AutoBody(sdf,map)
WaterLily.measure!(a,body)
Expand Down Expand Up @@ -264,7 +264,7 @@ import WaterLily: ×
N = 32
a,body = get_flow(N,f)
force = WaterLily.∮nds(a.p,a.V,body)
@test sum(abs,force/*(N÷4)^2) - [0,1]) < 1e-2
@test sum(abs,force/*(N/4)^2) - [0,1]) < 2e-3
end
end

Expand Down

0 comments on commit bd88748

Please sign in to comment.