Mercurial > repos > public > sbplib_julia
annotate DiffOps/src/laplace.jl @ 258:3ea8c60ccef3 boundary_conditions
Fix a few typos in documentation and add a few TODOs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 28 Jun 2019 14:11:57 +0200 |
parents | e960b877e07e |
children | 5571d2c5bf0f |
rev | line source |
---|---|
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
1 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
|
2 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
|
3 a::T |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
4 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
|
5 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
6 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
7 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
|
8 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
|
9 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
10 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
11 # 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
|
12 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
|
13 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
|
14 return uᵢ |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
15 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
16 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
17 @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
|
18 # 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
|
19 @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
|
20 @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
|
21 # 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
|
22 @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
|
23 @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
|
24 # 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
|
25 return uᵢ |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
26 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
27 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
28 # 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
|
29 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
|
30 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
|
31 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
|
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 |
252
9405c19b76bc
Move boundary_value and similar methods of laplce
Jonatan Werpers <jonatan@werpers.com>
parents:
251
diff
changeset
|
34 boundary_value(L::Laplace, bId::CartesianBoundary) = BoundaryValue(L.op, L.grid, bId) |
9405c19b76bc
Move boundary_value and similar methods of laplce
Jonatan Werpers <jonatan@werpers.com>
parents:
251
diff
changeset
|
35 normal_derivative(L::Laplace, bId::CartesianBoundary) = NormalDerivative(L.op, L.grid, bId) |
9405c19b76bc
Move boundary_value and similar methods of laplce
Jonatan Werpers <jonatan@werpers.com>
parents:
251
diff
changeset
|
36 boundary_quadrature(L::Laplace, bId::CartesianBoundary) = throw(MethodError) # TODO: Implement this |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
37 |
235
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 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
42 Implements the boundary operator `e` as a TensorMapping |
235
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} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
45 op::D2{T,N,M,K} |
255
e960b877e07e
Be more precise about grid dimension in BoundaryValue and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
252
diff
changeset
|
46 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
47 bId::CartesianBoundary |
228
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 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
56 # TODO: Make this independent of dimension |
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}) |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
58 i = I[dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
59 j = I[3-dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
60 N_i = size(e.grid)[dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
61 return apply_e(e.op, v[j], N_i, i, region(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
|
62 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
63 |
239
60011a10e17d
Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents:
235
diff
changeset
|
64 function LazyTensors.apply_transpose(e::BoundaryValue, v::AbstractArray, I::NTuple{1,Int}) |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
65 u = selectdim(v,3-dim(e.bId),I[1]) |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
66 return apply_e_T(e.op, u, region(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
|
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 |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
69 |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
70 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
71 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
72 NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1} |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
73 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
74 Implements the boundary operator `d` as a TensorMapping |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
75 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
76 struct NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
77 op::D2{T,N,M,K} |
255
e960b877e07e
Be more precise about grid dimension in BoundaryValue and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
252
diff
changeset
|
78 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
79 bId::CartesianBoundary |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
80 end |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
81 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
|
82 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
83 # TODO: This is obviouly strange. Is domain_size just discarded? Is there a way to avoid storing grid in BoundaryValue? |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
84 # Can we give special treatment to TensorMappings that go to a higher dim? |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
85 LazyTensors.range_size(e::NormalDerivative{T}, domain_size::NTuple{1,Integer}) where T = size(e.grid) |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
86 LazyTensors.domain_size(e::NormalDerivative{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],) |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
87 |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
88 # TODO: Not type stable D:< |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
89 # TODO: Make this independent of dimension |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
90 function LazyTensors.apply(d::NormalDerivative, v::AbstractArray, I::NTuple{2,Int}) |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
91 i = I[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
92 j = I[3-dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
93 N_i = size(d.grid)[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
94 h_inv = d.grid.inverse_spacing[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
95 return apply_d(d.op, h_inv, v[j], N_i, i, region(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
|
96 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
97 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
98 function LazyTensors.apply_transpose(d::NormalDerivative, v::AbstractArray, I::NTuple{1,Int}) |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
99 u = selectdim(v,3-dim(d.bId),I[1]) |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
100 return apply_d_T(d.op, d.grid.inverse_spacing[dim(d.bId)], u, region(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
|
101 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
102 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
103 |
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 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
|
106 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
107 function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid} |
246
3d83b4d78b55
Add methods to Laplace type for creating boundary value and normal derivative operators
Jonatan Werpers <jonatan@werpers.com>
parents:
245
diff
changeset
|
108 e = boundary_value(L.op, Bid()) |
3d83b4d78b55
Add methods to Laplace type for creating boundary value and normal derivative operators
Jonatan Werpers <jonatan@werpers.com>
parents:
245
diff
changeset
|
109 d = normal_derivative(L.op, Bid()) |
3d83b4d78b55
Add methods to Laplace type for creating boundary value and normal derivative operators
Jonatan Werpers <jonatan@werpers.com>
parents:
245
diff
changeset
|
110 Hᵧ = boundary_quadrature(L.op, Bid()) |
228
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 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
|
113 # 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
|
114 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
115 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
116 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
|
117 tau::Float64 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
118 end |
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 function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid} |
246
3d83b4d78b55
Add methods to Laplace type for creating boundary value and normal derivative operators
Jonatan Werpers <jonatan@werpers.com>
parents:
245
diff
changeset
|
121 e = boundary_value(L.op, Bid()) |
3d83b4d78b55
Add methods to Laplace type for creating boundary value and normal derivative operators
Jonatan Werpers <jonatan@werpers.com>
parents:
245
diff
changeset
|
122 d = normal_derivative(L.op, Bid()) |
3d83b4d78b55
Add methods to Laplace type for creating boundary value and normal derivative operators
Jonatan Werpers <jonatan@werpers.com>
parents:
245
diff
changeset
|
123 Hᵧ = boundary_quadrature(L.op, Bid()) |
228
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 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
|
126 # 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
|
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 apply(s::MyWaveEq{D}, v::AbstractArray{T,D}, i::CartesianIndex{D}) where D |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
130 # return apply(s.L, v, i) + |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
131 # 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
|
132 # 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
|
133 # 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
|
134 # 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
|
135 # end |