diff --git a/NEWS.md b/NEWS.md index fac0aa016..5cfd6ee24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.20.4] - 2026-03-23 +## [0.20.4] - 2026-04-09 ### Added - Added `get_free_dof_coordinates`. Since PR[#1262](https://github.com/gridap/Gridap.jl/pull/1262). +- The element type of a `LinearCombinationDofVector` is now `LinearCombinationDof`, since PR[#1266](https://github.com/gridap/Gridap.jl/pull/1266). ### Fixed diff --git a/src/ReferenceFEs/Dofs.jl b/src/ReferenceFEs/Dofs.jl index 127ad54d5..b5fdab866 100644 --- a/src/ReferenceFEs/Dofs.jl +++ b/src/ReferenceFEs/Dofs.jl @@ -7,6 +7,13 @@ and the range the scalar set. """ abstract type Dof <: Map end +""" + struct LinearCombinationDof <: Dof + +Type to represent an element of a [`LinearCombinationDofVector`](@ref). +""" +struct LinearCombinationDof <: Dof end + """ struct LinearCombinationDofVector{T<:Dof,V,F} <: AbstractVector{T} values :: V @@ -23,7 +30,7 @@ Fields: - `values::AbstractMatrix{<:Number}` the matrix of the change from dof basis (b) to (a) - `predofs::AbstractVector{T}` A type representing dof pre-basis (b), with `T<:Dof` """ -@ahe struct LinearCombinationDofVector{T,V,F} <: AbstractVector{T} +@ahe struct LinearCombinationDofVector{T,V,F} <: AbstractVector{LinearCombinationDof} values::V predofs::F function LinearCombinationDofVector( @@ -46,7 +53,7 @@ end Base.size(a::LinearCombinationDofVector) = (size(a.values,2),) Base.IndexStyle(::LinearCombinationDofVector) = IndexLinear() -Base.getindex(::LinearCombinationDofVector{T},::Integer) where T = T() +Base.getindex(::LinearCombinationDofVector,::Integer) = LinearCombinationDof() function linear_combination(a::AbstractMatrix{<:Number}, b::AbstractVector{<:Dof}) LinearCombinationDofVector(a,b) @@ -104,7 +111,7 @@ function Base.getindex(b::ConcatenatedDofVector, i::Integer) lengths = length.(bases) first_indices = accumulate(+, lengths) basis_index = findfirst(>=(i), first_indices) - first(bases[basis_index]) # this is PointValue() or Moment() whatever i + first(bases[basis_index]) # this is PointValue(..), Moment() or LinearCombinationDof() whatever i end function Arrays.return_cache(b::ConcatenatedDofVector, field) diff --git a/test/ReferenceFEsTests/DofsTests.jl b/test/ReferenceFEsTests/DofsTests.jl index f8e20b498..a32eee8e0 100644 --- a/test/ReferenceFEsTests/DofsTests.jl +++ b/test/ReferenceFEsTests/DofsTests.jl @@ -3,6 +3,7 @@ module DofsTests using Test using Gridap using Gridap.ReferenceFEs +using Gridap.ReferenceFEs: LinearCombinationDof using Gridap.Fields using FillArrays @@ -19,6 +20,7 @@ dofs = get_dof_basis(reffe0) # length 3 dofs_lc = linear_combination(Eye(3,6), dofs) # length 6 @test dofs_lc isa AbstractVector{<:Dof} @test length(dofs_lc) == 6 +@test dofs_lc[1] isa LinearCombinationDof basis = get_prebasis(reffe1) # length 4 @test basis isa AbstractVector{<:Field}