comparison SbpOperators/src/Quadrature.jl @ 317:75c61d927153

Merge
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 09 Sep 2020 22:00:13 +0200
parents 8c166b092b69
children 777063b6f049
comparison
equal deleted inserted replaced
316:d244f2e5f822 317:75c61d927153
4 4
5 Implements the quadrature operator `Q` of Dim dimension as a TensorMapping 5 Implements the quadrature operator `Q` of Dim dimension as a TensorMapping
6 The multi-dimensional tensor operator consists of a tuple of 1D DiagonalNorm H 6 The multi-dimensional tensor operator consists of a tuple of 1D DiagonalNorm H
7 tensor operators. 7 tensor operators.
8 """ 8 """
9 export Quadrature
9 struct Quadrature{Dim,T<:Real,N,M} <: TensorOperator{T,Dim} 10 struct Quadrature{Dim,T<:Real,N,M} <: TensorOperator{T,Dim}
10 H::NTuple{Dim,DiagonalNorm{T,N,M}} 11 H::NTuple{Dim,DiagonalNorm{T,N,M}}
11 end 12 end
12 export Quadrature
13 13
14 LazyTensors.domain_size(Q::Quadrature{Dim}, range_size::NTuple{Dim,Integer}) where Dim = range_size 14 LazyTensors.domain_size(Q::Quadrature{Dim}, range_size::NTuple{Dim,Integer}) where Dim = range_size
15 15
16 function LazyTensors.apply(Q::Quadrature{Dim,T}, v::AbstractArray{T,Dim}, I::NTuple{Dim,Index}) where {T,Dim} 16 function LazyTensors.apply(Q::Quadrature{Dim,T}, v::AbstractArray{T,Dim}, I::NTuple{Dim,Index}) where {T,Dim}
17 error("not implemented") 17 error("not implemented")
37 """ 37 """
38 DiagonalNorm{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} 38 DiagonalNorm{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim}
39 39
40 Implements the diagnoal norm operator `H` of Dim dimension as a TensorMapping 40 Implements the diagnoal norm operator `H` of Dim dimension as a TensorMapping
41 """ 41 """
42 export DiagonalNorm, closuresize, LazyTensors.apply
42 struct DiagonalNorm{T<:Real,N,M} <: TensorOperator{T,1} 43 struct DiagonalNorm{T<:Real,N,M} <: TensorOperator{T,1}
43 h::T # The grid spacing could be included in the stencil already. Preferable? 44 h::T # The grid spacing could be included in the stencil already. Preferable?
44 closure::NTuple{M,T} 45 closure::NTuple{M,T}
45 #TODO: Write a nice constructor 46 #TODO: Write a nice constructor
46 end 47 end
67 N = length(v); 68 N = length(v);
68 r = getregion(Int(index), closuresize(H), N) 69 r = getregion(Int(index), closuresize(H), N)
69 i = Index(Int(index), r) 70 i = Index(Int(index), r)
70 return LazyTensors.apply(H, v, i) 71 return LazyTensors.apply(H, v, i)
71 end 72 end
72 export LazyTensors.apply
73 73
74 function closuresize(H::DiagonalNorm{T<:Real,N,M}) where {T,N,M} 74 function closuresize(H::DiagonalNorm{T<:Real,N,M}) where {T,N,M}
75 return M 75 return M
76 end 76 end