Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundary_conditions/boundary_condition.jl @ 1620:48596b2f7923 feature/boundary_conditions
Remove type parameter from BoundaryCondition
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Mon, 10 Jun 2024 22:35:43 -0700 |
parents | a00fa58e9fb0 |
children |
comparison
equal
deleted
inserted
replaced
1619:1937be9502a7 | 1620:48596b2f7923 |
---|---|
1 """ | 1 """ |
2 BoundaryCondition{BID} | 2 BoundaryCondition |
3 | 3 |
4 Description of a boundary condition. Implementations describe the kind of | 4 Description of a boundary condition. Implementations describe the kind of |
5 boundary condition, what boundary the condition applies to, and any associated | 5 boundary condition, what boundary the condition applies to, and any associated |
6 data. Should implement [`boundary`](@ref) and may implement | 6 data. Should implement [`boundary`](@ref) and may implement |
7 [`boundary_data`](@ref) if applicable. | 7 [`boundary_data`](@ref) if applicable. |
8 | 8 |
9 For examples see [`DirichletCondition`](@ref) and [`NeumannCondition`](@ref) | 9 For examples see [`DirichletCondition`](@ref) and [`NeumannCondition`](@ref) |
10 """ | 10 """ |
11 abstract type BoundaryCondition{BID} end | 11 abstract type BoundaryCondition end |
12 | 12 |
13 """ | 13 """ |
14 boundary(::BoundaryCondition) | 14 boundary(::BoundaryCondition) |
15 | 15 |
16 The boundary identifier of the BoundaryCondition. | 16 The boundary identifier of the BoundaryCondition. |
17 """ | 17 """ |
18 boundary(::BoundaryCondition{BID}) where {BID} = BID() | 18 function boundary end |
19 | 19 |
20 """ | 20 """ |
21 boundary_data(::BoundaryCondition) | 21 boundary_data(::BoundaryCondition) |
22 | 22 |
23 If implemented, the data associated with the BoundaryCondition. | 23 If implemented, the data associated with the BoundaryCondition. |
38 DirichletCondition{DT,BID} | 38 DirichletCondition{DT,BID} |
39 | 39 |
40 A Dirichlet condition with `data::DT` on the boundary | 40 A Dirichlet condition with `data::DT` on the boundary |
41 specified by the boundary identifier `BID`. | 41 specified by the boundary identifier `BID`. |
42 """ | 42 """ |
43 struct DirichletCondition{DT,BID} <: BoundaryCondition{BID} | 43 struct DirichletCondition{DT,BID} <: BoundaryCondition |
44 data::DT | 44 data::DT |
45 function DirichletCondition(data, id) | 45 boundary::BID |
46 return new{typeof(data),typeof(id)}(data) | |
47 end | |
48 end | 46 end |
49 boundary_data(bc::DirichletCondition) = bc.data | 47 boundary_data(bc::DirichletCondition) = bc.data |
48 boundary(bc::DirichletCondition) = bc.boundary | |
50 | 49 |
51 """ | 50 """ |
52 NeumannCondition{DT,BID} | 51 NeumannCondition{DT,BID} |
53 | 52 |
54 A Neumann condition with `data::DT` on the boundary | 53 A Neumann condition with `data::DT` on the boundary |
55 specified by the boundary identifier `BID`. | 54 specified by the boundary identifier `BID`. |
56 """ | 55 """ |
57 struct NeumannCondition{DT,BID} <: BoundaryCondition{BID} | 56 struct NeumannCondition{DT,BID} <: BoundaryCondition |
58 data::DT | 57 data::DT |
59 function NeumannCondition(data, id) | 58 boundary::BID |
60 return new{typeof(data),typeof(id)}(data) | |
61 end | |
62 end | 59 end |
63 boundary_data(bc::NeumannCondition) = bc.data | 60 boundary_data(bc::NeumannCondition) = bc.data |
61 boundary(bc::NeumannCondition) = bc.boundary | |
64 | 62 |