@@ -180,7 +180,7 @@ function function_value(fe_v::AbstractValues, q_point::Int, u::AbstractVector, d
180180 @boundscheck checkbounds (u, dof_range)
181181 @boundscheck checkquadpoint (fe_v, q_point)
182182 val = function_value_init (fe_v, u)
183- @inbounds for (i, j) in pairs (dof_range)
183+ @inbounds for (i, j) in enumerate (dof_range)
184184 val += shape_value (fe_v, q_point, i) * u[j]
185185 end
186186 return val
@@ -220,20 +220,21 @@ function function_gradient(fe_v::AbstractValues, q_point::Int, u::AbstractVector
220220 @boundscheck checkbounds (u, dof_range)
221221 @boundscheck checkquadpoint (fe_v, q_point)
222222 grad = function_gradient_init (fe_v, u)
223- @inbounds for (i, j) in pairs (dof_range)
223+ @inbounds for (i, j) in enumerate (dof_range)
224224 grad += shape_gradient (fe_v, q_point, i) * u[j]
225225 end
226226 return grad
227227end
228228
229229# TODO : Deprecate this, nobody is using this in practice...
230- function function_gradient (fe_v:: AbstractValues , q_point:: Int , u:: AbstractVector{<:Vec} )
230+ function function_gradient (fe_v:: AbstractValues , q_point:: Int , u:: AbstractVector{<:Vec} , dof_range = eachindex (u) )
231231 n_base_funcs = getnbasefunctions (fe_v)
232- length (u) == n_base_funcs || throw_incompatible_dof_length (length (u), n_base_funcs)
232+ length (dof_range) == n_base_funcs || throw_incompatible_dof_length (length (dof_range), n_base_funcs)
233+ @boundscheck checkbounds (u, dof_range)
233234 @boundscheck checkquadpoint (fe_v, q_point)
234235 grad = function_gradient_init (fe_v, u)
235- @inbounds for i in 1 : n_base_funcs
236- grad += u[i ] ⊗ shape_gradient (fe_v, q_point, i)
236+ @inbounds for (i, j) in enumerate (dof_range)
237+ grad += u[j ] ⊗ shape_gradient (fe_v, q_point, i)
237238 end
238239 return grad
239240end
@@ -267,7 +268,7 @@ function function_hessian(fe_v::AbstractValues, q_point::Int, u::AbstractVector,
267268 @boundscheck checkbounds (u, dof_range)
268269 @boundscheck checkquadpoint (fe_v, q_point)
269270 hess = function_hessian_init (fe_v, u)
270- @inbounds for (i, j) in pairs (dof_range)
271+ @inbounds for (i, j) in enumerate (dof_range)
271272 hess += shape_hessian (fe_v, q_point, i) * u[j]
272273 end
273274 return hess
0 commit comments