Mercurial > repos > public > sbplib_julia
changeset 564:ccb41095def6 feature/boundary_ops
Clean up type parameters and remove obsolete todo
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 30 Nov 2020 23:18:33 +0100 |
parents | 212e266043dd |
children | 15423a868d28 |
files | src/SbpOperators/boundaryops/boundary_restriction.jl |
diffstat | 1 files changed, 11 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl Mon Nov 30 18:34:48 2020 +0100 +++ b/src/SbpOperators/boundaryops/boundary_restriction.jl Mon Nov 30 23:18:33 2020 +0100 @@ -3,17 +3,17 @@ Creates a BoundaryRestriction operator for the specified boundary """ -function boundary_restriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{1}) where {T,M} +function boundary_restriction(grid::EquidistantGrid{1}, closureStencil::Stencil, boundary::CartesianBoundary{1}) return e = BoundaryRestriction(grid, closureStencil, region(boundary)) end -function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{1}) where {T,M} +function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T}, boundary::CartesianBoundary{1}) where T e = BoundaryRestriction(restrict(grid, 1), closureStencil, region(boundary)) I = IdentityMapping{T}(size(restrict(grid,2))) return e⊗I end -function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{2}) where {T,M} +function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T}, boundary::CartesianBoundary{2}) where T e = BoundaryRestriction(restrict(grid, 2), closureStencil, region(boundary)) I = IdentityMapping{T}(size(restrict(grid,1))) return I⊗e @@ -25,36 +25,32 @@ Implements the boundary operator `e` as a TensorMapping """ -struct BoundaryRestriction{T,M,R<:Region} <: TensorMapping{T,0,1} - stencil::Stencil{T,M} +struct BoundaryRestriction{T,N,R<:Region} <: TensorMapping{T,0,1} + stencil::Stencil{T,N} size::NTuple{1,Int} end export BoundaryRestriction -function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M,R} - return BoundaryRestriction{T,M,typeof(region)}(closureStencil,size(grid)) +function BoundaryRestriction(grid::EquidistantGrid{1}, closureStencil::Stencil{T,N}, region::Region) where {T,N} + return BoundaryRestriction{T,N,typeof(region)}(closureStencil,size(grid)) end LazyTensors.range_size(e::BoundaryRestriction) = () LazyTensors.domain_size(e::BoundaryRestriction) = e.size -# TODO: Should we support indexing into the 0-dimensional lazyarray? This is -# supported for arrays with linear index style (i.e for e.g -# u = fill(1), u[] and u[1] are both valid.) This currently not supported by -# LazyTensorMappingApplication. " Restricts a grid function v on a grid of size m to the scalar element v[1]" -function LazyTensors.apply(e::BoundaryRestriction{T,M,Lower}, v::AbstractVector{T}) where {T,M} +function LazyTensors.apply(e::BoundaryRestriction{T,N,Lower}, v::AbstractVector{T}) where {T,N} apply_stencil(e.stencil,v,1) end " Restricts a grid function v on a grid of size m to the scalar element v[m]" -function LazyTensors.apply(e::BoundaryRestriction{T,M,Upper}, v::AbstractVector{T}) where {T,M} +function LazyTensors.apply(e::BoundaryRestriction{T,N,Upper}, v::AbstractVector{T}) where {T,N} apply_stencil_backwards(e.stencil,v,e.size[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,Lower}, v::AbstractArray{T,0}, i) where {T,M} +function LazyTensors.apply_transpose(e::BoundaryRestriction{T,N,Lower}, v::AbstractArray{T,0}, i) where {T,N} @boundscheck if !(0 < Int(i) <= e.size[1]) throw(BoundsError()) end @@ -63,7 +59,7 @@ " 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::AbstractArray{T,0}, i) where {T,M} +function LazyTensors.apply_transpose(e::BoundaryRestriction{T,N,Upper}, v::AbstractArray{T,0}, i) where {T,N} @boundscheck if !(0 < Int(i) <= e.size[1]) throw(BoundsError()) end