# Problem in computing discontinuous Galerkin method for incompressible Stokes equation

**URL:** <https://community.freefem.org/t/problem-in-computing-discontinuous-galerkin-method-for-incompressible-stokes-equation/801>\
**Category:** General Discussion\
**Created:** [February 12, 2021, 9:44am UTC](https://community.freefem.org/t/problem-in-computing-discontinuous-galerkin-method-for-incompressible-stokes-equation/801 "2021-02-12T09:44:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kallol](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kallol](https://community.freefem.org/u/kallol)\
**Post date:** [February 12, 2021, 9:44am UTC](https://community.freefem.org/t/problem-in-computing-discontinuous-galerkin-method-for-incompressible-stokes-equation/801/1 "2021-02-12T09:44:19Z")

</div>

I am trying to compute incompressible steady Stokes equation by using discontinuous Galerkin SIPG method. But in FreeFem++ the operators jump and mean giving error message for using vector valued finite element function (for example jump([ux,uy]) ). How can I use jump or mean operator for vector valued function?  
Here is the code:  
macro dn(u) (N.x_dx(u)+N.y_dy(u) ) // def the normal derivative  
macro gradx(u) (dx(u))//  
macro grady(u) (dy(u))//  
real[int] L2error(5); //an array of two values  
int i=1;  
for (i=1;i\<6;i++)  
{  
mesh Th = square(2^i,2^i); // unite square  
plot (Th);  
fespace Vh(Th,P2dc); // Discontinous P2 finite element  
Vh ux, uy;  
Vh vx, vy;  
Vh uex1, uex2, f1,f2;  
fespace Ph(Th, P1dc);  
Ph p=0, pp;  
Ph pex;  
real pena=10\*(2^i); // a paramater to add penalisation  
macro grad(z) [dx(z), dy(z)] //  
macro Grad(u) [grad(u#x), grad(u#y)] //  
macro div(ux,uy) (dx(ux) + dy(uy)) //  
varf Ans([ux, uy, p], [vx, vy, pp])=  
int2d(Th)(dx(ux)\*dx(vx)  
+ dy(ux)\*dy(vx)  
+ dx(uy)_dx(vy)  
+ dy(uy)dy(vy)  
- div(ux,uy) \* pp  
- div(vx,vy) \* p)  
+intalledges(Th)(  
// loop on all edge of all triangle  
// the edge are see nTonEdge times so we / nTonEdge  
// remark: nTonEdge =1 on border edge and =2 on internal  
// we are in a triange th normal is the exterior normal  
// def: jump = external - internal value; on border exter value =0  
// mean = (external + internal value)/2, on border just internal value  
(mean(Grad(u))[N.x,N.y])’  
 ([jump(vx),jump(vy)])+ (mean(Grad(v))[N.x,N.y])’_([jump(ux),jump(uy)])

- pena\*([jump(ux),jump(uy)])_([jump(vx),jump(vy)]) +mean§_([jump(vx),jump(vy)])’  
_[N.x,N.y]+mean(pp)_([jump(ux),jump(uy)])’_[N.x,N.y]) / nTonEdge  
);  
uex1= - 2.0 \* x ^ 2 \* ( x - 1.0 ) ^ 2 \* y \* ( y - 1.0 ) \* ( 2.0 \* y - 1.0 );  
uex2= 2.0 \* x \* ( x - 1.0 ) \* ( 2.0 \* x - 1.0 )_ y ^ 2 \* ( y - 1.0 ) ^ 2;  
f1 = 2.0  
\* ( 12.0 \* x ^ 2 - 12.0 \* x + 2.0 )  
\* ( 2.0 \* y ^ 3 - 3.0 \* y ^ 2 + y )  
+ 2.0  
\* ( x ^ 4 - 2.0 \* x ^ 3 + x ^ 2 )  
\* ( 12.0 \* y - 6.0 );  
f2 = - 2.0  
\* ( 12.0 \* x - 6.0 )  
\* ( y ^ 4 - 2.0 \* y ^ 3 + y ^ 2 )  
- 2.0  
\* ( 2.0 \* x ^ 3 - 3.0 \* x ^ 2 + x )  
\* ( 12.0 \* y ^ 2 - 12.0 \* y + 2.0 );  
func g=0;  
Vh u,v;  
problem stokes([ux,uy,p],[vx,vy,pp] ,solver=UMFPACK) = Ans

- int2d(Th)([f1,f2]’\*[vx,vy]);  
stokes; // solve DG  
}  
// Plot  
plot([ux, uy], p, wait=1);

---

<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:** [February 12, 2021, 12:50pm UTC](https://community.freefem.org/t/problem-in-computing-discontinuous-galerkin-method-for-incompressible-stokes-equation/801/2 "2021-02-12T12:50:15Z")

</div>

To day you can make only jump of scalar variable  
to so you have to write [jump(u1),jump(u2)] not jump([u1,u2]) sorry.

---

<div class="post-metadata">

**Author:** ![kallol](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kallol](https://community.freefem.org/u/kallol)\
**Post date:** [February 12, 2021, 6:05pm UTC](https://community.freefem.org/t/problem-in-computing-discontinuous-galerkin-method-for-incompressible-stokes-equation/801/3 "2021-02-12T18:05:11Z")

</div>

Thank you very much for the information.

---

<div class="post-metadata">

**Author:** ![Monirul25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/monirul25/32/3287_2.png) [@Monirul25](https://community.freefem.org/u/Monirul25)\
**Post date:** [December 2, 2024, 6:48am UTC](https://community.freefem.org/t/problem-in-computing-discontinuous-galerkin-method-for-incompressible-stokes-equation/801/6 "2024-12-02T06:48:32Z")

</div>

Why you are setting Vh p=0 brother??. The function g is not used anywhere.  
Setting p=0 means pressure will be zero or initially it is zero.  
Can you tell me pls brother.
