Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundaryops/boundary_restriction.jl @ 562:8f7919a9b398 feature/boundary_ops
Merge with default
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Mon, 30 Nov 2020 18:30:24 +0100 |
| parents | 2edacece1637 |
| children | 212e266043dd |
comparison
equal
deleted
inserted
replaced
| 544:884be64e82d9 | 562:8f7919a9b398 |
|---|---|
| 39 end | 39 end |
| 40 | 40 |
| 41 LazyTensors.range_size(e::BoundaryRestriction) = () | 41 LazyTensors.range_size(e::BoundaryRestriction) = () |
| 42 LazyTensors.domain_size(e::BoundaryRestriction) = e.size | 42 LazyTensors.domain_size(e::BoundaryRestriction) = e.size |
| 43 | 43 |
| 44 # TODO: Currently not working. | 44 # TODO: Should we support indexing into the 0-dimensional lazyarray? This is |
| 45 # We need to handle getindex for LazyTensorMappingApplication such that we pass more #indices than the | 45 # supported for arrays with linear index style (i.e for e.g |
| 46 # range size of the TensorMapping. Or we need to be able to handle the case where we dont pass any index, for | 46 # u = fill(1), u[] and u[1] are both valid.) This currently not supported by |
| 47 # 0-dimensional tensormappings. | 47 # LazyTensorMappingApplication. |
| 48 " Restricts a grid function v on a grid of size m to the scalar element v[1]" | 48 " Restricts a grid function v on a grid of size m to the scalar element v[1]" |
| 49 function LazyTensors.apply(e::BoundaryRestriction{T,M,Lower}, v::AbstractVector{T}, i::Index{Lower}) where {T,M} | 49 function LazyTensors.apply(e::BoundaryRestriction{T,M,Lower}, v::AbstractVector{T}) where {T,M} |
| 50 @boundscheck if Int(i)!=1 | 50 apply_stencil(e.stencil,v,1) |
| 51 throw(BoundsError()) | |
| 52 end | |
| 53 apply_stencil(e.stencil,v,Int(i)) | |
| 54 end | 51 end |
| 55 | 52 |
| 56 " Restricts a grid function v on a grid of size m to the scalar element v[m]" | 53 " Restricts a grid function v on a grid of size m to the scalar element v[m]" |
| 57 function LazyTensors.apply(e::BoundaryRestriction{T,M,Upper}, v::AbstractVector{T}, i::Index{Upper}) where {T,M} | 54 function LazyTensors.apply(e::BoundaryRestriction{T,M,Upper}, v::AbstractVector{T}) where {T,M} |
| 58 @boundscheck if Int(i) != e.size[1] | 55 apply_stencil_backwards(e.stencil,v,e.size[1]) |
| 59 throw(BoundsError()) | |
| 60 end | |
| 61 apply_stencil_backwards(e.stencil,v,Int(i)) | |
| 62 end | 56 end |
| 63 | 57 |
| 64 " Transpose of a restriction is an inflation or prolongation. | 58 " Transpose of a restriction is an inflation or prolongation. |
| 65 Inflates the scalar (1-element) vector to a vector of size of the grid" | 59 Inflates the scalar (1-element) vector to a vector of size of the grid" |
| 66 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,M,Lower}, v::AbstractArray{T,0}, i) where {T,M} | 60 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,M,Lower}, v::AbstractArray{T,0}, i) where {T,M} |
