Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundary_conditions/boundary_condition_test.jl @ 2057:8a2a0d678d6f feature/lazy_tensors/pretty_printing
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 10 Feb 2026 22:41:19 +0100 |
| parents | 471a948cd2b2 |
| children |
comparison
equal
deleted
inserted
replaced
| 1110:c0bff9f6e0fb | 2057:8a2a0d678d6f |
|---|---|
| 1 using Test | |
| 2 | |
| 3 using Diffinitive.Grids | |
| 4 using Diffinitive.RegionIndices | |
| 5 using Diffinitive.SbpOperators | |
| 6 | |
| 7 @testset "BoundaryCondition" begin | |
| 8 grid_1d = equidistant_grid(0.0, 1.0, 11) | |
| 9 grid_2d = equidistant_grid((0.0, 0.0), (1.0,1.0), 11, 15) | |
| 10 grid_3d = equidistant_grid((0.0, 0.0, 0.0), (1.0,1.0, 1.0), 11, 15, 13) | |
| 11 (id_l,_) = boundary_identifiers(grid_1d) | |
| 12 (_,_,_,id_n) = boundary_identifiers(grid_2d) | |
| 13 (_,_,_,_,id_b,_) = boundary_identifiers(grid_3d) | |
| 14 | |
| 15 g = 3.14 | |
| 16 f(x,y,z) = x^2+y^2+z^2 | |
| 17 @testset "Constructors" begin | |
| 18 @test DirichletCondition(g,id_l) isa DirichletCondition{Float64,LowerBoundary} | |
| 19 @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function,CartesianBoundary{3,LowerBoundary}} | |
| 20 end | |
| 21 | |
| 22 @testset "boundary" begin | |
| 23 @test boundary(DirichletCondition(g,id_l)) == id_l | |
| 24 @test boundary(NeumannCondition(f,id_b)) == id_b | |
| 25 end | |
| 26 | |
| 27 @testset "boundary_data" begin | |
| 28 @test boundary_data(DirichletCondition(g,id_l)) == g | |
| 29 @test boundary_data(NeumannCondition(f,id_b)) == f | |
| 30 end | |
| 31 | |
| 32 @testset "discretize_data" begin | |
| 33 @test fill(g) ≈ discretize_data(grid_1d,DirichletCondition(g,id_l)) | |
| 34 @test g*ones(11,1) ≈ discretize_data(grid_2d,DirichletCondition(g,id_n)) | |
| 35 X = repeat(0:1/10:1, inner = (1,15)) | |
| 36 Y = repeat(0:1/14:1, outer = (1,11)) | |
| 37 @test map((x,y)->f(x,y,0), X,Y') ≈ discretize_data(grid_3d,NeumannCondition(f,id_b)) | |
| 38 end | |
| 39 end |
