Mercurial > repos > public > sbplib_julia
diff src/SbpOperators/volumeops/derivatives/second_derivative.jl @ 1858:4a9be96f2569 feature/documenter_logo
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 12 Jan 2025 21:18:44 +0100 |
parents | 08f06bfacd5c |
children |
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/derivatives/second_derivative.jl Fri Jan 21 15:23:08 2022 +0100 +++ b/src/SbpOperators/volumeops/derivatives/second_derivative.jl Sun Jan 12 21:18:44 2025 +0100 @@ -1,19 +1,37 @@ """ - second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) + second_derivative(g::EquidistantGrid, stencil_set, direction) + +Creates the second derivative operator `D2` as a `LazyTensor` + +`D2` approximates the second-derivative d²/dξ² on `g` along the coordinate +dimension specified by `direction`. -Creates the second-derivative operator `D2` as a `TensorMapping` +See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). +""" +function second_derivative(g::TensorGrid, stencil_set, direction) + D₂ = second_derivative(g.grids[direction], stencil_set) + return LazyTensors.inflate(D₂, size(g), direction) +end -`D2` approximates the second-derivative d²/dξ² on `grid` along the coordinate dimension specified by -`direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils` -for the points in the closure regions. +""" + second_derivative(g::EquidistantGrid, stencil_set::::StencilSet) -On a one-dimensional `grid`, `D2` is a `VolumeOperator`. On a multi-dimensional `grid`, `D2` is the outer product of the -one-dimensional operator with the `IdentityMapping`s in orthogonal coordinate dirrections. -Also see the documentation of `SbpOperators.volume_operator(...)` for more details. +The second derivative operator on an `EquidistantGrid`. +Uses the `D2` stencil in `stencil_set`. +""" +function second_derivative(g::EquidistantGrid, stencil_set::StencilSet) + inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) + closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) + return second_derivative(g, inner_stencil, closure_stencils) +end + """ -function second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) - h_inv = inverse_spacing(grid)[direction] - return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv^2), scale.(closure_stencils,h_inv^2), even, direction) + second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) + +The second derivative operator on an `EquidistantGrid`, given `inner_stencil` and +`closure_stencils`. +""" +function second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) + h⁻¹ = inverse_spacing(g) + return VolumeOperator(g, scale(inner_stencil,h⁻¹^2), scale.(closure_stencils,h⁻¹^2), even) end -second_derivative(grid::EquidistantGrid{1}, inner_stencil, closure_stencils) = second_derivative(grid,inner_stencil,closure_stencils,1) -export second_derivative