annotate SbpOperators/src/laplace/laplace.jl @ 312:c1fcc35e19cb

Make Laplace consist of tuples of SecondDerivatives. Begin cleanup of functionallity which should be moved to separate files. WIP
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 09 Sep 2020 21:18:28 +0200
parents 6fa2ba769ae3
children 9cc5d1498b2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 """
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 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
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
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
10 struct Laplace{Dim,T,N,M,K} <: TensorOperator{T,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
11 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
12 #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
13 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
14
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
15 LazyTensors.domain_size(H::Laplace{Dim}, range_size::NTuple{Dim,Integer}) where {Dim} = 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
16
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
17 function LazyTensors.apply(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,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
18 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
19 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
20
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
21 # u = L*v
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
22 function LazyTensors.apply(L::Laplace{1,T}, v::AbstractVector{T}, I::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
23 @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
24 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
25 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
26
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
27 # TODO: Fix dispatch on tuples!
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
28 @inline function LazyTensors.apply(L::Laplace{2,T}, v::AbstractArray{T,2}, I::Index, J::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
29 # 2nd x-derivative
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
30 @inbounds vx = view(v, :, Int(J))
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
31 @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
32
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
33 # 2nd y-derivative
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
34 @inbounds vy = view(v, Int(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
35 @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
36
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
37 return uᵢ
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
38 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
39
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
40 @inline function LazyTensors.apply_transpose(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {T,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
41 return LazyTensors.apply(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
42 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
43
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
44 # 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
45 # 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
46 # 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
47 # 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
48 # 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
49 # 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
50 # """
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 # 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
52 #
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 # 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
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 # 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
56 # 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
57 # 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
58 # 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
59 # 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
60 #
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 # # 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
62 # # 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
63 # 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
64 # 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
65 # 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
66 # 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
67 # 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
68 # 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
69 # 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
70 # 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
71 #
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 # # 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
73 # # 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
74 # 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
75 # 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
76 # 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
77 # 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
78 # 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
79 # 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
80 # 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
81 #
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 # 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
83 # 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
84 # 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
85 # 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
86 #
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 # """
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 # 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
89 #
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 # 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
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 # 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
93 # 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
94 # 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
95 # 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
96 # 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
97 # 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
98 #
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 #
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 # # 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
101 # 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
102 # 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
103 # 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
104 # 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
105 # 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
106 #
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 # 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
108 #
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 #
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 #
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 # 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
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 # 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
115 # 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
116 # 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
117 # 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
118 # 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
119 # 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
120 # 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
121 #
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 # 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
123 # 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
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 # 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
127 # 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
128 # 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
129 # 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
130 # 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
131 # 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
132 # # 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
133 # end
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
134
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
135 # 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>
parents: 247 245
diff changeset
136 # 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
137 # 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
138 # 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
139 # 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
140 # 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
141 # end