Integrating a PDE Solution Over Each Cell in FEniCS Legacy

I am completely new to FEniCS, and I need guidance on a specific problem. After calculating the solution u of PDE using the solve() function, I need to integrate the solution over each cell of the mesh. The goal is to assign the integrated value to the corresponding cell, which will then be exported.

I am using FEniCS Legacy version 2019.2.0.dev0.

Here is the minimum working example.

# Importing Mesh file
mesh = Mesh(some_mesh_data.xml")

 #Define a function to store the integrated values
uu = MeshFunction("double", mesh, mesh.geometry().dim())

# Iterate over cells, the mesh is an xml file
for cell in cells(mesh):
    cell_index = cell.index()

    # Integrate solution u over the cell region
    u_integral = u*dx(cell)

    # Assign the result to the cell in the MeshFunction
   new_cell_value[cell_index] = u_integral

> # Export Result
> export_file = File( "integration_values.pvd")
> export_file << new_cell_values

But when I try to run this I get this error:

Invalid subdomain_id <Mesh entity 0 of topological dimension 2>.
Traceback (most recent call last):

    u_integral = u*dx(cell)
  File "/usr/lib/python3/dist-packages/ufl_legacy/", line 282, in __call__
    return self.reconstruct(subdomain_id=subdomain_id, domain=domain,
  File "/usr/lib/python3/dist-packages/ufl_legacy/", line 228, in reconstruct
    return Measure(self.integral_type(),
  File "/usr/lib/python3/dist-packages/ufl_legacy/", line 166, in __init__
    error("Invalid subdomain_id %s." % (subdomain_id,))
  File "/usr/lib/python3/dist-packages/ufl_legacy/", line 158, in error
    raise self._exception_type(self._format_raw(*message))
ufl_legacy.log.UFLException: Invalid subdomain_id <Mesh entity 0 of topological dimension 2>.