Skip to content

Commit

Permalink
better errors in wrong PolyBasis construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoinemarteau committed Jan 8, 2025
1 parent b8203fc commit facb8eb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Polynomials/CompWiseTensorPolyBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct CompWiseTensorPolyBasis{D,V,K,PT,L} <: PolynomialBasis{D,V,K,PT}
msg2 = "The Component Wise construction is useless for one component, use UniformPolyBasis instead"
@check L > 1 msg2
@check D > 0
@check isconcretetype(PT) "PT needs to be a concrete <:Polynomial type"
K = maximum(orders)

new{D,V,K,PT,L}(orders)
Expand Down
5 changes: 3 additions & 2 deletions src/Polynomials/NedelecPolyBases.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
struct NedelecPolyBasisOnSimplex{D,V,K,PT} <: PolynomialBasis{D,V,K,PT}
order::Int
function NedelecPolyBasisOnSimplex{D}(::Type{PT},::Type{T},order::Integer) where {D,PT,T}
function NedelecPolyBasisOnSimplex{D}(::Type{PT},::Type{T},order::Integer) where {D,PT<:Polynomial,T}
@check T<:Real "T needs to be <:Real since represents the type of the components of the vector value"
@check isconcretetype(PT) "PT needs to be a concrete <:Polynomial type"
@notimplementedif !(D in (2,3))
K = Int(order)+1
V = VectorValue{D,T}
Expand Down Expand Up @@ -260,6 +261,6 @@ function PGradBasis(::Type{PT},::Val{D},::Type{T},order::Int) where {PT,D,T}
# the code explicitely uses monomials for the terms of x×(ℙₙ \\ ℙₙ₋₁)ᴰ, so I
# disable them here.
# But one can use NedelecPolyBasisOnSimplex{D}(PT,T,order) if they wish.
@notimplemented "only implemented for monomials"
@notimplemented "Nedelec on simplices is only implemented for monomials"
end

3 changes: 2 additions & 1 deletion src/Polynomials/RaviartThomasPolyBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ struct RaviartThomasPolyBasis{D,V,K,PT} <: PolynomialBasis{D,V,K,PT}
function RaviartThomasPolyBasis{D}(
::Type{PT}, ::Type{T}, order::Int,
_filter::Function=_p_filter
) where {PT,D,T}
) where {PT<:Polynomial,D,T}

@check T<:Real "T needs to be <:Real since represents the type of the components of the vector value"
@check D > 1
@check isconcretetype(PT) "PT needs to be a concrete <:Polynomial type"
@check isHierarchical(PT) "The polynomial basis must be hierarchichal for this space."

V = VectorValue{D,T}
Expand Down
2 changes: 2 additions & 0 deletions src/Polynomials/UniformPolyBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ struct UniformPolyBasis{D,V,K,PT} <: PolynomialBasis{D,V,K,PT}
orders::NTuple{D,Int},
terms::Vector{CartesianIndex{D}}) where {D,V,PT<:Polynomial}

@check isconcretetype(PT) "PT needs to be a concrete <:Polynomial type"

K = maximum(orders; init=0)
msg = "Some term contain a higher index than the maximum degree + 1."
@check all( term -> (maximum(Tuple(term), init=0) <= K+1), terms) msg
Expand Down

0 comments on commit facb8eb

Please sign in to comment.