Mercurial > repos > public > sbplib_julia
annotate src/SbpOperators/volumeops/laplace/laplace.jl @ 869:4bd35ba8f34a feature/laplace_opset
REVIEW: Add a few comments and suggest code changes
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 25 Jan 2022 07:21:58 +0100 |
parents | 1784b1c0af3e |
children | c4dd4ceb2d40 |
rev | line source |
---|---|
869
4bd35ba8f34a
REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents:
866
diff
changeset
|
1 # 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
|
2 # 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
|
3 # 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
|
4 # 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
|
5 # 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
|
6 # 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
|
7 # 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
|
8 # wouldn't be. |
4bd35ba8f34a
REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents:
866
diff
changeset
|
9 # |
4bd35ba8f34a
REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents:
866
diff
changeset
|
10 # 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
|
11 # 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
|
12 # |
4bd35ba8f34a
REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents:
866
diff
changeset
|
13 # I see two ways out: |
4bd35ba8f34a
REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents:
866
diff
changeset
|
14 # * 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
|
15 # * 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
|
16 |
624
a85db383484f
Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
618
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 Laplace{T, Dim, TMdiffop} <: TensorMapping{T,Dim,Dim} |
866 | 19 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
|
20 |
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
|
21 Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a |
704 | 22 `TensorMapping`. Additionally, `Laplace` stores the inner product and boundary |
866 | 23 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
|
24 |
866 | 25 `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
|
26 where the operators are read from TOML. The differential operator is created |
866 | 27 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
|
28 |
866 | 29 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
|
30 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
|
31 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
|
32 |
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
|
33 """ |
755
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
34 struct Laplace{T, Dim, TMdiffop<:TensorMapping{T,Dim,Dim}} <: TensorMapping{T,Dim,Dim} |
722 | 35 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
|
36 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
|
37 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
|
38 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
|
39 d::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Normal derivative operators |
866 | 40 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
|
41 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
|
42 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
|
43 |
866 | 44 function Laplace(grid, filename; order) |
45 | |
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
|
46 # Read stencils |
866 | 47 stencil_set = read_stencil_set(filename; order) |
48 # TODO: Removed once we can construct the volume and | |
49 # boundary operators by op(grid, read_stencil_set(fn; order,...)). | |
50 D_inner_stecil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | |
51 D_closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
52 H_inner_stencils = parse_scalar(stencil_set["H"]["inner"]) | |
53 H_closure_stencils = parse_tuple(stencil_set["H"]["closure"]) | |
54 e_closure_stencil = parse_stencil(stencil_set["e"]["closure"]) | |
55 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
|
56 # 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
|
57 |
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 # 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
|
59 Δ = laplace(grid, D_inner_stecil, D_closure_stencils) |
866 | 60 H = inner_product(grid, H_inner_stencils, H_closure_stencils) |
61 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
|
62 |
677
011863b3f24c
Make use of the function boundary_quadrature in Laplace constructor
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
668
diff
changeset
|
63 # Boundary operator - id pairs |
708
693f5487ddba
Minor clean up
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
704
diff
changeset
|
64 ids = boundary_identifiers(grid) |
869
4bd35ba8f34a
REVIEW: Add a few comments and suggest code changes
Jonatan Werpers <jonatan@werpers.com>
parents:
866
diff
changeset
|
65 # 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
|
66 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
|
67 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
|
68 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
|
69 |
751
f94feb005e7d
Change from Dict to StaticDict in Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
723
diff
changeset
|
70 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
|
71 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
|
72 |
756
1970ebceabe4
Add suggestion for pretty printing of Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
755
diff
changeset
|
73 # 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
|
74 # 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
|
75 # 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
|
76 |
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
|
77 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
|
78 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
|
79 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
|
80 |
755
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 """ |
866 | 83 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
|
84 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
85 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
|
86 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
87 """ |
704 | 88 inner_product(L::Laplace) = L.H |
89 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
|
90 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
91 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
92 """ |
866 | 93 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
|
94 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
95 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
|
96 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
97 """ |
704 | 98 inverse_inner_product(L::Laplace) = L.H_inv |
99 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
|
100 |
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 """ |
866 | 103 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
|
104 boundary_restriction(L::Laplace, ids::Tuple) |
866 | 105 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
|
106 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
107 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
|
108 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
|
109 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
110 """ |
866 | 111 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
|
112 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
|
113 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
|
114 # 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
|
115 # 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
|
116 # `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
|
117 # 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
|
118 # 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
|
119 # 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
|
120 |
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
|
121 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
|
122 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
123 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
124 """ |
866 | 125 normal_derivative(L::Laplace, id::BoundaryIdentifier) |
126 normal_derivative(L::Laplace, ids::NTuple{N,BoundaryIdentifier}) | |
127 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
|
128 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
129 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
|
130 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
|
131 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
132 """ |
866 | 133 normal_derivative(L::Laplace, id::BoundaryIdentifier) = L.d[id] |
134 normal_derivative(L::Laplace, ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.d[ids[i]],N) | |
135 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
|
136 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
|
137 |
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 """ |
866 | 140 boundary_quadrature(L::Laplace, id::BoundaryIdentifier) |
141 boundary_quadrature(L::Laplace, ids::NTuple{N,BoundaryIdentifier}) | |
142 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
|
143 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
144 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
|
145 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
|
146 |
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
147 """ |
866 | 148 boundary_quadrature(L::Laplace, id::BoundaryIdentifier) = L.H_boundary[id] |
149 boundary_quadrature(L::Laplace, ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.H_boundary[ids[i]],N) | |
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 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
|
152 |
755
36adc15d3935
Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
754
diff
changeset
|
153 |
624
a85db383484f
Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
618
diff
changeset
|
154 """ |
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
|
155 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
|
156 |
648
d6edde60909b
Fix typo in documentation and remove obsolete out-commented code.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
624
diff
changeset
|
157 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
|
158 |
a85db383484f
Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
618
diff
changeset
|
159 `Δ` 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
|
160 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
|
161 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
|
162 |
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
|
163 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
|
164 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
|
165 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
|
166 """ |
820
b4acd25943f4
Remove some more types and type parameters
Jonatan Werpers <jonatan@werpers.com>
parents:
690
diff
changeset
|
167 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
|
168 Δ = 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
|
169 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
|
170 Δ += 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
|
171 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
|
172 return Δ |
356
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
333
diff
changeset
|
173 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
|
174 export laplace |