comparison src/SbpOperators/volumeops/quadratures/quadrature.jl @ 681:43cf58c69f91 feature/boundary_quads

Remove methods boundary_quadrature, and instead specialize quadrature on a zero-dimensional grid to return the IdentityMapping
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 08 Feb 2021 18:44:44 +0100
parents 1ce3a104afc8
children 728fd5a2455a
comparison
equal deleted inserted replaced
680:1d3e29ffc6c6 681:43cf58c69f91
10 interior stencil with weight 1 is used. 10 interior stencil with weight 1 is used.
11 11
12 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
13 `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
14 each coordinate direction. Also see the documentation of 14 each coordinate direction. Also see the documentation of
15 `SbpOperators.volume_operator(...)` for more details. 15 `SbpOperators.volume_operator(...)` for more details. On 0-dimensional `grid`,
16 `H` is a 0-dimensional `IdentityMapping`.
16 """ 17 """
17 function quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils) where Dim 18 function quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils)
18 h = spacing(grid) 19 h = spacing(grid)
19 H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1) 20 H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1)
20 for i ∈ 2:dimension(grid) 21 for i ∈ 2:dimension(grid)
21 Hᵢ = SbpOperators.volume_operator(grid, scale(inner_stencil,h[i]), scale.(closure_stencils,h[i]), even, i) 22 Hᵢ = SbpOperators.volume_operator(grid, scale(inner_stencil,h[i]), scale.(closure_stencils,h[i]), even, i)
22 H = H∘Hᵢ 23 H = H∘Hᵢ
23 end 24 end
24 return H 25 return H
25 end 26 end
26 export quadrature 27 export quadrature
27 28
28 function quadrature(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T}}) where {M,T} 29 quadrature(grid::EquidistantGrid{0,T}, inner_stencil, closure_stencils) where T = IdentityMapping{T}()
30 #TODO: Consider changing the interface of volume_operator to volume_operator(grid,closure_stencils,inner_stencil)
31 # in order to allow for having quadrature(grid, closure_stencils, inner_stencil = CenteredStencil(one(T)))
32 # Then the below function can be removed.
33 function quadrature(grid::EquidistantGrid{Dim,T}, closure_stencils) where {Dim,T}
29 inner_stencil = CenteredStencil(one(T)) 34 inner_stencil = CenteredStencil(one(T))
30 return quadrature(grid, inner_stencil, closure_stencils) 35 return quadrature(grid, inner_stencil, closure_stencils)
31 end 36 end
32
33 """
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)
37
38 Creates the lower-dimensional quadrature operator associated with the boundary
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.
44 """
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}
55 inner_stencil = CenteredStencil(one(T))
56 return boundary_quadrature(grid,inner_stencil,closure_stencils,id)
57 end
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