annotate src/BoundaryConditions/boundary_condition.jl @ 1396:35840a0681d1 feature/boundary_conditions

Start drafting new implemenentation of boundary conditions
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 26 Jul 2023 23:11:02 +0200
parents bdcdbd4ea9cd
children 481960ca366f
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 """
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
7 abstract type BoundaryCondition 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 """
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 discretize(::BoundaryData, boundary_grid)
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 Returns an anonymous time-dependent function f, such that f(t) is
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 a `LazyArray` holding the `BoundaryData` discretized on `boundary_grid`.
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
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
33
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
34 struct NeumannCondition{DT} <: BoundaryCondition{DT}
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
35 data::DT
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
36 id::BoundaryIdentifier
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
37 end
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
38 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
39 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
40
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
41 struct DirichletCondition{DT} <: BoundaryCondition{DT}
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
42 data::DT
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
43 id::BoundaryIdentifier
1396
35840a0681d1 Start drafting new implemenentation of boundary conditions
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1395
diff changeset
44 end
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::DirichletCondition) = bc.data