Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions src/ReferenceFEs/Dofs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/ReferenceFEsTests/DofsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module DofsTests
using Test
using Gridap
using Gridap.ReferenceFEs
using Gridap.ReferenceFEs: LinearCombinationDof
using Gridap.Fields
using FillArrays

Expand All @@ -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}
Expand Down
Loading