Mercurial > repos > public > sbplib_julia
annotate src/SbpOperators/volumeops/derivatives/second_derivative.jl @ 1292:6753b210d0ab refactor/grids
Add todos
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 07 Mar 2023 10:11:49 +0100 |
parents | 356ec6a72974 |
children | e94ddef5e72f |
rev | line source |
---|---|
623
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
1 """ |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
2 second_derivative(g::EquidistantGrid, inner_stencil, closure_stencils, direction) |
623
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
3 |
995 | 4 Creates the second-derivative operator `D2` as a `LazyTensor` |
623
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
5 |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
6 `D2` approximates the second-derivative d²/dξ² on `g` along the coordinate dimension specified by |
623
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
7 `direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils` |
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
8 for the points in the closure regions. |
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
9 |
1104
c0ab81e4c39c
Update docs
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1100
diff
changeset
|
10 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). |
623
914428a1fc61
Add documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
619
diff
changeset
|
11 """ |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
12 function second_derivative(g::TensorGrid, stencil_set, direction) |
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
13 D₂ = second_derivative(g.grids[direction], stencil_set) |
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
14 return LazyTensors.inflate(D₂, size(g), direction) |
356
0844069ab5ff
Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents:
348
diff
changeset
|
15 end |
990
b6238afd3bb0
Add methods for creating derivative operators in 1D from stencil sets without providing directions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
989
diff
changeset
|
16 |
964
2ae62dbaf839
Add method for creating second derivative from a stencil set.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
952
diff
changeset
|
17 """ |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
18 second_derivative(g, stencil_set) |
952
6a8d7fbf55fc
Review: Stencil set method for second_derivative?
Jonatan Werpers <jonatan@werpers.com>
parents:
947
diff
changeset
|
19 |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
20 Creates a `second_derivative` operator on a 1D `g` given a `stencil_set`. |
964
2ae62dbaf839
Add method for creating second derivative from a stencil set.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
952
diff
changeset
|
21 """ |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
22 function second_derivative(g::EquidistantGrid, stencil_set::StencilSet) |
964
2ae62dbaf839
Add method for creating second derivative from a stencil set.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
952
diff
changeset
|
23 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) |
2ae62dbaf839
Add method for creating second derivative from a stencil set.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
952
diff
changeset
|
24 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
25 return second_derivative(g, inner_stencil, closure_stencils) |
990
b6238afd3bb0
Add methods for creating derivative operators in 1D from stencil sets without providing directions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
989
diff
changeset
|
26 end |
b6238afd3bb0
Add methods for creating derivative operators in 1D from stencil sets without providing directions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
989
diff
changeset
|
27 |
b6238afd3bb0
Add methods for creating derivative operators in 1D from stencil sets without providing directions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
989
diff
changeset
|
28 """ |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
29 second_derivative(g, inner_stencil, closure_stencils) |
990
b6238afd3bb0
Add methods for creating derivative operators in 1D from stencil sets without providing directions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
989
diff
changeset
|
30 |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
31 Creates a `second_derivative` operator on a 1D `g` given `inner_stencil` and `closure_stencils`. |
990
b6238afd3bb0
Add methods for creating derivative operators in 1D from stencil sets without providing directions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
989
diff
changeset
|
32 """ |
1291
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
33 function second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) |
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
34 h⁻¹ = inverse_spacing(g) |
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
35 return VolumeOperator(g, scale(inner_stencil,h⁻¹^2), scale.(closure_stencils,h⁻¹^2), even) |
356ec6a72974
Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents:
1104
diff
changeset
|
36 end |