comparison diffOp.jl @ 59:60d575e4a2d8

Merge with latest changes
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 16 Jan 2019 12:40:20 +0100
parents c62ea0112d4d
children 27a8d3021a1c 8a7a537f54e5 d04569696918
comparison
equal deleted inserted replaced
58:f3ea15c8ebb6 59:60d575e4a2d8
10 10
11 function matrixRepresentation(D::DiffOp) 11 function matrixRepresentation(D::DiffOp)
12 error("not implemented") 12 error("not implemented")
13 end 13 end
14 14
15 function boundaryCondition(D::DiffOp) 15 function boundaryCondition(D::DiffOp,b::Grid.BoundaryId,type)::(Closure, Penalty)
16 error("not implemented") 16 error("not implemented")
17 end 17 end
18 18
19 function interface(Du::DiffOp, Dv::DiffOp, b::grid.BoundaryId; type) 19 function interface(Du::DiffOp, Dv::DiffOp, b::Grid.BoundaryId; type)
20 error("not implemented") 20 error("not implemented")
21 end 21 end
22 22
23 abstract type Closure end
24
25 function apply(c::Closure, v::AbstractVector, i::Int)
26 error("not implemented")
27 end
28
29 abstract type Penalty end
30
31 function apply(c::Penalty, g, i::Int)
32 error("not implemented")
33 end
23 34
24 # Differential operator for a*d^2/dx^2 35 # Differential operator for a*d^2/dx^2
25 struct Laplace1D <: DiffOp 36 struct Laplace1D <: DiffOp
26 grid 37 grid
27 a 38 a
28 op 39 op
29 end 40 end
30 41
31 # u = L*v 42 # u = L*v
32 function apply!(L::Laplace1D, u::AbstractVector, v::AbstractVector) 43 function apply!(L::Laplace1D, u::AbstractVector, v::AbstractVector)
33 h = grid.spacings(L.grid)[1] 44 h = Grid.spacings(L.grid)[1]
34 apply!(L.op, u, v, h) 45 apply!(L.op, u, v, h)
35 u .= L.a * u 46 u .= L.a * u
36 return nothing 47 return nothing
37 end 48 end
38 49
45 end 56 end
46 57
47 # u = L*v 58 # u = L*v
48 function apply!(L::Laplace2D, u::AbstractVector, v::AbstractVector) 59 function apply!(L::Laplace2D, u::AbstractVector, v::AbstractVector)
49 u .= 0*u 60 u .= 0*u
50 h = grid.spacings(L.grid) 61 h = Grid.spacings(L.grid)
51 62
52 li = LinearIndices(L.grid.numberOfPointsPerDim) 63 li = LinearIndices(L.grid.numberOfPointsPerDim)
53 n_x, n_y = L.grid.numberOfPointsPerDim 64 n_x, n_y = L.grid.numberOfPointsPerDim
54 65
55 66