annotate SbpOperators/src/constantstenciloperator.jl @ 271:ecd49ffe0bc8 boundary_conditions

Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 05 Dec 2019 11:54:56 +0100
parents ccef055233a2
children fe9e8737ddfa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
1 abstract type ConstantStencilOperator end
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
2
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
3 # Apply for different regions Lower/Interior/Upper or Unknown region
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
4 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i::Index{Lower})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
5 return @inbounds h_inv*h_inv*apply_stencil(op.closureStencils[Int(i)], v, Int(i))
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
6 end
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
7
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
8 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i::Index{Interior})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
9 return @inbounds h_inv*h_inv*apply_stencil(op.innerStencil, v, Int(i))
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
10 end
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
11
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
12 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i::Index{Upper})
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
13 N = length(v)
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
14 return @inbounds h_inv*h_inv*Int(op.parity)*apply_stencil_backwards(op.closureStencils[N-Int(i)+1], v, Int(i))
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
15 end
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
16
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
17 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, index::Index{Unknown})
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18 N = length(v)
271
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
19 r = getregion(Int(index), closuresize(op), N)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
20 i = Index(Int(index), r)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
21 return apply_2nd_derivative(op, h_inv, v, i)
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
22 end
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
23
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
24 # Wrapper functions for using regular indecies without specifying regions
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
25 @inline function apply_2nd_derivative(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, i::Int)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
26 return apply_2nd_derivative(op, h_inv, v, Index{Unknown}(i))
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
27 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
28 export apply_2nd_derivative
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
29
271
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
30 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Lower}, N::Integer) where T = v*h*op.quadratureClosure[Int(i)]
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
31 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Upper}, N::Integer) where T = v*h*op.quadratureClosure[N-Int(i)+1]
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
32 apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Index{Interior}, N::Integer) where T = v*h
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
33
271
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
34 function apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, index::Index{Unknown}, N::Integer) where T
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
35 r = getregion(Int(index), closuresize(op), N)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
36 i = Index(Int(index), r)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
37 return apply_quadrature(op, h, v, i, N)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
38 end
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
39
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
40 # Wrapper functions for using regular indecies without specifying regions
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
41 function apply_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Integer, N::Integer) where T
271
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
42 return apply_quadrature(op, h, v, Index{Unknown}(i), N)
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
43 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
44 export apply_quadrature
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
45
271
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
46 # TODO: Evaluate if divisions affect performance
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
47 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Lower}, N::Integer) where T = h_inv*v/op.quadratureClosure[Int(i)]
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
48 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]
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
49 apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, i::Index{Interior}, N::Integer) where T = v*h_inv
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
50
271
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
51 function apply_inverse_quadrature(op::ConstantStencilOperator, h_inv::Real, v::T, index::Index{Unknown}, N::Integer) where T
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
52 r = getregion(Int(index), closuresize(op), N)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
53 i = Index(Int(index), r)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
54 return apply_inverse_quadrature(op, h_inv, v, i, N)
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
55 end
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
56
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
57 # Wrapper functions for using regular indecies without specifying regions
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
58 function apply_inverse_quadrature(op::ConstantStencilOperator, h::Real, v::T, i::Integer, N::Integer) where T
ecd49ffe0bc8 Dispatch apply_quadrature and apply_inverse_quadrature on Index-type. Add convenience functions dispatching on integer-indices
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 269
diff changeset
59 return apply_inverse_quadrature(op, h, v, Index{Unknown}(i), N)
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
60 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
61 export apply_inverse_quadrature
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
62
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
63 function apply_boundary_value_transpose(op::ConstantStencilOperator, v::AbstractVector, ::Type{Lower})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
64 @boundscheck if length(v) < closuresize(op)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
65 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
66 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
67 apply_stencil(op.eClosure,v,1)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
68 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
69
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
70 function apply_boundary_value_transpose(op::ConstantStencilOperator, v::AbstractVector, ::Type{Upper})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
71 @boundscheck if length(v) < closuresize(op)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
72 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
73 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
74 apply_stencil_backwards(op.eClosure,v,length(v))
249
7cb4492ccd60 Refactor package SbpOperators
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
75 end
269
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
76 export apply_boundary_value_transpose
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
77
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
78 function apply_boundary_value(op::ConstantStencilOperator, v::Number, N::Integer, i::Integer, ::Type{Lower})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
79 @boundscheck if !(0<length(i) <= N)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
80 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
81 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
82 op.eClosure[i-1]*v
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
83 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
84
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
85 function apply_boundary_value(op::ConstantStencilOperator, v::Number, N::Integer, i::Integer, ::Type{Upper})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
86 @boundscheck if !(0<length(i) <= N)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
87 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
88 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
89 op.eClosure[N-i]*v
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
90 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
91 export apply_boundary_value
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
92
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
93 function apply_normal_derivative_transpose(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, ::Type{Lower})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
94 @boundscheck if length(v) < closuresize(op)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
95 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
96 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
97 h_inv*apply_stencil(op.dClosure,v,1)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
98 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
99
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
100 function apply_normal_derivative_transpose(op::ConstantStencilOperator, h_inv::Real, v::AbstractVector, ::Type{Upper})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
101 @boundscheck if length(v) < closuresize(op)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
102 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
103 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
104 -h_inv*apply_stencil_backwards(op.dClosure,v,length(v))
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
105 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
106
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
107 export apply_normal_derivative_transpose
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
108
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
109 function apply_normal_derivative(op::ConstantStencilOperator, h_inv::Real, v::Number, N::Integer, i::Integer, ::Type{Lower})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
110 @boundscheck if !(0<length(i) <= N)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
111 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
112 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
113 h_inv*op.dClosure[i-1]*v
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
114 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
115
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
116 function apply_normal_derivative(op::ConstantStencilOperator, h_inv::Real, v::Number, N::Integer, i::Integer, ::Type{Upper})
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
117 @boundscheck if !(0<length(i) <= N)
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
118 throw(BoundsError())
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
119 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
120 -h_inv*op.dClosure[N-i]*v
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
121 end
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
122
ccef055233a2 Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 253
diff changeset
123 export apply_normal_derivative