# Navier Stokes Channel flow tutorial IPCS: step 1 implicit?

**URL:** <https://fenicsproject.discourse.group/t/navier-stokes-channel-flow-tutorial-ipcs-step-1-implicit/14963>\
**Category:** variational formulation\
**Created:** [June 12, 2024, 11:53pm UTC](https://fenicsproject.discourse.group/t/navier-stokes-channel-flow-tutorial-ipcs-step-1-implicit/14963 "2024-06-12T23:53:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shufan\_Xia](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/shufan_xia/32/6118_2.png) [@Shufan\_Xia](https://fenicsproject.discourse.group/u/Shufan_Xia)\
**Post date:** [June 12, 2024, 11:53pm UTC](https://fenicsproject.discourse.group/t/navier-stokes-channel-flow-tutorial-ipcs-step-1-implicit/14963/1 "2024-06-12T23:53:57Z")

</div>

I am very new to FEM and FeniCS. I need to learn how to use FeniCS to solve NS equations for my work. I am following the tutorial on Naveir Stokes from here [https://fenicsproject.org/pub/tutorial/html/.\_ftut1009.html](https://fenicsproject.org/pub/tutorial/html/._ftut1009.html) and have a few questions about the weak form and the code. For the first step of IPCS (eq below), the velocity used for the tensor \sigma is the midpoint velocity \frac{1}{2} (u^n + u^{n+1}):  
 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/1/1d986dbf1800b0ec4f8b2ff392db4213055275a9.png).  
but in the code provided, I see this as the equation for solving the tentative u^\*

```auto
F1 = rho*dot((u - u_n) / k, v)*dx + \
rho*dot(dot(u_n, nabla_grad(u_n)), v)*dx \
+ inner(sigma(U, p_n), epsilon(v))*dx \
+ dot(p_n*n, v)*ds - dot(mu*nabla_grad(U)*n, v)*ds \
- dot(f, v)*dx
a1 = lhs(F1)
L1 = rhs(F1)

```

where U is defined as  
`U = 0.5*(u_n + u)`

1. Why do I think this means that the U to evaluate \sigma is \frac{1}{2} (u^n + u^{\*}) instead of the midpoint velocity?
2. Is this step 1 a nonlinear problem as the term \sigma depends on the implicit u? why this first step can be solved as by a linear solve calling `solve()`:

```auto
b1 = assemble(L1)
[bc.apply(b1) for bc in bcu]
solve(A1, u_.vector(), b1)

```

1. Where can I find an example of using a fully implicit formulation to solve NS for a channel flow?

2. I want to apply a neumann BC \nabla\vec{u} \cdot \vec{n}-p \vec{n} = \vec{g} as an outlet BC. how do I modify the surface integral/boundary terms in the weak form given this mid-point velocity and pressure at time n?

Thanks a lot. Truly appreciate your help.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [June 18, 2024, 8:17pm UTC](https://fenicsproject.discourse.group/t/navier-stokes-channel-flow-tutorial-ipcs-step-1-implicit/14963/2 "2024-06-18T20:17:24Z")

</div>

> [@Shufan\_Xia](#):
>
> Why do I think this means that the U to evaluate \sigmaσ\sigma is \frac{1}{2} (u^n + u^{_})12(un+u∗)\frac{1}{2} (u^n + u^{_}) instead of the midpoint velocity?

I cant speak for the authors of the orginal tutorial. I’ve got an updated tutorial at:  
[https://jsdokken.com/dolfinx-tutorial/chapter2/ns\_code2.html#variational-form](https://jsdokken.com/dolfinx-tutorial/chapter2/ns_code2.html#variational-form)  
and ive made extensive documentation on splitting schemes at:  
[https://computationalphysiology.github.io/oasisx/splitting\_schemes.html](https://computationalphysiology.github.io/oasisx/splitting_schemes.html)

> [@Shufan\_Xia](#):
>
> Is this step 1 a nonlinear problem as the term \sigmaσ\sigma depends on the implicit uuu? why this first step can be solved as by a linear solve calling `solve()`:

It is not nonlinear, as the only term that could be nonlinear is

> [@Shufan\_Xia](#):
>
> `rho*dot(dot(u_n, nabla_grad(u_n)), v)*dx \`

but it is linear wrt the unknown u.

> [@Shufan\_Xia](#):
>
> Where can I find an example of using a fully implicit formulation to solve NS for a channel flow?

I would suggest having a look at the oasisx presentation of splitting schemes. I am not sure you want a fully implicit splitting scheme though. Semi-implicit is usually recommended

> [@Shufan\_Xia](#):
>
> 1. I want to apply a neumann BC \nabla\vec{u} \cdot \vec{n}-p \vec{n} = \vec{g}∇→u⋅→n−p→n=→g\nabla\vec{u} \cdot \vec{n}-p \vec{n} = \vec{g} as an outlet BC. how do I modify the surface integral/boundary terms in the weak form given this mid-point velocity and pressure at time nnn?

You add the term dot(g,v)\*ds(outlet\_marker) to your variational form after integration by parts of the pressure gradient and the laplace (diffusive) term
