Mercurial > repos > public > sbplib_julia
changeset 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 | 1937be9502a7 |
children | 8141c184cc2f |
files | src/SbpOperators/boundary_conditions/boundary_condition.jl test/SbpOperators/boundary_conditions/boundary_condition_test.jl |
diffstat | 2 files changed, 10 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/boundary_conditions/boundary_condition.jl Tue Jun 11 00:19:09 2024 +0200 +++ b/src/SbpOperators/boundary_conditions/boundary_condition.jl Mon Jun 10 22:35:43 2024 -0700 @@ -1,5 +1,5 @@ """ - BoundaryCondition{BID} + BoundaryCondition Description of a boundary condition. Implementations describe the kind of boundary condition, what boundary the condition applies to, and any associated @@ -8,14 +8,14 @@ For examples see [`DirichletCondition`](@ref) and [`NeumannCondition`](@ref) """ -abstract type BoundaryCondition{BID} end +abstract type BoundaryCondition end """ boundary(::BoundaryCondition) The boundary identifier of the BoundaryCondition. """ -boundary(::BoundaryCondition{BID}) where {BID} = BID() +function boundary end """ boundary_data(::BoundaryCondition) @@ -40,13 +40,12 @@ A Dirichlet condition with `data::DT` on the boundary specified by the boundary identifier `BID`. """ -struct DirichletCondition{DT,BID} <: BoundaryCondition{BID} +struct DirichletCondition{DT,BID} <: BoundaryCondition data::DT - function DirichletCondition(data, id) - return new{typeof(data),typeof(id)}(data) - end + boundary::BID end boundary_data(bc::DirichletCondition) = bc.data +boundary(bc::DirichletCondition) = bc.boundary """ NeumannCondition{DT,BID} @@ -54,11 +53,10 @@ A Neumann condition with `data::DT` on the boundary specified by the boundary identifier `BID`. """ -struct NeumannCondition{DT,BID} <: BoundaryCondition{BID} +struct NeumannCondition{DT,BID} <: BoundaryCondition data::DT - function NeumannCondition(data, id) - return new{typeof(data),typeof(id)}(data) - end + boundary::BID end boundary_data(bc::NeumannCondition) = bc.data +boundary(bc::NeumannCondition) = bc.boundary
--- a/test/SbpOperators/boundary_conditions/boundary_condition_test.jl Tue Jun 11 00:19:09 2024 +0200 +++ b/test/SbpOperators/boundary_conditions/boundary_condition_test.jl Mon Jun 10 22:35:43 2024 -0700 @@ -15,10 +15,8 @@ g = 3.14 f(x,y,z) = x^2+y^2+z^2 @testset "Constructors" begin - @test DirichletCondition(g,id_l) isa BoundaryCondition{Lower} - @test DirichletCondition(g,id_n) isa BoundaryCondition{CartesianBoundary{2,Upper}} @test DirichletCondition(g,id_l) isa DirichletCondition{Float64,Lower} - @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function} + @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function,CartesianBoundary{3,Lower}} end @testset "boundary" begin