Mercurial > repos > public > sbplib_julia
annotate DiffOps/src/laplace.jl @ 244:a827568fc251 boundary_conditions
Fix NormalDerivative and add tests
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 26 Jun 2019 21:22:36 +0200 |
parents | 9819243102dd |
children | d9e262cb2e8d ed29ee13e92e |
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 |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
13 # TODO: This is obviouly strange. Is domain_size just discarded? Is there a way to avoid storing grid in BoundaryValue? |
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
14 # Can we give special treatment to TensorMappings that go to a higher dim? |
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
15 LazyTensors.range_size(e::NormalDerivative{T}, domain_size::NTuple{1,Integer}) where T = size(e.grid) |
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
16 LazyTensors.domain_size(e::NormalDerivative{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],) |
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
17 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
18 # 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
|
19 # TODO: Not type stable D:< |
242
9819243102dd
Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents:
239
diff
changeset
|
20 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
|
21 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
|
22 j = I[3-dim(d.bId)] |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
23 N_i = size(d.grid)[dim(d.bId)] |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
24 |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
25 if region(d.bId) == Lower |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
26 # 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
|
27 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[i-1]*v[j] |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
28 elseif region(d.bId) == Upper |
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
29 return -d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[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
|
30 end |
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 |
242
9819243102dd
Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents:
239
diff
changeset
|
33 function LazyTensors.apply_transpose(d::NormalDerivative, v::AbstractArray, I::NTuple{1,Int}) |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
34 u = selectdim(v,3-dim(d.bId),I[1]) |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
35 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
|
36 end |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
37 |
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 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
|
41 |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
42 Implements the boundary operator `e` as a TensorMapping |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
43 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
44 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
|
45 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
|
46 grid::EquidistantGrid |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
47 bId::CartesianBoundary |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
48 end |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
49 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
|
50 |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
51 # 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
|
52 # 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
|
53 LazyTensors.range_size(e::BoundaryValue{T}, domain_size::NTuple{1,Integer}) where T = size(e.grid) |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
54 LazyTensors.domain_size(e::BoundaryValue{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],) |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
55 |
239
60011a10e17d
Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents:
235
diff
changeset
|
56 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
|
57 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
|
58 j = I[3-dim(e.bId)] |
242
9819243102dd
Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents:
239
diff
changeset
|
59 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
|
60 |
242
9819243102dd
Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents:
239
diff
changeset
|
61 if region(e.bId) == Lower |
9819243102dd
Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents:
239
diff
changeset
|
62 # 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
|
63 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
|
64 elseif region(e.bId) == Upper |
9819243102dd
Add test for and fix apply(::BoundaryValue)
Jonatan Werpers <jonatan@werpers.com>
parents:
239
diff
changeset
|
65 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
|
66 end |
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 |
239
60011a10e17d
Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents:
235
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
73 |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
74 |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
75 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
76 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
|
77 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
|
78 a::T |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
79 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
|
80 # e::BoundaryValue |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
81 # d::NormalDerivative |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
82 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
83 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
84 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
|
85 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
|
86 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
87 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
88 # 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
|
89 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
|
90 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
|
91 return uᵢ |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
92 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
93 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
94 @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
|
95 # 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
|
96 @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
|
97 @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
|
98 # 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
|
99 @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
|
100 @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
|
101 # 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
|
102 return uᵢ |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
103 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
104 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
105 # 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
|
106 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
|
107 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
|
108 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
|
109 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
110 |
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 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
|
113 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 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
|
118 # 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
|
119 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
120 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
|
121 # 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
|
122 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
123 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
124 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
|
125 tau::Float64 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
126 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
127 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 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
|
132 # 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
|
133 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
134 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
|
135 # 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
|
136 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
137 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
138 # 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
|
139 # 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
|
140 # 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
|
141 # 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
|
142 # 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
|
143 # 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
|
144 # end |