annotate DiffOps/src/laplace.jl @ 242:9819243102dd boundary_conditions

Add test for and fix apply(::BoundaryValue)
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 26 Jun 2019 20:24:21 +0200
parents 60011a10e17d
children a827568fc251
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
235
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
1 """
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
2 NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1}
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
3
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
4 Implements the boundary operator `d` as a TensorMapping
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
5 """
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
6 struct NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1}
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
7 op::D2{T,N,M,K}
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
8 grid::EquidistantGrid
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
9 bId::CartesianBoundary
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
10 end
235
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
11 export NormalDerivative
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
12
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
13 # Not correct abstraction level
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
14 # TODO: Not type stable D:<
242
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
15 function LazyTensors.apply(d::NormalDerivative, v::AbstractArray, I::NTuple{2,Int})
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
16 i = I[dim(d.bId)]
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
17 j = I[3-dim(d.bId)]
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18 N_i = d.grid.size[dim(d.bId)]
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
19
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
20 r = getregion(i, closureSize(d.op), N_i)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
21
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
22 if r != region(d.bId)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
23 return 0
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
24 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
25
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
26 if r == Lower
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
27 # Note, closures are indexed by offset. Fix this D:<
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
28 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[i-1]*v[j]
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
29 elseif r == Upper
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
30 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[N_i-j]*v[j]
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
31 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
32 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
33
242
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
34 function LazyTensors.apply_transpose(d::NormalDerivative, v::AbstractArray, I::NTuple{1,Int})
235
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
35 u = selectdim(v,3-dim(d.bId),I)
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
36 return apply_d(d.op, d.grid.inverse_spacing[dim(d.bId)], u, region(d.bId))
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
37 end
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
38
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
39
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
40 """
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
41 BoundaryValue{T,N,M,K} <: TensorMapping{T,2,1}
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
42
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
43 Implements the boundary operator `e` as a TensorMapping
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
44 """
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
45 struct BoundaryValue{T,N,M,K} <: TensorMapping{T,2,1}
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
46 op::D2{T,N,M,K}
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
47 grid::EquidistantGrid
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
48 bId::CartesianBoundary
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
49 end
235
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
50 export BoundaryValue
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
51
235
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
52 # TODO: This is obviouly strange. Is domain_size just discarded? Is there a way to avoid storing grid in BoundaryValue?
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
53 # Can we give special treatment to TensorMappings that go to a higher dim?
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
54 LazyTensors.range_size(e::BoundaryValue{T}, domain_size::NTuple{1,Integer}) where T = size(e.grid)
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
55 LazyTensors.domain_size(e::BoundaryValue{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],);
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
56
239
60011a10e17d Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents: 235
diff changeset
57 function LazyTensors.apply(e::BoundaryValue, v::AbstractArray, I::NTuple{2,Int})
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
58 i = I[dim(e.bId)]
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
59 j = I[3-dim(e.bId)]
242
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
60 N_i = size(e.grid)[dim(e.bId)]
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
61
242
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
62 if region(e.bId) == Lower
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
63 # NOTE: closures are indexed by offset. Fix this D:<
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
64 return e.op.eClosure[i-1]*v[j]
242
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
65 elseif region(e.bId) == Upper
9819243102dd Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents: 239
diff changeset
66 return e.op.eClosure[N_i-i]*v[j]
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
67 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
68 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
69
239
60011a10e17d Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents: 235
diff changeset
70 function LazyTensors.apply_transpose(e::BoundaryValue, v::AbstractArray, I::NTuple{1,Int})
60011a10e17d Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents: 235
diff changeset
71 u = selectdim(v,3-dim(e.bId),I[1])
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
72 return apply_e(e.op, u, region(e.bId))
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
73 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
74
235
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
75
a5fdc00d5070 Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents: 228
diff changeset
76
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
77 struct Laplace{Dim,T<:Real,N,M,K} <: DiffOpCartesian{Dim}
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
78 grid::EquidistantGrid{Dim,T}
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
79 a::T
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
80 op::D2{Float64,N,M,K}
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
81 # e::BoundaryValue
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
82 # d::NormalDerivative
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
83 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
84
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
85 function apply(L::Laplace{Dim}, v::AbstractArray{T,Dim} where T, I::CartesianIndex{Dim}) where Dim
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
86 error("not implemented")
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
87 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
88
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
89 # u = L*v
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
90 function apply(L::Laplace{1}, v::AbstractVector, i::Int)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
91 uᵢ = L.a * SbpOperators.apply(L.op, L.grid.spacing[1], v, i)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
92 return uᵢ
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
93 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
94
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
95 @inline function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2}
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
96 # 2nd x-derivative
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
97 @inbounds vx = view(v, :, Int(I[2]))
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
98 @inbounds uᵢ = L.a*SbpOperators.apply(L.op, L.grid.inverse_spacing[1], vx , I[1])
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
99 # 2nd y-derivative
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
100 @inbounds vy = view(v, Int(I[1]), :)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
101 @inbounds uᵢ += L.a*SbpOperators.apply(L.op, L.grid.inverse_spacing[2], vy, I[2])
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
102 # NOTE: the package qualifier 'SbpOperators' can problably be removed once all "applying" objects use LazyTensors
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
103 return uᵢ
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
104 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
105
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
106 # Slow but maybe convenient?
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
107 function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, i::CartesianIndex{2})
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
108 I = Index{Unknown}.(Tuple(i))
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
109 apply(L, v, I)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
110 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
111
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
112
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
113 struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
114
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
115 function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid}
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
116 e = BoundaryValue(L.op, L.grid, Bid())
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
117 d = NormalDerivative(L.op, L.grid, Bid())
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
118 Hᵧ = BoundaryQuadrature(L.op, L.grid, Bid())
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
119 # TODO: Implement BoundaryQuadrature method
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
120
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
121 return -L.Hi*e*Hᵧ*(d'*v - g)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
122 # Need to handle d'*v - g so that it is an AbstractArray that TensorMappings can act on
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
123 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
124
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
125 struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
126 tau::Float64
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
127 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
128
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
129 function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid}
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
130 e = BoundaryValue(L.op, L.grid, Bid())
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
131 d = NormalDerivative(L.op, L.grid, Bid())
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
132 Hᵧ = BoundaryQuadrature(L.op, L.grid, Bid())
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
133 # TODO: Implement BoundaryQuadrature method
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
134
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
135 return -L.Hi*(tau/h*e + d)*Hᵧ*(e'*v - g)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
136 # Need to handle scalar multiplication and addition of TensorMapping
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
137 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
138
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
139 # function apply(s::MyWaveEq{D}, v::AbstractArray{T,D}, i::CartesianIndex{D}) where D
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
140 # return apply(s.L, v, i) +
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
141 # sat(s.L, Dirichlet{CartesianBoundary{1,Lower}}(s.tau), v, s.g_w, i) +
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
142 # sat(s.L, Dirichlet{CartesianBoundary{1,Upper}}(s.tau), v, s.g_e, i) +
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
143 # sat(s.L, Dirichlet{CartesianBoundary{2,Lower}}(s.tau), v, s.g_s, i) +
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
144 # sat(s.L, Dirichlet{CartesianBoundary{2,Upper}}(s.tau), v, s.g_n, i)
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
145 # end