comparison test/ext/sparse_arrays_test.jl @ 1736:863385aae454 feature/grids/curvilinear

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 10 Sep 2024 21:59:10 +0200
parents 471a948cd2b2
children
comparison
equal deleted inserted replaced
1735:36986b75bf98 1736:863385aae454
1 using Test
2
3 using Diffinitive
4 using Diffinitive.Grids
5 using Diffinitive.SbpOperators
6
7 using SparseArrays
8 using Tokens
9
10
11 @testset "SparseArray" begin
12 g = equidistant_grid((0,0),(1,2), 20,30)
13 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=4)
14
15
16 @testset let Δ = laplace(g, stencil_set), M = sparse(Δ)
17 @test ndims(M) == 2
18 @test size(M) == (20*30,20*30)
19
20 v = rand(size(g)...)
21
22 Mv = M*reshape(v,:)
23 @test Mv ≈ reshape(Δ*v,:)
24 end
25
26 @testset let dₙ = normal_derivative(g, stencil_set,CartesianBoundary{1,LowerBoundary}()), M = sparse(dₙ)
27 @test ndims(M) == 2
28 @test size(M) == (30,20*30)
29
30 v = rand(size(g)...)
31 Mv = M*reshape(v,:)
32 @test Mv ≈ reshape(dₙ*v,:)
33 end
34 end