annotate src/SbpOperators/volumeops/laplace/laplace.jl @ 624:a85db383484f feature/volume_and_boundary_operators

Update documentation and remove some out-commented lines
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 21 Dec 2020 23:12:37 +0100
parents c64793f77509
children d6edde60909b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
1 """
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
2 Laplace(grid::EquidistantGrid{Dim}, inner_stencil, closure_stencils)
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
3
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
4 Creates the Laplace ooperator operator `Δ` as a `TensorMapping`
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
5
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
6 `Δ` approximates the Laplace operator ∑d²/xᵢ² , i = 1,...,`Dim` on `grid`, using
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
7 the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils`
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
8 for the points in the closure regions.
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
9
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
10 On a one-dimensional `grid`, `Δ` is a `SecondDerivative`. On a multi-dimensional `grid`, `Δ` is the sum of
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
11 multi-dimensional `SecondDerivative`s where the sum is carried out lazily.
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
12 """
616
d9324671b412 Use julian naming conventions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 611
diff changeset
13 function Laplace(grid::EquidistantGrid{Dim}, inner_stencil, closure_stencils) where Dim
d9324671b412 Use julian naming conventions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 611
diff changeset
14 Δ = SecondDerivative(grid, inner_stencil, closure_stencils, 1)
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 542
diff changeset
15 for d = 2:Dim
616
d9324671b412 Use julian naming conventions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 611
diff changeset
16 Δ += SecondDerivative(grid, inner_stencil, closure_stencils, d)
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
17 end
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 542
diff changeset
18 return Δ
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
19 end
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 542
diff changeset
20 export Laplace
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
21
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 # 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
23 # 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
24 # 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
25 # 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
26 # boundary_quadrature(L::Laplace, bId::CartesianBoundary) = BoundaryQuadrature(L.op, L.grid, bId)
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
27
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
28 # """
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 # 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
30 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 # 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
32 # """
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 # 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
34 # 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
35 # 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
36 # 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
37 # 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
38 # 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
39 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 # # 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
42 # 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
43 # 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
44 # 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
45 # 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
46 # 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
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 # 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
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 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 # 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
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 # 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
56 # 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
57 # 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
58 # 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
59 # 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
60 # 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
61 # 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
62 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 # 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
64 # 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
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 #
c1fcc35e19cb Make Laplace consist of tuples of SecondDerivatives. 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 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
68 # 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
69 # 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
70 # 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
71 # 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
72 # 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
73 # # 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
74 # end
228
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
75
5acef2d5db2e Move Laplace operator and related structs/functions to separate file.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
76 # 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
77 # 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
78 # 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
79 # 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
80 # 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
81 # 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
82 # end