diff diffOp.jl @ 11:7f075bacbd68

merge with default
author Ylva Rydin <ylva.rydin@telia.com>
date Mon, 17 Dec 2018 14:42:38 +0100
parents 433008d3b7d3
children aafc4bdbe675
line wrap: on
line diff
--- a/diffOp.jl	Mon Dec 17 14:42:11 2018 +0100
+++ b/diffOp.jl	Mon Dec 17 14:42:38 2018 +0100
@@ -0,0 +1,47 @@
+abstract type DiffOp end
+
+function apply(D::DiffOp, v::AbstractVector)
+    error("not implemented")
+end
+
+function innerProduct(D::DiffOp, u::AbstractVector, v::AbstractVector)::Real
+    error("not implemented")
+end
+
+function matrixRepresentation(D::DiffOp)
+    error("not implemented")
+end
+
+function boundaryCondition(D::DiffOp)
+    error("not implemented")
+end
+
+function interface(Du::DiffOp, Dv::DiffOp, b::BoundaryID; type)
+    error("not implemented")
+end
+
+
+# Differential operator for a*d^2/dx^2
+struct Laplace1D <: DiffOp
+    grid
+    a
+    op
+end
+
+# u = L*v
+function apply(L::Laplace1D, u::AbstractVector, v::AbstractVector)::AbstractVector
+    N = closureSize(L.op)
+    M = length(v)
+
+    for i ∈ 1:N
+        u[i] = apply(L.op.closureStencils[i], v, i)
+    end
+
+    for i ∈ N+1:M-N
+        u[i] = apply(L.op.innerStencil, i);
+    end
+
+    for i ∈ M:-1:M-N+1
+        u[i] = apply(flip(L.op.closureStencils[M-i+1]), v, i)
+    end
+end