annotate src/BoundaryConditions/boundary_condition.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 37b05221beda
children
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
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
4 A type for implementing boundary_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
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
33 struct DirichletCondition{T1,T2} <: BoundaryCondition{T2}
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
34 data::T1
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
35 function DirichletCondition(data, id)
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
36 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
37 end
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
38 end
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
39 boundary_data(bc::DirichletCondition) = bc.data
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
40
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
41 struct NeumannCondition{T1,T2} <: BoundaryCondition{T2}
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
42 data::T1
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
43 function NeumannCondition(data, id)
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
44 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
45 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
46 end
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1599
diff changeset
47 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
48