comparison src/SbpOperators/boundaryops/boundary_operator.jl @ 1023:52f07c77299d refactor/sbpoperators/inflation

Merge refactor/lazy_tensors
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 21 Mar 2022 09:51:07 +0100
parents bbbc31953367 1ba8a398af9c
children 5a3281429a48 62f321caa964 05a25a5063bb
comparison
equal deleted inserted replaced
1022:bbbc31953367 1023:52f07c77299d
4 Creates a boundary operator on a `Dim`-dimensional grid for the 4 Creates a boundary operator on a `Dim`-dimensional grid for the
5 specified `boundary`. The action of the operator is determined by `closure_stencil`. 5 specified `boundary`. The action of the operator is determined by `closure_stencil`.
6 6
7 When `Dim=1`, the corresponding `BoundaryOperator` tensor mapping is returned. 7 When `Dim=1`, the corresponding `BoundaryOperator` tensor mapping is returned.
8 When `Dim>1`, the `BoundaryOperator` `op` is inflated by the outer product 8 When `Dim>1`, the `BoundaryOperator` `op` is inflated by the outer product
9 of `IdentityMappings` in orthogonal coordinate directions, e.g for `Dim=3`, 9 of `IdentityTensors` in orthogonal coordinate directions, e.g for `Dim=3`,
10 the boundary restriction operator in the y-direction direction is `Ix⊗op⊗Iz`. 10 the boundary restriction operator in the y-direction direction is `Ix⊗op⊗Iz`.
11 """ 11 """
12 function boundary_operator(grid::EquidistantGrid, closure_stencil, boundary::CartesianBoundary) 12 function boundary_operator(grid::EquidistantGrid, closure_stencil, boundary::CartesianBoundary)
13 #TODO:Check that dim(boundary) <= Dim? 13 #TODO:Check that dim(boundary) <= Dim?
14 14
15 d = dim(boundary) 15 d = dim(boundary)
16 op = BoundaryOperator(restrict(grid, d), closure_stencil, region(boundary)) 16 op = BoundaryOperator(restrict(grid, d), closure_stencil, region(boundary))
17 17
18 # Create 1D IdentityTensors for each coordinate direction
19 one_d_grids = restrict.(Ref(grid), Tuple(1:dimension(grid)))
20 Is = IdentityTensor{eltype(grid)}.(size.(one_d_grids))
21
18 return LazyTensors.inflate(op, size(grid), d) 22 return LazyTensors.inflate(op, size(grid), d)
19 end 23 end
20 24
21 """ 25 """
22 BoundaryOperator{T,R,N} <: TensorMapping{T,0,1} 26 BoundaryOperator{T,R,N} <: LazyTensor{T,0,1}
23 27
24 Implements the boundary operator `op` for 1D as a `TensorMapping` 28 Implements the boundary operator `op` for 1D as a `LazyTensor`
25 29
26 `op` is the restriction of a grid function to the boundary using some closure `Stencil{T,N}`. 30 `op` is the restriction of a grid function to the boundary using some closure `Stencil{T,N}`.
27 The boundary to restrict to is determined by `R`. 31 The boundary to restrict to is determined by `R`.
28 `op'` is the prolongation of a zero dimensional array to the whole grid using the same closure stencil. 32 `op'` is the prolongation of a zero dimensional array to the whole grid using the same closure stencil.
29 """ 33 """
30 struct BoundaryOperator{T,R<:Region,N} <: TensorMapping{T,0,1} 34 struct BoundaryOperator{T,R<:Region,N} <: LazyTensor{T,0,1}
31 stencil::Stencil{T,N} 35 stencil::Stencil{T,N}
32 size::Int 36 size::Int
33 end 37 end
34 38
35 BoundaryOperator{R}(stencil::Stencil{T,N}, size::Int) where {T,R,N} = BoundaryOperator{T,R,N}(stencil, size) 39 BoundaryOperator{R}(stencil::Stencil{T,N}, size::Int) where {T,R,N} = BoundaryOperator{T,R,N}(stencil, size)