diff src/SbpOperators/boundaryops/boundary_restriction.jl @ 1858:4a9be96f2569 feature/documenter_logo

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 12 Jan 2025 21:18:44 +0100
parents 08f06bfacd5c
children 65b2d2c72fbc
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl	Fri Jan 21 15:23:08 2022 +0100
+++ b/src/SbpOperators/boundaryops/boundary_restriction.jl	Sun Jan 12 21:18:44 2025 +0100
@@ -1,18 +1,27 @@
 """
-    boundary_restriction(grid::EquidistantGrid, closure_stencil::Stencil, boundary::CartesianBoundary)
-    boundary_restriction(grid::EquidistantGrid{1}, closure_stencil::Stencil, region::Region)
+    boundary_restriction(g, stencil_set::StencilSet, boundary)
+    boundary_restriction(g::TensorGrid, stencil_set::StencilSet, boundary::TensorGridBoundary)
+    boundary_restriction(g::EquidistantGrid, stencil_set::StencilSet, boundary)
+
+Creates boundary restriction operators `e` as `LazyTensor`s on `boundary`
 
-Creates the boundary restriction operator `e` as a `TensorMapping`
+`e` restricts a grid function on `g` to `boundary` using the 'e' stencil
+in `stencil_set`. `e'` prolongates a grid function on
+`boundary` to the whole grid using the same stencil. On a one-dimensional
+grid, `e` is a `BoundaryOperator`. On a multi-dimensional grid, `e` is the
+inflation of a `BoundaryOperator`.
 
-`e` is the restriction of a grid function to the boundary specified by `boundary` or `region` using some `closure_stencil`.
-`e'` is the prolongation of a grid function on the boundary to the whole grid using the same `closure_stencil`.
-On a one-dimensional `grid`, `e` is a `BoundaryOperator`. On a multi-dimensional `grid`, `e` is the inflation of
-a `BoundaryOperator`. Also see the documentation of `SbpOperators.boundary_operator(...)` for more details.
+See also: [`BoundaryOperator`](@ref), [`LazyTensors.inflate`](@ref).
 """
-function boundary_restriction(grid::EquidistantGrid, closure_stencil, boundary::CartesianBoundary)
-    converted_stencil = convert(Stencil{eltype(grid)}, closure_stencil)
-    return SbpOperators.boundary_operator(grid, converted_stencil, boundary)
+function boundary_restriction end
+
+function boundary_restriction(g::TensorGrid, stencil_set::StencilSet, boundary::TensorGridBoundary)
+    op = boundary_restriction(g.grids[grid_id(boundary)], stencil_set, boundary_id(boundary))
+    return LazyTensors.inflate(op, size(g), grid_id(boundary))
 end
-boundary_restriction(grid::EquidistantGrid{1}, closure_stencil, region::Region) = boundary_restriction(grid, closure_stencil, CartesianBoundary{1,typeof(region)}())
 
-export boundary_restriction
+function boundary_restriction(g::EquidistantGrid, stencil_set::StencilSet, boundary)
+    closure_stencil = parse_stencil(stencil_set["e"]["closure"])
+    converted_stencil = convert(Stencil{eltype(g)}, closure_stencil)
+    return BoundaryOperator(g, converted_stencil, boundary)
+end