Mercurial > repos > public > sbplib_julia
comparison test/testSbpOperators.jl @ 513:547639572208 feature/boundary_ops
Get some kind of tested working implementation.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 23 Nov 2020 20:22:14 +0100 |
parents | 3cecbfb3d623 |
children | 14e722e8607d |
comparison
equal
deleted
inserted
replaced
512:5a8cfcc0765d | 513:547639572208 |
---|---|
170 @test Qinv isa TensorMapping{T,2,2} where T | 170 @test Qinv isa TensorMapping{T,2,2} where T |
171 @test Qinv' isa TensorMapping{T,2,2} where T | 171 @test Qinv' isa TensorMapping{T,2,2} where T |
172 @test_broken Qinv*(Q*v) ≈ v | 172 @test_broken Qinv*(Q*v) ≈ v |
173 @test Qinv*v == Qinv'*v | 173 @test Qinv*v == Qinv'*v |
174 end | 174 end |
175 # | 175 |
176 # @testset "BoundaryValue" begin | 176 @testset "BoundaryRestrictrion" begin |
177 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 177 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
178 # g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0)) | 178 |
179 # | 179 g = EquidistantGrid(4, 0.0, 1.0) |
180 # e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}()) | 180 |
181 # e_e = BoundaryValue(op, g, CartesianBoundary{1,Upper}()) | 181 e_l = BoundaryRestriction(g,op.eClosure,Lower()) |
182 # e_s = BoundaryValue(op, g, CartesianBoundary{2,Lower}()) | 182 e_r = BoundaryRestriction(g,op.eClosure,Upper()) |
183 # e_n = BoundaryValue(op, g, CartesianBoundary{2,Upper}()) | 183 |
184 # | 184 v = evalOn(g,x->1+x^2) |
185 # v = zeros(Float64, 4, 5) | 185 u = [3.124] #How to handle scalars having to be arrays? It's kind of ugly. |
186 # v[:,5] = [1, 2, 3,4] | 186 |
187 # v[:,4] = [1, 2, 3,4] | 187 e_l*v isa LazyTensorMappingApplication |
188 # v[:,3] = [4, 5, 6, 7] | 188 @test (e_l*v)[Index{Lower}(1)] == v[1] |
189 # v[:,2] = [7, 8, 9, 10] | 189 @test (e_r*v)[Index{Upper}(4)] == v[end] |
190 # v[:,1] = [10, 11, 12, 13] | 190 @test e_l'*u == [u[1], 0, 0, 0] |
191 # | 191 @test e_r'*u == [0, 0, 0, u[1]] |
192 # @test e_w isa TensorMapping{T,2,1} where T | 192 @test_throws BoundsError (e_l*v)[Index{Lower}(3)] |
193 # @test e_w' isa TensorMapping{T,1,2} where T | 193 @test_throws BoundsError (e_r*v)[Index{Upper}(3)] |
194 # | 194 |
195 # @test domain_size(e_w, (3,2)) == (2,) | 195 |
196 # @test domain_size(e_e, (3,2)) == (2,) | 196 |
197 # @test domain_size(e_s, (3,2)) == (3,) | 197 |
198 # @test domain_size(e_n, (3,2)) == (3,) | 198 |
199 # | 199 g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0)) |
200 # @test size(e_w'*v) == (5,) | 200 |
201 # @test size(e_e'*v) == (5,) | 201 e_w = boundary_restriction(g, op.eClosure, CartesianBoundary{1,Lower}()) |
202 # @test size(e_s'*v) == (4,) | 202 e_e = boundary_restriction(g, op.eClosure, CartesianBoundary{1,Upper}()) |
203 # @test size(e_n'*v) == (4,) | 203 e_s = boundary_restriction(g, op.eClosure, CartesianBoundary{2,Lower}()) |
204 # | 204 e_n = boundary_restriction(g, op.eClosure, CartesianBoundary{2,Upper}()) |
205 # @test e_w'*v == [10,7,4,1.0,1] | 205 |
206 # @test e_e'*v == [13,10,7,4,4.0] | 206 v = zeros(Float64, 4, 5) |
207 # @test e_s'*v == [10,11,12,13.0] | 207 v[:,5] = [1, 2, 3,4] |
208 # @test e_n'*v == [1,2,3,4.0] | 208 v[:,4] = [1, 2, 3,4] |
209 # | 209 v[:,3] = [4, 5, 6, 7] |
210 # g_x = [1,2,3,4.0] | 210 v[:,2] = [7, 8, 9, 10] |
211 # g_y = [5,4,3,2,1.0] | 211 v[:,1] = [10, 11, 12, 13] |
212 # | 212 |
213 # G_w = zeros(Float64, (4,5)) | 213 @test_broken e_w isa TensorMapping{T,1,2} where T |
214 # G_w[1,:] = g_y | 214 @test_broken e_w' isa TensorMapping{T,2,1} where T |
215 # | 215 |
216 # G_e = zeros(Float64, (4,5)) | 216 |
217 # G_e[4,:] = g_y | 217 |
218 # | 218 @test domain_size(e_w) == (4,5) |
219 # G_s = zeros(Float64, (4,5)) | 219 @test domain_size(e_e) == (4,5) |
220 # G_s[:,1] = g_x | 220 @test domain_size(e_s) == (4,5) |
221 # | 221 @test domain_size(e_n) == (4,5) |
222 # G_n = zeros(Float64, (4,5)) | 222 |
223 # G_n[:,5] = g_x | 223 @test range_size(e_w) == (1,5) |
224 # | 224 @test range_size(e_e) == (1,5) |
225 # @test size(e_w*g_y) == (UnknownDim,5) | 225 @test range_size(e_s) == (4,1) |
226 # @test size(e_e*g_y) == (UnknownDim,5) | 226 @test range_size(e_n) == (4,1) |
227 # @test size(e_s*g_x) == (4,UnknownDim) | 227 |
228 # @test size(e_n*g_x) == (4,UnknownDim) | 228 e_w*v isa LazyTensorMappingApplication |
229 # | 229 |
230 # # These tests should be moved to where they are possible (i.e we know what the grid should be) | 230 @test_broken e_w'*v == [10,7,4,1.0,1] |
231 # @test_broken e_w*g_y == G_w | 231 @test_broken e_e'*v == [13,10,7,4,4.0] |
232 # @test_broken e_e*g_y == G_e | 232 @test_broken e_s'*v == [10,11,12,13.0] |
233 # @test_broken e_s*g_x == G_s | 233 @test_broken e_n'*v == [1,2,3,4.0] |
234 # @test_broken e_n*g_x == G_n | 234 |
235 # end | 235 g_x = [1,2,3,4.0] |
236 g_y = [5,4,3,2,1.0] | |
237 | |
238 G_w = zeros(Float64, (4,5)) | |
239 G_w[1,:] = g_y | |
240 | |
241 G_e = zeros(Float64, (4,5)) | |
242 G_e[4,:] = g_y | |
243 | |
244 G_s = zeros(Float64, (4,5)) | |
245 G_s[:,1] = g_x | |
246 | |
247 G_n = zeros(Float64, (4,5)) | |
248 G_n[:,5] = g_x | |
249 | |
250 @test_broken size(e_w*g_y) == (UnknownDim,5) | |
251 @test_broken size(e_e*g_y) == (UnknownDim,5) | |
252 @test_broken size(e_s*g_x) == (4,UnknownDim) | |
253 @test_broken size(e_n*g_x) == (4,UnknownDim) | |
254 | |
255 # These tests should be moved to where they are possible (i.e we know what the grid should be) | |
256 @test_broken e_w*g_y == G_w | |
257 @test_broken e_e*g_y == G_e | |
258 @test_broken e_s*g_x == G_s | |
259 @test_broken e_n*g_x == G_n | |
260 end | |
236 # | 261 # |
237 # @testset "NormalDerivative" begin | 262 # @testset "NormalDerivative" begin |
238 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") | 263 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") |
239 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0)) | 264 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0)) |
240 # | 265 # |