Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/src/BoundaryConditions/boundary_condition.jl Wed May 29 23:28:33 2024 +0200 +++ b/src/BoundaryConditions/boundary_condition.jl Sat Jun 01 17:39:54 2024 -0700 @@ -1,47 +1,48 @@ """ - BoundaryCondition + BoundaryCondition{BID} -A type for implementing data needed in order to impose a boundary condition. +A type for implementing boundary_data needed in order to impose a boundary condition. Subtypes refer to perticular types of boundary conditions, e.g. Neumann conditions. """ -abstract type BoundaryCondition{T1,T2} end # REVIEW: No type parameters needed here. +abstract type BoundaryCondition{BID} end """ - id(::BoundaryCondition) + boundary(::BoundaryCondition) The boundary identifier of the BoundaryCondition. -Must be implemented by subtypes. """ -function id end +boundary(::BoundaryCondition{BID}) where {BID} = BID() """ - data(::BoundaryCondition) + boundary_data(::BoundaryCondition) If implemented, the data associated with the BoundaryCondition """ -function data end +function boundary_data end """ discretize(grid, bc::BoundaryCondition) -The grid function obtained from discretizing the `bc` data on the boundary grid +The grid function obtained from discretizing the `bc` boundary_data on the boundary grid specified the by bc `id`. """ function discretize_data(grid, bc::BoundaryCondition) - return eval_on(boundary_grid(grid, id(bc)), data(bc)) + return eval_on(boundary_grid(grid, boundary(bc)), boundary_data(bc)) end -struct DirichletCondition{T1,T2} <: BoundaryCondition{T1,T2} +struct DirichletCondition{T1,T2} <: BoundaryCondition{T2} data::T1 - id::T2 # REVIEW: This field not needed since BoundaryId are usually type parameters? + function DirichletCondition(data, id) + return new{typeof(data),typeof(id)}(data) + end end -id(bc::DirichletCondition) = bc.id -data(bc::DirichletCondition) = bc.data +boundary_data(bc::DirichletCondition) = bc.data -struct NeumannCondition{T1,T2} <: BoundaryCondition{T1,T2} +struct NeumannCondition{T1,T2} <: BoundaryCondition{T2} data::T1 - id::T2 # REVIEW: This field not needed since BoundaryId are usually type parameters? + function NeumannCondition(data, id) + return new{typeof(data),typeof(id)}(data) + end end -id(bc::NeumannCondition) = bc.id -data(bc::NeumannCondition) = bc.data +boundary_data(bc::NeumannCondition) = bc.data