Skip to content

Commit b44a772

Browse files
committed
clean up influence
In the most annoying bug ever... Windows was only specializing on the closure function after recompiling influence. Before that, it was allocating absurdly. New version just brute forces the sum over i,j,m and rewrites the derivative explicitly. works on Windows without issue now.
1 parent 2857867 commit b44a772

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/NeumannKelvin.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export BodyPanelSystem,bodyarea,bodyvol
2020

2121
import AcceleratedKernels as AK # multi-threaded mapreduce,foreachindex
2222
include("panel_method.jl")
23-
export ∫G,∂ₙϕ,Φ,∇Φ,u,cₚ,steadyforce,addedmass
23+
export source,∫G,Φ,∇Φ,u,cₚ,steadyforce,addedmass
2424

2525
# Direct and matrix-free solver
2626
include("solvers.jl")
@@ -37,7 +37,7 @@ export FSPanelSystem,ζ
3737

3838
# Kelvin Green function definitions
3939
include("NKPanelSystem.jl")
40-
export NKPanelSystem,kelvin
40+
export NKPanelSystem,∫NK,kelvin
4141

4242
# General support functions
4343
components(data,i) = getindex.(data, i)

src/solvers.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ function directsolve!(sys;verbose=true)
7777
end
7878
influence((;body,mirrors)::AbstractPanelSystem) = influence(body,mirrors,∫G)
7979
function influence(body,mirrors,ϕ)
80-
ϕ_sym(x,p) = sum(m->ϕ(x .* m,p),mirrors)
81-
A = Array{eltype(body.dA)}(undef,length(body),length(body))
82-
AK.foraxes(A,2) do j
83-
@simd for i in axes(A,1)
84-
@inbounds A[i,j] = ∂ₙϕ(body[i],body[j];ϕ=ϕ_sym)
85-
end
86-
end; A
80+
A = zeros(length(body),length(body))
81+
AK.foraxes(A,2) do j; for m in mirrors, i in axes(A,1)
82+
@inbounds A[i,j] += derivative(t->ϕ(body.x[i] .* m + t*body.n[i], body[j]), 0)
83+
end; end; A
8784
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ using BenchmarkTools
9494
end
9595

9696
using LinearAlgebra
97+
using NeumannKelvin:∂ₙϕ
9798
@testset "panel_method.jl" begin
9899
S(θ₁,θ₂) = SA[cos(θ₂)*sin(θ₁),sin(θ₂)*sin(θ₁),cos(θ₁)]
99100
panels = measure.(S,[π/4,3π/4]'/4:π/2:2π,π/2/2,cubature=true) |> Table

0 commit comments

Comments
 (0)