diff src/SbpOperators/boundaryops/boundary_restriction.jl @ 1351:d7f29359b822

Merge refactor/grids
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 19 May 2023 23:53:36 +0200
parents 08f06bfacd5c
children 65b2d2c72fbc
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl	Mon May 01 11:37:09 2023 +0200
+++ b/src/SbpOperators/boundaryops/boundary_restriction.jl	Fri May 19 23:53:36 2023 +0200
@@ -1,25 +1,27 @@
 """
-    boundary_restriction(grid, closure_stencil::Stencil, boundary)
+    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`
 
-`e` is the restriction of a grid function to `boundary` using a `Stencil` `closure_stencil`.
-`e'` is the prolongation of a grid function on `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`.
+`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`.
 
 See also: [`BoundaryOperator`](@ref), [`LazyTensors.inflate`](@ref).
 """
-function boundary_restriction(grid, closure_stencil, boundary)
-    converted_stencil = convert(Stencil{eltype(grid)}, closure_stencil)
+function boundary_restriction end
 
-    op = BoundaryOperator(restrict(grid, dim(boundary)), converted_stencil, region(boundary))
-    return LazyTensors.inflate(op, size(grid), dim(boundary))
+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, stencil_set, boundary)
-
-Creates a `boundary_restriction` operator on `grid` given a `stencil_set`.
-"""
-boundary_restriction(grid, stencil_set::StencilSet, boundary) = boundary_restriction(grid, parse_stencil(stencil_set["e"]["closure"]), boundary)
+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