Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundaryops/boundary_operator.jl @ 995:1ba8a398af9c refactor/lazy_tensors
Rename types
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Mar 2022 21:14:47 +0100 |
parents | 469ed954b493 |
children | 52f07c77299d 3bb94ce74697 fc57804c9bf4 |
comparison
equal
deleted
inserted
replaced
994:55ab7801c45f | 995:1ba8a398af9c |
---|---|
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 # Create 1D boundary operator | 15 # Create 1D boundary operator |
16 r = region(boundary) | 16 r = region(boundary) |
17 d = dim(boundary) | 17 d = dim(boundary) |
18 op = BoundaryOperator(restrict(grid, d), closure_stencil, r) | 18 op = BoundaryOperator(restrict(grid, d), closure_stencil, r) |
19 | 19 |
20 # Create 1D IdentityMappings for each coordinate direction | 20 # Create 1D IdentityTensors for each coordinate direction |
21 one_d_grids = restrict.(Ref(grid), Tuple(1:dimension(grid))) | 21 one_d_grids = restrict.(Ref(grid), Tuple(1:dimension(grid))) |
22 Is = IdentityMapping{eltype(grid)}.(size.(one_d_grids)) | 22 Is = IdentityTensor{eltype(grid)}.(size.(one_d_grids)) |
23 | 23 |
24 # Formulate the correct outer product sequence of the identity mappings and | 24 # Formulate the correct outer product sequence of the identity mappings and |
25 # the boundary operator | 25 # the boundary operator |
26 parts = Base.setindex(Is, op, d) | 26 parts = Base.setindex(Is, op, d) |
27 return foldl(⊗, parts) | 27 return foldl(⊗, parts) |
28 end | 28 end |
29 | 29 |
30 """ | 30 """ |
31 BoundaryOperator{T,R,N} <: TensorMapping{T,0,1} | 31 BoundaryOperator{T,R,N} <: LazyTensor{T,0,1} |
32 | 32 |
33 Implements the boundary operator `op` for 1D as a `TensorMapping` | 33 Implements the boundary operator `op` for 1D as a `LazyTensor` |
34 | 34 |
35 `op` is the restriction of a grid function to the boundary using some closure `Stencil{T,N}`. | 35 `op` is the restriction of a grid function to the boundary using some closure `Stencil{T,N}`. |
36 The boundary to restrict to is determined by `R`. | 36 The boundary to restrict to is determined by `R`. |
37 `op'` is the prolongation of a zero dimensional array to the whole grid using the same closure stencil. | 37 `op'` is the prolongation of a zero dimensional array to the whole grid using the same closure stencil. |
38 """ | 38 """ |
39 struct BoundaryOperator{T,R<:Region,N} <: TensorMapping{T,0,1} | 39 struct BoundaryOperator{T,R<:Region,N} <: LazyTensor{T,0,1} |
40 stencil::Stencil{T,N} | 40 stencil::Stencil{T,N} |
41 size::Int | 41 size::Int |
42 end | 42 end |
43 | 43 |
44 BoundaryOperator{R}(stencil::Stencil{T,N}, size::Int) where {T,R,N} = BoundaryOperator{T,R,N}(stencil, size) | 44 BoundaryOperator{R}(stencil::Stencil{T,N}, size::Int) where {T,R,N} = BoundaryOperator{T,R,N}(stencil, size) |