Fenics vs FreeFem

Hi,

I am trying to rewrite the Fenics example to FreeFem++ and I ran into some problems when I tried to rewrite the following piece

metadata = {"quadrature_degree": deg_stress, "quadrature_scheme": "default"}
dxm = dx(metadata=metadata)

a_Newton = inner(eps(v), sigma_tang(eps(u_)))*dxm
res = -inner(eps(u_), as_3D_tensor(sig))*dxm + F_ext(u_)

The above is then used to later assemble the final system.

Here is my freefem attempt:

int initLoadLoop = 1;

for (int t = initLoadLoop; t <= loadSteps; t++){
    if (verbosity > 1) {
        cout << "======================" << endl;
        cout << "Load step: " << t << "/" << loadSteps << "." << endl; 
        cout << "======================" << endl;
    }
    real tension = sqrt(real(t) * 1.1 / real(loadSteps)) * pres;
    // Assemble system.
    varf elasticity(tu, v) = 
        int2d(Th)(sigma(tu)' * e(v))
        + on(1, tuy = 0)
        + on(3, tux = 0)
        ;
    varf ext(tu, v) =
        - int2d(Th)(e(tu)` * sig) 
        int1d(Th, 2)(tension * [N.x, N.y, N.z]' * v) 
        + on(1, tuy = 0)
        + on(3, tux = 0)
        ;
    real[int] fExternal = ext(0, Nh);

}

Question

I assume the a_Newton from fenics is the same as my varf elasticity. But I can’t figure out how to write the res from fenics, because it would require to compute int2d(Th)(e(tu) * sig) ` in freefem, which is for some reason not allowed.

Is there a way I can get the sig variable to the varf function?