Mercurial > repos > public > sbplib_julia
annotate src/SbpOperators/boundary_conditions/boundary_condition.jl @ 1616:e41eddc640f3 feature/boundary_conditions
Docs
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Sun, 09 Jun 2024 17:51:57 -0700 |
parents | 1388149b54ad |
children | a00fa58e9fb0 |
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:
1134
diff
changeset
|
1 """ |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
2 BoundaryCondition{BID} |
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:
1134
diff
changeset
|
3 |
1616 | 4 A type for implementing data needed in order to impose a boundary condition. |
1396
35840a0681d1
Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
5 Subtypes refer to perticular types of boundary conditions, e.g. Neumann conditions. |
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:
1134
diff
changeset
|
6 """ |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
7 abstract type BoundaryCondition{BID} 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:
1134
diff
changeset
|
8 |
1134
667e9c588f23
Add type for different kind of boundary data and refactor the BoundaryConditions such that they are general w.r.t the boundary data type
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1106
diff
changeset
|
9 """ |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
10 boundary(::BoundaryCondition) |
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:
1134
diff
changeset
|
11 |
1396
35840a0681d1
Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
12 The boundary identifier of the BoundaryCondition. |
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:
1134
diff
changeset
|
13 """ |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
14 boundary(::BoundaryCondition{BID}) where {BID} = BID() |
1134
667e9c588f23
Add type for different kind of boundary data and refactor the BoundaryConditions such that they are general w.r.t the boundary data type
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1106
diff
changeset
|
15 |
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:
1134
diff
changeset
|
16 """ |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
17 boundary_data(::BoundaryCondition) |
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:
1134
diff
changeset
|
18 |
1396
35840a0681d1
Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
19 If implemented, the data associated with the BoundaryCondition |
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:
1134
diff
changeset
|
20 """ |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
21 function boundary_data 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:
1134
diff
changeset
|
22 |
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:
1134
diff
changeset
|
23 """ |
1481
ee242c3fe4af
Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1404
diff
changeset
|
24 discretize(grid, bc::BoundaryCondition) |
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:
1134
diff
changeset
|
25 |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
26 The grid function obtained from discretizing the `bc` boundary_data on the boundary grid |
1481
ee242c3fe4af
Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1404
diff
changeset
|
27 specified the by bc `id`. |
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:
1134
diff
changeset
|
28 """ |
1396
35840a0681d1
Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1395
diff
changeset
|
29 function discretize_data(grid, bc::BoundaryCondition) |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
30 return eval_on(boundary_grid(grid, boundary(bc)), boundary_data(bc)) |
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:
1134
diff
changeset
|
31 end |
1404
481960ca366f
Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1396
diff
changeset
|
32 |
1616 | 33 """ |
34 DirichletCondition{DT,BID} | |
35 | |
36 A Dirichlet condition with `data::DT` on the boundary | |
37 specified by the boundary identifier `BID`. | |
38 """ | |
1605
1388149b54ad
REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents:
1603
diff
changeset
|
39 struct DirichletCondition{DT,BID} <: BoundaryCondition{BID} |
1388149b54ad
REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents:
1603
diff
changeset
|
40 data::DT |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
41 function DirichletCondition(data, id) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
42 return new{typeof(data),typeof(id)}(data) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
43 end |
1404
481960ca366f
Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1396
diff
changeset
|
44 end |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
45 boundary_data(bc::DirichletCondition) = bc.data |
1404
481960ca366f
Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1396
diff
changeset
|
46 |
1616 | 47 """ |
48 DirichletCondition{DT,BID} | |
49 | |
50 A Neumann condition with `data::DT` on the boundary | |
51 specified by the boundary identifier `BID`. | |
52 """ | |
1605
1388149b54ad
REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents:
1603
diff
changeset
|
53 struct NeumannCondition{DT,BID} <: BoundaryCondition{BID} |
1388149b54ad
REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents:
1603
diff
changeset
|
54 data::DT |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
55 function NeumannCondition(data, id) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
56 return new{typeof(data),typeof(id)}(data) |
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
57 end |
1134
667e9c588f23
Add type for different kind of boundary data and refactor the BoundaryConditions such that they are general w.r.t the boundary data type
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1106
diff
changeset
|
58 end |
1602
3e7438e2a033
Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents:
1599
diff
changeset
|
59 boundary_data(bc::NeumannCondition) = bc.data |
1134
667e9c588f23
Add type for different kind of boundary data and refactor the BoundaryConditions such that they are general w.r.t the boundary data type
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1106
diff
changeset
|
60 |