@@ -71,6 +71,10 @@ function interpolate_values(::FESpace,::Function)::Tuple{Vector{E},Vector{E}} wh
7171 @abstractmethod
7272end
7373
74+ function interpolate_values (:: FESpace{D,Z,T} ,:: T ) where {D,Z,T}
75+ @abstractmethod
76+ end
77+
7478"""
7579Given a FESpace and its array of labels that represent the Dirichlet boundary
7680in the geometrical model and an array of functions for every Dirichlet
@@ -81,11 +85,20 @@ function interpolate_diri_values(::FESpace, funs::Vector{<:Function})::Vector{E}
8185 @abstractmethod
8286end
8387
88+ function interpolate_diri_values ( :: FESpace{D,Z,T} , :: Vector{T} ) where {D,Z,T}
89+ @abstractmethod
90+ end
91+
8492function interpolate_diri_values (this:: FESpace , fun:: Function )
8593 tags = diri_tags (this)
8694 interpolate_diri_values (this,fill (fun,length (tags)))
8795end
8896
97+ function interpolate_diri_values (this:: FESpace{D,Z,T} , val:: T ) where {D,Z,T}
98+ tags = diri_tags (this)
99+ interpolate_diri_values (this,fill (val,length (tags)))
100+ end
101+
89102"""
90103Returns the CellField that represents the FE function thorough its free and
91104dirichlet values. E = eltype(T)
@@ -111,27 +124,40 @@ function TestFESpace(this::FESpace{D,Z,T}) where {D,Z,T}
111124 return FESpaceWithDirichletData (this, dv)
112125end
113126
114- function TrialFESpace ( this:: FESpace , funs:: Vector{<:Function} = Function[]) where {D}
127+ function TrialFESpace ( this:: FESpace , funs:: Vector{<:Function} = Function[])
128+ _TrialFESpace (this,funs)
129+ end
130+
131+ function TrialFESpace ( this:: FESpace{D,Z,T} , vals:: Vector{T} ) where {D,Z,T}
132+ _TrialFESpace (this,vals)
133+ end
134+
135+ function _TrialFESpace ( this, funs)
115136 tags = diri_tags (this)
116137 @assert length (tags) == length (funs)
117138 dv = interpolate_diri_values (this,funs)
118139 return FESpaceWithDirichletData (this, dv)
119140end
120141
121- function TrialFESpace ( this:: FESpace , fun:: Function ) where {D}
142+ function TrialFESpace ( this:: FESpace , fun:: Function )
122143 dv = interpolate_diri_values (this,fun)
123144 return FESpaceWithDirichletData (this, dv)
124145end
125146
147+ function TrialFESpace ( this:: FESpace{D,Z,T} , val:: T ) where {D,Z,T}
148+ dv = interpolate_diri_values (this,val)
149+ return FESpaceWithDirichletData (this, dv)
150+ end
151+
126152# Testers
127153
128154function test_fe_space (
129- fespace:: FESpace{D,Z} ,
155+ fespace:: FESpace{D,Z,T } ,
130156 nfree:: Integer ,
131157 ndiri:: Integer ,
132158 cellmat:: CellMatrix ,
133159 cellvec:: CellVector ,
134- ufun:: Function ) where {D,Z}
160+ ufun:: Function ) where {D,Z,T }
135161
136162 @test num_free_dofs (fespace) == nfree
137163 @test num_diri_dofs (fespace) == ndiri
@@ -160,6 +186,13 @@ function test_fe_space(
160186 @test length (freevals) == nfree
161187 @test length (dirivals) == ndiri
162188
189+ z = zero (T)
190+ freevals, dirivals = interpolate_values (fespace,z)
191+ @test isa (freevals,AbstractVector)
192+ @test isa (dirivals,AbstractVector)
193+ @test length (freevals) == nfree
194+ @test length (dirivals) == ndiri
195+
163196 dirivals = interpolate_diri_values (fespace,ufun)
164197 @test isa (dirivals,AbstractVector)
165198 @test length (dirivals) == ndiri
@@ -170,6 +203,10 @@ function test_fe_space(
170203 trian = Triangulation (fespace)
171204 @test isa (trian,Triangulation{Z,D})
172205
206+ dirivals = interpolate_diri_values (fespace,z)
207+ @test isa (dirivals,AbstractVector)
208+ @test length (dirivals) == ndiri
209+
173210end
174211
175212# Helpers
@@ -216,6 +253,11 @@ function interpolate_values(f::FESpaceWithDirichletData,fun::Function)
216253 free_vals, f. diri_dofs
217254end
218255
256+ function interpolate_values (f:: FESpaceWithDirichletData{D,Z,T} ,val:: T ) where {D,Z,T}
257+ free_vals, _ = interpolate_values (f. fespace,val)
258+ free_vals, f. diri_dofs
259+ end
260+
219261function CellField (
220262 f:: FESpaceWithDirichletData{D,Z,T} ,free_dofs:: AbstractVector{E} ,diri_dofs:: AbstractVector{E} )where {D,Z,T,E}
221263 CellField (f. fespace,free_dofs,f. diri_dofs)
@@ -231,4 +273,8 @@ function interpolate_diri_values(f::FESpaceWithDirichletData, funs::Vector{<:Fun
231273 f. diri_dofs
232274end
233275
276+ function interpolate_diri_values (f:: FESpaceWithDirichletData{D,Z,T} , vals:: Vector{T} ) where {D,Z,T}
277+ f. diri_dofs
278+ end
279+
234280end # module FESpaces
0 commit comments