Skip to content

Commit

Permalink
fallback for no vortices
Browse files Browse the repository at this point in the history
  • Loading branch information
AshtonSBradley committed Dec 29, 2023
1 parent f1b4969 commit 2c56028
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/detection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ function findvortices(psi::Field;periodic=false)
if periodic
Lx,Ly = last(x)-first(x),last(y)-first(y)
vdat = vortex_array(vort)
xx,yy,qq = vdat[:,1],vdat[:,2],vdat[:,3]
@. xx[xx>Lx/2] -= Lx
@. xx[xx<-Lx/2] += Lx
@. yy[yy>Ly/2] -= Ly
@. yy[yy<-Lx/2] += Ly
vort = PointVortex.(xx,yy,qq)
if size(vdat) != (0,0)
xx,yy,qq = vdat[:,1],vdat[:,2],vdat[:,3]
@. xx[xx>Lx/2] -= Lx
@. xx[xx<-Lx/2] += Lx
@. yy[yy>Ly/2] -= Ly
@. yy[yy<-Lx/2] += Ly
vort = PointVortex.(xx,yy,qq)
else
end
end
return vort
end
Expand Down
8 changes: 8 additions & 0 deletions test/no_vortex_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# simple test field
using VortexDistributions, Test
Nx = 400; Ny = 400
Lx = 200; Ly = Lx
x = LinRange(-Lx/2,Lx/2, Nx+1)[1:end-1]; y = LinRange(-Ly/2,Ly/2, Ny+1)[1:end-1];
psi = one.(x*y') |> complex

vfound = findvortices(Torus(psi,x,y), periodic=true)

0 comments on commit 2c56028

Please sign in to comment.