Dolfin-adjoint overloaded solve fails but regular dolfin solve succeeds?

You Need to call Mesh(generate_mesh(domain,20)) as dolfin-adjoint overloads the mesh class (to be able to do shape optimization).