annotate src/SbpOperators/volumeops/derivatives/first_derivative.jl @ 989:7bf3121c6864 feature/stencil_set_type

Add type StencilSet
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Mar 2022 21:31:20 +0100
parents ba023fc09961
children b6238afd3bb0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
972
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
1 """
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
2 first_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction)
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
3
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
4 Creates the first-derivative operator `D1` as a `TensorMapping`
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
5
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
6 `D1` approximates the first-derivative d/dξ on `grid` along the coordinate dimension specified by
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
7 `direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils`
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
8 for the points in the closure regions.
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
9
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
10 On a one-dimensional `grid`, `D1` is a `VolumeOperator`. On a multi-dimensional `grid`, `D1` is the outer product of the
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
11 one-dimensional operator with the `IdentityMapping`s in orthogonal coordinate dirrections.
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
12
974
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
13 See also: [`volume_operator`](@ref).
972
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
14 """
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
15 function first_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction)
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
16 h_inv = inverse_spacing(grid)[direction]
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
17 return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv), scale.(closure_stencils,h_inv), odd, direction)
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
18 end
974
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
19 first_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = first_derivative(grid,inner_stencil,closure_stencils,1)
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
20
989
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
21
974
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
22 """
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
23 first_derivative(grid, stencil_set, direction)
972
803f60f461c1 Start adding the first derivative
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
24
989
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
25 Creates a `first_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`.
974
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
26 """
989
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
27 function first_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction)
974
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
28 inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"])
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
29 closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"])
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
30 first_derivative(grid,inner_stencil,closure_stencils,direction);
ba023fc09961 Add stencil_set method and accuracy tests
Jonatan Werpers <jonatan@werpers.com>
parents: 972
diff changeset
31 end
989
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
32
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
33 # TODO: Not possible to remove ::Stencil from first_derivative(grid::EquidistantGrid{1},...) due to type deduction failing.
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
34 # Is this due to the type ambuguity of StencilSet? Possible to address in some other way?
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 974
diff changeset
35 # If not, should we drop ::StencilSet from the method above (it is not required)?