Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/laplace/secondderivative.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 | e73af120ad38 |
children | 81053b1992b6 |
comparison
equal
deleted
inserted
replaced
366:0af6da238d95 | 370:8e55dee6a1a1 |
---|---|
2 SecondDerivative{T<:Real,N,M,K} <: TensorOperator{T,1} | 2 SecondDerivative{T<:Real,N,M,K} <: TensorOperator{T,1} |
3 Implements the Laplace tensor operator `L` with constant grid spacing and coefficients | 3 Implements the Laplace tensor operator `L` with constant grid spacing and coefficients |
4 in 1D dimension | 4 in 1D dimension |
5 """ | 5 """ |
6 | 6 |
7 struct SecondDerivative{T,N,M,K} <: TensorOperator{T,1} | 7 struct SecondDerivative{T,N,M,K} <: TensorMapping{T,1,1} |
8 h_inv::T # The grid spacing could be included in the stencil already. Preferable? | 8 h_inv::T # The grid spacing could be included in the stencil already. Preferable? |
9 innerStencil::Stencil{T,N} | 9 innerStencil::Stencil{T,N} |
10 closureStencils::NTuple{M,Stencil{T,K}} | 10 closureStencils::NTuple{M,Stencil{T,K}} |
11 parity::Parity | 11 parity::Parity |
12 #TODO: Write a nice constructor | 12 size::NTuple{1,Int} |
13 end | 13 end |
14 export SecondDerivative | 14 export SecondDerivative |
15 | 15 |
16 LazyTensors.domain_size(D2::SecondDerivative, range_size::NTuple{1,Integer}) = range_size | 16 function SecondDerivative(grid::EquidistantGrid{1}, innerStencil, closureStencils) |
17 h_inv = grid.inverse_spacing[1] | |
18 return SecondDerivative(h_inv, innerStencil, closureStencils, even, size(grid)) | |
19 end | |
20 | |
21 LazyTensors.range_size(D2::SecondDerivative) = D2.size | |
22 LazyTensors.domain_size(D2::SecondDerivative) = D2.size | |
17 | 23 |
18 #TODO: The 1D tensor mappings should not have to dispatch on 1D tuples if we write LazyTensor.apply for vararg right?!?! | 24 #TODO: The 1D tensor mappings should not have to dispatch on 1D tuples if we write LazyTensor.apply for vararg right?!?! |
19 # Currently have to index the Tuple{Index} in each method in order to call the stencil methods which is ugly. | 25 # Currently have to index the Tuple{Index} in each method in order to call the stencil methods which is ugly. |
20 # I thought I::Vararg{Index,R} fell back to just Index for R = 1 | 26 # I thought I::Vararg{Index,R} fell back to just Index for R = 1 |
21 | 27 |
38 r = getregion(Int(index), closuresize(D2), N) | 44 r = getregion(Int(index), closuresize(D2), N) |
39 I = Index(Int(index), r) | 45 I = Index(Int(index), r) |
40 return LazyTensors.apply(D2, v, I) | 46 return LazyTensors.apply(D2, v, I) |
41 end | 47 end |
42 | 48 |
43 LazyTensors.apply_transpose(D2::SecondDerivative{T}, v::AbstractVector{T}, I::Index) where {T} = LazyTensors.apply(D2, v, I) | |
44 | |
45 closuresize(D2::SecondDerivative{T,N,M,K}) where {T<:Real,N,M,K} = M | 49 closuresize(D2::SecondDerivative{T,N,M,K}) where {T<:Real,N,M,K} = M |