annotate src/BoundaryConditions/boundary_condition.jl @ 1594:d68d02dd882f feature/boundary_conditions

Merge with default
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Sat, 25 May 2024 16:07:10 -0700
parents ee242c3fe4af
children 37b05221beda
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 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
2 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
3
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
4 A type for implementing data needed in order to impose a boundary condition.
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 """
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
7 abstract type BoundaryCondition{T1,T2} 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 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
10 id(::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.
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
13 Must be implemented by subtypes.
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
14 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
15 function id 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
16
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 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
18 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
19
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
20 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
21 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
22 function 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
23
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 """
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
25 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
26
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
27 The grid function obtained from discretizing the `bc` data on the boundary grid
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
28 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
29 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
30 function discretize_data(grid, bc::BoundaryCondition)
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
31 return eval_on(boundary_grid(grid, id(bc)), 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
32 end
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
33
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
34 struct DirichletCondition{T1,T2} <: BoundaryCondition{T1,T2}
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
35 data::T1
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
36 id::T2
1404
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
37 end
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
38 id(bc::DirichletCondition) = bc.id
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
39 data(bc::DirichletCondition) = bc.data
481960ca366f Fix type signatures
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
40
1481
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
41 struct NeumannCondition{T1,T2} <: BoundaryCondition{T1,T2}
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
42 data::T1
ee242c3fe4af Support boundary identifiers for 1D grids
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1404
diff changeset
43 id::T2
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
44 end
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
45 id(bc::NeumannCondition) = bc.id
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
46 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
47