Mercurial > repos > public > sbplib_julia
annotate DiffOps/src/laplace.jl @ 273:babc4288e6a6 boundary_conditions
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 06 Jan 2020 10:48:38 +0100 |
parents | ccef055233a2 |
children | fe9e8737ddfa |
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) |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
13 uᵢ = L.a * SbpOperators.apply_2nd_derivative(L.op, inverse_spacing(L.grid)[1], 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
|
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])) |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
20 @inbounds uᵢ = L.a*SbpOperators.apply_2nd_derivative(L.op, inverse_spacing(L.grid)[1], vx , 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
|
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]), :) |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
23 @inbounds uᵢ += L.a*SbpOperators.apply_2nd_derivative(L.op, inverse_spacing(L.grid)[2], vy, I[2]) |
228
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}}? |
273
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
55 @inline function LazyTensors.apply(H::Quadrature{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2} |
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
|
56 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
|
57 # Quadrature in x direction |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
58 @inbounds q = apply_quadrature(H.op, spacing(H.grid)[1], v[I] , I[1], N[1]) |
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
|
59 # Quadrature in y-direction |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
60 @inbounds q = apply_quadrature(H.op, spacing(H.grid)[2], q, I[2], N[2]) |
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
|
61 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
|
62 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
|
63 |
273
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
64 function LazyTensors.apply(H::Quadrature{2}, v::AbstractArray{T,2} where T, i::NTuple{2,Integer}) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
65 I = Index{Unknown}.(i) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
66 LazyTensors.apply(H, v, I) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
67 end |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
68 |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
69 LazyTensors.apply_transpose(H::Quadrature{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}} where {R1, R2}) = LazyTensors.apply(H,v,I) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
70 |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
71 function LazyTensors.apply_transpose(H::Quadrature{2}, v::AbstractArray{T,2} where T, i::NTuple{2,Integer}) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
72 I = Index{Unknown}.(i) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
73 LazyTensors.apply_transpose(H, v, I) |
babc4288e6a6
Dispatch apply(Quadrature) etc on region indices and create utility wrapper function dispatching on standard ints
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
269
diff
changeset
|
74 end |
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
|
75 |
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 """ |
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 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
|
78 |
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 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
|
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 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 |
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 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
|
88 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
|
89 |
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 # 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
|
91 @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
|
92 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
|
93 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
|
94 # Inverse quadrature in x direction |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
95 @inbounds q_inv = apply_inverse_quadrature(H_inv.op, inverse_spacing(H_inv.grid)[1], v[I] , I[1], N[1]) |
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
|
96 # Inverse quadrature in y-direction |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
97 @inbounds q_inv = apply_inverse_quadrature(H_inv.op, inverse_spacing(H_inv.grid)[2], q_inv, I[2], N[2]) |
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
|
98 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
|
99 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
|
100 |
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
|
101 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
|
102 |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
103 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
104 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
|
105 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
106 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
|
107 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
108 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
|
109 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
|
110 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
111 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
|
112 end |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
113 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
|
114 |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
115 # 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
|
116 # 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
|
117 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
|
118 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
|
119 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
120 # 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
|
121 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
|
122 i = I[dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
123 j = I[3-dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
124 N_i = size(e.grid)[dim(e.bId)] |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
125 return apply_boundary_value(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
|
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 |
239
60011a10e17d
Add tests for BoundaryValue and fix index types
Jonatan Werpers <jonatan@werpers.com>
parents:
235
diff
changeset
|
128 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
|
129 u = selectdim(v,3-dim(e.bId),I[1]) |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
130 return apply_boundary_value_transpose(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
|
131 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
132 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
133 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
134 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
|
135 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
136 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
|
137 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
138 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
|
139 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
|
140 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
141 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
|
142 end |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
143 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
|
144 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
145 # 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
|
146 # 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
|
147 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
|
148 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
|
149 |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
150 # 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
|
151 # TODO: Make this independent of dimension |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
152 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
|
153 i = I[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
154 j = I[3-dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
155 N_i = size(d.grid)[dim(d.bId)] |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
156 h_inv = inverse_spacing(d.grid)[dim(d.bId)] |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
157 return apply_normal_derivative(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
|
158 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
159 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
160 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
|
161 u = selectdim(v,3-dim(d.bId),I[1]) |
269
ccef055233a2
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
268
diff
changeset
|
162 return apply_normal_derivative_transpose(d.op, inverse_spacing(d.grid)[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
|
163 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
164 |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
165 """ |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
166 BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
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 Implements the boundary operator `q` as a TensorOperator |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
169 """ |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
170 struct BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
171 op::D2{T,N,M,K} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
172 grid::EquidistantGrid{2} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
173 bId::CartesianBoundary |
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 export BoundaryQuadrature |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
176 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
177 # 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
|
178 # TODO: Dispatch directly on Index{R}? |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
179 function LazyTensors.apply(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Int}) where T |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
180 h = spacing(q.grid)[3-dim(q.bId)] |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
181 N = size(v) |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
182 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
|
183 end |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
184 |
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
|
185 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
|
186 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
187 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
188 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
189 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
190 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
|
191 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
199 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
200 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
|
201 tau::Float64 |
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 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 # 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
|
211 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
212 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
213 # 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
|
214 # 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
|
215 # 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
|
216 # 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
|
217 # 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
|
218 # 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
|
219 # end |