Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/first_derivative.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 | e21c295fb2da |
| children |
comparison
equal
deleted
inserted
replaced
| 2082:87157cfca640 | 2096:5af7534e5b3c |
|---|---|
| 1 """ | 1 """ |
| 2 first_derivative(g, ..., [direction]) | 2 first_derivative(g, ..., [dim]) |
| 3 | 3 |
| 4 The first derivative operator `D1` as a `LazyTensor` on the given grid. | 4 The first derivative operator `D1` as a `LazyTensor` on the given grid. |
| 5 | 5 |
| 6 `D1` approximates the first-derivative d/dξ on `g` along the coordinate | 6 `D1` approximates the first-derivative d/dξ on `g` along the coordinate |
| 7 dimension specified by `direction`. | 7 dimension specified by `dim`. |
| 8 """ | 8 """ |
| 9 function first_derivative end | 9 function first_derivative end |
| 10 | 10 |
| 11 """ | 11 """ |
| 12 first_derivative(g::TensorGrid, stencil_set, direction) | 12 first_derivative(g::TensorGrid, stencil_set, dim) |
| 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, dim) |
| 17 D₁ = first_derivative(g.grids[direction], stencil_set) | 17 if dim ∉ 1:ndims(g) |
| 18 return LazyTensors.inflate(D₁, size(g), direction) | 18 throw(DomainError(dim, "Derivative direction must be in 1:$(ndims(g)).")) |
| 19 end | |
| 20 D₁ = first_derivative(g.grids[dim], stencil_set) | |
| 21 return LazyTensors.inflate(D₁, size(g), dim) | |
| 19 end | 22 end |
| 23 | |
| 20 | 24 |
| 21 """ | 25 """ |
| 22 first_derivative(g::EquidistantGrid, stencil_set::StencilSet) | 26 first_derivative(g::EquidistantGrid, stencil_set::StencilSet) |
| 23 | 27 |
| 24 The first derivative operator on an `EquidistantGrid`. | 28 The first derivative operator on an `EquidistantGrid`. |
| 28 inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"]) | 32 inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"]) |
| 29 closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"]) | 33 closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"]) |
| 30 return first_derivative(g, inner_stencil, closure_stencils); | 34 return first_derivative(g, inner_stencil, closure_stencils); |
| 31 end | 35 end |
| 32 | 36 |
| 37 function first_derivative(g::EquidistantGrid, stencil_set, dim) | |
| 38 if dim != 1 | |
| 39 throw(DomainError(dim, "Derivative direction must be 1.")) | |
| 40 end | |
| 41 return first_derivative(g, stencil_set) | |
| 42 end | |
| 43 | |
| 33 """ | 44 """ |
| 34 first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) | 45 first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) |
| 35 | 46 |
| 36 The first derivative operator on an `EquidistantGrid` given an | 47 The first derivative operator on an `EquidistantGrid` given an |
| 37 `inner_stencil` and `closure_stencils`. | 48 `inner_stencil` and `closure_stencils`. |
