Using the Elasticity script to calculate the displacements I want to run some optimization loops. The variable I use to check my computations is a P0 element called dc. It needs to be a P0 element so later on I can reduce the density of each element with small dc. To compute dc I need to calculate the variable ce which is equal to the work W of each triangle. I have the forces applied as a P2 element and I have calculated them with the use of stiffness matrix and the equations F=K*U.
My problem is when I try to calculate:
ce=fx*ux+fy*uy;
where fx,ux,fy,uy are P2 elements and ce is a P0 element, my ce returns values equals to 0 which is not correct.
Is there any way use P2 elements to calculate P0 elements?