Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundary_conditions/boundary_condition_test.jl @ 1623:07e8080c9f1a
Merge feature/boundary_conditions
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Mon, 10 Jun 2024 22:39:22 -0700 |
parents | 48596b2f7923 |
children | 3714a391545a |
comparison
equal
deleted
inserted
replaced
1610:bb4c119e91fa | 1623:07e8080c9f1a |
---|---|
1 using Test | |
2 | |
3 using Sbplib.Grids | |
4 using Sbplib.RegionIndices | |
5 using Sbplib.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,Lower} | |
19 @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function,CartesianBoundary{3,Lower}} | |
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 |