Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl Mon Nov 23 13:11:19 2020 +0100 +++ b/src/SbpOperators/boundaryops/boundary_restriction.jl Mon Nov 23 20:22:14 2020 +0100 @@ -2,11 +2,11 @@ r = region(boundary) d = dim(boundary) d_orth = 3-d # orthogonal dimension - e = BoundaryRestriction(restrict(grid, d), closureStencil, r) - I = IdentityMapping(size(restrict(g,d_orth))) - if r == Lower + e = BoundaryRestriction(restrict(grid, d), closureStencil, r()) + I = IdentityMapping{T}(size(restrict(grid,d_orth))) + if d == 1 return e⊗I - elseif r == Upper + elseif d == 2 return I⊗e else # throw error @@ -26,7 +26,7 @@ export BoundaryRestriction function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M} - return BoundaryRestriction{T,M,typeof(region)}(stencil,size(grid)) + return BoundaryRestriction{T,M,typeof(region)}(closureStencil,size(grid)) end LazyTensors.range_size(e::BoundaryRestriction) = (1,) @@ -56,3 +56,12 @@ end return e.stencil[Int(i)-1]*v[1] end + +" Transpose of a restriction is an inflation or prolongation. + Inflates the scalar (1-element) vector to a vector of size of the grid" +function LazyTensors.apply_transpose(e::BoundaryRestriction{T,M,Upper}, v::AbstractVector{T}, i) where {T,M} + @boundscheck if !(0 < Int(i) <= e.size[1]) + throw(BoundsError()) + end + return e.stencil[e.size[1] - Int(i)]*v[1] +end