Co-rotating vortices


In [1]:
using ViscousFlow

In [2]:
using Plots
pyplot()
clibrary(:colorbrewer)
default(grid = false)

Set up a grid and a Reynolds number


In [3]:
xlim = (-2,2); ylim = (-2,2)
Δx = 0.02
Re = 200


Out[3]:
200

In [4]:
Δt = min(0.5*Δx,0.5*Δx^2*Re)


Out[4]:
0.01

In [5]:
sys = NavierStokes(Re,Δx,xlim,ylim,Δt)


Out[5]:
Navier-Stokes system on a grid of size 202 x 202

In [6]:
w₀ = Nodes(Dual,size(sys));

In [7]:
xg,yg = coordinates(w₀,dx=Δx,I0=Systems.origin(sys))


Out[7]:
(-2.0100000000000002:0.02:2.0100000000000002, -2.0100000000000002:0.02:2.0100000000000002)

Make a Gaussian patch function


In [8]:
using LinearAlgebra
gaussian(x,x0,σ) = exp(-LinearAlgebra.norm(x.-x0)^2/σ^2)/(π*σ^2)


Out[8]:
gaussian (generic function with 1 method)

Set up the integrator

First set up the integrating factor plan


In [9]:
plan_intfact(t,w) = Systems.plan_intfact(t,w,sys)


Out[9]:
plan_intfact (generic function with 1 method)

The right-hand side function


In [10]:
r₁(w,t) = Systems.r₁(w,t,sys)


Out[10]:
r₁ (generic function with 1 method)

And finally, the integrator


In [11]:
ifrk = IFRK(w₀,sys.Δt,plan_intfact,r₁,rk=TimeMarching.RK31)


Out[11]:
Order-3 IF-RK integator with
   State of type Nodes{Dual,202,202}
   Time step size 0.01

Now solve the problem


In [12]:
t = 0.0
x01 = (-0.5,0); x02 = (0.5,0); σ = 0.2; Γ = 1
w₀ .= [Γ*gaussian((x,y),x01,σ) + Γ*gaussian((x,y),x02,σ) for x in xg, y in yg]*Δx
w = deepcopy(w₀);

In [16]:
tf = 5
T = 0:Δt:tf;

In [17]:
@time for ti in T
    global t, w = ifrk(t,w)
end


 36.625689 seconds (43.59 k allocations: 4.258 GiB, 1.84% gc time)

In [18]:
plot(xg,yg,w)


Out[18]:

In [ ]: