comparison src/SbpOperators/boundaryops/boundary_restriction.jl @ 569:2a7a258eaaa6 feature/boundary_ops

Collect documentation for BoundaryRestriction at the type definition
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 01 Dec 2020 15:21:01 +0100
parents ccb41095def6
children a8fe91861116
comparison
equal deleted inserted replaced
568:34d9e10f0001 569:2a7a258eaaa6
21 export boundary_restriction 21 export boundary_restriction
22 22
23 """ 23 """
24 BoundaryRestriction{T,N,R} <: TensorMapping{T,0,1} 24 BoundaryRestriction{T,N,R} <: TensorMapping{T,0,1}
25 25
26 Implements the boundary operator `e` as a TensorMapping 26 Implements the boundary operator `e` for 1D as a TensorMapping
27 `e` is the restriction of a grid function to the boundary using some `closureStencil`.
28 The boundary to restrict to is determined by `R`.
29
30 `e'` is the prolongation of a zero dimensional array to the whole grid using the same `closureStencil`.
27 """ 31 """
28 struct BoundaryRestriction{T,N,R<:Region} <: TensorMapping{T,0,1} 32 struct BoundaryRestriction{T,N,R<:Region} <: TensorMapping{T,0,1}
29 stencil::Stencil{T,N} 33 stencil::Stencil{T,N}
30 size::NTuple{1,Int} 34 size::NTuple{1,Int}
31 end 35 end
36 end 40 end
37 41
38 LazyTensors.range_size(e::BoundaryRestriction) = () 42 LazyTensors.range_size(e::BoundaryRestriction) = ()
39 LazyTensors.domain_size(e::BoundaryRestriction) = e.size 43 LazyTensors.domain_size(e::BoundaryRestriction) = e.size
40 44
41 " Restricts a grid function v on a grid of size m to the scalar element v[1]"
42 function LazyTensors.apply(e::BoundaryRestriction{T,N,Lower}, v::AbstractVector{T}) where {T,N} 45 function LazyTensors.apply(e::BoundaryRestriction{T,N,Lower}, v::AbstractVector{T}) where {T,N}
43 apply_stencil(e.stencil,v,1) 46 apply_stencil(e.stencil,v,1)
44 end 47 end
45 48
46 " Restricts a grid function v on a grid of size m to the scalar element v[m]"
47 function LazyTensors.apply(e::BoundaryRestriction{T,N,Upper}, v::AbstractVector{T}) where {T,N} 49 function LazyTensors.apply(e::BoundaryRestriction{T,N,Upper}, v::AbstractVector{T}) where {T,N}
48 apply_stencil_backwards(e.stencil,v,e.size[1]) 50 apply_stencil_backwards(e.stencil,v,e.size[1])
49 end 51 end
50 52
51 " Transpose of a restriction is an inflation or prolongation.
52 Inflates the scalar (1-element) vector to a vector of size of the grid"
53 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,N,Lower}, v::AbstractArray{T,0}, i) where {T,N} 53 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,N,Lower}, v::AbstractArray{T,0}, i) where {T,N}
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[] 57 return e.stencil[Int(i)-1]*v[]
58 end 58 end
59 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,N,Upper}, v::AbstractArray{T,0}, i) where {T,N} 60 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,N,Upper}, v::AbstractArray{T,0}, i) where {T,N}
63 @boundscheck if !(0 < Int(i) <= e.size[1]) 61 @boundscheck if !(0 < Int(i) <= e.size[1])
64 throw(BoundsError()) 62 throw(BoundsError())
65 end 63 end
66 return e.stencil[e.size[1] - Int(i)]*v[] 64 return e.stencil[e.size[1] - Int(i)]*v[]