Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/laplace/laplace.jl @ 370:8e55dee6a1a1
Merge branch refactor/remove_dynamic_size_tensormapping
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 28 Sep 2020 22:56:54 +0200 |
parents | 0546cb279fc2 |
children | 011ca1639153 |
comparison
equal
deleted
inserted
replaced
366:0af6da238d95 | 370:8e55dee6a1a1 |
---|---|
1 export Laplace | 1 export Laplace |
2 """ | 2 """ |
3 Laplace{Dim,T<:Real,N,M,K} <: TensorOperator{T,Dim} | 3 Laplace{Dim,T<:Real,N,M,K} <: TensorMapping{T,Dim,Dim} |
4 | 4 |
5 Implements the Laplace operator `L` in Dim dimensions as a tensor operator | 5 Implements the Laplace operator `L` in Dim dimensions as a tensor operator |
6 The multi-dimensional tensor operator consists of a tuple of 1D SecondDerivative | 6 The multi-dimensional tensor operator consists of a tuple of 1D SecondDerivative |
7 tensor operators. | 7 tensor operators. |
8 """ | 8 """ |
9 #export quadrature, inverse_quadrature, boundary_quadrature, boundary_value, normal_derivative | 9 #export quadrature, inverse_quadrature, boundary_quadrature, boundary_value, normal_derivative |
10 struct Laplace{Dim,T,N,M,K} <: TensorOperator{T,Dim} | 10 struct Laplace{Dim,T,N,M,K} <: TensorMapping{T,Dim,Dim} |
11 D2::NTuple{Dim,SecondDerivative{T,N,M,K}} | 11 D2::NTuple{Dim,SecondDerivative{T,N,M,K}} |
12 #TODO: Write a good constructor | |
13 end | 12 end |
14 | 13 |
15 LazyTensors.domain_size(L::Laplace{Dim}, range_size::NTuple{Dim,Integer}) where {Dim} = range_size | 14 function Laplace(g::EquidistantGrid{Dim}, innerStencil, closureStencils) where Dim |
15 D2 = () | |
16 for i ∈ 1:Dim | |
17 D2 = (D2..., SecondDerivative(restrict(g,i), innerStencil, closureStencils)) | |
18 end | |
19 | |
20 return Laplace(D2) | |
21 end | |
22 | |
23 LazyTensors.range_size(L::Laplace) = getindex.(range_size.(L.D2),1) | |
24 LazyTensors.domain_size(L::Laplace) = getindex.(domain_size.(L.D2),1) | |
16 | 25 |
17 function LazyTensors.apply(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {T,Dim} | 26 function LazyTensors.apply(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {T,Dim} |
18 error("not implemented") | 27 error("not implemented") |
19 end | 28 end |
20 | 29 |
33 @inbounds vy = view(v, Int(I), :) | 42 @inbounds vy = view(v, Int(I), :) |
34 @inbounds uᵢ += LazyTensors.apply(L.D2[2], vy , J) | 43 @inbounds uᵢ += LazyTensors.apply(L.D2[2], vy , J) |
35 | 44 |
36 return uᵢ | 45 return uᵢ |
37 end | 46 end |
38 | |
39 LazyTensors.apply_transpose(L::Laplace{Dim,T}, v::AbstractArray{T,Dim}, I::Vararg{Index,Dim}) where {T,Dim} = LazyTensors.apply(L, v, I...) | |
40 | 47 |
41 # quadrature(L::Laplace) = Quadrature(L.op, L.grid) | 48 # quadrature(L::Laplace) = Quadrature(L.op, L.grid) |
42 # inverse_quadrature(L::Laplace) = InverseQuadrature(L.op, L.grid) | 49 # inverse_quadrature(L::Laplace) = InverseQuadrature(L.op, L.grid) |
43 # boundary_value(L::Laplace, bId::CartesianBoundary) = BoundaryValue(L.op, L.grid, bId) | 50 # boundary_value(L::Laplace, bId::CartesianBoundary) = BoundaryValue(L.op, L.grid, bId) |
44 # normal_derivative(L::Laplace, bId::CartesianBoundary) = NormalDerivative(L.op, L.grid, bId) | 51 # normal_derivative(L::Laplace, bId::CartesianBoundary) = NormalDerivative(L.op, L.grid, bId) |