Get information about the solution

In the Hyperelasticity example of the doc.

How can I get the final value of the potential energie Pi? (ie evaluate Pi on the mesh+vector u solution)

You can evaluate scalar-valued integrals using the assemble function. To get the final value of Pi, you would call assemble(Pi) after the solve, which will return the value of the integral as a Python float. To get just the elastic potential energy, you would use assemble(psi*dx), and so on.