Rotation

First simulation using semi-lagrangian method to get a rotation

import SemiLagrangian: magicsplit

using SemiLagrangian
using LinearAlgebra

function exact!(f, mesh1::UniformMesh{T}, mesh2::UniformMesh{T}, tf::T) where {T}
    for (i, x) in enumerate(mesh1.points), (j, y) in enumerate(mesh2.points)
        s, c = sincos(tf)
        xn, yn = c * x - s * y, s * x + c * y
        f[i,j] = exp(-13*((xn)^2+(yn+T(6//5))^2))
    end
end

function run_rotation()

    mesh_sp = UniformMesh( -5.0, 5.0, 256)
    mesh_v = UniformMesh( -5.0, 5.0, 256)
    nbdt=50
    dt = 2pi/nbdt
    interp_sp = Lagrange(11)
    interp_v = Lagrange(11)

    adv = Advection(
               (mesh_sp, mesh_v),
               [interp_sp, interp_v],
               dt,
               [([1, 2], 1, 1, true), ([2, 1], 1, 2, true)];
               tab_coef = magicsplit(dt),
           )

    sz = sizeall(adv)
    tabref = zeros(sz)
    exact!(tabref, mesh_sp, mesh_v, 0.0)

    pvar = getrotationvar(adv)

    advdata = AdvectionData(adv, tabref, pvar)

    diffmax = 0
    data = getdata(advdata)
    for ind=1:nbdt
        while advection!(advdata) end
        exact!(tabref, mesh_sp, mesh_v, dt*ind)
        diff = norm(data .- tabref, Inf)
        diffmax = max(diffmax, diff)
        println("ind=$ind sz=$sz interp=$interp_sp, $interp_v nbdt=$nbdt diff,diffmax=$diff,$diffmax")
    end

end

run_rotation()
ind=1 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=2.720717429127717e-9,2.720717429127717e-9
ind=2 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=5.426907589978214e-9,5.426907589978214e-9
ind=3 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=8.540088303199411e-9,8.540088303199411e-9
ind=4 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.2389074988128357e-8,1.2389074988128357e-8
ind=5 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.6302517558131058e-8,1.6302517558131058e-8
ind=6 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=2.150038780346364e-8,2.150038780346364e-8
ind=7 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=2.4565168232904e-8,2.4565168232904e-8
ind=8 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=2.6644191963853814e-8,2.6644191963853814e-8
ind=9 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=2.9374689458627756e-8,2.9374689458627756e-8
ind=10 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=3.406096837910155e-8,3.406096837910155e-8
ind=11 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=3.8563625293086545e-8,3.8563625293086545e-8
ind=12 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=4.125212804684253e-8,4.125212804684253e-8
ind=13 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=4.393345309772201e-8,4.393345309772201e-8
ind=14 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=4.772145634213132e-8,4.772145634213132e-8
ind=15 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=5.181817808175282e-8,5.181817808175282e-8
ind=16 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=5.587387930106047e-8,5.587387930106047e-8
ind=17 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=5.911457423568578e-8,5.911457423568578e-8
ind=18 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=5.890404408681604e-8,5.911457423568578e-8
ind=19 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=6.54671566957532e-8,6.54671566957532e-8
ind=20 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=7.052268014007268e-8,7.052268014007268e-8
ind=21 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=7.351569064617536e-8,7.351569064617536e-8
ind=22 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=7.731054341153509e-8,7.731054341153509e-8
ind=23 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=7.824339876005837e-8,7.824339876005837e-8
ind=24 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=8.434378462318648e-8,8.434378462318648e-8
ind=25 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=8.46239429641571e-8,8.46239429641571e-8
ind=26 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=8.83282956776199e-8,8.83282956776199e-8
ind=27 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=8.652264549269262e-8,8.83282956776199e-8
ind=28 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=9.423600422220346e-8,9.423600422220346e-8
ind=29 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=9.587383120734927e-8,9.587383120734927e-8
ind=30 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.0096010194526883e-7,1.0096010194526883e-7
ind=31 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.0750887657895447e-7,1.0750887657895447e-7
ind=32 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.0704766661984166e-7,1.0750887657895447e-7
ind=33 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.1075712669228466e-7,1.1075712669228466e-7
ind=34 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.1380138220662417e-7,1.1380138220662417e-7
ind=35 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.1835150448558096e-7,1.1835150448558096e-7
ind=36 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.2540696514573568e-7,1.2540696514573568e-7
ind=37 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.268692502165436e-7,1.268692502165436e-7
ind=38 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.2899573120783714e-7,1.2899573120783714e-7
ind=39 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.3321142300348754e-7,1.3321142300348754e-7
ind=40 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.380369133441306e-7,1.380369133441306e-7
ind=41 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.409357565096414e-7,1.409357565096414e-7
ind=42 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.4518337054791886e-7,1.4518337054791886e-7
ind=43 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.4220855004687394e-7,1.4518337054791886e-7
ind=44 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.5261320240878007e-7,1.5261320240878007e-7
ind=45 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.556093395249647e-7,1.556093395249647e-7
ind=46 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.58368612557247e-7,1.58368612557247e-7
ind=47 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.6267826330462754e-7,1.6267826330462754e-7
ind=48 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.6098251220952875e-7,1.6267826330462754e-7
ind=49 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.711825026173841e-7,1.711825026173841e-7
ind=50 sz=(256, 256) interp=Lagrange{Float64, SemiLagrangian.CircEdge, 11}, Lagrange{Float64, SemiLagrangian.CircEdge, 11} nbdt=50 diff,diffmax=1.6940978286861252e-7,1.711825026173841e-7
SemiLagrangian.getalphaMethod
getalpha(pv, self, ind)
getalpha(pv::RotationVar, self::AdvectionData, ind)

Implementation of the interface function that is called before each interpolation in advection

source
SemiLagrangian.initcoef!Method
initcoef!(pv, self)
initcoef!(pv::RotationVar{T, Nsp, Nv}, self::AdvectionData{T, Nsp, Nv, Nsum})

Implementation of the interface function that is called at the begining of each advection This is implementation for Vlasov-Poisson equation

source