annotate src/SbpOperators/volumeops/laplace/laplace.jl @ 922:0bf5952c240d feature/laplace_opset

Review: Add review comment regarding restructuring of Laplace
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sun, 30 Jan 2022 13:00:18 +0100
parents 86776d06b883
children 12e8e431b43c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
871
86776d06b883 REVIEW: Move export statements. Some to the top of the file and some to SbpOperators.jl since they seem more general
Jonatan Werpers <jonatan@werpers.com>
parents: 870
diff changeset
1 export Laplace
86776d06b883 REVIEW: Move export statements. Some to the top of the file and some to SbpOperators.jl since they seem more general
Jonatan Werpers <jonatan@werpers.com>
parents: 870
diff changeset
2 export laplace
86776d06b883 REVIEW: Move export statements. Some to the top of the file and some to SbpOperators.jl since they seem more general
Jonatan Werpers <jonatan@werpers.com>
parents: 870
diff changeset
3 # REVIEW: Makes more sense to me to have the exports at the top of the file.
86776d06b883 REVIEW: Move export statements. Some to the top of the file and some to SbpOperators.jl since they seem more general
Jonatan Werpers <jonatan@werpers.com>
parents: 870
diff changeset
4 # Might as well start fixing that.
86776d06b883 REVIEW: Move export statements. Some to the top of the file and some to SbpOperators.jl since they seem more general
Jonatan Werpers <jonatan@werpers.com>
parents: 870
diff changeset
5
922
0bf5952c240d Review: Add review comment regarding restructuring of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 871
diff changeset
6 # REVIEW:
0bf5952c240d Review: Add review comment regarding restructuring of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 871
diff changeset
7 # Design discussions has led to attempt a restructuring of Laplace to a more
0bf5952c240d Review: Add review comment regarding restructuring of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 871
diff changeset
8 # minimal type, holding the tensor mapping and a stencil set. This allows
0bf5952c240d Review: Add review comment regarding restructuring of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 871
diff changeset
9 # construction of associated tensor mappings, e.g. boundary operators, based on the
0bf5952c240d Review: Add review comment regarding restructuring of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 871
diff changeset
10 # stencil set while keeping the type simpler.
0bf5952c240d Review: Add review comment regarding restructuring of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 871
diff changeset
11
869
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
12 # REVIEW: The style of name `Laplace` might clash with other concepts. When
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
13 # thinking about implementing the variable second derivative I think I will
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
14 # have to create it as a full TM for the full dimensional problem instead of
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
15 # building it as a 1D operator and then use that with outer products. The
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
16 # natural name there would be `VariableSecondDerivative` (or something
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
17 # similar). But the similarity of the two names would suggest that `Laplace`
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
18 # and `VariableSecondDerivative` are the same kind of thing, which they
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
19 # wouldn't be.
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
20 #
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
21 # How do we distinguish the kind of type we are implementing here and what we
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
22 # could potentially do for the variable second derivative?
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
23 #
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
24 # I see two ways out:
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
25 # * Come up with a name for these sets of operators and change `Laplace` accordingly.
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
26 # * Come up with a name for the bare operators and change `VariableSecondDerivative` accordingly.
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
27
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
28 """
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
29 Laplace{T, Dim, TMdiffop} <: TensorMapping{T,Dim,Dim}
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
30 Laplace(grid, filename; 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
31
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 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
33 `TensorMapping`. Additionally, `Laplace` stores the inner product and boundary
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
34 operators relevant for constructing a SBP finite difference scheme as a `TensorMapping`.
677
011863b3f24c Make use of the function boundary_quadrature in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 668
diff changeset
35
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
36 `Laplace(grid, filename; order)` creates the Laplace operator defined on `grid`,
723
c16abc564b82 Change from EquidistantGrid to AbstractGrid in Laplace interface
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 722
diff changeset
37 where the operators are read from TOML. The differential operator is created
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
38 using `laplace(grid,...)`.
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
39
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
40 Note that all properties of Laplace, excluding the differential operator `Laplace.D`, are
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
41 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
42 accessed via the provided getter functions (e.g `inner_product(::Laplace)`).
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 """
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
44 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
45 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
46 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
47 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
48 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
49 d::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Normal derivative operators
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
50 H_boundary::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary quadrature operators
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
51 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
52
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
53 function Laplace(grid, filename; order)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
54
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
55 # Read stencils
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
56 stencil_set = read_stencil_set(filename; order)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
57 # TODO: Removed once we can construct the volume and
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
58 # boundary operators by op(grid, read_stencil_set(fn; order,...)).
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
59 D_inner_stecil = parse_stencil(stencil_set["D2"]["inner_stencil"])
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
60 D_closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"])
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
61 H_inner_stencils = parse_scalar(stencil_set["H"]["inner"])
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
62 H_closure_stencils = parse_tuple(stencil_set["H"]["closure"])
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
63 e_closure_stencil = parse_stencil(stencil_set["e"]["closure"])
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
64 d_closure_stencil = parse_stencil(stencil_set["d1"]["closure"])
869
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
65 # REVIEW: Do we add the methods to get rid of this in this branch or a new one?
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
66
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
67 # 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
68 Δ = laplace(grid, D_inner_stecil, D_closure_stencils)
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
69 H = inner_product(grid, H_inner_stencils, H_closure_stencils)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
70 H⁻¹ = inverse_inner_product(grid, H_inner_stencils, 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
71
677
011863b3f24c Make use of the function boundary_quadrature in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 668
diff changeset
72 # Boundary operator - id pairs
708
693f5487ddba Minor clean up
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 704
diff changeset
73 ids = boundary_identifiers(grid)
869
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
74 # REVIEW: Change suggestion: Seems more readable to me but pretty subjective so feel free to ignore
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
75 e_pairs = map(id -> Pair(id, boundary_restriction(grid, e_closure_stencil, id)), ids)
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
76 d_pairs = map(id -> Pair(id, normal_derivative(grid, d_closure_stencil, id)), ids)
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
77 Hᵧ_pairs = map(id -> Pair(id, inner_product(boundary_grid(grid, id), H_inner_stencils, H_closure_stencils)), ids)
668
2d56a53a1646 Simplify construction of boundary-operator pairs in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 667
diff changeset
78
751
f94feb005e7d Change from Dict to StaticDict in Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 723
diff changeset
79 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
80 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
81
756
1970ebceabe4 Add suggestion for pretty printing of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 755
diff changeset
82 # 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
83 # 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, ")")
869
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
84 # REVIEW: Should leave a todo here to update this once we have some pretty printing for tensor mappings in general.
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
85
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
86 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
87 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
88 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
89
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
90
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
91 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
92 inner_product(L::Laplace)
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
93
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
94 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
95 """
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
96 inner_product(L::Laplace) = L.H
755
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
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
99 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
100 inverse_inner_product(L::Laplace)
755
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 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
103 """
704
a7efedbdede9 Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 702
diff changeset
104 inverse_inner_product(L::Laplace) = L.H_inv
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
105
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
106
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
107 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
108 boundary_restriction(L::Laplace, id::BoundaryIdentifier)
869
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
109 boundary_restriction(L::Laplace, ids::Tuple)
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
110 boundary_restriction(L::Laplace, ids...)
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
111
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
112 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
113 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
114 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
115 boundary_restriction(L::Laplace, id::BoundaryIdentifier) = L.e[id]
869
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
116 boundary_restriction(L::Laplace, ids::Tuple) = map(id-> L.e[id], ids)
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
117 boundary_restriction(L::Laplace, ids...) = boundary_restriction(L, ids)
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
118 # REVIEW: I propose changing the following implementations according to the
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
119 # above. There are some things we're missing with regards to
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
120 # `BoundaryIdentifier`, for example we should be able to handle groups of
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
121 # boundaries as a single `BoundaryIdentifier`. I don't know if we can figure
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
122 # out the interface for that now or if we save it for the future but either
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
123 # way these methods will be affected.
4bd35ba8f34a REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents: 866
diff changeset
124
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
125
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
126
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
127 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
128 normal_derivative(L::Laplace, id::BoundaryIdentifier)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
129 normal_derivative(L::Laplace, ids::NTuple{N,BoundaryIdentifier})
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
130 normal_derivative(L::Laplace, ids...)
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
131
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
132 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
133 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
134 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
135 normal_derivative(L::Laplace, id::BoundaryIdentifier) = L.d[id]
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
136 normal_derivative(L::Laplace, ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.d[ids[i]],N)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
137 normal_derivative(L::Laplace, ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.d[ids[i]],N)
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
138
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
139
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
140 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
141 boundary_quadrature(L::Laplace, id::BoundaryIdentifier)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
142 boundary_quadrature(L::Laplace, ids::NTuple{N,BoundaryIdentifier})
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
143 boundary_quadrature(L::Laplace, ids...)
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
144
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
145 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
146 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
147 """
866
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
148 boundary_quadrature(L::Laplace, id::BoundaryIdentifier) = L.H_boundary[id]
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
149 boundary_quadrature(L::Laplace, ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.H_boundary[ids[i]],N)
1784b1c0af3e Merge with default
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 756 820
diff changeset
150 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
151
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
152
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
153 """
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
154 laplace(grid::EquidistantGrid{Dim}, 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
155
648
d6edde60909b Fix typo in documentation and remove obsolete out-commented code.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 624
diff changeset
156 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
157
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
158 `Δ` 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
159 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
160 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
161
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
162 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
163 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
164 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
165 """
820
b4acd25943f4 Remove some more types and type parameters
Jonatan Werpers <jonatan@werpers.com>
parents: 690
diff changeset
166 function laplace(grid::EquidistantGrid, 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
167 Δ = second_derivative(grid, inner_stencil, closure_stencils, 1)
820
b4acd25943f4 Remove some more types and type parameters
Jonatan Werpers <jonatan@werpers.com>
parents: 690
diff changeset
168 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
169 Δ += 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
170 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
171 return Δ
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
172 end