Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl @ 2080:0f949681d3d3 refactor/sbp_operators/direction_check tip
Check that direction of first/second derivative operators is within the dimension of the grid. Add 1D functions for first/second derivative operators that take a direction.
| author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
|---|---|
| date | Fri, 20 Feb 2026 12:01:05 +0100 |
| parents | e9dfc1998d31 |
| children |
comparison
equal
deleted
inserted
replaced
| 2079:118c09b168f5 | 2080:0f949681d3d3 |
|---|---|
| 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 | 11 |
| 12 function second_derivative_variable(g::TensorGrid, coeff, stencil_set, dir::Int) | 12 function second_derivative_variable(g::TensorGrid, coeff, stencil_set, direction::Int) |
| 13 if direction ∉ Interval(0, ndims(g)) | |
| 14 throw(DomainError(direction, "Direction must be inside [0, $(ndims(g))].")) | |
| 15 end | |
| 13 inner_stencil = parse_nested_stencil(eltype(coeff), stencil_set["D2variable"]["inner_stencil"]) | 16 inner_stencil = parse_nested_stencil(eltype(coeff), stencil_set["D2variable"]["inner_stencil"]) |
| 14 closure_stencils = parse_nested_stencil.(eltype(coeff), stencil_set["D2variable"]["closure_stencils"]) | 17 closure_stencils = parse_nested_stencil.(eltype(coeff), stencil_set["D2variable"]["closure_stencils"]) |
| 15 | 18 |
| 16 return second_derivative_variable(g, coeff, inner_stencil, closure_stencils, dir) | 19 return second_derivative_variable(g, coeff, inner_stencil, closure_stencils, direction) |
| 20 end | |
| 21 | |
| 22 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, direction) | |
| 23 return second_derivative_variable(TensorGrid(g), coeff, stencil_set, direction) | |
| 17 end | 24 end |
| 18 | 25 |
| 19 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set) | 26 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set) |
| 20 return second_derivative_variable(TensorGrid(g), coeff, stencil_set, 1) | 27 return second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, 1) |
| 21 end | 28 end |
| 22 | 29 |
| 23 function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, dir) | 30 function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, direction) |
| 24 check_coefficient(g, coeff) | 31 check_coefficient(g, coeff) |
| 25 | 32 |
| 26 Δxᵢ = spacing(g.grids[dir]) | 33 Δxᵢ = spacing(g.grids[direction]) |
| 27 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2) | 34 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2) |
| 28 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2) | 35 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2) |
| 29 return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, dir) | 36 return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, direction) |
| 30 end | 37 end |
| 31 | 38 |
| 32 function check_coefficient(g, coeff) | 39 function check_coefficient(g, coeff) |
| 33 if ndims(g) != ndims(coeff) | 40 if ndims(g) != ndims(coeff) |
| 34 throw(ArgumentError("The coefficient has dimension $(ndims(coeff)) while the grid is dimension $(ndims(g))")) | 41 throw(ArgumentError("The coefficient has dimension $(ndims(coeff)) while the grid is dimension $(ndims(g))")) |
