Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl @ 2096:5af7534e5b3c feature/sbp_operators/laplace_curvilinear tip
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Mon, 02 Mar 2026 15:58:27 +0100 |
| parents | 3684db043add e21c295fb2da |
| children |
comparison
equal
deleted
inserted
replaced
| 2082:87157cfca640 | 2096:5af7534e5b3c |
|---|---|
| 1 """ | 1 """ |
| 2 second_derivative_variable(g, coeff ..., [direction]) | 2 second_derivative_variable(g, coeff, ..., [dim]) |
| 3 | 3 |
| 4 The variable second derivative operator as a `LazyTensor` on the given grid. | 4 The variable second derivative operator as a `LazyTensor` on the given grid. |
| 5 `coeff` is a grid function of the variable coefficient. | 5 `coeff` is a grid function of the variable coefficient. |
| 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 `dim`. |
| 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, dim::Int) |
| 13 if dim ∉ 1:ndims(g) | |
| 14 throw(DomainError(dim, "Derivative direction must be in 1:$(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, dim) |
| 17 end | 20 end |
| 18 | 21 |
| 19 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set) | 22 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set) |
| 20 return second_derivative_variable(TensorGrid(g), coeff, stencil_set, 1) | 23 return second_derivative_variable(TensorGrid(g), coeff, stencil_set, 1) |
| 21 end | 24 end |
| 22 | 25 |
| 23 function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, dir) | 26 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, dim) |
| 27 if dim != 1 | |
| 28 throw(DomainError(dim, "Derivative direction must be 1.")) | |
| 29 end | |
| 30 return second_derivative_variable(g, coeff, stencil_set) | |
| 31 end | |
| 32 | |
| 33 function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, dim) | |
| 24 check_coefficient(g, coeff) | 34 check_coefficient(g, coeff) |
| 25 | 35 |
| 26 Δxᵢ = spacing(g.grids[dir]) | 36 Δxᵢ = spacing(g.grids[dim]) |
| 27 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2) | 37 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2) |
| 28 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2) | 38 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2) |
| 29 return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, dir) | 39 return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, dim) |
| 30 end | 40 end |
| 31 | 41 |
| 32 function check_coefficient(g, coeff) | 42 function check_coefficient(g, coeff) |
| 33 if ndims(g) != ndims(coeff) | 43 if ndims(g) != ndims(coeff) |
| 34 throw(ArgumentError("The coefficient has dimension $(ndims(coeff)) while the grid is dimension $(ndims(g))")) | 44 throw(ArgumentError("The coefficient has dimension $(ndims(coeff)) while the grid is dimension $(ndims(g))")) |
