# Computing 3D integral with mixed/vector element variables is very slow

**URL:** <https://community.freefem.org/t/computing-3d-integral-with-mixed-vector-element-variables-is-very-slow/30>\
**Category:** General Discussion\
**Created:** [April 20, 2019, 11:49am UTC](https://community.freefem.org/t/computing-3d-integral-with-mixed-vector-element-variables-is-very-slow/30 "2019-04-20T11:49:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffeppon](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ffeppon/32/1011_2.png) [@ffeppon](https://community.freefem.org/u/ffeppon)\
**Post date:** [April 20, 2019, 11:49am UTC](https://community.freefem.org/t/computing-3d-integral-with-mixed-vector-element-variables-is-very-slow/30/1 "2019-04-20T11:49:22Z")

</div>

Hello,

I noticed that the computation of 3D integrals with [P1,P1,P1] elements is about ten times slower compared to the integration with P1 elements (after interpolating each coordinate), see the code below and the files attached below:

[essai.zip](https://github.com/FreeFem/FreeFem-sources/files/2816361/essai.zip)

```auto

func int readData(string fileName, real[int] &data){
	{
		ifstream f(fileName);
		f>>data;
	}
}

mesh3 Ths=readmesh3("Ths.mesh");
fespace Fhs12d(Ths,[P1,P1,P1]);
fespace Fhs1(Ths,P1);
Fhs12d [ux,uy,uz];
Fhs1 ux1, uy1, uz1;
readData("ux.gptmp",ux[]);
plot(ux,cmm="ux");
ux1=ux;
uy1=uy;
uz1=uz;

real mu=1, lambda=1;
real sqrt2=sqrt(2);
macro e(vx,vy,vz) [dx(vx),dy(vy),dz(vz),(dx(vy)+dy(vx))/sqrt2, (dx(vz)+dz(vx))/sqrt2, (dy(vz)+dz(vy))/sqrt2]//
macro div(vx,vy,vz) (dx(vx)+dy(vy)+dz(vz))//
real cpu1=clock();
real objectiveValue=int3d(Ths)(2*mu*e(ux1,uy1,uz1)'*e(ux1,uy1,uz1)+lambda*div(ux1,uy1,uz1)*div(ux1,uy1,uz1));
cout << "Time 1 : "<<clock()-cpu1 << " VALUE = " << objectiveValue << endl;

real cpu2=clock();
real objectiveValue2=int3d(Ths)(2*mu*e(ux,uy,uz)'*e(ux,uy,uz)+lambda*div(ux,uy,uz)*div(ux,uy,uz));
cout << "Time 2 : "<<clock()-cpu2 << " Value = "<< objectiveValue << endl;

```

Thanks,
