comparison src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl @ 1371:d0e48c2e6aad feature/variable_derivatives

Remove stencil input for 1d grid and reorder methods of second_derivative_variable
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 26 May 2023 21:44:33 +0200
parents 4ef8fb75d144
children 3f7f826489a1
comparison
equal deleted inserted replaced
1370:4ef8fb75d144 1371:d0e48c2e6aad
6 6
7 Approximates the d/dξ c d/dξ on `g` along the coordinate dimension specified 7 Approximates the d/dξ c d/dξ on `g` along the coordinate dimension specified
8 by `direction`. 8 by `direction`.
9 """ 9 """
10 function second_derivative_variable end 10 function second_derivative_variable end
11
12
13 function second_derivative_variable(g::TensorGrid, coeff::AbstractArray, inner_stencil::NestedStencil, closure_stencils, dir)
14 check_coefficient(g, coeff)
15
16 Δxᵢ = spacing(g.grids[dir])
17 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2)
18 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2)
19 return SecondDerivativeVariable{dir, ndims(g)}(scaled_inner_stencil, scaled_closure_stencils, coeff)
20 end
21
22 function second_derivative_variable(g::EquidistantGrid, coeff::AbstractVector, inner_stencil::NestedStencil, closure_stencils)
23 return second_derivative_variable(TensorGrid(g), coeff, inner_stencil, closure_stencils, 1)
24 end
25 11
26 function second_derivative_variable(g::TensorGrid, coeff::AbstractArray, stencil_set, dir::Int) 12 function second_derivative_variable(g::TensorGrid, coeff::AbstractArray, stencil_set, dir::Int)
27 inner_stencil = parse_nested_stencil(eltype(coeff), stencil_set["D2variable"]["inner_stencil"]) 13 inner_stencil = parse_nested_stencil(eltype(coeff), stencil_set["D2variable"]["inner_stencil"])
28 closure_stencils = parse_nested_stencil.(eltype(coeff), stencil_set["D2variable"]["closure_stencils"]) 14 closure_stencils = parse_nested_stencil.(eltype(coeff), stencil_set["D2variable"]["closure_stencils"])
29 15
32 18
33 function second_derivative_variable(g::EquidistantGrid, coeff::AbstractArray, stencil_set) 19 function second_derivative_variable(g::EquidistantGrid, coeff::AbstractArray, stencil_set)
34 return second_derivative_variable(TensorGrid(g), coeff, stencil_set, 1) 20 return second_derivative_variable(TensorGrid(g), coeff, stencil_set, 1)
35 end 21 end
36 22
23 function second_derivative_variable(g::TensorGrid, coeff::AbstractArray, inner_stencil::NestedStencil, closure_stencils, dir)
24 check_coefficient(g, coeff)
25
26 Δxᵢ = spacing(g.grids[dir])
27 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2)
28 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2)
29 return SecondDerivativeVariable{dir, ndims(g)}(scaled_inner_stencil, scaled_closure_stencils, coeff)
30 end
37 31
38 function check_coefficient(g, coeff) 32 function check_coefficient(g, coeff)
39 if ndims(g) != ndims(coeff) 33 if ndims(g) != ndims(coeff)
40 throw(ArgumentError("The coefficient has dimension $(ndims(coeff)) while the grid is dimension $(ndims(g))")) 34 throw(ArgumentError("The coefficient has dimension $(ndims(coeff)) while the grid is dimension $(ndims(g))"))
41 end 35 end