comparison src/SbpOperators/volumeops/derivatives/first_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 first_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) 15 function first_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), scale.(closure_stencils,h_inv), odd, direction) 17 return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv), scale.(closure_stencils,h_inv), odd, direction)
18 end 18 end
19 first_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = first_derivative(grid,inner_stencil,closure_stencils,1)
20 19
21 20
22 """ 21 """
23 first_derivative(grid, stencil_set, direction) 22 first_derivative(grid, inner_stencil, closure_stencils)
23
24 Creates a `first_derivative` operator on a 1D `grid` given `inner_stencil` and `closure_stencils`.
25 """
26 first_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = first_derivative(grid, inner_stencil, closure_stencils, 1)
27
28
29 """
30 first_derivative(grid, stencil_set::StencilSet, direction)
24 31
25 Creates a `first_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`. 32 Creates a `first_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`.
26 """ 33 """
27 function first_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction) 34 function first_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction)
28 inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"]) 35 inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"])
29 closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"]) 36 closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"])
30 first_derivative(grid,inner_stencil,closure_stencils,direction); 37 first_derivative(grid,inner_stencil,closure_stencils,direction);
31 end 38 end
32 39
33 # TODO: Not possible to remove ::Stencil from first_derivative(grid::EquidistantGrid{1},...) due to type deduction failing. 40
34 # Is this due to the type ambuguity of StencilSet? Possible to address in some other way? 41 """
35 # If not, should we drop ::StencilSet from the method above (it is not required)? 42 first_derivative(grid, stencil_set)
43
44 Creates a `first_derivative` operator on a 1D `grid` given a `stencil_set`.
45 """
46 first_derivative(grid::EquidistantGrid{1}, stencil_set) = first_derivative(grid, stencil_set, 1)