# Compilation error in the definition of a problem

**URL:** https://community.freefem.org/t/compilation-error-in-the-definition-of-a-problem/3292
**Category:** General Discussion
**Created:** [June 7, 2024, 7:14am UTC](https://community.freefem.org/t/compilation-error-in-the-definition-of-a-problem/3292 "2024-06-07T07:14:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lee-maximee](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/lee-maximee/32/2418_2.png) [@lee-maximee](https://community.freefem.org/u/lee-maximee)
#### Post date: [June 7, 2024, 7:14am UTC](https://community.freefem.org/t/compilation-error-in-the-definition-of-a-problem/3292/1 "2024-06-07T07:14:38Z")

</div>

I want to simulate a von Karman vortex past a cylinder. I get the following error when defining the Navier-Stokes problem:

```auto
Error line number 87, in file karman-vortices.edp, before token +

   79 : ////----------------------------------
   80 : //// Equations
   81 : ////----------------------------------
   82 : problem nvs(u, v, p, uh, vh, q)
   83 : = int2d(Th)(
   84 : (u * uh + v * vh)/dt
   85 : )
   86 : + int2d(Th)(
   87 : uh * (u * dx(u) + error operator * <10LinearCombI7MGauche4C_F0E>, <10LinearCombI7MGauche4C_F0E> 
...
  current line = 87
Compile error : 
	line number :87, +
error Compile error : 
	line number :87, +
 code = 1 mpirank: 0

```

Here is the problem definition:

```auto
problem nvs(u, v, p, uh, vh, q)                                                                       
    = int2d(Th)(
        (u * uh + v * vh)/dt                                                                          
    )
    + int2d(Th)(
        uh * (u * dx(u) + v * dy(u))
        + vh * (u * dx(v) + v * dy(v))
    )
    - nu * int2d(Th)(
      Grad(U) : Grad(V)
    )
    + int2d(Th)(
      dx(p) * uh + dy(p) * vh
    )
    + penalty * int2d(Th)(
      q * (dx(u) + dy(v))
    )
    + on(outlet, p = pout)
    + on(farfield, u = ufarfield, v = 0)
    + on(noslip, u = 0, v = 0);

```

Here is the full script if needed:

```auto
include "getARGV.idp";

//----------------------------------
// macros
//----------------------------------
macro grad(u) [dx(u), dy(u)]; //
macro Grad(U) [grad(U#x), grad(U#y)]; //
macro Div(U) (dx(U#x) + dy(U#y)); //

//----------------------------------
// physical/problem parameters
//----------------------------------
real Re = getARGV("-Re", 1.0);
real D = 10; // cylinder diameter
real ufarfield = 10.0; // inlet velocity
real nu = ufarfield*D/Re; // kinematic viscosity
real T = 1000;
real pout = 0.0;
real penalty = 1.0;
real dt = 1e-3;

//----------------------------------
// MESH 
//----------------------------------
// parameters
real xmin = 0; 
real ymin = 0;
real xmax = 800; 
real ymax = 300;
real xcyl = (xmin+xmax)/2;
real ycyl = (ymin+ymax)/2;

int nx = getARGV("-nx", 50);
int ny = getARGV("-ny", 50);
int ncylinder = getARGV("-ncylinder", 100);

// tags
int farfield = 1;
int inlet = 1;
int noslip = 2;
int outlet = 3;

// rectangle borders
border left(t=0, ymax){x=xmin; y=(ymax-t); label=farfield;};
border right(t=0, ymax){x=xmax; y=t; label=outlet;};
border bot(t=0, xmax){x=t; y=ymin; label=farfield;};
border top(t=0, xmax){x=(xmax-t); y=ymax; label=farfield;};

// cylinder 
border cylinder(theta=0, 2*pi){
    x = D*cos(theta) + xcyl; 
    y = D*sin(theta) + ycyl; 
    label=noslip;
};

// generation
mesh Th = buildmesh(
    left(ny) + top(nx) + right(ny) + bot(nx) + cylinder(-ncylinder)
);
//plot(Mesh, wait=1);

//----------------------------------
// PDE
//----------------------------------
fespace Space1(Th, P1);
Space1 p, q;

fespace Space2(Th, P2);
Space2 u, v;
Space2 uh, vh;

//----------------------------------
// Initial conditions
//----------------------------------
u = ufarfield * (x< (xmin + (xmax-xmin)/4));
p = 0;
v = 0;

//----------------------------------
// Equations
//----------------------------------
problem nvs(u, v, p, uh, vh, q)
    = int2d(Th)(
        (u * uh + v * vh)/dt
    )
    + int2d(Th)(
        uh * (u * dx(u) + v * dy(u))
        + vh * (u * dx(v) + v * dy(v))
    )
    - nu * int2d(Th)(
      Grad(U) : Grad(V) 
    )
    + int2d(Th)(
      dx(p) * uh + dy(p) * vh 
    )
    + penalty * int2d(Th)(
      q * (dx(u) + dy(v)) 
    )
    + on(outlet, p = pout)
    + on(farfield, u = ufarfield, v = 0)
    + on(noslip, u = 0, v = 0);

```

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [June 7, 2024, 9:58am UTC](https://community.freefem.org/t/compilation-error-in-the-definition-of-a-problem/3292/2 "2024-06-07T09:58:56Z")

</div>

FreeFem++ cannot solve a nonlinear problem like you put in  
`u * dx(u) + v * dy(u)`  
Instead you should use  
`uold * dx(u) + vold* dy(u)`  
where uold and vold and the values at previous timestep. Then it becomes linear in u,v.

---

<div class="post-metadata">

### Author: ![lee-maximee](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/lee-maximee/32/2418_2.png) [@lee-maximee](https://community.freefem.org/u/lee-maximee)
#### Post date: [June 8, 2024, 2:46pm UTC](https://community.freefem.org/t/compilation-error-in-the-definition-of-a-problem/3292/3 "2024-06-08T14:46:59Z")

</div>

Ty. Alongside other bugs, this solution makes the script working. The scheme has some explicit/implicit terms.
