Advection-diffusion on a triangle



In [15]:
mgrid(0f0:dphi:(pi+dphi*1.5f0), 0f0:dtheta:(2f0*pi+dtheta*1.5f0));


LoadError: UndefVarError: mgrid not defined
while loading In[15], in expression starting on line 1

In [30]:
using MultivariateOrthogonalPolynomials

S = MultivariateOrthogonalPolynomials.ProductTriangle(1,1,1)
ApproxFun.points(S,1)


LoadError: MethodError: no method matching points(::MultivariateOrthogonalPolynomials.Triangle, ::Int64)
Closest candidates are:
  points{T,DD}(::Union{ApproxFun.Domain{T,2},ApproxFun.Space{T,DD,2}}, ::Any, !Matched::Any) at /Users/solver/.julia/v0.5/ApproxFun/src/Multivariate/TensorSpace.jl:438
  points(!Matched::MultivariateOrthogonalPolynomials.JacobiTriangle, ::Integer) at /Users/solver/.julia/v0.5/MultivariateOrthogonalPolynomials/src/Triangle.jl:40
  points(!Matched::ApproxFun.IntervalCurve{S<:ApproxFun.Space,T}, ::Integer) at /Users/solver/.julia/v0.5/ApproxFun/src/Domains/Curve.jl:30
  ...
while loading In[30], in expression starting on line 4

 in points(::MultivariateOrthogonalPolynomials.ProductTriangle, ::Int64) at /Users/solver/.julia/v0.5/ApproxFun/src/Fun/Space.jl:144

In [22]:
function mgrid(dim1, dim2)
    X = [i for i in dim1, j in dim2]
    Y = [j for i in dim1, j in dim2]
    return X,Y
end
X, Y = mgrid(linspace(-1f0,1f0,100),linspace(-1f0,1f0,100))
Z = exp.(-X.^2-Y.^2)


window = glscreen()
_view(visualize((X,Y,Z), :surface))
@async renderloop(window)


WARNING: Method definition mgrid(Any, Any) in module Main at In[21]:2 overwritten at In[22]:2.
Out[22]:
Task (runnable) @0x000000011be6a410

In [11]:
using GLVisualize, GLAbstraction, Colors, Reactive, GeometryTypes, ApproxFun


f = Fun((x,y)->exp(-x^2-y^2)*cos(y))


pts = points(f)

x = Float32.(first.(pts))
y = Float32.(last.(pts))
z = Float32.(values(f))


window = glscreen()
_view(visualize((x,y,z), :surface))
@async renderloop(window)


LoadError: MethodError: no method matching _default(::Tuple{Array{Float32,1},Array{Float32,1},Array{Float32,1}}, ::GLAbstraction.Style{:surface}, ::Dict{Symbol,Any})
Closest candidates are:
  _default(!Matched::GLAbstraction.Shader, ::GLAbstraction.Style{StyleValue}, ::Dict{K,V}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize/image_like.jl:129
  _default(!Matched::GeometryTypes.HomogenousMesh{FixedSizeArrays.Point{3,Float32},GeometryTypes.Face{3,UInt32,-1},GeometryTypes.Normal{3,Float32},Void,ColorTypes.RGBA{Float32},Void,Void}, ::GLAbstraction.Style{StyleValue}, ::Dict{K,V}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize/mesh.jl:40
  _default{T<:FixedSizeArrays.Point{N,T}}(!Matched::Union{Array{GeometryTypes.Simplex{2,T<:FixedSizeArrays.Point},1},GLAbstraction.GPUArray{GeometryTypes.Simplex{2,T<:FixedSizeArrays.Point},1},Reactive.Signal{Array{GeometryTypes.Simplex{2,T<:FixedSizeArrays.Point},1}}}, ::GLAbstraction.Style{StyleValue}, ::Dict{K,V}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize/lines.jl:107
  ...
while loading In[11], in expression starting on line 15

 in default(::Any, ::Any, ::Any) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize_interface.jl:4
 in visualize(::Any, ::GLAbstraction.Style{:surface}, ::Dict{Symbol,Any}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize_interface.jl:21
 in visualize(::Any, ::Symbol) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize_interface.jl:20

In [6]:
using GLVisualize, GLAbstraction, Colors, Reactive, GeometryTypes

window = glscreen()
timesignal = loop(linspace(0f0,1f0,360))

# generate some pretty data
function xy_data(x,y,i, N)
    x = ((x/N)-0.5f0)*i
    y = ((y/N)-0.5f0)*i
    r = sqrt(x*x + y*y)
    Float32(sin(r)/r)
end

surf(i, N) = Float32[xy_data(x, y, i, N) for x=1:N, y=1:N]

t = map(t->(t*30f0)+20f0, timesignal)

bb = Signal(AABB{Float32}(Vec3f0(0), Vec3f0(1)))

_view(visualize((Float32.(1:400),Float32.(1:400),surf(1,400)), :surface, boundingbox=bb))

@async renderloop(window)


WARNING: Method definition xy_data(Any, Any, Any, Any) in module Main at In[5]:8 overwritten at In[6]:8.
WARNING: Method definition surf(Any, Any) in module Main at In[5]:14 overwritten at In[6]:14.
LoadError: MethodError: no method matching _default(::Tuple{Array{Float32,1},Array{Float32,1},Array{Float32,2}}, ::GLAbstraction.Style{:surface}, ::Dict{Symbol,Any})
Closest candidates are:
  _default(!Matched::GLAbstraction.Shader, ::GLAbstraction.Style{StyleValue}, ::Dict{K,V}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize/image_like.jl:129
  _default(!Matched::GeometryTypes.HomogenousMesh{FixedSizeArrays.Point{3,Float32},GeometryTypes.Face{3,UInt32,-1},GeometryTypes.Normal{3,Float32},Void,ColorTypes.RGBA{Float32},Void,Void}, ::GLAbstraction.Style{StyleValue}, ::Dict{K,V}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize/mesh.jl:40
  _default{T<:FixedSizeArrays.Point{N,T}}(!Matched::Union{Array{GeometryTypes.Simplex{2,T<:FixedSizeArrays.Point},1},GLAbstraction.GPUArray{GeometryTypes.Simplex{2,T<:FixedSizeArrays.Point},1},Reactive.Signal{Array{GeometryTypes.Simplex{2,T<:FixedSizeArrays.Point},1}}}, ::GLAbstraction.Style{StyleValue}, ::Dict{K,V}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize/lines.jl:107
  ...
while loading In[6], in expression starting on line 20

 in default(::Any, ::Any, ::Any) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize_interface.jl:4
 in visualize(::Any, ::GLAbstraction.Style{:surface}, ::Dict{Symbol,Any}) at /Users/solver/.julia/v0.5/GLVisualize/src/visualize_interface.jl:21
 in (::GLVisualize.#kw##visualize)(::Array{Any,1}, ::GLVisualize.#visualize, ::Any, ::Symbol) at ./<missing>:0

In [4]:
Float32.(1:400)


Out[4]:
400-element Array{Float32,1}:
   1.0
   2.0
   3.0
   4.0
   5.0
   6.0
   7.0
   8.0
   9.0
  10.0
  11.0
  12.0
  13.0
   ⋮  
 389.0
 390.0
 391.0
 392.0
 393.0
 394.0
 395.0
 396.0
 397.0
 398.0
 399.0
 400.0

In [2]:
using GLVisualize, GLAbstraction, Colors, Reactive, GeometryTypes

window = glscreen()
timesignal = loop(linspace(0f0,1f0,360))

# generate some pretty data
function xy_data(x,y,i, N)
    x = ((x/N)-0.5f0)*i
    y = ((y/N)-0.5f0)*i
    r = sqrt(x*x + y*y)
    Float32(sin(r)/r)
end

surf(i, N) = Float32[xy_data(x, y, i, N) for x=1:N, y=1:N]

t = map(t->(t*30f0)+20f0, timesignal)

bb = Signal(AABB{Float32}(Vec3f0(0), Vec3f0(1)))

_view(visualize(const_lift(surf, t, 400), :surface, boundingbox=bb))

renderloop(window)


WARNING: Method definition xy_data(Any, Any, Any, Any) in module Main at In[1]:8 overwritten at In[2]:8.
WARNING: Method definition surf(Any, Any) in module Main at In[1]:14 overwritten at In[2]:14.

In [1]:
using ApproxFun, MultivariateOrthogonalPolynomials, Reactive, GLAbstraction, GLVisualize

In [3]:
function xy_data(x,y,i, N)
    x = ((x/N)-0.5f0)*i
    y = ((y/N)-0.5f0)*i
    r = sqrt(x*x + y*y)
    Float32(sin(r)/r)
end

surf(i, N) = Float32[xy_data(x, y, i, N) for x=1:N, y=1:N]

window = glscreen()
view(visualize(surf(1,10),:surface))
@async renderloop(window)


WARNING: Method definition xy_data(Any, Any, Any, Any) in module Main at In[2]:2 overwritten at In[3]:2.
WARNING: Method definition surf(Any, Any) in module Main at In[2]:8 overwritten at In[3]:8.
LoadError: MethodError: no method matching view(::GLAbstraction.Context{GLAbstraction.DeviceUnit})
Closest candidates are:
  view(!Matched::ApproxFun.BandedBlockBandedMatrix{T,RI,CI}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R}}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R}}) at /Users/solver/.julia/v0.5/ApproxFun/src/LinearAlgebra/BandedBlockBandedMatrix.jl:80
  view(!Matched::ApproxFun.AbstractBlockBandedMatrix{T}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R},UnitRange{ApproxFun.Block}}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R},UnitRange{ApproxFun.Block}}) at /Users/solver/.julia/v0.5/ApproxFun/src/LinearAlgebra/BlockBandedMatrix.jl:765
  view(!Matched::SubArray{T,2,BBM<:ApproxFun.BlockBandedMatrix,Tuple{II<:Union{ApproxFun.Block,ApproxFun.SubBlock},JJ<:Union{ApproxFun.Block,ApproxFun.SubBlock}},false}, !Matched::Colon, !Matched::Colon) at /Users/solver/.julia/v0.5/ApproxFun/src/LinearAlgebra/BlockBandedMatrix.jl:768
  ...
while loading In[3], in expression starting on line 11

In [12]:
timesignal = loop(linspace(0f0,1f0,360))
t = map(t->(t*30f0)+20f0, timesignal)


LoadError: MethodError: no method matching view(::GLAbstraction.Context{GLAbstraction.DeviceUnit})
Closest candidates are:
  view(!Matched::ApproxFun.BandedBlockBandedMatrix{T,RI,CI}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R}}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R}}) at /Users/solver/.julia/v0.5/ApproxFun/src/LinearAlgebra/BandedBlockBandedMatrix.jl:80
  view(!Matched::ApproxFun.AbstractBlockBandedMatrix{T}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R},UnitRange{ApproxFun.Block}}, !Matched::Union{ApproxFun.Block,ApproxFun.SubBlock{R},UnitRange{ApproxFun.Block}}) at /Users/solver/.julia/v0.5/ApproxFun/src/LinearAlgebra/BlockBandedMatrix.jl:765
  view(!Matched::SubArray{T,2,BBM<:ApproxFun.BlockBandedMatrix,Tuple{II<:Union{ApproxFun.Block,ApproxFun.SubBlock},JJ<:Union{ApproxFun.Block,ApproxFun.SubBlock}},false}, !Matched::Colon, !Matched::Colon) at /Users/solver/.julia/v0.5/ApproxFun/src/LinearAlgebra/BlockBandedMatrix.jl:768
  ...
while loading In[12], in expression starting on line 3

In [5]:
f = Fun((x,y)->exp(-x^2-y^2)*cos(y))


Out[5]:
Fun(Chebyshev(【-1.0,1.0】)⊗Chebyshev(【-1.0,1.0】),[0.341625,0.0,8.831e-18,-0.253402,0.0,-0.165688,0.0,3.56592e-18,0.0,-2.07425e-17  …  0.0,-3.66372e-14,0.0,-3.00777e-14,0.0,-1.8232e-14,0.0,-8.03017e-15,0.0,-2.4789e-15])

In [ ]:


In [47]:
S = TriangleWeight(1,1,1,JacobiTriangle(1,1,1))
Δ = Laplacian(S)
Dx = Derivative(S,[1,0])
Dy = Derivative(S,[0,1])

h=0.001
ε=0.01


A=I-h*(ε*Δ+Dx)

QR=qrfact(A)

u0=10Fun(S,randn(10));

In [48]:
u = Signal(u0);
map(u->surface(u),u)


Out[48]:
Signal{Plots.Plot{Plots.GRBackend}}(Plot{Plots.GRBackend() n=1}, nactions=0)

In [38]:
push!(u,10u0)

In [51]:
plotly()


Out[51]:
Plots.PlotlyBackend()

In [ ]: