Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundaryops/boundary_restriction.jl @ 581:ea4176a5dfc5 feature/boundary_ops
Implement boundary_restriction in a dimension independent way
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 01 Dec 2020 17:31:30 +0100 |
parents | cae4d5b428d6 |
children | aa44edea36fc |
comparison
equal
deleted
inserted
replaced
577:cae4d5b428d6 | 581:ea4176a5dfc5 |
---|---|
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 BoundaryRestriction operator for the specified boundary |
5 """ | 5 """ |
6 function boundary_restriction(grid::EquidistantGrid{1}, closureStencil::Stencil, boundary::CartesianBoundary{1}) | 6 function boundary_restriction(grid::EquidistantGrid{D,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary) where {D,T,M} |
7 return e = BoundaryRestriction(grid, closureStencil, region(boundary)) | 7 r = region(boundary) |
8 d = dim(boundary) | |
9 e = BoundaryRestriction(restrict(grid, d), closureStencil, r) | |
10 | |
11 one_d_grids = restrict.(Ref(grid), tuple(1:D)) | |
12 Is = IdentityMapping{T}.(size.(one_d_grids)) | |
13 parts = Base.setindex(Is, e, d) | |
14 return foldl(⊗, parts) | |
8 end | 15 end |
9 | 16 |
10 function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T}, boundary::CartesianBoundary{1}) where T | |
11 e = BoundaryRestriction(restrict(grid, 1), closureStencil, region(boundary)) | |
12 I = IdentityMapping{T}(size(restrict(grid,2))) | |
13 return e⊗I | |
14 end | |
15 | |
16 function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T}, boundary::CartesianBoundary{2}) where T | |
17 e = BoundaryRestriction(restrict(grid, 2), closureStencil, region(boundary)) | |
18 I = IdentityMapping{T}(size(restrict(grid,1))) | |
19 return I⊗e | |
20 end | |
21 export boundary_restriction | 17 export boundary_restriction |
22 | 18 |
23 """ | 19 """ |
24 BoundaryRestriction{T,R,N} <: TensorMapping{T,0,1} | 20 BoundaryRestriction{T,R,N} <: TensorMapping{T,0,1} |
25 | 21 |