@@ -25,17 +25,26 @@ struct NKPanelSystem{B,L,T,M} <: AbstractPanelSystem
2525 mirrors:: M
2626end
2727function NKPanelSystem(body; Umag= 1 , ℓ= 1 , sym_axes= ())
28- any(components(body . x, 3 ) .≥ 0 ) && throw(ArgumentError(" NK panels must be below z=0" ))
28+ any(x -> x[ 3 ] ≥ 0 ,body . x ) && throw(ArgumentError(" NK panels must be below z=0" ))
2929 NKPanelSystem(Table(body,q= zeros_like(body. dA)), ℓ, SA[- abs(Umag),0 ,0 ], mirrors(sym_axes... ))
3030end
3131Base. show(io:: IO , sys:: NKPanelSystem ) = println(io, " NKPanelSystem($(length(sys. body)) panels, ℓ=$(sys. ℓ) )" )
3232Base. show(io:: IO , :: MIME"text/plain" , sys:: NKPanelSystem ) = (
3333 println(io," NKPanelSystem" ); println(io," Froude length ℓ: $(sys. ℓ) " ); abstract_show(io,sys))
3434
3535# Overload with Neumann-Kelvin potential
36- Φ(x,sys:: NKPanelSystem ) = sum(m-> sum(p-> p. q* ∫NK(x .* m,p,sys. ℓ),sys. body),sys. mirrors)
37- influence(sys:: NKPanelSystem ) = influence(sys. body,sys. mirrors,(x,p)-> ∫NK(x,p,sys. ℓ))
38- @inline ∫NK(x,p,ℓ) = ∫G(x,p)- ∫G(x .* SA[1 ,1 ,- 1 ],p)+ p. dA* kelvin(x,p. x;ℓ)
36+ Φ(x,sys:: NKPanelSystem ) = sum(m-> sum(p-> p. q* ∫NK(x .* m,p,ℓ= sys. ℓ),sys. body),sys. mirrors)
37+ influence(sys:: NKPanelSystem ) = influence(sys. body,sys. mirrors,(x,p)-> ∫NK(x,p,ℓ= sys. ℓ))
38+ @inline function ∫NK(x,p;ℓ,filter= true ,contour= false )
39+ # Waterline contour factor ℓ∫n₁dy
40+ dy = extent(components(p. verts,2 )); dl = hypot(extent(components(p. verts,1 )),dy)
41+ c = contour && onwaterline(p) ? 1 - ℓ* dy^ 2 / (dl* p. dA) : one(dy)
42+ c < 0 && @warn " Waterline ℓ∫n₁dy > ∫da" maxlog= 2
43+ # Evaluate potential with kelvin(x,y,z ≤ -dl) to filter unresolved waves
44+ z_max = filter ? - dl : - 0.
45+ ∫G(x,p)- ∫G(x .* SA[1 ,1 ,- 1 ],p)+ p. dA* kelvin(x,p. x;ℓ,z_max)* c
46+ end
47+ @inline onwaterline(p) = any(x-> x[3 ]≥ 0 ,p. verts)
3948
4049"""
4150 kelvin(ξ,α;ℓ)
8493Ngk(X:: SVector{3} ) = Ngk(X... )
8594
8695# Wave-like disturbance
87- function wavelike(x,y,z)
88- (x≥ 0 || z≤ - 10 ) && return 0.
96+ function wavelike(x:: T ,y :: T ,z :: T ) :: T where T
97+ (x≥ 0 || z≤ - 10 ) && return zero(T)
8998 S = stationary_points(x,y) # g'=0 points
9099 rngs = finite_ranges(S,t-> g(x,y,t),6 ,√ (- 10 / z- 1 )) # finite phase ranges
91100 4 complex_path(t-> g(x,y,t)- im* z* (1 + t^ 2 ), # complex phase
0 commit comments