diff diffOp.jl @ 76:81d9510cb2d0

Make Laplace take dimension as a parameter
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 24 Jan 2019 09:24:21 +0100
parents d04569696918
children 700a74c41b26 48079bd39969
line wrap: on
line diff
--- a/diffOp.jl	Thu Jan 17 15:19:33 2019 +0100
+++ b/diffOp.jl	Thu Jan 24 09:24:21 2019 +0100
@@ -33,30 +33,22 @@
 end
 
 # Differential operator for a*d^2/dx^2
-struct Laplace1D <: DiffOp
-    grid::Grid.EquidistantGrid
-    a::Real
+struct Laplace{D, T<:Real} <: DiffOp
+    grid::Grid.EquidistantGrid{D,T}
+    a::T
     op::D2{Float64}
 end
 
 # u = L*v
-function apply!(L::Laplace1D, u::AbstractVector, v::AbstractVector)
+function apply!(L::Laplace{1}, u::AbstractVector, v::AbstractVector)
     h = Grid.spacings(L.grid)[1]
     apply!(L.op, u, v, h)
     u .= L.a * u
     return nothing
 end
 
-
-# Differential operator for a*d^2/dx^2 + a*d^2/dy^2
-struct Laplace2D <: DiffOp
-    grid::Grid.EquidistantGrid
-    a::Real
-    op::D2{Float64}
-end
-
 # u = L*v
-function apply!(L::Laplace2D, u::AbstractVector, v::AbstractVector)
+function apply!(L::Laplace{2}, u::AbstractVector, v::AbstractVector)
     u .= 0*u
     h = Grid.spacings(L.grid)