Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/second_derivative.jl @ 1291:356ec6a72974 refactor/grids
Implement changes in SbpOperators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 07 Mar 2023 09:48:00 +0100 |
parents | c0ab81e4c39c |
children | e94ddef5e72f |
comparison
equal
deleted
inserted
replaced
1290:31d0b7638304 | 1291:356ec6a72974 |
---|---|
1 """ | 1 """ |
2 second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) | 2 second_derivative(g::EquidistantGrid, inner_stencil, closure_stencils, 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 dimension specified by |
7 `direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils` | 7 `direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils` |
8 for the points in the closure regions. | 8 for the points in the closure regions. |
9 | 9 |
10 On a one-dimensional `grid`, `D2` is a `VolumeOperator`. On a multi-dimensional `grid`, `D2` is the inflation of | |
11 a `VolumeOperator`. | |
12 | |
13 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). | 10 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref). |
14 """ | 11 """ |
15 function second_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction) | 12 function second_derivative(g::TensorGrid, stencil_set, direction) |
16 h_inv = inverse_spacing(grid)[direction] | 13 D₂ = second_derivative(g.grids[direction], stencil_set) |
17 | 14 return LazyTensors.inflate(D₂, size(g), direction) |
18 D₂ = VolumeOperator(restrict(grid, direction), scale(inner_stencil,h_inv^2), scale.(closure_stencils,h_inv^2), even) | |
19 return LazyTensors.inflate(D₂, size(grid), direction) | |
20 end | 15 end |
21 | 16 |
17 """ | |
18 second_derivative(g, stencil_set) | |
19 | |
20 Creates a `second_derivative` operator on a 1D `g` given a `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 | |
22 | 27 |
23 """ | 28 """ |
24 second_derivative(grid, inner_stencil, closure_stencils) | 29 second_derivative(g, inner_stencil, closure_stencils) |
25 | 30 |
26 Creates a `second_derivative` operator on a 1D `grid` given `inner_stencil` and `closure_stencils`. | 31 Creates a `second_derivative` operator on a 1D `g` given `inner_stencil` and `closure_stencils`. |
27 """ | 32 """ |
28 second_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = second_derivative(grid, inner_stencil, closure_stencils,1) | 33 function second_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils) |
29 | 34 h⁻¹ = inverse_spacing(g) |
30 | 35 return VolumeOperator(g, scale(inner_stencil,h⁻¹^2), scale.(closure_stencils,h⁻¹^2), even) |
31 """ | |
32 second_derivative(grid, stencil_set, direction) | |
33 | |
34 Creates a `second_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`. | |
35 """ | |
36 function second_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction) | |
37 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | |
38 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
39 second_derivative(grid,inner_stencil,closure_stencils,direction); | |
40 end | 36 end |
41 | |
42 | |
43 """ | |
44 second_derivative(grid, stencil_set) | |
45 | |
46 Creates a `second_derivative` operator on a 1D `grid` given a `stencil_set`. | |
47 """ | |
48 second_derivative(grid::EquidistantGrid{1}, stencil_set::StencilSet) = second_derivative(grid, stencil_set, 1) |