# Type mismatch when using varf

**URL:** https://community.freefem.org/t/type-mismatch-when-using-varf/1165
**Category:** General Discussion
**Created:** [August 20, 2021, 6:59am UTC](https://community.freefem.org/t/type-mismatch-when-using-varf/1165 "2021-08-20T06:59:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![distractor](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@distractor](https://community.freefem.org/u/distractor)
#### Post date: [August 20, 2021, 6:59am UTC](https://community.freefem.org/t/type-mismatch-when-using-varf/1165/1 "2021-08-20T06:59:11Z")

</div>

# Problem

So I took [this example](https://www.um.es/freefem/ff++/pmwiki.php?n=Main.Beam-3d) and my goal is to rewrite it using `varf` functionality and get the same results.

# Note

The usage of `varf` is explained [here](https://raw.githubusercontent.com/fotios-kasolis/FreeFEM-tutorial-public/master/main.pdf) on a 2D and 3D Poisson problem.

```auto
load "msh3" //import three-dimensional meshing tools
mesh3 T = cube(10, 10, 10);
fespace V(T, P1);
varf a(u, v) = int3d(T)( dx(u)*dx(v) + dy(u)*dy(v) + dz(u)*dz(v) )
+ on(1, 2, u = 0.0);
varf l(u, v) = int3d(T)( x*v ) + on(1, 2, u = 0.0);
matrix A = a(V, V);
real[int] b = l(0, V);
V u;
u[] = A^-1*b;
plot(u, value = true, fill = true, nbiso = 64, wait = true);

```

# Attempt at solution

So my attempt to rewrite the example is as follows

```auto
load "medit"
include "cube.idp"
int[int] Nxyz=[20,5,5];
real [int,int] Bxyz=[[0.,5.],[0.,1.],[0.,1.]];
int [int,int] Lxyz=[[1,2],[2,2],[2,2]];
mesh3 Th=Cube(Nxyz,Bxyz,Lxyz);

real E = 21.5e4;
real sigma = 0.29;
real mu = E/(2*(1+sigma));
real lambda = E*sigma/((1+sigma)*(1-2*sigma));
real gravity = -0.05;

fespace Vh(Th,[P1,P1,P1]);
Vh [u1,u2,u3], [v1,v2,v3];

real sqrt2=sqrt(2.);
macro epsilon(u1,u2,u3) [dx(u1),dy(u2),dz(u3),(dz(u2)+dy(u3))/sqrt2,(dz(u1)+dx(u3))/sqrt2,(dy(u1)+dx(u2))/sqrt2] // EOM
macro div(u1,u2,u3) ( dx(u1)+dy(u2)+dz(u3) ) // EOM

// ******************** Modification below.

varf a([u1,u2,u3],[v1,v2,v3]) =
  int3d(Th)(  
	    lambda*div(u1,u2,u3)*div(v1,v2,v3)	
	    +2.*mu*( epsilon(u1,u2,u3)'*epsilon(v1,v2,v3) ) //')
	      )
  + on(1,u1=0,u2=0,u3=0)
  ;
varf l([u1,u2,u3],[v1,v2,v3]) = int3d(Th) (gravity*v3);

matrix A = a(Vh, Vh);
real[int] b = l(0, Vh);

// The following lines break but I do not know why!
Vh [uu1, uu2, uu3];
[uu1[, uu2, uu3]] = A^-1*b;

```

As marked above, the final couple of lines break at compile time but I can not figure out why. Could anybody help?
