Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundaryops/boundary_restriction.jl @ 513:547639572208 feature/boundary_ops
Get some kind of tested working implementation.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 23 Nov 2020 20:22:14 +0100 |
parents | 5a8cfcc0765d |
children | 14e722e8607d |
comparison
equal
deleted
inserted
replaced
512:5a8cfcc0765d | 513:547639572208 |
---|---|
1 function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary) where {T,M} | 1 function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary) where {T,M} |
2 r = region(boundary) | 2 r = region(boundary) |
3 d = dim(boundary) | 3 d = dim(boundary) |
4 d_orth = 3-d # orthogonal dimension | 4 d_orth = 3-d # orthogonal dimension |
5 e = BoundaryRestriction(restrict(grid, d), closureStencil, r) | 5 e = BoundaryRestriction(restrict(grid, d), closureStencil, r()) |
6 I = IdentityMapping(size(restrict(g,d_orth))) | 6 I = IdentityMapping{T}(size(restrict(grid,d_orth))) |
7 if r == Lower | 7 if d == 1 |
8 return e⊗I | 8 return e⊗I |
9 elseif r == Upper | 9 elseif d == 2 |
10 return I⊗e | 10 return I⊗e |
11 else | 11 else |
12 # throw error | 12 # throw error |
13 end | 13 end |
14 end | 14 end |
24 size::NTuple{1,Int} | 24 size::NTuple{1,Int} |
25 end | 25 end |
26 export BoundaryRestriction | 26 export BoundaryRestriction |
27 | 27 |
28 function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M} | 28 function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M} |
29 return BoundaryRestriction{T,M,typeof(region)}(stencil,size(grid)) | 29 return BoundaryRestriction{T,M,typeof(region)}(closureStencil,size(grid)) |
30 end | 30 end |
31 | 31 |
32 LazyTensors.range_size(e::BoundaryRestriction) = (1,) | 32 LazyTensors.range_size(e::BoundaryRestriction) = (1,) |
33 LazyTensors.domain_size(e::BoundaryRestriction) = e.size | 33 LazyTensors.domain_size(e::BoundaryRestriction) = e.size |
34 | 34 |
54 @boundscheck if !(0 < Int(i) <= e.size[1]) | 54 @boundscheck if !(0 < Int(i) <= e.size[1]) |
55 throw(BoundsError()) | 55 throw(BoundsError()) |
56 end | 56 end |
57 return e.stencil[Int(i)-1]*v[1] | 57 return e.stencil[Int(i)-1]*v[1] |
58 end | 58 end |
59 | |
60 " Transpose of a restriction is an inflation or prolongation. | |
61 Inflates the scalar (1-element) vector to a vector of size of the grid" | |
62 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,M,Upper}, v::AbstractVector{T}, i) where {T,M} | |
63 @boundscheck if !(0 < Int(i) <= e.size[1]) | |
64 throw(BoundsError()) | |
65 end | |
66 return e.stencil[e.size[1] - Int(i)]*v[1] | |
67 end |