Mercurial > repos > public > sbplib_julia
annotate SbpOperators/src/laplace/laplace.jl @ 299:27a0bca5e1f2
Add apply_transpose and fix minor issues
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 23 Jun 2020 17:31:50 +0200 |
parents | f63232aeb1c6 |
children | b00eea62c78e |
rev | line source |
---|---|
286
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
1 """ |
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
2 Laplace{Dim,T<:Real,N,M,K} <: TensorOperator{T,Dim} |
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
3 |
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
4 Implements the Laplace operator `L` in Dim dimensions as a tensor operator |
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
5 The multi-dimensional tensor operator simply consists of a tuple of the 1D |
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
6 Laplace tensor operator as defined by ConstantLaplaceOperator. |
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
7 """ |
282
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
8 struct Laplace{Dim,T<:Real,N,M,K} <: TensorOperator{T,Dim} |
293
f63232aeb1c6
Move laplace.jl from DiffOps to SbpOperators. Rename constandlaplace to secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
286
diff
changeset
|
9 D2::NTuple(Dim,SecondDerivative{T,N,M,K}) |
286
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
10 #TODO: Write a good constructor |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
11 end |
282
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
12 export Laplace |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
13 |
286
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
14 LazyTensors.domain_size(H::Laplace{Dim}, range_size::NTuple{Dim,Integer}) = range_size |
282
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
15 |
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
16 function LazyTensors.apply(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::NTuple{Dim,Index}) where {T,Dim} |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
17 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
|
18 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
19 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
20 # u = L*v |
282
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
21 function LazyTensors.apply(L::Laplace{1,T}, v::AbstractVector{T}, I::NTuple{1,Index}) where T |
293
f63232aeb1c6
Move laplace.jl from DiffOps to SbpOperators. Rename constandlaplace to secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
286
diff
changeset
|
22 return apply(L.D2[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
|
23 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
24 |
282
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
25 |
ce6a2f3f732a
Make Laplace a TensorOperator and add tests. NOTE: Two of the tests for Laplace2D are currently failing.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
281
diff
changeset
|
26 @inline function LazyTensors.apply(L::Laplace{2,T}, v::AbstractArray{T,2}, I::NTuple{2,Index}) where T |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
27 # 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
|
28 @inbounds vx = view(v, :, Int(I[2])) |
293
f63232aeb1c6
Move laplace.jl from DiffOps to SbpOperators. Rename constandlaplace to secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
286
diff
changeset
|
29 @inbounds uᵢ = apply(L.D2[1], vx , (I[1],)) #Tuple conversion here is ugly. How to do it? Should we use indexing here? |
286
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
30 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
31 # 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
|
32 @inbounds vy = view(v, Int(I[1]), :) |
293
f63232aeb1c6
Move laplace.jl from DiffOps to SbpOperators. Rename constandlaplace to secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
286
diff
changeset
|
33 @inbounds uᵢ += apply(L.D2[2], vy , (I[2],)) #Tuple conversion here is ugly. How to do it? |
286
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
34 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
35 return uᵢ |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
36 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
37 |
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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 boundary_quadrature(L::Laplace, bId::CartesianBoundary) = BoundaryQuadrature(L.op, L.grid, bId) |
283
12a12a5cd973
Fix tests for Laplace2D.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
282
diff
changeset
|
43 export quadrature |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
44 |
286
7247e85dc1e8
Start separating ConstantStencilOp into multiple 1D tensor mappings, e.g. ConstantLaplaceOp. Sketch an implementation of the multi-D laplace tensor operator as a tuple of 1D laplace tensor operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
285
diff
changeset
|
45 # At the moment the grid property is used all over. It could possibly be removed if we implement all the 1D operators as TensorMappings |
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
|
46 """ |
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 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
|
48 |
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 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
|
50 """ |
280
fe9e8737ddfa
Change to using region indices in apply of BoundaryValue, NormalDerivative and BoundaryQuadrature
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
273
diff
changeset
|
51 struct Quadrature{Dim,T<:Real,N,M,K} <: TensorOperator{T,Dim} |
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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
57 LazyTensors.domain_size(H::Quadrature{Dim}, range_size::NTuple{Dim,Integer}) where Dim = range_size |
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
|
58 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
59 @inline function LazyTensors.apply(H::Quadrature{2,T}, v::AbstractArray{T,2}, I::NTuple{2,Index}) 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
|
60 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
|
61 # 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
|
62 @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
|
63 # 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
|
64 @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
|
65 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
|
66 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
|
67 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
68 LazyTensors.apply_transpose(H::Quadrature{2,T}, v::AbstractArray{T,2}, I::NTuple{2,Index}) where T = LazyTensors.apply(H,v,I) |
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
|
69 |
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
|
70 |
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 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 |
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 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
|
75 """ |
280
fe9e8737ddfa
Change to using region indices in apply of BoundaryValue, NormalDerivative and BoundaryQuadrature
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
273
diff
changeset
|
76 struct InverseQuadrature{Dim,T<:Real,N,M,K} <: TensorOperator{T,Dim} |
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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
82 LazyTensors.domain_size(H_inv::InverseQuadrature{Dim}, range_size::NTuple{Dim,Integer}) where Dim = range_size |
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
|
83 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
84 @inline function LazyTensors.apply(H_inv::InverseQuadrature{2,T}, v::AbstractArray{T,2}, I::NTuple{2,Index}) 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
|
85 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
|
86 # 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
|
87 @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
|
88 # 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
|
89 @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
|
90 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
|
91 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
|
92 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
93 LazyTensors.apply_transpose(H_inv::InverseQuadrature{2,T}, v::AbstractArray{T,2}, I::NTuple{2,Index}) where T = LazyTensors.apply(H_inv,v,I) |
235
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 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
96 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
|
97 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
98 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
|
99 """ |
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
100 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
|
101 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
|
102 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
103 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
|
104 end |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
105 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
|
106 |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
107 # 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
|
108 # Can we give special treatment to TensorMappings that go to a higher dim? |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
109 function LazyTensors.range_size(e::BoundaryValue{T}, domain_size::NTuple{1,Integer}) where T |
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
110 if dim(e.bId) == 1 |
285
e21dcda55163
Add type representing an unknown dimension in the domain of tensormappings
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
284
diff
changeset
|
111 return (UnknownDim, domain_size[1]) |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
112 elseif dim(e.bId) == 2 |
285
e21dcda55163
Add type representing an unknown dimension in the domain of tensormappings
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
284
diff
changeset
|
113 return (domain_size[1], UnknownDim) |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
114 end |
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
115 end |
244
a827568fc251
Fix NormalDerivative and add tests
Jonatan Werpers <jonatan@werpers.com>
parents:
242
diff
changeset
|
116 LazyTensors.domain_size(e::BoundaryValue{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],) |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
117 # TODO: Make a nicer solution for 3-dim(e.bId) |
235
a5fdc00d5070
Fix a bunch of compilation errors
Jonatan Werpers <jonatan@werpers.com>
parents:
228
diff
changeset
|
118 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
119 # TODO: Make this independent of dimension |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
120 function LazyTensors.apply(e::BoundaryValue{T}, v::AbstractArray{T}, I::NTuple{2,Index}) where T |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
121 i = I[dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
122 j = I[3-dim(e.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
123 N_i = size(e.grid)[dim(e.bId)] |
280
fe9e8737ddfa
Change to using region indices in apply of BoundaryValue, NormalDerivative and BoundaryQuadrature
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
273
diff
changeset
|
124 return apply_boundary_value(e.op, v[j], i, N_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
|
125 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
126 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
127 function LazyTensors.apply_transpose(e::BoundaryValue{T}, v::AbstractArray{T}, I::NTuple{1,Index}) where T |
280
fe9e8737ddfa
Change to using region indices in apply of BoundaryValue, NormalDerivative and BoundaryQuadrature
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
273
diff
changeset
|
128 u = selectdim(v,3-dim(e.bId),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
|
129 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
|
130 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
131 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
132 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
133 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
|
134 |
258
3ea8c60ccef3
Fix a few typos in documentation and add a few TODOs
Jonatan Werpers <jonatan@werpers.com>
parents:
255
diff
changeset
|
135 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
|
136 """ |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
137 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
|
138 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
|
139 grid::EquidistantGrid{2} |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
140 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
|
141 end |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
142 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
|
143 |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
144 # 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
|
145 # Can we give special treatment to TensorMappings that go to a higher dim? |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
146 function LazyTensors.range_size(e::NormalDerivative, domain_size::NTuple{1,Integer}) |
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
147 if dim(e.bId) == 1 |
285
e21dcda55163
Add type representing an unknown dimension in the domain of tensormappings
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
284
diff
changeset
|
148 return (UnknownDim, domain_size[1]) |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
149 elseif dim(e.bId) == 2 |
285
e21dcda55163
Add type representing an unknown dimension in the domain of tensormappings
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
284
diff
changeset
|
150 return (domain_size[1], UnknownDim) |
284
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
151 end |
0b8e041a1873
Change how range_size and domain_size work with BoundaryValues and NormalDerivative
Jonatan Werpers <jonatan@werpers.com>
parents:
283
diff
changeset
|
152 end |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
153 LazyTensors.domain_size(e::NormalDerivative, range_size::NTuple{2,Integer}) = (range_size[3-dim(e.bId)],) |
247
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
154 |
ed29ee13e92e
Restructure laplace.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
244
diff
changeset
|
155 # 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
|
156 # TODO: Make this independent of dimension |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
157 function LazyTensors.apply(d::NormalDerivative{T}, v::AbstractArray{T}, I::NTuple{2,Index}) where T |
248
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
158 i = I[dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
159 j = I[3-dim(d.bId)] |
05e7bbe0af97
Merge refactoring of laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
diff
changeset
|
160 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
|
161 h_inv = inverse_spacing(d.grid)[dim(d.bId)] |
280
fe9e8737ddfa
Change to using region indices in apply of BoundaryValue, NormalDerivative and BoundaryQuadrature
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
273
diff
changeset
|
162 return apply_normal_derivative(d.op, h_inv, v[j], i, N_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
|
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 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
165 function LazyTensors.apply_transpose(d::NormalDerivative{T}, v::AbstractArray{T}, I::NTuple{1,Index}) where T |
280
fe9e8737ddfa
Change to using region indices in apply of BoundaryValue, NormalDerivative and BoundaryQuadrature
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
273
diff
changeset
|
166 u = selectdim(v,3-dim(d.bId),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
|
167 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
|
168 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
169 |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
170 """ |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
171 BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
172 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
173 Implements the boundary operator `q` as a TensorOperator |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
174 """ |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
175 struct BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
176 op::D2{T,N,M,K} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
177 grid::EquidistantGrid{2} |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
178 bId::CartesianBoundary |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
179 end |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
180 export BoundaryQuadrature |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
181 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
182 # TODO: Make this independent of dimension |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
183 function LazyTensors.apply(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Index}) where T |
268
f67ce2eb6019
Remove property spacing in EquidistantGrid, due to redundancy.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
266
diff
changeset
|
184 h = spacing(q.grid)[3-dim(q.bId)] |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
185 N = size(v) |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
186 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
|
187 end |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
188 |
281
1eefaefdd0c7
Add missing type parametrization
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
189 LazyTensors.apply_transpose(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Index}) where T = LazyTensors.apply(q,v,I) |
259
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
190 |
5571d2c5bf0f
Implement BaoundaryQuadrature for Laplace
Jonatan Werpers <jonatan@werpers.com>
parents:
258
diff
changeset
|
191 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
192 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
193 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
194 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
|
195 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
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 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
|
205 tau::Float64 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
206 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
207 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 # 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
|
215 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
216 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
217 # 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
|
218 # 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
|
219 # 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
|
220 # 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
|
221 # 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
|
222 # 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
|
223 # end |