Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/second_derivative.jl @ 2057:8a2a0d678d6f feature/lazy_tensors/pretty_printing
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 10 Feb 2026 22:41:19 +0100 |
| parents | 08f06bfacd5c |
| children |
comparison
equal
deleted
inserted
replaced
| 1110:c0bff9f6e0fb | 2057:8a2a0d678d6f |
|---|---|
| 1 """ | 1 """ |
| 2 second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) | 2 second_derivative(g::EquidistantGrid, stencil_set, direction) |
| 3 | 3 |
| 4 Creates the second-derivative operator `D2` as a `LazyTensor` | 4 Creates the second derivative operator `D2` as a `LazyTensor` |
| 5 | 5 |
| 6 `D2` approximates the second-derivative d²/dξ² on `grid` along the coordinate dimension specified by | 6 `D2` approximates the second-derivative d²/dξ² on `g` along the coordinate |
| 7 `direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils` | 7 dimension specified by `direction`. |
| 8 for the points in the closure regions. | |
| 9 | 8 |
| 10 On a one-dimensional `grid`, `D2` is a `VolumeOperator`. On a multi-dimensional `grid`, `D2` is the outer product of the | 9 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). |
| 11 one-dimensional operator with the `IdentityTensor`s in orthogonal coordinate dirrections. | |
| 12 | |
| 13 See also: [`volume_operator`](@ref). | |
| 14 """ | 10 """ |
| 15 function second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) | 11 function second_derivative(g::TensorGrid, stencil_set, direction) |
| 16 h_inv = inverse_spacing(grid)[direction] | 12 D₂ = second_derivative(g.grids[direction], stencil_set) |
| 17 return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv^2), scale.(closure_stencils,h_inv^2), even, direction) | 13 return LazyTensors.inflate(D₂, size(g), direction) |
| 18 end | 14 end |
| 19 | 15 |
| 16 """ | |
| 17 second_derivative(g::EquidistantGrid, stencil_set::::StencilSet) | |
| 18 | |
| 19 The second derivative operator on an `EquidistantGrid`. | |
| 20 Uses the `D2` stencil in `stencil_set`. | |
| 21 """ | |
| 22 function second_derivative(g::EquidistantGrid, stencil_set::StencilSet) | |
| 23 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | |
| 24 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
| 25 return second_derivative(g, inner_stencil, closure_stencils) | |
| 26 end | |
| 20 | 27 |
| 21 """ | 28 """ |
| 22 second_derivative(grid, inner_stencil, closure_stencils) | 29 second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) |
| 23 | 30 |
| 24 Creates a `second_derivative` operator on a 1D `grid` given `inner_stencil` and `closure_stencils`. | 31 The second derivative operator on an `EquidistantGrid`, given `inner_stencil` and |
| 32 `closure_stencils`. | |
| 25 """ | 33 """ |
| 26 second_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = second_derivative(grid, inner_stencil, closure_stencils,1) | 34 function second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) |
| 27 | 35 h⁻¹ = inverse_spacing(g) |
| 28 | 36 return VolumeOperator(g, scale(inner_stencil,h⁻¹^2), scale.(closure_stencils,h⁻¹^2), even) |
| 29 """ | |
| 30 second_derivative(grid, stencil_set, direction) | |
| 31 | |
| 32 Creates a `second_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`. | |
| 33 """ | |
| 34 function second_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction) | |
| 35 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | |
| 36 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
| 37 second_derivative(grid,inner_stencil,closure_stencils,direction); | |
| 38 end | 37 end |
| 39 | |
| 40 | |
| 41 """ | |
| 42 second_derivative(grid, stencil_set) | |
| 43 | |
| 44 Creates a `second_derivative` operator on a 1D `grid` given a `stencil_set`. | |
| 45 """ | |
| 46 second_derivative(grid::EquidistantGrid{1}, stencil_set::StencilSet) = second_derivative(grid, stencil_set, 1) |
