Mercurial > repos > public > sbplib_julia
annotate test/BoundaryConditions/boundary_condition_test.jl @ 1602:3e7438e2a033 feature/boundary_conditions
Address review comments (1 left to be discussed)
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Sat, 01 Jun 2024 17:39:54 -0700 |
parents | 330c39505a94 |
children |
rev | line source |
---|---|
1164
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
1 using Test |
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
2 |
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
3 using Sbplib.BoundaryConditions |
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
4 using Sbplib.Grids |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
5 using Sbplib.RegionIndices |
1164
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
6 |
1406
b4ec84190e6b
Start reimplementing tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
7 @testset "BoundaryCondition" begin |
1597
330c39505a94
Fix boundary condition tests
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1481
diff
changeset
|
8 grid_1d = equidistant_grid(0.0, 1.0, 11) |
330c39505a94
Fix boundary condition tests
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1481
diff
changeset
|
9 grid_2d = equidistant_grid((0.0, 0.0), (1.0,1.0), 11, 15) |
330c39505a94
Fix boundary condition tests
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1481
diff
changeset
|
10 grid_3d = equidistant_grid((0.0, 0.0, 0.0), (1.0,1.0, 1.0), 11, 15, 13) |
1481
ee242c3fe4af
Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1478
diff
changeset
|
11 (id_l,_) = boundary_identifiers(grid_1d) |
1406
b4ec84190e6b
Start reimplementing tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
12 (_,_,_,id_n) = boundary_identifiers(grid_2d) |
b4ec84190e6b
Start reimplementing tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
13 (_,_,_,_,id_b,_) = boundary_identifiers(grid_3d) |
1164
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
14 |
1406
b4ec84190e6b
Start reimplementing tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
15 g = 3.14 |
1478
fefc81a9c155
Test spatially variable data
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1417
diff
changeset
|
16 f(x,y,z) = x^2+y^2+z^2 |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
17 @testset "Constructors" begin |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
18 @test DirichletCondition(g,id_l) isa BoundaryCondition{Lower} |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
19 @test DirichletCondition(g,id_n) isa BoundaryCondition{CartesianBoundary{2,Upper}} |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
20 @test DirichletCondition(g,id_l) isa DirichletCondition{Float64,Lower} |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
21 @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function} |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
22 end |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
23 |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
24 @testset "boundary" begin |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
25 @test boundary(DirichletCondition(g,id_l)) == id_l |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
26 @test boundary(NeumannCondition(f,id_b)) == id_b |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
27 end |
1164
d26aef8a5987
Add types for different kinds of boundary data functions to discretize the data on the grid. Add tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
28 |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
29 @testset "boundary_data" begin |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
30 @test boundary_data(DirichletCondition(g,id_l)) == g |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
31 @test boundary_data(NeumannCondition(f,id_b)) == f |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
32 end |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
33 |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
34 @testset "discretize_data" begin |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
35 @test fill(g) ≈ discretize_data(grid_1d,DirichletCondition(g,id_l)) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
36 @test g*ones(11,1) ≈ discretize_data(grid_2d,DirichletCondition(g,id_n)) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
37 X = repeat(0:1/10:1, inner = (1,15)) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
38 Y = repeat(0:1/14:1, outer = (1,11)) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
39 @test map((x,y)->f(x,y,0), X,Y') ≈ discretize_data(grid_3d,NeumannCondition(f,id_b)) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1597
diff
changeset
|
40 end |
1406
b4ec84190e6b
Start reimplementing tests
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
41 end |