Mercurial > repos > public > sbplib_julia
comparison diffOp.jl @ 73:d04569696918
Add types to Laplace operators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 15 Jan 2019 19:51:16 +0100 |
parents | c62ea0112d4d |
children | 81d9510cb2d0 |
comparison
equal
deleted
inserted
replaced
69:8cd8d83b92e7 | 73:d04569696918 |
---|---|
32 error("not implemented") | 32 error("not implemented") |
33 end | 33 end |
34 | 34 |
35 # Differential operator for a*d^2/dx^2 | 35 # Differential operator for a*d^2/dx^2 |
36 struct Laplace1D <: DiffOp | 36 struct Laplace1D <: DiffOp |
37 grid | 37 grid::Grid.EquidistantGrid |
38 a | 38 a::Real |
39 op | 39 op::D2{Float64} |
40 end | 40 end |
41 | 41 |
42 # u = L*v | 42 # u = L*v |
43 function apply!(L::Laplace1D, u::AbstractVector, v::AbstractVector) | 43 function apply!(L::Laplace1D, u::AbstractVector, v::AbstractVector) |
44 h = Grid.spacings(L.grid)[1] | 44 h = Grid.spacings(L.grid)[1] |
48 end | 48 end |
49 | 49 |
50 | 50 |
51 # Differential operator for a*d^2/dx^2 + a*d^2/dy^2 | 51 # Differential operator for a*d^2/dx^2 + a*d^2/dy^2 |
52 struct Laplace2D <: DiffOp | 52 struct Laplace2D <: DiffOp |
53 grid | 53 grid::Grid.EquidistantGrid |
54 a | 54 a::Real |
55 op | 55 op::D2{Float64} |
56 end | 56 end |
57 | 57 |
58 # u = L*v | 58 # u = L*v |
59 function apply!(L::Laplace2D, u::AbstractVector, v::AbstractVector) | 59 function apply!(L::Laplace2D, u::AbstractVector, v::AbstractVector) |
60 u .= 0*u | 60 u .= 0*u |