annotate src/SbpOperators/volumeops/laplace/laplace.jl @ 756:1970ebceabe4 feature/laplace_opset

Add suggestion for pretty printing of Laplace
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 02 Jul 2021 11:13:14 +0200
parents 36adc15d3935
children 1784b1c0af3e 9929c99754fb
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 """
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
2 Laplace{T, Dim, TMdiffop} <: TensorMapping{T,Dim,Dim}
723
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
3 Laplace(grid::AbstractGrid, fn; order)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
4
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
5 Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
6 `TensorMapping`. Additionally, `Laplace` stores the inner product and boundary
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
7 operators relevant for constructing a SBP finite difference scheme as `TensorMapping`s.
677
011863b3f24c Make use of the function boundary_quadrature in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 668
diff changeset
8
723
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
9 Laplace(grid, fn; order) creates the Laplace operator defined on `grid`,
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
10 where the operators are read from TOML. The differential operator is created
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
11 using `laplace(grid::AbstractGrid,...)`.
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
12
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
13 Note that all properties of Laplace, excluding the Differential operator `D`, are
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
14 abstract types. For performance reasons, they should therefore be
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
15 accessed via the provided getter functions (e.g `inner_product(::Laplace)`).
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
16
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
17 """
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
18 struct Laplace{T, Dim, TMdiffop<:TensorMapping{T,Dim,Dim}} <: TensorMapping{T,Dim,Dim}
722
0402b9042adc Fix comment
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 708
diff changeset
19 D::TMdiffop # Differential operator
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
20 H::TensorMapping # Inner product operator
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
21 H_inv::TensorMapping # Inverse inner product operator
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
22 e::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary restriction operators.
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
23 d::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Normal derivative operators
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
24 H_boundary::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary quadrature operators # TODO: Boundary inner product?
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
25 end
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
26 export Laplace
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
27
723
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
28 function Laplace(grid::AbstractGrid, fn; order)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
29 # TODO: Removed once we can construct the volume and
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
30 # boundary operators by op(grid, fn; order,...).
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
31 # Read stencils
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
32 op = read_D2_operator(fn; order)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
33 D_inner_stecil = op.innerStencil
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
34 D_closure_stencils = op.closureStencils
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
35 H_closure_stencils = op.quadratureClosure
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
36 e_closure_stencil = op.eClosure
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
37 d_closure_stencil = op.dClosure
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
38
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
39 # Volume operators
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
40 Δ = laplace(grid, D_inner_stecil, D_closure_stencils)
702
3cd582257072 Merge in default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 677 690
diff changeset
41 H = inner_product(grid, H_closure_stencils)
3cd582257072 Merge in default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 677 690
diff changeset
42 H⁻¹ = inverse_inner_product(grid, H_closure_stencils)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
43
677
011863b3f24c Make use of the function boundary_quadrature in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 668
diff changeset
44 # Boundary operator - id pairs
708
693f5487ddba Minor clean up
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 704
diff changeset
45 ids = boundary_identifiers(grid)
693f5487ddba Minor clean up
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 704
diff changeset
46 n_ids = length(ids)
753
fc83d672be36 Minor cleanup of code
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 751
diff changeset
47 e_pairs = ntuple(i -> ids[i] => boundary_restriction(grid,e_closure_stencil,ids[i]),n_ids)
fc83d672be36 Minor cleanup of code
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 751
diff changeset
48 d_pairs = ntuple(i -> ids[i] => normal_derivative(grid,d_closure_stencil,ids[i]),n_ids)
fc83d672be36 Minor cleanup of code
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 751
diff changeset
49 Hᵧ_pairs = ntuple(i -> ids[i] => inner_product(boundary_grid(grid,ids[i]),H_closure_stencils),n_ids)
668
2d56a53a1646 Simplify construction of boundary-operator pairs in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 667
diff changeset
50
751
f94feb005e7d Change from Dict to StaticDict in Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 723
diff changeset
51 return Laplace(Δ, H, H⁻¹, StaticDict(e_pairs), StaticDict(d_pairs), StaticDict(Hᵧ_pairs))
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
52 end
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
53
756
1970ebceabe4 Add suggestion for pretty printing of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 755
diff changeset
54 # TODO: Consider pretty printing of the following form
1970ebceabe4 Add suggestion for pretty printing of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 755
diff changeset
55 # Base.show(io::IO, L::Laplace{T, Dim}) where {T,Dim,TM} = print(io, "Laplace{$T, $Dim, $TM}(", L.D, L.H, L.H_inv, L.e, L.d, L.H_boundary, ")")
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
56
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
57 LazyTensors.range_size(L::Laplace) = LazyTensors.range_size(L.D)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
58 LazyTensors.domain_size(L::Laplace) = LazyTensors.domain_size(L.D)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
59 LazyTensors.apply(L::Laplace, v::AbstractArray, I...) = LazyTensors.apply(L.D,v,I...)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
60
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
61
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
62 """
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
63 inner_product(L::Lapalace)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
64
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
65 Returns the inner product operator associated with `L`
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
66
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
67 """
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
68 inner_product(L::Laplace) = L.H
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
69 export inner_product
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
70
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
71
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
72 """
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
73 inverse_inner_product(L::Lapalace)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
74
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
75 Returns the inverse of the inner product operator associated with `L`
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
76
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
77 """
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
78 inverse_inner_product(L::Laplace) = L.H_inv
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
79 export inverse_inner_product
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
80
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
81
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
82 """
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
83 boundary_restriction(L::Lapalace,id::BoundaryIdentifier)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
84 boundary_restriction(L::Lapalace,ids::NTuple{N,BoundaryIdentifier})
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
85 boundary_restriction(L::Lapalace,ids...)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
86
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
87 Returns boundary restriction operator(s) associated with `L` for the boundary(s)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
88 identified by id(s).
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
89
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
90 """
754
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
91 boundary_restriction(L::Laplace,id::BoundaryIdentifier) = L.e[id]
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
92 boundary_restriction(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.e[ids[i]],N)
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
93 boundary_restriction(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.e[ids[i]],N)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
94 export boundary_restriction
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
95
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
96
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
97 """
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
98 normal_derivative(L::Lapalace,id::BoundaryIdentifier)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
99 normal_derivative(L::Lapalace,ids::NTuple{N,BoundaryIdentifier})
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
100 normal_derivative(L::Lapalace,ids...)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
101
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
102 Returns normal derivative operator(s) associated with `L` for the boundary(s)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
103 identified by id(s).
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
104
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
105 """
754
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
106 normal_derivative(L::Laplace,id::BoundaryIdentifier) = L.d[id]
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
107 normal_derivative(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.d[ids[i]],N)
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
108 normal_derivative(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.d[ids[i]],N)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
109 export normal_derivative
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
110
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
111
708
693f5487ddba Minor clean up
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 704
diff changeset
112 # TODO: boundary_inner_product?
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
113 """
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
114 boundary_quadrature(L::Lapalace,id::BoundaryIdentifier)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
115 boundary_quadrature(L::Lapalace,ids::NTuple{N,BoundaryIdentifier})
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
116 boundary_quadrature(L::Lapalace,ids...)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
117
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
118 Returns boundary quadrature operator(s) associated with `L` for the boundary(s)
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
119 identified by id(s).
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
120
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
121 """
754
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
122 boundary_quadrature(L::Laplace,id::BoundaryIdentifier) = L.H_boundary[id]
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
123 boundary_quadrature(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.H_boundary[ids[i]],N)
dc38e57ebd1b Add convenience functions for returning multiple boundary operators from Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 753
diff changeset
124 boundary_quadrature(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.H_boundary[ids[i]],N)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
125 export boundary_quadrature
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
126
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
127
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
128 """
723
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
129 laplace(grid, inner_stencil, closure_stencils)
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
130
648
d6edde60909b Fix typo in documentation and remove obsolete out-commented code.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 624
diff changeset
131 Creates the Laplace operator operator `Δ` as a `TensorMapping`
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
132
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
133 `Δ` approximates the Laplace operator ∑d²/xᵢ² , i = 1,...,N on the N-dimensional
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
134 `grid`, using the stencil `inner_stencil` in the interior and a set of stencils
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
135 `closure_stencils` for the points in the closure regions.
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
136
690
1accc3e051d0 Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
137 On a one-dimensional `grid`, `Δ` is equivalent to `second_derivative`. On a
1accc3e051d0 Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
138 multi-dimensional `grid`, `Δ` is the sum of multi-dimensional `second_derivative`s
1accc3e051d0 Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
139 where the sum is carried out lazily.
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
140 """
723
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
141 function laplace(grid::AbstractGrid, inner_stencil, closure_stencils)
690
1accc3e051d0 Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
142 Δ = second_derivative(grid, inner_stencil, closure_stencils, 1)
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
143 for d = 2:dimension(grid)
690
1accc3e051d0 Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
144 Δ += second_derivative(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
145 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
146 return Δ
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
147 end
690
1accc3e051d0 Start changing the name of functions creating operators that are not types to lower case. E.g SecondDerivative->second_derivative
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
148 export laplace