diff src/SbpOperators/volumeops/quadratures/quadrature.jl @ 638:08b2c7a2d063 feature/volume_and_boundary_operators

Implement the Quadrature operator as a VolumeOperator. Make DiagonalQuadrature a special case of the general Quadrature operator. Update tests.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 04 Jan 2021 09:32:11 +0100
parents src/SbpOperators/volumeops/quadratures/diagonal_quadrature.jl@a1dfaf305f41
children 0e20bfef5cee
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SbpOperators/volumeops/quadratures/quadrature.jl	Mon Jan 04 09:32:11 2021 +0100
@@ -0,0 +1,36 @@
+"""
+    Quadrature(grid::EquidistantGrid, inner_stencil, closure_stencils)
+
+Creates the quadrature operator `H` as a `TensorMapping`
+
+The quadrature approximates the integral operator on the grid using
+`inner_stencil` in the interior and a set of stencils `closure_stencils`
+for the points in the closure regions.
+
+On a one-dimensional `grid`, `H` is a `VolumeOperator`. On a multi-dimensional
+`grid`, `H` is the outer product of the 1-dimensional quadrature operators in
+each  coordinate direction. Also see the documentation of
+`SbpOperators.volume_operator(...)` for more details.
+"""
+function Quadrature(grid::EquidistantGrid{Dim}, inner_stencil, closure_stencils) where Dim
+    h = spacing(grid)
+    H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1)
+    for i ∈ 2:Dim
+        Hᵢ = SbpOperators.volume_operator(grid, scale(inner_stencil,h[i]), scale.(closure_stencils,h[i]), even, i)
+        H = H∘Hᵢ
+    end
+    return H
+end
+export Quadrature
+
+"""
+    DiagonalQuadrature(grid::EquidistantGrid, closure_stencils)
+
+Creates the quadrature operator with the inner stencil 1/h and 1-element sized
+closure stencils (i.e the operator is diagonal)
+"""
+function DiagonalQuadrature(grid::EquidistantGrid, closure_stencils::NTuple{M,Stencil{T,1}}) where {M,T}
+    inner_stencil = Stencil(Tuple{T}(1),center=1)
+    return Quadrature(grid, inner_stencil, closure_stencils)
+end
+export DiagonalQuadrature