# Navier Stoke Operation Error

**URL:** https://community.freefem.org/t/navier-stoke-operation-error/478
**Category:** General Discussion
**Created:** [June 19, 2020, 10:18am UTC](https://community.freefem.org/t/navier-stoke-operation-error/478 "2020-06-19T10:18:32Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)
#### Post date: [June 19, 2020, 10:18am UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/1 "2020-06-19T10:18:32Z")

</div>

Dear @prj  
I have taken a simple model for Navier Stoke Equation over a square.

which I have taken from [Navier-Stoke](https://doc.freefem.org/tutorials/navierStokesNewton.html).

- I am getting an error as " operation error ".

code is:

```
real nu = 1.0/50.;
real eps = 1e-6;
verbosity = 0;

mesh Th = square(10,10);

fespace Xh(Th, P2);
Xh u1, u2;
Xh du1, du2;
Xh v1, v2;

fespace Mh(Th, P1);
Mh p;
Mh q;
Mh dp;

macro Grad(u1, u2) [dx(u1), dy(u1), dx(u2), dy(u2)] //

macro UgradV(u1, u2, v1, v2) [[u1, u2]' * [dx(v1), dy(v1)], [u1, u2]' * [dx(v2), dy( v2)] ] //

macro div( u1, u2) ( dx(u1) + dy(u2) ) //

// initialization

u1 = x^2 + y^2 ;
u2 = 0;

// viscosity loop

while(1)
{
int n;
real err = 0 ;

for ( n =0; n< 10; n++)

{
solve viscous([du1, du2, dp], [v1, v2, q] ) =

int2d(Th) ( nu *( Grad(u1, u2)' * Grad( v1, v2))
- div( v1, v2)*dp
- div( du1, du2)*q
+ UgradV( du1, du2, u1, u2 )'* [v1, v2]
+ UgradV( u1, u2, du1, du2 )'* [v1, v2]
- 1e-8*dp*q )

- int2d( Th) ( nu * (Grad(u1, u2)'Grad(v1, v2))
+ UgradV( u1, u2, u1, u2)' * [v1, v2]
- p * div(v1, v2 ) - q * div(u1, u2)

)
+ on( 1,2,4, du1 = 0 , du2 = 0 )

+ on ( 3, du1 = 1, du2 = 0 )

u1[] -= du1[];
u2[] -= du2[];
p[] -= dp[];

real Lu1=u1[].linfty, Lu2=u2[].linfty, Lp=p[].linfty;
err = du1[].linfty/Lu1 + du2[].linfty/Lu2 + dp[].linfty/Lp;

cout << n << " err = " << err << " " << eps << " rey = " << 1./nu << endl;
if(err < eps) break; //converge
if( n>3 && err > 10.) break; //blowup

    }
}

```

Kindly, suggest me to fix it.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [June 19, 2020, 10:38am UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/2 "2020-06-19T10:38:01Z")

</div>

The example from the documentation works just fine. What did you change?

---

<div class="post-metadata">

### Author: ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)
#### Post date: [June 19, 2020, 10:56am UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/3 "2020-06-19T10:56:36Z")

</div>

only, I was trying to run this code over an square domain.

and, rest equations are the same.

But, I am getting the operation error in my case whose code is mentioned above.

I am confused about the operation in my case because the same operation has mentioned in the documentation example [Navier-Stoke](https://doc.freefem.org/tutorials/navierStokesNewton.html).

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [June 19, 2020, 11:28am UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/4 "2020-06-19T11:28:29Z")

</div>

You are mixing linear and bilinear terms in your `problem` definition. The code does not look at all like the one from the documentation, if I’m not mistaken.

---

<div class="post-metadata">

### Author: ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)
#### Post date: [June 19, 2020, 5:19pm UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/5 "2020-06-19T17:19:04Z")

</div>

I need to rectify it.

Thanks @prj

---

<div class="post-metadata">

### Author: ![Duzi100](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/duzi100/32/441_2.png) [@Duzi100](https://community.freefem.org/u/Duzi100)
#### Post date: [August 21, 2020, 9:47am UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/6 "2020-08-21T09:47:00Z")

</div>

Sadly, I have the same error, and I have no idea to fix it.

---

<div class="post-metadata">

### Author: ![sumantkr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/sumantkr/32/2681_2.png) [@sumantkr](https://community.freefem.org/u/sumantkr)
#### Post date: [August 21, 2020, 12:59pm UTC](https://community.freefem.org/t/navier-stoke-operation-error/478/7 "2020-08-21T12:59:32Z")

</div>

It can be solved using linearization technique using Newton’s Method.
