Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/boundary_conditions/boundary_condition_test.jl @ 1603:fca4a01d60c9 feature/boundary_conditions
Remove module BoundaryConditions, moving its content to SbpOperators
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Tue, 04 Jun 2024 16:46:14 -0700 |
parents | test/BoundaryConditions/boundary_condition_test.jl@3e7438e2a033 |
children | 48596b2f7923 |
comparison
equal
deleted
inserted
replaced
1602:3e7438e2a033 | 1603:fca4a01d60c9 |
---|---|
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 BoundaryCondition{Lower} | |
19 @test DirichletCondition(g,id_n) isa BoundaryCondition{CartesianBoundary{2,Upper}} | |
20 @test DirichletCondition(g,id_l) isa DirichletCondition{Float64,Lower} | |
21 @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function} | |
22 end | |
23 | |
24 @testset "boundary" begin | |
25 @test boundary(DirichletCondition(g,id_l)) == id_l | |
26 @test boundary(NeumannCondition(f,id_b)) == id_b | |
27 end | |
28 | |
29 @testset "boundary_data" begin | |
30 @test boundary_data(DirichletCondition(g,id_l)) == g | |
31 @test boundary_data(NeumannCondition(f,id_b)) == f | |
32 end | |
33 | |
34 @testset "discretize_data" begin | |
35 @test fill(g) ≈ discretize_data(grid_1d,DirichletCondition(g,id_l)) | |
36 @test g*ones(11,1) ≈ discretize_data(grid_2d,DirichletCondition(g,id_n)) | |
37 X = repeat(0:1/10:1, inner = (1,15)) | |
38 Y = repeat(0:1/14:1, outer = (1,11)) | |
39 @test map((x,y)->f(x,y,0), X,Y') ≈ discretize_data(grid_3d,NeumannCondition(f,id_b)) | |
40 end | |
41 end |