Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundary_conditions/boundary_condition.jl @ 1603:fca4a01d60c9 feature/boundary_conditions
Remove module BoundaryConditions, moving its content to SbpOperators
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Tue, 04 Jun 2024 16:46:14 -0700 |
parents | src/BoundaryConditions/boundary_condition.jl@3e7438e2a033 |
children | 1388149b54ad |
comparison
equal
deleted
inserted
replaced
1602:3e7438e2a033 | 1603:fca4a01d60c9 |
---|---|
1 """ | |
2 BoundaryCondition{BID} | |
3 | |
4 A type for implementing boundary_data needed in order to impose a boundary condition. | |
5 Subtypes refer to perticular types of boundary conditions, e.g. Neumann conditions. | |
6 """ | |
7 abstract type BoundaryCondition{BID} end | |
8 | |
9 """ | |
10 boundary(::BoundaryCondition) | |
11 | |
12 The boundary identifier of the BoundaryCondition. | |
13 """ | |
14 boundary(::BoundaryCondition{BID}) where {BID} = BID() | |
15 | |
16 """ | |
17 boundary_data(::BoundaryCondition) | |
18 | |
19 If implemented, the data associated with the BoundaryCondition | |
20 """ | |
21 function boundary_data end | |
22 | |
23 """ | |
24 discretize(grid, bc::BoundaryCondition) | |
25 | |
26 The grid function obtained from discretizing the `bc` boundary_data on the boundary grid | |
27 specified the by bc `id`. | |
28 """ | |
29 function discretize_data(grid, bc::BoundaryCondition) | |
30 return eval_on(boundary_grid(grid, boundary(bc)), boundary_data(bc)) | |
31 end | |
32 | |
33 struct DirichletCondition{T1,T2} <: BoundaryCondition{T2} | |
34 data::T1 | |
35 function DirichletCondition(data, id) | |
36 return new{typeof(data),typeof(id)}(data) | |
37 end | |
38 end | |
39 boundary_data(bc::DirichletCondition) = bc.data | |
40 | |
41 struct NeumannCondition{T1,T2} <: BoundaryCondition{T2} | |
42 data::T1 | |
43 function NeumannCondition(data, id) | |
44 return new{typeof(data),typeof(id)}(data) | |
45 end | |
46 end | |
47 boundary_data(bc::NeumannCondition) = bc.data | |
48 |