# Using P2 Finite elements to calculate P0 elements

**URL:** <https://community.freefem.org/t/using-p2-finite-elements-to-calculate-p0-elements/2046>\
**Category:** General Discussion\
**Created:** [October 7, 2022, 11:25am UTC](https://community.freefem.org/t/using-p2-finite-elements-to-calculate-p0-elements/2046 "2022-10-07T11:25:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefanosv](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Stefanosv](https://community.freefem.org/u/Stefanosv)\
**Post date:** [October 7, 2022, 11:25am UTC](https://community.freefem.org/t/using-p2-finite-elements-to-calculate-p0-elements/2046/1 "2022-10-07T11:25:23Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [October 7, 2022, 12:38pm UTC](https://community.freefem.org/t/using-p2-finite-elements-to-calculate-p0-elements/2046/2 "2022-10-07T12:38:05Z")

</div>

I think the line you wrote achieves just what you want - it does interpolation from `P2` to `P0` FE space. Maybe you should calculate a stiffness matrix which maps for `P2` to `P0`, and calculate the forces directly on `P0`, and calculate the work also using `˙P0`

However, I think the `P2-P0` might be not ideal - you effectively throw away a lot of grid points and reduce your resolution. I would consider maybe using `P1` elements and a finer grid in your case .
