Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
10:bed51234616b | 11:7f075bacbd68 |
---|---|
1 abstract type DiffOp end | |
2 | |
3 function apply(D::DiffOp, v::AbstractVector) | |
4 error("not implemented") | |
5 end | |
6 | |
7 function innerProduct(D::DiffOp, u::AbstractVector, v::AbstractVector)::Real | |
8 error("not implemented") | |
9 end | |
10 | |
11 function matrixRepresentation(D::DiffOp) | |
12 error("not implemented") | |
13 end | |
14 | |
15 function boundaryCondition(D::DiffOp) | |
16 error("not implemented") | |
17 end | |
18 | |
19 function interface(Du::DiffOp, Dv::DiffOp, b::BoundaryID; type) | |
20 error("not implemented") | |
21 end | |
22 | |
23 | |
24 # Differential operator for a*d^2/dx^2 | |
25 struct Laplace1D <: DiffOp | |
26 grid | |
27 a | |
28 op | |
29 end | |
30 | |
31 # u = L*v | |
32 function apply(L::Laplace1D, u::AbstractVector, v::AbstractVector)::AbstractVector | |
33 N = closureSize(L.op) | |
34 M = length(v) | |
35 | |
36 for i ∈ 1:N | |
37 u[i] = apply(L.op.closureStencils[i], v, i) | |
38 end | |
39 | |
40 for i ∈ N+1:M-N | |
41 u[i] = apply(L.op.innerStencil, i); | |
42 end | |
43 | |
44 for i ∈ M:-1:M-N+1 | |
45 u[i] = apply(flip(L.op.closureStencils[M-i+1]), v, i) | |
46 end | |
47 end |