Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/quadratures/quadrature.jl @ 669:2a95beb9ef1d feature/boundary_quads
Add methods for getting boundary quadratures of a grid. Align naming of quadrature operators.
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Sat, 06 Feb 2021 12:03:46 +0100 |
| parents | 0e20bfef5cee |
| children | 1ce3a104afc8 |
comparison
equal
deleted
inserted
replaced
| 664:7d7c1d636de3 | 669:2a95beb9ef1d |
|---|---|
| 1 """ | 1 """ |
| 2 Quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils) | 2 quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils) |
| 3 quadrature(grid::EquidistantGrid, closure_stencils) | |
| 3 | 4 |
| 4 Creates the quadrature operator `H` as a `TensorMapping` | 5 Creates the quadrature operator `H` as a `TensorMapping` |
| 5 | 6 |
| 6 The quadrature approximates the integral operator on the grid using | 7 `H` approximiates the integral operator on `grid` the using the stencil |
| 7 `inner_stencil` in the interior and a set of stencils `closure_stencils` | 8 `inner_stencil` in the interior and a set of stencils `closure_stencils` |
| 8 for the points in the closure regions. | 9 for the points in the closure regions. If `inner_stencil` is omitted a central |
| 10 interior stencil with weight 1 is used. | |
| 9 | 11 |
| 10 On a one-dimensional `grid`, `H` is a `VolumeOperator`. On a multi-dimensional | 12 On a one-dimensional `grid`, `H` is a `VolumeOperator`. On a multi-dimensional |
| 11 `grid`, `H` is the outer product of the 1-dimensional quadrature operators in | 13 `grid`, `H` is the outer product of the 1-dimensional quadrature operators in |
| 12 each coordinate direction. Also see the documentation of | 14 each coordinate direction. Also see the documentation of |
| 13 `SbpOperators.volume_operator(...)` for more details. | 15 `SbpOperators.volume_operator(...)` for more details. |
| 14 """ | 16 """ |
| 15 function Quadrature(grid::EquidistantGrid{Dim}, inner_stencil, closure_stencils) where Dim | 17 function quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils) where Dim |
| 16 h = spacing(grid) | 18 h = spacing(grid) |
| 17 H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1) | 19 H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1) |
| 18 for i ∈ 2:Dim | 20 for i ∈ 2:dimension(grid) |
| 19 Hᵢ = SbpOperators.volume_operator(grid, scale(inner_stencil,h[i]), scale.(closure_stencils,h[i]), even, i) | 21 Hᵢ = SbpOperators.volume_operator(grid, scale(inner_stencil,h[i]), scale.(closure_stencils,h[i]), even, i) |
| 20 H = H∘Hᵢ | 22 H = H∘Hᵢ |
| 21 end | 23 end |
| 22 return H | 24 return H |
| 23 end | 25 end |
| 24 export Quadrature | 26 export quadrature |
| 27 | |
| 28 function quadrature(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T}}) where {M,T} | |
| 29 inner_stencil = Stencil(Tuple{T}(1),center=1) | |
| 30 return quadrature(grid, inner_stencil, closure_stencils) | |
| 31 end | |
| 25 | 32 |
| 26 """ | 33 """ |
| 27 DiagonalQuadrature(grid::EquidistantGrid, closure_stencils) | 34 boundary_quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils, id::CartesianBoundary) |
| 35 boundary_quadrature(grid::EquidistantGrid{1}, inner_stencil, closure_stencils, id) | |
| 36 boundary_quadrature(grid::EquidistantGrid, closure_stencils, id) | |
| 28 | 37 |
| 29 Creates the quadrature operator with the inner stencil 1/h and 1-element sized | 38 Creates the lower-dimensional quadrature operator associated with the boundary |
| 30 closure stencils (i.e the operator is diagonal) | 39 of `grid` specified by `id`. The quadrature operator is defined on the grid |
| 40 spanned by the dimensions orthogonal to the boundary coordinate direction. | |
| 41 If the dimension of `grid` is 1, then the boundary quadrature is the 0-dimensional | |
| 42 `IdentityMapping`. If `inner_stencil` is omitted a central interior stencil with | |
| 43 weight 1 is used. | |
| 31 """ | 44 """ |
| 32 function DiagonalQuadrature(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T,1}}) where {M,T} | 45 function boundary_quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils, id::CartesianBoundary) |
| 46 return quadrature(orthogonal_grid(grid,dim(id)),inner_stencil,closure_stencils) | |
| 47 end | |
| 48 export boundary_quadrature | |
| 49 | |
| 50 function boundary_quadrature(grid::EquidistantGrid{1}, inner_stencil::Stencil{T}, closure_stencils::NTuple{M,Stencil{T}}, id::CartesianBoundary{1}) where {M,T} | |
| 51 return IdentityMapping{T}() | |
| 52 end | |
| 53 | |
| 54 function boundary_quadrature(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T}}, id::CartesianBoundary) where {M,T} | |
| 33 inner_stencil = Stencil(Tuple{T}(1),center=1) | 55 inner_stencil = Stencil(Tuple{T}(1),center=1) |
| 34 return Quadrature(grid, inner_stencil, closure_stencils) | 56 return boundary_quadrature(grid,inner_stencil,closure_stencils,id) |
| 35 end | 57 end |
| 36 export DiagonalQuadrature | 58 |
| 59 """ | |
| 60 orthogonal_grid(grid,dim) | |
| 61 | |
| 62 Creates the lower-dimensional restriciton of `grid` spanned by the dimensions | |
| 63 orthogonal to `dim`. | |
| 64 """ | |
| 65 function orthogonal_grid(grid,dim) | |
| 66 dims = collect(1:dimension(grid)) | |
| 67 orth_dims = dims[dims .!= dim] | |
| 68 return restrict(grid,orth_dims) | |
| 69 end |
