annotate src/SbpOperators/boundary_conditions/boundary_condition.jl @ 1617:a00fa58e9fb0 feature/boundary_conditions

REVIEW: Suggest changes to doc string in boundary_condition.jl
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 11 Jun 2024 00:02:15 +0200
parents e41eddc640f3
children 48596b2f7923
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1617
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
4 Description of a boundary condition. Implementations describe the kind of
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
5 boundary condition, what boundary the condition applies to, and any associated
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
6 data. Should implement [`boundary`](@ref) and may implement
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
7 [`boundary_data`](@ref) if applicable.
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
8
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
9 For examples see [`DirichletCondition`](@ref) and [`NeumannCondition`](@ref)
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
10 """
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
11 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
12
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
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)
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
15
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
16 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
17 """
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
18 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
19
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 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
22
1617
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
23 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
24 """
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
25 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
26
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
27 """
1617
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
28 discretize_data(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
29
1617
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
30 The data of `bc` as a lazily evaluated grid function on the boundary grid
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
31 specified by `boundary(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
32 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
33 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
34 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
35 end
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
36
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
37 """
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
38 DirichletCondition{DT,BID}
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
39
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
40 A Dirichlet condition with `data::DT` on the boundary
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
41 specified by the boundary identifier `BID`.
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
42 """
1605
1388149b54ad REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents: 1603
diff changeset
43 struct DirichletCondition{DT,BID} <: BoundaryCondition{BID}
1388149b54ad REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents: 1603
diff changeset
44 data::DT
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
45 function DirichletCondition(data, id)
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
46 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
47 end
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
48 end
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
49 boundary_data(bc::DirichletCondition) = bc.data
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
50
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
51 """
1617
a00fa58e9fb0 REVIEW: Suggest changes to doc string in boundary_condition.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
52 NeumannCondition{DT,BID}
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
53
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
54 A Neumann condition with `data::DT` on the boundary
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
55 specified by the boundary identifier `BID`.
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1605
diff changeset
56 """
1605
1388149b54ad REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents: 1603
diff changeset
57 struct NeumannCondition{DT,BID} <: BoundaryCondition{BID}
1388149b54ad REVIEW: Suggestions for minor fixes
Jonatan Werpers <jonatan@werpers.com>
parents: 1603
diff changeset
58 data::DT
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
59 function NeumannCondition(data, id)
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
60 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
61 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
62 end
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
63 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
64