Skip to content
Snippets Groups Projects
Commit a08de423 authored by Stephan Hilb's avatar Stephan Hilb
Browse files

avoid allocations

parent 7daf94ff
Branches
Tags
No related merge requests found
...@@ -211,8 +211,9 @@ function integrate(mesh::Mesh, expr; params...) ...@@ -211,8 +211,9 @@ function integrate(mesh::Mesh, expr; params...)
end end
function bind!(f::FeFunction, cell) function bind!(f::FeFunction, cell)
# TODO: make this non-allocating gdofs_view = view(f.space.dofmap, :, :, cell)
f.ldata .= vec(f.data[f.space.dofmap[:, :, cell]]) gdofs = SArray{Tuple{prod(f.space.size) * ndofs(f.space.element)}}(gdofs_view)
f.ldata .= f.data[gdofs]
return f return f
end end
...@@ -223,6 +224,7 @@ evaluate(f::FeFunction, x) = evaluate(f.space, f.ldata, x) ...@@ -223,6 +224,7 @@ evaluate(f::FeFunction, x) = evaluate(f.space, f.ldata, x)
bind!(c, cell) = c bind!(c, cell) = c
evaluate(c, xloc) = c evaluate(c, xloc) = c
# TODO: inherit from some abstract function type # TODO: inherit from some abstract function type
struct Derivative{F, M} struct Derivative{F, M}
f::F f::F
...@@ -242,6 +244,7 @@ function bind!(df::Derivative, cell) ...@@ -242,6 +244,7 @@ function bind!(df::Derivative, cell)
delmap = jacobian(elmap(df.f.space.mesh, cell), SA[0., 0.]) delmap = jacobian(elmap(df.f.space.mesh, cell), SA[0., 0.])
df.delmapinv .= inv(delmap) df.delmapinv .= inv(delmap)
end end
function evaluate(df::Derivative, x) function evaluate(df::Derivative, x)
# size: (:, d) # size: (:, d)
jac = jacobian(x -> evaluate(df.f.space, df.f.ldata, x), x) jac = jacobian(x -> evaluate(df.f.space, df.f.ldata, x), x)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment