Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/first_derivative.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 | 08f06bfacd5c |
| children |
comparison
equal
deleted
inserted
replaced
| 2079:118c09b168f5 | 2080:0f949681d3d3 |
|---|---|
| 12 first_derivative(g::TensorGrid, stencil_set, direction) | 12 first_derivative(g::TensorGrid, stencil_set, direction) |
| 13 | 13 |
| 14 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). | 14 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). |
| 15 """ | 15 """ |
| 16 function first_derivative(g::TensorGrid, stencil_set, direction) | 16 function first_derivative(g::TensorGrid, stencil_set, direction) |
| 17 if direction ∉ Interval(0, ndims(g)) | |
| 18 throw(DomainError(direction, "Direction must be inside [0, $(ndims(g))].")) | |
| 19 end | |
| 17 D₁ = first_derivative(g.grids[direction], stencil_set) | 20 D₁ = first_derivative(g.grids[direction], stencil_set) |
| 18 return LazyTensors.inflate(D₁, size(g), direction) | 21 return LazyTensors.inflate(D₁, size(g), direction) |
| 22 end | |
| 23 | |
| 24 function first_derivative(g::EquidistantGrid, stencil_set, direction) | |
| 25 return first_derivative(TensorGrid(g), stencil_set, direction) | |
| 19 end | 26 end |
| 20 | 27 |
| 21 """ | 28 """ |
| 22 first_derivative(g::EquidistantGrid, stencil_set::StencilSet) | 29 first_derivative(g::EquidistantGrid, stencil_set::StencilSet) |
| 23 | 30 |
