comparison src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl @ 932:863287577ad4 feature/variable_derivatives

Temporarily add specialized methods for 2D
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 22 Feb 2022 07:24:22 +0100
parents 720b1358e06d
children 025a506ca2fa
comparison
equal deleted inserted replaced
931:720b1358e06d 932:863287577ad4
127 return LazyTensors.apply(op, v, I...) 127 return LazyTensors.apply(op, v, I...)
128 else 128 else
129 error("Bounds error") # TODO: Make this more standard 129 error("Bounds error") # TODO: Make this more standard
130 end 130 end
131 end 131 end
132
133
134 ## 2D Specific implementations to avoid instability
135 ## TODO: Should really be solved by fixing the general methods instead
136
137
138 ## x-direction
139 function apply_lower(op::SecondDerivativeVariable{1}, v, i, j)
140 ṽ = @view v[:,j]
141 c̃ = @view op.coefficient[:,j]
142
143 return @inbounds apply_stencil(op.closure_stencils[i], c̃, ṽ, i)
144 end
145
146 function apply_interior(op::SecondDerivativeVariable{1}, v, i, j)
147 ṽ = @view v[:,j]
148 c̃ = @view op.coefficient[:,j]
149
150 return @inbounds apply_stencil(op.inner_stencil, c̃, ṽ, i)
151 end
152
153 function apply_upper(op::SecondDerivativeVariable{1}, v, i, j)
154 ṽ = @view v[:,j]
155 c̃ = @view op.coefficient[:,j]
156
157 stencil = op.closure_stencils[op.size[derivative_direction(op)]-i+1]
158 return @inbounds apply_stencil_backwards(stencil, c̃, ṽ, i)
159 end
160
161
162 ## y-direction
163 function apply_lower(op::SecondDerivativeVariable{2}, v, i, j)
164 ṽ = @view v[i,:]
165 c̃ = @view op.coefficient[i,:]
166
167 return @inbounds apply_stencil(op.closure_stencils[j], c̃, ṽ, j)
168 end
169
170 function apply_interior(op::SecondDerivativeVariable{2}, v, i, j)
171 ṽ = @view v[i,:]
172 c̃ = @view op.coefficient[i,:]
173
174 return @inbounds apply_stencil(op.inner_stencil, c̃, ṽ, j)
175 end
176
177 function apply_upper(op::SecondDerivativeVariable{2}, v, i, j)
178 ṽ = @view v[i,:]
179 c̃ = @view op.coefficient[i,:]
180
181 stencil = op.closure_stencils[op.size[derivative_direction(op)]-j+1]
182 return @inbounds apply_stencil_backwards(stencil, c̃, ṽ, j)
183 end