Mercurial > repos > public > sbplib_julia
annotate src/SbpOperators/laplace/laplace.jl @ 542:011ca1639153 refactor/tensor_index_coupling
Remove Index{Unknown} and replace with general Any implementations
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 27 Nov 2020 11:27:37 +0100 |
parents | 0546cb279fc2 |
children | e71f2f81b5f8 |
rev | line source |
---|---|
312
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
1 export Laplace |
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
|
2 """ |
356
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
3 Laplace{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} |
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
|
4 |
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 Implements the Laplace operator `L` in Dim dimensions as a tensor operator |
300
b00eea62c78e
Create 1D tensor mapping for diagonal norm quadratures, and make the multi-dimensional quadrature use those. Move Qudrature from laplace.jl into Quadrature.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
293
diff
changeset
|
6 The multi-dimensional tensor operator consists of a tuple of 1D SecondDerivative |
b00eea62c78e
Create 1D tensor mapping for diagonal norm quadratures, and make the multi-dimensional quadrature use those. Move Qudrature from laplace.jl into Quadrature.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
293
diff
changeset
|
7 tensor operators. |
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
|
8 """ |
312
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
9 #export quadrature, inverse_quadrature, boundary_quadrature, boundary_value, normal_derivative |
356
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
10 struct Laplace{Dim,T,N,M,K} <: TensorMapping{T,Dim,Dim} |
312
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
11 D2::NTuple{Dim,SecondDerivative{T,N,M,K}} |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
12 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
13 |
356
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
14 function Laplace(g::EquidistantGrid{Dim}, innerStencil, closureStencils) where Dim |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
15 D2 = () |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
16 for i ∈ 1:Dim |
368
0546cb279fc2
Fix breaking tests by fixing calls to subgrid/restrict
Jonatan Werpers <jonatan@werpers.com>
parents:
361
diff
changeset
|
17 D2 = (D2..., SecondDerivative(restrict(g,i), innerStencil, closureStencils)) |
356
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
18 end |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
19 |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
20 return Laplace(D2) |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
21 end |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
22 |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
23 LazyTensors.range_size(L::Laplace) = getindex.(range_size.(L.D2),1) |
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
24 LazyTensors.domain_size(L::Laplace) = getindex.(domain_size.(L.D2),1) |
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 |
542
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
26 function LazyTensors.apply(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Any,Dim}) 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
|
27 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
|
28 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
29 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
30 # u = L*v |
542
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
31 function LazyTensors.apply(L::Laplace{1,T}, v::AbstractVector{T}, i) where T |
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
32 @inbounds u = LazyTensors.apply(L.D2[1],v,i) |
300
b00eea62c78e
Create 1D tensor mapping for diagonal norm quadratures, and make the multi-dimensional quadrature use those. Move Qudrature from laplace.jl into Quadrature.jl
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
293
diff
changeset
|
33 return u |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
34 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
35 |
542
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
36 function LazyTensors.apply(L::Laplace{2,T}, v::AbstractArray{T,2}, i, j) 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
|
37 # 2nd x-derivative |
542
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
38 @inbounds vx = view(v, :, Int(j)) |
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
39 @inbounds uᵢ = LazyTensors.apply(L.D2[1], vx , i) |
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
|
40 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
41 # 2nd y-derivative |
542
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
42 @inbounds vy = view(v, Int(i), :) |
011ca1639153
Remove Index{Unknown} and replace with general Any implementations
Jonatan Werpers <jonatan@werpers.com>
parents:
368
diff
changeset
|
43 @inbounds uᵢ += LazyTensors.apply(L.D2[2], vy , j) |
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
|
44 |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
45 return uᵢ |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
46 end |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
47 |
312
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
48 # quadrature(L::Laplace) = Quadrature(L.op, L.grid) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
49 # inverse_quadrature(L::Laplace) = InverseQuadrature(L.op, L.grid) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
50 # boundary_value(L::Laplace, bId::CartesianBoundary) = BoundaryValue(L.op, L.grid, bId) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
51 # normal_derivative(L::Laplace, bId::CartesianBoundary) = NormalDerivative(L.op, L.grid, bId) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
52 # boundary_quadrature(L::Laplace, bId::CartesianBoundary) = BoundaryQuadrature(L.op, L.grid, bId) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
53 # export NormalDerivative |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
54 # """ |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
55 # NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
56 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
57 # Implements the boundary operator `d` as a TensorMapping |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
58 # """ |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
59 # struct NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
60 # op::D2{T,N,M,K} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
61 # grid::EquidistantGrid{2} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
62 # bId::CartesianBoundary |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
63 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
64 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
65 # # TODO: This is obviouly strange. Is domain_size just discarded? Is there a way to avoid storing grid in BoundaryValue? |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
66 # # Can we give special treatment to TensorMappings that go to a higher dim? |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
67 # function LazyTensors.range_size(e::NormalDerivative, domain_size::NTuple{1,Integer}) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
68 # if dim(e.bId) == 1 |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
69 # return (UnknownDim, domain_size[1]) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
70 # elseif dim(e.bId) == 2 |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
71 # return (domain_size[1], UnknownDim) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
72 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
73 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
74 # LazyTensors.domain_size(e::NormalDerivative, range_size::NTuple{2,Integer}) = (range_size[3-dim(e.bId)],) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
75 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
76 # # TODO: Not type stable D:< |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
77 # # TODO: Make this independent of dimension |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
78 # function LazyTensors.apply(d::NormalDerivative{T}, v::AbstractArray{T}, I::NTuple{2,Index}) where T |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
79 # i = I[dim(d.bId)] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
80 # j = I[3-dim(d.bId)] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
81 # N_i = size(d.grid)[dim(d.bId)] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
82 # h_inv = inverse_spacing(d.grid)[dim(d.bId)] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
83 # return apply_normal_derivative(d.op, h_inv, v[j], i, N_i, region(d.bId)) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
84 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
85 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
86 # function LazyTensors.apply_transpose(d::NormalDerivative{T}, v::AbstractArray{T}, I::NTuple{1,Index}) where T |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
87 # u = selectdim(v,3-dim(d.bId),Int(I[1])) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
88 # return apply_normal_derivative_transpose(d.op, inverse_spacing(d.grid)[dim(d.bId)], u, region(d.bId)) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
89 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
90 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
91 # """ |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
92 # BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
93 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
94 # Implements the boundary operator `q` as a TensorOperator |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
95 # """ |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
96 # export BoundaryQuadrature |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
97 # struct BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
98 # op::D2{T,N,M,K} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
99 # grid::EquidistantGrid{2} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
100 # bId::CartesianBoundary |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
101 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
102 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
103 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
104 # # TODO: Make this independent of dimension |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
105 # function LazyTensors.apply(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Index}) where T |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
106 # h = spacing(q.grid)[3-dim(q.bId)] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
107 # N = size(v) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
108 # return apply_quadrature(q.op, h, v[I[1]], I[1], N[1]) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
109 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
110 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
111 # LazyTensors.apply_transpose(q::BoundaryQuadrature{T}, v::AbstractArray{T,1}, I::NTuple{1,Index}) where T = LazyTensors.apply(q,v,I) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
112 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
113 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
114 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
115 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
116 # struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
117 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
118 # function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
119 # e = boundary_value(L, Bid()) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
120 # d = normal_derivative(L, Bid()) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
121 # Hᵧ = boundary_quadrature(L, Bid()) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
122 # H⁻¹ = inverse_quadrature(L) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
123 # return (-H⁻¹*e*Hᵧ*(d'*v - g))[I] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
124 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
125 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
126 # struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
127 # tau::Float64 |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
128 # end |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
129 # |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
130 # function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid} |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
131 # e = boundary_value(L, Bid()) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
132 # d = normal_derivative(L, Bid()) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
133 # Hᵧ = boundary_quadrature(L, Bid()) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
134 # H⁻¹ = inverse_quadrature(L) |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
135 # return (-H⁻¹*(tau/h*e + d)*Hᵧ*(e'*v - g))[I] |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
136 # # Need to handle scalar multiplication and addition of TensorMapping |
c1fcc35e19cb
Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
302
diff
changeset
|
137 # end |
228
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
138 |
5acef2d5db2e
Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
139 # 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
|
140 # 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
|
141 # 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
|
142 # 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
|
143 # 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
|
144 # 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
|
145 # end |