Rrule for zygote

I think the OP @mary is trying to do topology optimization through Gridap.jl FEM, similar to this tutorial, in which case ForwardDiff may not be so easy.

I would usually finite difference to compare the gradient to some random directional derivatives, i.e. check that f(x + \delta x) - f(x) \approx \delta x^T \nabla f for some small random vectors \delta x.

1 Like