From facb8eb60cba522f2860710af96688f3c6416bcf Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Wed, 8 Jan 2025 12:14:31 +1100 Subject: [PATCH] better errors in wrong PolyBasis construction --- src/Polynomials/CompWiseTensorPolyBases.jl | 1 + src/Polynomials/NedelecPolyBases.jl | 5 +++-- src/Polynomials/RaviartThomasPolyBases.jl | 3 ++- src/Polynomials/UniformPolyBases.jl | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Polynomials/CompWiseTensorPolyBases.jl b/src/Polynomials/CompWiseTensorPolyBases.jl index d0d1a2283..536c5e89e 100644 --- a/src/Polynomials/CompWiseTensorPolyBases.jl +++ b/src/Polynomials/CompWiseTensorPolyBases.jl @@ -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) diff --git a/src/Polynomials/NedelecPolyBases.jl b/src/Polynomials/NedelecPolyBases.jl index 807c2d4a8..7c96be8a1 100644 --- a/src/Polynomials/NedelecPolyBases.jl +++ b/src/Polynomials/NedelecPolyBases.jl @@ -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} @@ -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 diff --git a/src/Polynomials/RaviartThomasPolyBases.jl b/src/Polynomials/RaviartThomasPolyBases.jl index 9b0c99fcd..8cc689194 100644 --- a/src/Polynomials/RaviartThomasPolyBases.jl +++ b/src/Polynomials/RaviartThomasPolyBases.jl @@ -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} diff --git a/src/Polynomials/UniformPolyBases.jl b/src/Polynomials/UniformPolyBases.jl index 7130144b1..982c983ea 100644 --- a/src/Polynomials/UniformPolyBases.jl +++ b/src/Polynomials/UniformPolyBases.jl @@ -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