Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundaryops/boundary_restriction.jl @ 585:0e1a95b35999 feature/boundary_ops
Update documentation and add some comments.
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Wed, 02 Dec 2020 13:19:14 +0100 |
| parents | 6db96ef13a29 |
| children | 0c411d865d66 |
comparison
equal
deleted
inserted
replaced
| 583:6db96ef13a29 | 585:0e1a95b35999 |
|---|---|
| 1 """ | 1 """ |
| 2 boundary_restriction(grid,closureStencil,boundary) | 2 boundary_restriction(grid,closureStencil,boundary) |
| 3 | 3 |
| 4 Creates a BoundaryRestriction operator for the specified boundary | 4 Creates a boundary restriction operator on a `Dim`-dimensional grid for the |
| 5 specified `boundary`. | |
| 6 | |
| 7 When `Dim=1`, the corresponding `BoundaryRestriction` tensor mapping is returned. | |
| 8 When `Dim>1`, the `BoundaryRestriction` `e` is inflated by the outer product | |
| 9 of `IdentityMappings` in orthogonal coordinate directions, e.g for `Dim=3`, | |
| 10 the boundary restriction operator in the y-direction direction is `Ix⊗e⊗Iz`. | |
| 5 """ | 11 """ |
| 6 function boundary_restriction(grid::EquidistantGrid{D,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary) where {D,T,M} | 12 function boundary_restriction(grid::EquidistantGrid{Dim,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary) where {Dim,T,M} |
| 13 # Create 1D boundary restriction operator | |
| 7 r = region(boundary) | 14 r = region(boundary) |
| 8 d = dim(boundary) | 15 d = dim(boundary) |
| 9 e = BoundaryRestriction(restrict(grid, d), closureStencil, r) | 16 e = BoundaryRestriction(restrict(grid, d), closureStencil, r) |
| 10 | 17 |
| 18 # Create 1D IdentityMappings for each coordinate direction | |
| 11 one_d_grids = restrict.(Ref(grid), Tuple(1:D)) | 19 one_d_grids = restrict.(Ref(grid), Tuple(1:D)) |
| 20 Is = IdentityMapping{T}.(size.(one_d_grids)) | |
| 12 | 21 |
| 13 Is = IdentityMapping{T}.(size.(one_d_grids)) | 22 # Formulate the correct outer product sequence of the identity mappings and |
| 23 # the boundary restriction operator | |
| 14 parts = Base.setindex(Is, e, d) | 24 parts = Base.setindex(Is, e, d) |
| 15 return foldl(⊗, parts) | 25 return foldl(⊗, parts) |
| 16 end | 26 end |
| 17 | 27 |
| 18 export boundary_restriction | 28 export boundary_restriction |
| 19 | 29 |
| 20 """ | 30 """ |
| 21 BoundaryRestriction{T,R,N} <: TensorMapping{T,0,1} | 31 BoundaryRestriction{T,R,N} <: TensorMapping{T,0,1} |
| 22 | 32 |
| 23 Implements the boundary operator `e` for 1D as a TensorMapping | 33 Implements the boundary operator `e` for 1D as a `TensorMapping` |
| 34 | |
| 24 `e` is the restriction of a grid function to the boundary using some `closureStencil`. | 35 `e` is the restriction of a grid function to the boundary using some `closureStencil`. |
| 25 The boundary to restrict to is determined by `R`. | 36 The boundary to restrict to is determined by `R`. |
| 26 | 37 |
| 27 `e'` is the prolongation of a zero dimensional array to the whole grid using the same `closureStencil`. | 38 `e'` is the prolongation of a zero dimensional array to the whole grid using the same `closureStencil`. |
| 28 """ | 39 """ |
