diff --git a/src/function.jl b/src/function.jl
index c454677c660a901c677de784cd1f4d659fff4f43..31ffbacccbc54a480420aafa6f98ea18209b0ce7 100644
--- a/src/function.jl
+++ b/src/function.jl
@@ -211,8 +211,9 @@ function integrate(mesh::Mesh, expr; params...)
end
function bind!(f::FeFunction, cell)
- # TODO: make this non-allocating
- f.ldata .= vec(f.data[f.space.dofmap[:, :, cell]])
+ gdofs_view = view(f.space.dofmap, :, :, cell)
+ gdofs = SArray{Tuple{prod(f.space.size) * ndofs(f.space.element)}}(gdofs_view)
+ f.ldata .= f.data[gdofs]
return f
end
@@ -223,6 +224,7 @@ evaluate(f::FeFunction, x) = evaluate(f.space, f.ldata, x)
bind!(c, cell) = c
evaluate(c, xloc) = c
+
# TODO: inherit from some abstract function type
struct Derivative{F, M}
f::F
@@ -242,6 +244,7 @@ function bind!(df::Derivative, cell)
delmap = jacobian(elmap(df.f.space.mesh, cell), SA[0., 0.])
df.delmapinv .= inv(delmap)
end
+
function evaluate(df::Derivative, x)
# size: (:, d)
jac = jacobian(x -> evaluate(df.f.space, df.f.ldata, x), x)