Mercurial > repos > public > sbplib_julia
changeset 558:9b5710ae6587 feature/quadrature_as_outer_product
Update documentation
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sun, 29 Nov 2020 22:06:53 +0100 |
parents | 3c18a15934a7 |
children | 08e27dee76c3 |
files | src/SbpOperators/quadrature/diagonal_quadrature.jl src/SbpOperators/quadrature/inverse_diagonal_quadrature.jl |
diffstat | 2 files changed, 46 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/quadrature/diagonal_quadrature.jl Sun Nov 29 21:52:44 2020 +0100 +++ b/src/SbpOperators/quadrature/diagonal_quadrature.jl Sun Nov 29 22:06:53 2020 +0100 @@ -33,27 +33,39 @@ """ DiagonalQuadrature(g, quadrature_closure) -Constructs the `DiagonalQuadrature` `H` on the `EquidistantGrid` `g` with -`H.closure` specified by `quadrature_closure`. +Constructs the `DiagonalQuadrature` on the `EquidistantGrid` `g` with +closure given by `quadrature_closure`. """ function DiagonalQuadrature(g::EquidistantGrid{1}, quadrature_closure) return DiagonalQuadrature(spacing(g)[1], quadrature_closure, size(g)) end +""" + range_size(H::DiagonalQuadrature) + +The size of an object in the range of `H` +""" LazyTensors.range_size(H::DiagonalQuadrature) = H.size + +""" + domain_size(H::DiagonalQuadrature) + +The size of an object in the domain of `H` +""" LazyTensors.domain_size(H::DiagonalQuadrature) = H.size """ apply(H::DiagonalQuadrature{T}, v::AbstractVector{T}, i) where T Implements the application `(H*v)[i]` an `Index{R}` where `R` is one of the regions -`Lower`,`Interior`,`Upper`. +`Lower`,`Interior`,`Upper`. If `i` is another type of index (e.g an `Int`) it will first +be converted to an `Index{R}`. """ function LazyTensors.apply(H::DiagonalQuadrature{T}, v::AbstractVector{T}, i::Index{Lower}) where T return @inbounds H.h*H.closure[Int(i)]*v[Int(i)] end function LazyTensors.apply(H::DiagonalQuadrature{T},v::AbstractVector{T}, i::Index{Upper}) where T - N = length(v); + N = length(v); #TODO: Use dim_size here? return @inbounds H.h*H.closure[N-Int(i)+1]*v[Int(i)] end @@ -62,9 +74,8 @@ end function LazyTensors.apply(H::DiagonalQuadrature{T}, v::AbstractVector{T}, i) where T - N = length(v); + N = length(v); #TODO: Use dim_size here? r = getregion(i, closure_size(H), N) - return LazyTensors.apply(H, v, Index(i, r)) end
--- a/src/SbpOperators/quadrature/inverse_diagonal_quadrature.jl Sun Nov 29 21:52:44 2020 +0100 +++ b/src/SbpOperators/quadrature/inverse_diagonal_quadrature.jl Sun Nov 29 22:06:53 2020 +0100 @@ -1,8 +1,8 @@ """ inverse_diagonal_quadrature(g,quadrature_closure) -Constructs the diagonal quadrature inverse operator `Hi` on a grid of `Dim` dimensions as -a `TensorMapping`. The one-dimensional operator is a InverseDiagonalQuadrature, while +Constructs the inverse `Hi` of a `DiagonalQuadrature` on a grid of `Dim` dimensions as +a `TensorMapping`. The one-dimensional operator is a `InverseDiagonalQuadrature`, while the multi-dimensional operator is the outer-product of the one-dimensional operators in each coordinate direction. """ @@ -19,8 +19,10 @@ """ InverseDiagonalQuadrature{T,M} <: TensorMapping{T,1,1} -Implements the one-dimensional inverse diagonal quadrature operator as a `TensorMapping -TODO: Elaborate on properties +Implements the inverse of a one-dimensional `DiagonalQuadrature` as a `TensorMapping` +The operator is defined by the reciprocal of the quadrature interval length `h_inv`, the +reciprocal of the quadrature closure weights `closure` and the number of quadrature intervals `size`. The +interior stencil has the weight 1. """ struct InverseDiagonalQuadrature{T<:Real,M} <: TensorMapping{T,1,1} h_inv::T @@ -29,15 +31,36 @@ end export InverseDiagonalQuadrature +""" + InverseDiagonalQuadrature(g, quadrature_closure) + +Constructs the `InverseDiagonalQuadrature` on the `EquidistantGrid` `g` with +closure given by the reciprocal of `quadrature_closure`. +""" function InverseDiagonalQuadrature(g::EquidistantGrid{1}, quadrature_closure) return InverseDiagonalQuadrature(inverse_spacing(g)[1], 1 ./ quadrature_closure, size(g)) end +""" + domain_size(Hi::InverseDiagonalQuadrature) +The size of an object in the range of `Hi` +""" LazyTensors.range_size(Hi::InverseDiagonalQuadrature) = Hi.size + +""" + domain_size(Hi::InverseDiagonalQuadrature) + +The size of an object in the domain of `Hi` +""" LazyTensors.domain_size(Hi::InverseDiagonalQuadrature) = Hi.size - +""" + apply(Hi::InverseDiagonalQuadrature{T}, v::AbstractVector{T}, i) where T +Implements the application `(Hi*v)[i]` an `Index{R}` where `R` is one of the regions +`Lower`,`Interior`,`Upper`. If `i` is another type of index (e.g an `Int`) it will first +be converted to an `Index{R}`. +""" function LazyTensors.apply(Hi::InverseDiagonalQuadrature{T}, v::AbstractVector{T}, I::Index{Lower}) where T return @inbounds Hi.h_inv*Hi.closure[Int(I)]*v[Int(I)] end @@ -60,7 +83,7 @@ LazyTensors.apply_transpose(Hi::InverseDiagonalQuadrature{T}, v::AbstractVector{T}, i) where T = LazyTensors.apply(Hi,v,i) """ - closure_size(H) + closure_size(Hi) Returns the size of the closure stencil of a InverseDiagonalQuadrature `Hi`. """ closure_size(Hi::InverseDiagonalQuadrature{T,M}) where {T,M} = M