# About Array Calculation

**URL:** <https://community.freefem.org/t/about-array-calculation/2037>\
**Category:** General Discussion\
**Created:** [October 4, 2022, 1:02am UTC](https://community.freefem.org/t/about-array-calculation/2037 "2022-10-04T01:02:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yangshen](https://avatars.discourse-cdn.com/v4/letter/y/838e76/32.png) [@Yangshen](https://community.freefem.org/u/Yangshen)\
**Post date:** [October 4, 2022, 1:02am UTC](https://community.freefem.org/t/about-array-calculation/2037/1 "2022-10-04T01:02:11Z")

</div>

Deal all,  
In my example, I want to calculate e (uu, vv) '\* D \* e (uu, vv), but an error occurs.  
Here’s my code

// Parameters  
real E = 21.5;  
real sigma = 0.29;  
real gravity = -0.05;

// Mesh  
border a(t=2, 0){x=0; y=t; label=1;}  
border b(t=0, 10){x=t; y=0; label=2;}  
border c(t=0, 2){ x=10; y=t; label=1;}  
border d(t=0, 10){ x=10-t; y=2; label=3;}  
mesh th = buildmesh(b(20) + c(5) + d(20) + a(5));

// Fespace  
fespace Vh(th, [P1, P1]);  
Vh [uu, vv];  
Vh [w, s];

// Macro  
fespace Zh(th,[P1,P1,P1]);  
Zh [Sxx,Syy,Sxy];  
real sqrt2 = sqrt(2.);  
macro epsilon(u1, u2) [dx(u1), dy(u2), (dy(u1)+dx(u2))/sqrt2] //  
macro div(u,v) (dx(u) + dy(v)) //  
macro e(x1,x2) [dx(x1),0.5\*(dx(x2)+dy(x1)), dy(x2)]//  
// Problem  
real mu = E/(2\*(1+sigma));  
real lambda = E_sigma/((1+sigma)_(1-2_sigma));  
real a11 = 2_mu + lambda,a12 = 0,a13 = lambda;  
real a22 = mu,a23 = 0;  
real a33 = 2_mu + lambda;  
func D = [[a11,a12,a13],[a12,a22,a23],[a13,a23,a33]];  
solve Elasticity ([uu, vv], [w, s])  
= int2d(th)(  
lambda_div(w,s)\*div(uu,vv)  
+ 2._mu_( epsilon(w,s)'_epsilon(uu,vv) )  
)  
+ int2d(th)(  
- gravity_s  
)  
+ on(1, uu=0, vv=0)  
;

[Sxx,Syy,Sxy]=D\*e(uu,vv);

real[int] auxVec = (Sxx.n);  
auxVec = Sxx;  
real com = e(uu,vv)‘\*Sxx;  
// real c = Sxx’\*auxVec;  
//real k = e(uu,vv)'\*Sxx;  
// Movemesh  
cout \<\< auxVec \<\< endl;

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [October 5, 2022, 7:10am UTC](https://community.freefem.org/t/about-array-calculation/2037/2 "2022-10-05T07:10:29Z")

</div>

Remark, `e (uu, vv) '* D * e (uu, vv)`is a function so to store a variable function yon can use a finite function with some interpolation interpolation , like in  
[yang.edp](https://community.freefem.org/uploads/short-url/jzxeewIEJsKO0XnYjor3VlRxOV2.edp) (865 Bytes)

remakes in this case you lose nothing because `e (uu, vv) '* D * e (uu, vv)` is P0 by element

---

<div class="post-metadata">

**Author:** ![Yangshen](https://avatars.discourse-cdn.com/v4/letter/y/838e76/32.png) [@Yangshen](https://community.freefem.org/u/Yangshen)\
**Post date:** [October 5, 2022, 11:10am UTC](https://community.freefem.org/t/about-array-calculation/2037/3 "2022-10-05T11:10:24Z")

</div>

Thank you very much.

---

<div class="post-metadata">

**Author:** ![Yangshen](https://avatars.discourse-cdn.com/v4/letter/y/838e76/32.png) [@Yangshen](https://community.freefem.org/u/Yangshen)\
**Post date:** [October 5, 2022, 1:59pm UTC](https://community.freefem.org/t/about-array-calculation/2037/4 "2022-10-05T13:59:24Z")

</div>

Sorry to bother you again. About the following three lines of code

fespace Vh(th, [P1, P1]);

Vh [uu, vv]=[x,y];

Vh [w, s];

If I change the second line of code to

Vh [uu, vv]；

The results are the same.

I don’t quite understand=[x, y]; The role of this part of the code.
