Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/quadratures/inverse_quadrature.jl @ 696:0bec3c4e78c0 refactor/operator_naming
Rename InverseQuadrature to inverse_inner_product. Make InverseDiagonalQuadrature a special case of inverse_inner_product
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sun, 14 Feb 2021 13:48:54 +0100 |
parents | e14627e79a54 |
children |
comparison
equal
deleted
inserted
replaced
695:fc755b29d418 | 696:0bec3c4e78c0 |
---|---|
1 """ | |
2 inverse_inner_product(grid::EquidistantGrid, inv_inner_stencil, inv_closure_stencils) | |
3 inverse_inner_product(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T,1}}) | |
1 | 4 |
5 Creates the inverse inner product operator `H⁻¹` as a `TensorMapping` on an | |
6 equidistant grid. `H⁻¹` is defined implicitly by `H⁻¹∘H = I`, where | |
7 `H` is the corresponding inner product operator and `I` is the `IdentityMapping`. | |
8 | |
9 `inverse_inner_product(grid::EquidistantGrid, inv_inner_stencil, inv_closure_stencils)` | |
10 constructs `H⁻¹` using a set of stencils `inv_closure_stencils` for the points | |
11 in the closure regions and the stencil `inv_inner_stencil` in the interior. If | |
12 `inv_closure_stencils` is omitted, a central interior stencil with weight 1 is used. | |
13 | |
14 `inverse_inner_product(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T,1}})` | |
15 constructs a diagonal inverse inner product operator where `closure_stencils` are the | |
16 closure stencils of `H` (not `H⁻¹`!). | |
17 | |
18 On a 1-dimensional `grid`, `H⁻¹` is a `VolumeOperator`. On a N-dimensional | |
19 `grid`, `H⁻¹` is the outer product of the 1-dimensional inverse inner product | |
20 operators in each coordinate direction. Also see the documentation of | |
21 `SbpOperators.volume_operator(...)` for more details. On a 0-dimensional `grid`, | |
22 `H⁻¹` is a 0-dimensional `IdentityMapping`. | |
2 """ | 23 """ |
3 InverseQuadrature(grid::EquidistantGrid, inv_inner_stencil, inv_closure_stencils) | 24 function inverse_inner_product(grid::EquidistantGrid, inv_closure_stencils, inv_inner_stencil = CenteredStencil(one(eltype(grid)))) |
4 | |
5 Creates the inverse `H⁻¹` of the quadrature operator as a `TensorMapping` | |
6 | |
7 The inverse quadrature approximates the integral operator on the grid using | |
8 `inv_inner_stencil` in the interior and a set of stencils `inv_closure_stencils` | |
9 for the points in the closure regions. | |
10 | |
11 On a one-dimensional `grid`, `H⁻¹` is a `VolumeOperator`. On a multi-dimensional | |
12 `grid`, `H` is the outer product of the 1-dimensional inverse quadrature operators in | |
13 each coordinate direction. Also see the documentation of | |
14 `SbpOperators.volume_operator(...)` for more details. | |
15 """ | |
16 function InverseQuadrature(grid::EquidistantGrid{Dim}, inv_inner_stencil, inv_closure_stencils) where Dim | |
17 h⁻¹ = inverse_spacing(grid) | 25 h⁻¹ = inverse_spacing(grid) |
18 H⁻¹ = SbpOperators.volume_operator(grid,scale(inv_inner_stencil,h⁻¹[1]),scale.(inv_closure_stencils,h⁻¹[1]),even,1) | 26 H⁻¹ = SbpOperators.volume_operator(grid,scale(inv_inner_stencil,h⁻¹[1]),scale.(inv_closure_stencils,h⁻¹[1]),even,1) |
19 for i ∈ 2:Dim | 27 for i ∈ 2:dimension(grid) |
20 Hᵢ⁻¹ = SbpOperators.volume_operator(grid,scale(inv_inner_stencil,h⁻¹[i]),scale.(inv_closure_stencils,h⁻¹[i]),even,i) | 28 Hᵢ⁻¹ = SbpOperators.volume_operator(grid,scale(inv_inner_stencil,h⁻¹[i]),scale.(inv_closure_stencils,h⁻¹[i]),even,i) |
21 H⁻¹ = H⁻¹∘Hᵢ⁻¹ | 29 H⁻¹ = H⁻¹∘Hᵢ⁻¹ |
22 end | 30 end |
23 return H⁻¹ | 31 return H⁻¹ |
24 end | 32 end |
25 export InverseQuadrature | 33 export inverse_inner_product |
26 | 34 |
27 """ | 35 inverse_inner_product(grid::EquidistantGrid{0}, inv_closure_stencils, inv_inner_stencil) = IdentityMapping{eltype(grid)}() |
28 InverseDiagonalQuadrature(grid::EquidistantGrid, closure_stencils) | |
29 | 36 |
30 Creates the inverse of the diagonal quadrature operator defined by the inner stencil | 37 function inverse_inner_product(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T,1}}) where {M,T} |
31 1/h and a set of 1-element closure stencils in `closure_stencils`. Note that | 38 inv_closure_stencils = reciprocal_stencil.(closure_stencils) |
32 the closure stencils are those of the quadrature operator (and not the inverse). | 39 inv_inner_stencil = CenteredStencil(one(T)) |
33 """ | 40 return inverse_inner_product(grid, inv_closure_stencils, inv_inner_stencil) |
34 function InverseDiagonalQuadrature(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T,1}}) where {T,M} | |
35 inv_inner_stencil = Stencil(one(T), center=1) | |
36 inv_closure_stencils = reciprocal_stencil.(closure_stencils) | |
37 return InverseQuadrature(grid, inv_inner_stencil, inv_closure_stencils) | |
38 end | 41 end |
39 export InverseDiagonalQuadrature | |
40 | 42 |
41 reciprocal_stencil(s::Stencil{T}) where T = Stencil(s.range,one(T)./s.weights) | 43 reciprocal_stencil(s::Stencil{T}) where T = Stencil(s.range,one(T)./s.weights) |