comparison src/SbpOperators/volumeops/derivatives/second_derivative.jl @ 990:b6238afd3bb0 feature/stencil_set_type

Add methods for creating derivative operators in 1D from stencil sets without providing directions
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 18 Mar 2022 13:02:46 +0100
parents 7bf3121c6864
children 99d1f5651d0b
comparison
equal deleted inserted replaced
989:7bf3121c6864 990:b6238afd3bb0
14 """ 14 """
15 function second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) 15 function second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction)
16 h_inv = inverse_spacing(grid)[direction] 16 h_inv = inverse_spacing(grid)[direction]
17 return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv^2), scale.(closure_stencils,h_inv^2), even, direction) 17 return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv^2), scale.(closure_stencils,h_inv^2), even, direction)
18 end 18 end
19 second_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = second_derivative(grid,inner_stencil,closure_stencils,1) 19
20
21 """
22 second_derivative(grid, inner_stencil, closure_stencils)
23
24 Creates a `second_derivative` operator on a 1D `grid` given `inner_stencil` and `closure_stencils`.
25 """
26 second_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = second_derivative(grid, inner_stencil, closure_stencils,1)
27
20 28
21 """ 29 """
22 second_derivative(grid, stencil_set, direction) 30 second_derivative(grid, stencil_set, direction)
23 31
24 Creates a `second_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`. 32 Creates a `second_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`.
25 """ 33 """
26 function second_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction) 34 function second_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction)
27 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) 35 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"])
28 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) 36 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"])
29 second_derivative(grid,inner_stencil,closure_stencils,direction); 37 second_derivative(grid,inner_stencil,closure_stencils,direction);
30 end 38 end
31 39
32 # TODO: Not possible to remove ::Stencil from second_derivative(grid::EquidistantGrid{1},...) due to type deduction failing. 40
33 # Is this due to the type ambuguity of StencilSet? Possible to address in some other way? 41 """
34 # If not, should we drop ::StencilSet from the method above (it is not required)? 42 second_derivative(grid, stencil_set)
43
44 Creates a `second_derivative` operator on a 1D `grid` given a `stencil_set`.
45 """
46 second_derivative(grid::EquidistantGrid{1}, stencil_set) = second_derivative(grid, stencil_set, 1)