Skip to content

Commit 1a41629

Browse files
authored
Merge pull request #1266 from gridap/linear-combination-dof
Linear combination dof
2 parents 43df4e2 + 7f050c3 commit 1a41629

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.20.4] - 2026-03-23
10+
## [0.20.4] - 2026-04-09
1111

1212
### Added
1313

1414
- Added `get_free_dof_coordinates`. Since PR[#1262](https://github.com/gridap/Gridap.jl/pull/1262).
15+
- The element type of a `LinearCombinationDofVector` is now `LinearCombinationDof`, since PR[#1266](https://github.com/gridap/Gridap.jl/pull/1266).
1516

1617
### Fixed
1718

src/ReferenceFEs/Dofs.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and the range the scalar set.
77
"""
88
abstract type Dof <: Map end
99

10+
"""
11+
struct LinearCombinationDof <: Dof
12+
13+
Type to represent an element of a [`LinearCombinationDofVector`](@ref).
14+
"""
15+
struct LinearCombinationDof <: Dof end
16+
1017
"""
1118
struct LinearCombinationDofVector{T<:Dof,V,F} <: AbstractVector{T}
1219
values :: V
@@ -23,7 +30,7 @@ Fields:
2330
- `values::AbstractMatrix{<:Number}` the matrix of the change from dof basis (b) to (a)
2431
- `predofs::AbstractVector{T}` A type representing dof pre-basis (b), with `T<:Dof`
2532
"""
26-
@ahe struct LinearCombinationDofVector{T,V,F} <: AbstractVector{T}
33+
@ahe struct LinearCombinationDofVector{T,V,F} <: AbstractVector{LinearCombinationDof}
2734
values::V
2835
predofs::F
2936
function LinearCombinationDofVector(
@@ -46,7 +53,7 @@ end
4653

4754
Base.size(a::LinearCombinationDofVector) = (size(a.values,2),)
4855
Base.IndexStyle(::LinearCombinationDofVector) = IndexLinear()
49-
Base.getindex(::LinearCombinationDofVector{T},::Integer) where T = T()
56+
Base.getindex(::LinearCombinationDofVector,::Integer) = LinearCombinationDof()
5057

5158
function linear_combination(a::AbstractMatrix{<:Number}, b::AbstractVector{<:Dof})
5259
LinearCombinationDofVector(a,b)
@@ -104,7 +111,7 @@ function Base.getindex(b::ConcatenatedDofVector, i::Integer)
104111
lengths = length.(bases)
105112
first_indices = accumulate(+, lengths)
106113
basis_index = findfirst(>=(i), first_indices)
107-
first(bases[basis_index]) # this is PointValue() or Moment() whatever i
114+
first(bases[basis_index]) # this is PointValue(..), Moment() or LinearCombinationDof() whatever i
108115
end
109116

110117
function Arrays.return_cache(b::ConcatenatedDofVector, field)

test/ReferenceFEsTests/DofsTests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module DofsTests
33
using Test
44
using Gridap
55
using Gridap.ReferenceFEs
6+
using Gridap.ReferenceFEs: LinearCombinationDof
67
using Gridap.Fields
78
using FillArrays
89

@@ -19,6 +20,7 @@ dofs = get_dof_basis(reffe0) # length 3
1920
dofs_lc = linear_combination(Eye(3,6), dofs) # length 6
2021
@test dofs_lc isa AbstractVector{<:Dof}
2122
@test length(dofs_lc) == 6
23+
@test dofs_lc[1] isa LinearCombinationDof
2224

2325
basis = get_prebasis(reffe1) # length 4
2426
@test basis isa AbstractVector{<:Field}

0 commit comments

Comments
 (0)