From 257c56462fda86d76e4b3ecf8dadd5c471dc8526 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 30 Sep 2024 11:08:12 +0200 Subject: [PATCH] Remove the unused and deprecated third parameter for interpolations --- CHANGELOG.md | 12 ++++++++++++ src/deprecations.jl | 39 --------------------------------------- src/interpolations.jl | 28 ++++++++++++++-------------- test/test_deprecations.jl | 17 ----------------- 4 files changed, 26 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12325b97cf..a2be9f3a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Removed + - The deprecated third type parameter for interpolations have been removed. Old code which + tries to use three parameters will now throw the somewhat cryptic error: + ``` + julia> Lagrange{2, RefCube, 1}() + ERROR: too many parameters for type + ``` + ([#1083]) + ## [v1.0.0] - 2024-09-30 Ferrite version 1.0 is a relatively large release, with a lot of new features, improvements, @@ -1015,3 +1026,4 @@ poking into Ferrite internals: [#974]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/974 [#1058]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1058 [#1059]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1059 +[#1083]: https://github.com/Ferrite-FEM/Ferrite.jl/issues/1083 diff --git a/src/deprecations.jl b/src/deprecations.jl index 8043a837d4..207fb938fc 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -231,31 +231,6 @@ end struct RefCube end export RefCube -function Lagrange{D, RefCube, O}() where {D, O} - shape = D == 1 ? RefLine : D == 2 ? RefQuadrilateral : RefHexahedron - throw(DeprecationError("Lagrange{$D, RefCube, $O}()" => "Lagrange{$(shape), $O}()")) -end -function Lagrange{2, RefTetrahedron, O}() where {O} - throw(DeprecationError("Lagrange{2, RefTetrahedron, $O}()" => "Lagrange{RefTriangle, $O}()")) -end -function DiscontinuousLagrange{D, RefCube, O}() where {D, O} - shape = D == 1 ? RefLine : D == 2 ? RefQuadrilateral : RefHexahedron - throw(DeprecationError("DiscontinuousLagrange{$D, RefCube, $O}()" => "DiscontinuousLagrange{$(shape), $O}()")) -end -function BubbleEnrichedLagrange{2, RefTetrahedron, O}() where {O} - throw(DeprecationError("BubbleEnrichedLagrange{2, RefTetrahedron, $O}()" => "BubbleEnrichedLagrange{RefTriangle, $O}()")) -end -function DiscontinuousLagrange{2, RefTetrahedron, O}() where {O} - throw(DeprecationError("DiscontinuousLagrange{2, RefTetrahedron, $O}()" => "DiscontinuousLagrange{RefTriangle, $O}()")) -end -function Serendipity{D, RefCube, O}() where {D, O} - shape = D == 1 ? RefLine : D == 2 ? RefQuadrilateral : RefHexahedron - throw(DeprecationError("Serendipity{$D, RefCube, $O}()" => "Serendipity{$(shape), $O}()")) -end -function CrouzeixRaviart{2, 1}() - throw(DeprecationError("CrouzeixRaviart{2, 1}()" => "CrouzeixRaviart{RefTriangle, 1}()")) -end - # For the quadrature: Some will be wrong for face integration, so then we warn # in the FaceValue constructor... @@ -359,20 +334,6 @@ function FacetValues( throw(DeprecationError(msg)) end -# Hide the last unused type param... -function Base.show(io::IO, ::DiscontinuousLagrange{shape, order}) where {shape, order} - print(io, "DiscontinuousLagrange{$(shape), $(order)}()") -end -function Base.show(io::IO, ::Lagrange{shape, order}) where {shape, order} - print(io, "Lagrange{$(shape), $(order)}()") -end -function Base.show(io::IO, ::Serendipity{shape, order}) where {shape, order} - print(io, "Serendipity{$(shape), $(order)}()") -end -function Base.show(io::IO, ::CrouzeixRaviart{shape, order}) where {shape, order} - print(io, "CrouzeixRaviart{$(shape), $(order)}()") -end - function value(ip::Interpolation, ξ::Vec) throw(DeprecationError("value(ip::Interpolation, ξ::Vec)" => "[reference_shape_value(ip, ξ, i) for i in 1:getnbasefunctions(ip)]")) end diff --git a/src/interpolations.jl b/src/interpolations.jl index 8ce950b1ee..c78621c90e 100644 --- a/src/interpolations.jl +++ b/src/interpolations.jl @@ -44,12 +44,12 @@ julia> getnbasefunctions(ip) 6 ``` """ -abstract type Interpolation{shape #=<: AbstractRefShape=#, order, unused} end +abstract type Interpolation{shape #=<: AbstractRefShape=#, order} end const InterpolationByDim{dim} = Interpolation{<:AbstractRefShape{dim}} -abstract type ScalarInterpolation{ refshape, order} <: Interpolation{refshape, order, Nothing} end -abstract type VectorInterpolation{vdim, refshape, order} <: Interpolation{refshape, order, Nothing} end +abstract type ScalarInterpolation{ refshape, order} <: Interpolation{refshape, order} end +abstract type VectorInterpolation{vdim, refshape, order} <: Interpolation{refshape, order} end # Number of components for the interpolation. n_components(::ScalarInterpolation) = 1 @@ -429,9 +429,9 @@ dirichlet_boundarydof_indices(::Type{FacetIndex}) = dirichlet_facetdof_indices """ Piecewise discontinuous Lagrange basis via Gauss-Lobatto points. """ -struct DiscontinuousLagrange{shape, order, unused} <: ScalarInterpolation{shape, order} +struct DiscontinuousLagrange{shape, order} <: ScalarInterpolation{shape, order} function DiscontinuousLagrange{shape, order}() where {shape <: AbstractRefShape, order} - new{shape, order, Nothing}() + new{shape, order}() end end @@ -486,9 +486,9 @@ is_discontinuous(::Type{<:DiscontinuousLagrange}) = true Standard continuous Lagrange polynomials with equidistant node placement. """ -struct Lagrange{shape, order, unused} <: ScalarInterpolation{shape, order} +struct Lagrange{shape, order} <: ScalarInterpolation{shape, order} function Lagrange{shape, order}() where {shape <: AbstractRefShape, order} - new{shape, order, Nothing}() + new{shape, order}() end end @@ -1269,9 +1269,9 @@ end """ Lagrange element with bubble stabilization. """ -struct BubbleEnrichedLagrange{shape, order, unused} <: ScalarInterpolation{shape, order} +struct BubbleEnrichedLagrange{shape, order} <: ScalarInterpolation{shape, order} function BubbleEnrichedLagrange{shape, order}() where {shape <: AbstractRefShape, order} - new{shape, order, Nothing}() + new{shape, order}() end end @@ -1312,9 +1312,9 @@ end Serendipity element on hypercubes. Currently only second order variants are implemented. """ -struct Serendipity{shape, order, unused} <: ScalarInterpolation{shape,order} +struct Serendipity{shape, order} <: ScalarInterpolation{shape,order} function Serendipity{shape, order}() where {shape <: AbstractRefShape, order} - new{shape, order, Nothing}() + new{shape, order}() end end @@ -1459,9 +1459,9 @@ Classical non-conforming Crouzeix–Raviart element. For details we refer to the original paper [CroRav:1973:cnf](@cite). """ -struct CrouzeixRaviart{shape, order, unused} <: ScalarInterpolation{shape, order} - CrouzeixRaviart{RefTriangle, 1}() = new{RefTriangle, 1, Nothing}() - CrouzeixRaviart{RefTetrahedron, 1}() = new{RefTetrahedron, 1, Nothing}() +struct CrouzeixRaviart{shape, order} <: ScalarInterpolation{shape, order} + CrouzeixRaviart{RefTriangle, 1}() = new{RefTriangle, 1}() + CrouzeixRaviart{RefTetrahedron, 1}() = new{RefTetrahedron, 1}() end # CR elements are characterized by not having vertex dofs diff --git a/test/test_deprecations.jl b/test/test_deprecations.jl index fe461748df..1d9bb65add 100644 --- a/test/test_deprecations.jl +++ b/test/test_deprecations.jl @@ -38,23 +38,6 @@ end end @testset "Deprecation of old RefShapes" begin - # Interpolations - for order in 1:2 - @test_throws Ferrite.DeprecationError Lagrange{1, RefCube, order}() - end - for order in 1:5 - @test_throws Ferrite.DeprecationError Lagrange{2, RefTetrahedron, order}() - end - for order in 1:2 - @test_throws Ferrite.DeprecationError Lagrange{2, RefCube, order}() - end - for order in 1:2 - @test_throws Ferrite.DeprecationError Lagrange{3, RefCube, order}() - end - @test_throws Ferrite.DeprecationError Serendipity{2, RefCube, 2}() - @test_throws Ferrite.DeprecationError Serendipity{3, RefCube, 2}() - @test_throws Ferrite.DeprecationError CrouzeixRaviart{2, 1}() - @test_throws Ferrite.DeprecationError BubbleEnrichedLagrange{2, RefTetrahedron, 1}() # Quadrature/(Cell|Face)Value combinations (sometimes warns in the QR constructor, sometimes it the FEValues constructor) function test_combo(constructor, qdim, qshape, qargs, ip) qr = QuadratureRule{qdim, qshape}(qargs...)