Mercurial > repos > public > sbplib_julia
annotate DiffOps/src/laplace.jl @ 266:9ad447176ba1 boundary_conditions
Minor work on implementation of SATs for laplace
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 05 Dec 2019 09:27:31 +0100 |
parents | f1e90a92ad74 |
children | f67ce2eb6019 |
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 |
262
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
34 quadrature(L::Laplace) = Quadrature(L.op, L.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
35 inverse_quadrature(L::Laplace) = InverseQuadrature(L.op, L.grid) |
252
9405c19b76bc
Move boundary_value and similar methods of laplce
Jonatan Werpers <jonatan@werpers.com>
parents:
251
diff
changeset
|
36 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
|
37 normal_derivative(L::Laplace, bId::CartesianBoundary) = NormalDerivative(L.op, L.grid, bId) |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
38 boundary_quadrature(L::Laplace, bId::CartesianBoundary) = BoundaryQuadrature(L.op, L.grid, bId) |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
39 |
262
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
40 """ |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
41 Quadrature{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
42 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
43 Implements the quadrature operator `H` of Dim dimension as a TensorMapping |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
44 """ |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
45 struct Quadrature{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
46 op::D2{T,N,M,K} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
47 grid::EquidistantGrid{Dim,T} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
48 end |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
49 export Quadrature |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
50 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
51 LazyTensors.range_size(H::Quadrature{2}, domain_size::NTuple{2,Integer}) where T = size(H.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
52 LazyTensors.domain_size(H::Quadrature{2}, range_size::NTuple{2,Integer}) where T = size(H.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
53 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
54 # TODO: Dispatch on Tuple{Index{R1},Index{R2}}? |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
55 @inline function LazyTensors.apply(H::Quadrature{2}, v::AbstractArray{T,2} where T, I::NTuple{2,Integer}) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
56 I = CartesianIndex(I); |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
57 N = size(H.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
58 # Quadrature in x direction |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
59 @inbounds q = apply_quadrature(H.op, H.grid.spacing[1], v[I] , I[1], N[1]) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
60 # Quadrature in y-direction |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
61 @inbounds q = apply_quadrature(H.op, H.grid.spacing[2], q, I[2], N[2]) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
62 return q |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
63 end |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
64 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
65 LazyTensors.apply_transpose(H::Quadrature{2}, v::AbstractArray{T,2} where T, I::NTuple{2,Integer}) = LazyTensors.apply(H,v,I) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
66 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
67 """ |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
68 InverseQuadrature{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
69 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
70 Implements the inverse quadrature operator `inv(H)` of Dim dimension as a TensorMapping |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
71 """ |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
72 struct InverseQuadrature{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
73 op::D2{T,N,M,K} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
74 grid::EquidistantGrid{Dim,T} |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
75 end |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
76 export InverseQuadrature |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
77 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
78 LazyTensors.range_size(H_inv::InverseQuadrature{2}, domain_size::NTuple{2,Integer}) where T = size(H_inv.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
79 LazyTensors.domain_size(H_inv::InverseQuadrature{2}, range_size::NTuple{2,Integer}) where T = size(H_inv.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
80 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
81 # TODO: Dispatch on Tuple{Index{R1},Index{R2}}? |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
82 @inline function LazyTensors.apply(H_inv::InverseQuadrature{2}, v::AbstractArray{T,2} where T, I::NTuple{2,Integer}) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
83 I = CartesianIndex(I); |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
84 N = size(H_inv.grid) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
85 # Inverse quadrature in x direction |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
86 @inbounds q_inv = apply_inverse_quadrature(H_inv.op, H_inv.grid.inverse_spacing[1], v[I] , I[1], N[1]) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
87 # Inverse quadrature in y-direction |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
88 @inbounds q_inv = apply_inverse_quadrature(H_inv.op, H_inv.grid.inverse_spacing[2], q_inv, I[2], N[2]) |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
89 return q_inv |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
90 end |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
91 |
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
92 LazyTensors.apply_transpose(H_inv::InverseQuadrature{2}, v::AbstractArray{T,2} where T, I::NTuple{2,Integer}) = LazyTensors.apply(H_inv,v,I) |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
93 |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
94 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
95 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
|
96 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
97 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
|
98 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
99 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
|
100 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
|
101 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
102 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
|
103 end |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
104 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
|
105 |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
106 # 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
|
107 # 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
|
108 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
|
109 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
|
110 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
111 # 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
|
112 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
|
113 i = I[dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
114 j = I[3-dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
115 N_i = size(e.grid)[dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
116 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
|
117 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
118 |
239
60011a10e17d
Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents:
235
diff
changeset
|
119 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
|
120 u = selectdim(v,3-dim(e.bId),I[1]) |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
121 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
|
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 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
124 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
125 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
|
126 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
127 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
|
128 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
129 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
|
130 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
|
131 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
132 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
|
133 end |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
134 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
|
135 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
136 # 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
|
137 # 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
|
138 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
|
139 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
|
140 |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
141 # 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
|
142 # TODO: Make this independent of dimension |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
143 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
|
144 i = I[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
145 j = I[3-dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
146 N_i = size(d.grid)[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
147 h_inv = d.grid.inverse_spacing[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
148 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
|
149 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
150 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
155 |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
156 """ |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
157 BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
158 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
159 Implements the boundary operator `q` as a TensorOperator |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
160 """ |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
161 struct BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
162 op::D2{T,N,M,K} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
163 grid::EquidistantGrid{2} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
164 bId::CartesianBoundary |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
165 end |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
166 export BoundaryQuadrature |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
167 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
168 # TODO: Make this independent of dimension |
262
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
169 # TODO: Dispatch directly on Index{R}? |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
170 function LazyTensors.apply(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Int}) where T |
262
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
171 h = q.grid.spacing[3-dim(q.bId)] |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
172 N = size(v) |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
173 return apply_quadrature(q.op, h, v[I[1]], I[1], N[1]) |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
174 end |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
175 |
262
f1e90a92ad74
Add Quadrature and InverseQuadrature for Laplace as TensorMappings. Implement and test the 2D case. Fix implementation of apply_transpose for BoundaryQuadrature and add tests.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
259
diff
changeset
|
176 LazyTensors.apply_transpose(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Int}) where T = LazyTensors.apply(q,v,I) |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
177 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
178 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
179 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
180 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
181 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
|
182 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
183 function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid} |
266
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
184 e = boundary_value(L, Bid()) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
185 d = normal_derivative(L, Bid()) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
186 Hᵧ = boundary_quadrature(L, Bid()) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
187 H⁻¹ = inverse_quadrature(L) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
188 return (-H⁻¹*e*Hᵧ*(d'*v - g))[I] |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
189 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
190 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
191 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
|
192 tau::Float64 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
193 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
194 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
195 function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid} |
266
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
196 e = boundary_value(L, Bid()) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
197 d = normal_derivative(L, Bid()) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
198 Hᵧ = boundary_quadrature(L, Bid()) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
199 H⁻¹ = inverse_quadrature(L) |
9ad447176ba1
Minor work on implementation of SATs for laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
262
diff
changeset
|
200 return (-H⁻¹*(tau/h*e + d)*Hᵧ*(e'*v - g))[I] |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
201 # 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
|
202 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
203 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
204 # 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
|
205 # 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
|
206 # 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
|
207 # 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
|
208 # 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
|
209 # 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
|
210 # end |