Topology optimization loop cannot update the new design variable

Dear @Pasuta,
I will make an exception and reply to this post, even if I believe it does not qualify as a minimal example.
Here are a couple of reasons:

  1. Unused imports
  2. Unused variables

However, as the error is quite clear, consider

Here, you first create a variable eps, which is an numpy.ndarray. You then try to access x.array of this variable in

Just remove x.array, i.e.

def update_eps(m_n,result_grad_J):
    eps = m_n.x.array[:]
    eps_new = fem.Function(V)
    eps_new.x.array[:] = eps - 10**17*result_grad_J.x.array   
    m_n.x.array[:] = eps_new  
    return m_n

and the code does contine.

Please note that I made an adjoint solver for DOLFINx at: Calculate sensitivity when the control is a fem function - #3 by dokken
which is a general wrapper for linear problems