comparison SbpOperators/src/constantlaplace.jl @ 292:3747e5636eef

Remove field a from laplace tensor operator
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 22 Jun 2020 21:46:45 +0200
parents dd621017b695
children
comparison
equal deleted inserted replaced
291:0f94dc29c4bf 292:3747e5636eef
8 Implements the Laplace tensor operator `L` with constant grid spacing and coefficients 8 Implements the Laplace tensor operator `L` with constant grid spacing and coefficients
9 in 1D dimension 9 in 1D dimension
10 """ 10 """
11 struct ConstantLaplaceOperator{T<:Real,N,M,K} <: TensorOperator{T,1} 11 struct ConstantLaplaceOperator{T<:Real,N,M,K} <: TensorOperator{T,1}
12 h_inv::T # The grid spacing could be included in the stencil already. Preferable? 12 h_inv::T # The grid spacing could be included in the stencil already. Preferable?
13 a::T # TODO: Better name?
14 innerStencil::Stencil{T,N} 13 innerStencil::Stencil{T,N}
15 closureStencils::NTuple{M,Stencil{T,K}} 14 closureStencils::NTuple{M,Stencil{T,K}}
16 parity::Parity 15 parity::Parity
17 #TODO: Write a nice constructor 16 #TODO: Write a nice constructor
18 end 17 end
28 return apply(L, v, I[1]) 27 return apply(L, v, I[1])
29 end 28 end
30 29
31 # Apply for different regions Lower/Interior/Upper or Unknown region 30 # Apply for different regions Lower/Interior/Upper or Unknown region
32 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, i::Index{Lower}) 31 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, i::Index{Lower})
33 return @inbounds L.a*L.h_inv*L.h_inv*apply_stencil(L.closureStencils[Int(i)], v, Int(i)) 32 return @inbounds L.h_inv*L.h_inv*apply_stencil(L.closureStencils[Int(i)], v, Int(i))
34 end 33 end
35 34
36 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, i::Index{Interior}) 35 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, i::Index{Interior})
37 return @inbounds L.a*L.h_inv*L.h_inv*apply_stencil(L.innerStencil, v, Int(i)) 36 return @inbounds L.h_inv*L.h_inv*apply_stencil(L.innerStencil, v, Int(i))
38 end 37 end
39 38
40 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, i::Index{Upper}) 39 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, i::Index{Upper})
41 N = length(v) # TODO: Use domain_size here instead? 40 N = length(v) # TODO: Use domain_size here instead?
42 return @inbounds L.a*L.h_inv*L.h_inv*Int(L.parity)*apply_stencil_backwards(L.closureStencils[N-Int(i)+1], v, Int(i)) 41 return @inbounds L.h_inv*L.h_inv*Int(L.parity)*apply_stencil_backwards(L.closureStencils[N-Int(i)+1], v, Int(i))
43 end 42 end
44 43
45 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, index::Index{Unknown}) 44 @inline function LazyTensors.apply(L::ConstantLaplaceOperator, v::AbstractVector, index::Index{Unknown})
46 N = length(v) # TODO: Use domain_size here instead? 45 N = length(v) # TODO: Use domain_size here instead?
47 r = getregion(Int(index), closuresize(L), N) 46 r = getregion(Int(index), closuresize(L), N)