Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/constantstenciloperator.jl @ 556:37a81dad36b9
Merge refactor/tensor_index_coupling
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Sun, 29 Nov 2020 21:18:45 +0100 |
parents | 1a53eb83ed24 |
children | d1929491180b |
comparison
equal
deleted
inserted
replaced
540:013ca4892540 | 556:37a81dad36b9 |
---|---|
12 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i::Index{Upper}) | 12 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i::Index{Upper}) |
13 N = length(v) | 13 N = length(v) |
14 return @inbounds h_inv*h_inv*Int(op.parity)*apply_stencil_backwards(op.closureStencils[N-Int(i)+1], v, Int(i)) | 14 return @inbounds h_inv*h_inv*Int(op.parity)*apply_stencil_backwards(op.closureStencils[N-Int(i)+1], v, Int(i)) |
15 end | 15 end |
16 | 16 |
17 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, index::Index{Unknown}) | 17 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i) |
18 N = length(v) | 18 N = length(v) |
19 r = getregion(Int(index), closuresize(op), N) | 19 r = getregion(Int(index), closuresize(op), N) |
20 i = Index(Int(index), r) | 20 i = Index(Int(index), r) |
21 return apply_2nd_derivative(op, h_inv, v, i) | 21 return apply_2nd_derivative(op, h_inv, v, i) |
22 end | 22 end |
24 | 24 |
25 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Lower}, N::Integer) where T = v*h*op.quadratureClosure[Int(i)] | 25 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Lower}, N::Integer) where T = v*h*op.quadratureClosure[Int(i)] |
26 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Upper}, N::Integer) where T = v*h*op.quadratureClosure[N-Int(i)+1] | 26 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Upper}, N::Integer) where T = v*h*op.quadratureClosure[N-Int(i)+1] |
27 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Interior}, N::Integer) where T = v*h | 27 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Interior}, N::Integer) where T = v*h |
28 | 28 |
29 function apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, index::Index{Unknown}, N::Integer) where T | 29 function apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i, N::Integer) where T |
30 r = getregion(Int(index), closuresize(op), N) | 30 r = getregion(i, closuresize(op), N) |
31 i = Index(Int(index), r) | 31 i = Index(i, r) |
32 return apply_quadrature(op, h, v, i, N) | 32 return apply_quadrature(op, h, v, i, N) |
33 end | 33 end |
34 export apply_quadrature | 34 export apply_quadrature |
35 | 35 |
36 # TODO: Evaluate if divisions affect performance | 36 # TODO: Evaluate if divisions affect performance |
37 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Lower}, N::Integer) where T = h_inv*v/op.quadratureClosure[Int(i)] | 37 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Lower}, N::Integer) where T = h_inv*v/op.quadratureClosure[Int(i)] |
38 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Upper}, N::Integer) where T = h_inv*v/op.quadratureClosure[N-Int(i)+1] | 38 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Upper}, N::Integer) where T = h_inv*v/op.quadratureClosure[N-Int(i)+1] |
39 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Interior}, N::Integer) where T = v*h_inv | 39 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Interior}, N::Integer) where T = v*h_inv |
40 | 40 |
41 function apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, index::Index{Unknown}, N::Integer) where T | 41 function apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i, N::Integer) where T |
42 r = getregion(Int(index), closuresize(op), N) | 42 r = getregion(i, closuresize(op), N) |
43 i = Index(Int(index), r) | 43 i = Index(i, r) |
44 return apply_inverse_quadrature(op, h_inv, v, i, N) | 44 return apply_inverse_quadrature(op, h_inv, v, i, N) |
45 end | 45 end |
46 | 46 |
47 export apply_inverse_quadrature | 47 export apply_inverse_quadrature |
48 | 48 |
60 -h_inv*apply_stencil_backwards(op.dClosure,v,length(v)) | 60 -h_inv*apply_stencil_backwards(op.dClosure,v,length(v)) |
61 end | 61 end |
62 | 62 |
63 export apply_normal_derivative_transpose | 63 export apply_normal_derivative_transpose |
64 | 64 |
65 function apply_normal_derivative(op::ConstantStencilOperator, h_inv::Real, v::Number, i::Index, N::Integer, ::Type{Lower}) | 65 function apply_normal_derivative(op::ConstantStencilOperator, h_inv::Real, v::Number, i, N::Integer, ::Type{Lower}) |
66 @boundscheck if !(0<length(Int(i)) <= N) | 66 @boundscheck if !(0<length(Int(i)) <= N) |
67 throw(BoundsError()) | 67 throw(BoundsError()) |
68 end | 68 end |
69 h_inv*op.dClosure[Int(i)-1]*v | 69 h_inv*op.dClosure[Int(i)-1]*v |
70 end | 70 end |
71 | 71 |
72 function apply_normal_derivative(op::ConstantStencilOperator, h_inv::Real, v::Number, i::Index, N::Integer, ::Type{Upper}) | 72 function apply_normal_derivative(op::ConstantStencilOperator, h_inv::Real, v::Number, i, N::Integer, ::Type{Upper}) |
73 @boundscheck if !(0<length(Int(i)) <= N) | 73 @boundscheck if !(0<length(Int(i)) <= N) |
74 throw(BoundsError()) | 74 throw(BoundsError()) |
75 end | 75 end |
76 -h_inv*op.dClosure[N-Int(i)]*v | 76 -h_inv*op.dClosure[N-Int(i)]*v |
77 end | 77 end |