annotate src/SbpOperators/laplace/laplace.jl @ 333:01b851161018 refactor/combine_to_one_package

Start converting to one package by moving all the files to their correct location
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 25 Sep 2020 13:06:02 +0200
parents SbpOperators/src/laplace/laplace.jl@9cc5d1498b2d
children 0844069ab5ff
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
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 312
diff changeset
15 LazyTensors.domain_size(L::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
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 312
diff changeset
27 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
28 # 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
29 @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
30 @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
31
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
32 # 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
33 @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
34 @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
35
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
36 return uᵢ
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
37 end
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
38
328
9cc5d1498b2d Refactor 1D diagonal inner product in quadrature.jl to separate file. Write tests for quadratures. Clean up laplace and secondderivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 312
diff changeset
39 LazyTensors.apply_transpose(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {T,Dim} = 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
40
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
41 # 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
42 # 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
43 # 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
44 # 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
45 # 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
46 # 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
47 # """
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 # 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
49 #
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 # 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
51 # """
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 # 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
53 # 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
54 # 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
55 # 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
56 # 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
57 #
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 # # 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
59 # # 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
60 # 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
61 # 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
62 # 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
63 # 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
64 # 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
65 # 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
66 # 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
67 # 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
68 #
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 # # 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
70 # # 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
71 # 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
72 # 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
73 # 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
74 # 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
75 # 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
76 # 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
77 # 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
78 #
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 # 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
80 # 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
81 # 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
82 # 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
83 #
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 # """
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 # 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
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 # 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
88 # """
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 # 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
90 # 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
91 # 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
92 # 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
93 # 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
94 # 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
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 #
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 # # 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
98 # 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
99 # 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
100 # 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
101 # 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
102 # 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
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 # 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
105 #
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 #
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 # 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
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 # 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
112 # 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
113 # 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
114 # 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
115 # 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
116 # 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
117 # 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
118 #
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 # 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
120 # 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
121 # 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
122 #
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 # 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
124 # 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
125 # 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
126 # 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
127 # 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
128 # 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
129 # # 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
130 # end
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
131
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
132 # 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
133 # 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
134 # 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
135 # 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
136 # 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
137 # 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
138 # end