# Pressure projection methods

**URL:** <https://community.freefem.org/t/pressure-projection-methods/3247>\
**Category:** General Discussion\
**Created:** [May 14, 2024, 8:49am UTC](https://community.freefem.org/t/pressure-projection-methods/3247 "2024-05-14T08:49:31Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [May 28, 2024, 2:37am UTC](https://community.freefem.org/t/pressure-projection-methods/3247/21 "2024-05-28T02:37:23Z")

</div>

Thank you, professor. but there might be something wrong.

About comment 2. We can replace \bar{p} = 2\*p^n - p^{n-1} with p^n, and this format is also formally second-order, but it is unstable. There is currently no proof of stability. There is also a rotational pressure correction method to avoid artificial Neumann BC maybe we can use it, but I am trying to update this code. Page 5 [An overview of projection methods for incompressible flows.pdf](https://community.freefem.org/uploads/short-url/hH1ESAZTNDGpYHk7LhM8zBuQ9Vp.pdf) (943.4 KB)

About comment 3. I understand what you mean. But I’m not sure if I can theoretically use the Dirichelt BC instead of the artificial Neumann BC. For the Neumann BC. I only need to add `int1d(Th)(1e-8*pnp1*pp)`, but the Dirichlet BC requires `on(1,2,3,4,pnp1 = pe(t))`.

About comment 4. I understand roughly what you mean. I’m still trying to figure out how to fix or avoid this problem.

---

<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:** [May 28, 2024, 8:58am UTC](https://community.freefem.org/t/pressure-projection-methods/3247/22 "2024-05-28T08:58:06Z")

</div>

Ok, this is possible that the use of \bar p is unstable in general, even if it performs well on this test.

The Dirichlet BC is not usable in general since we do not know pe(t). Here it was just to check that it gives the same result as Neumann BC, so that we conclude that on this test there is no boundary layer due to the Neumann BC. Therefore this validates the Neumann BC.

About comment 4, there is no problem, the scheme is OK. This is just to explain that one has to be cautious on the procedure of evaluation of accuracy. One should not take into account the results for too small timestep, because when the timestep tends to 0 the error does not tend to 0, it tends to the error due to mesh size.  
For a rigorous testing one should diminish timestep and mesh size simultaneously (but this can be very costly in computational time).

---

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [May 28, 2024, 9:29am UTC](https://community.freefem.org/t/pressure-projection-methods/3247/23 "2024-05-28T09:29:24Z")

</div>

About comment 4. Does this require limiting the spatial step size? Professor. I always use `Th = square(200,200)`, is this enough?

---

<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:** [May 28, 2024, 11:35am UTC](https://community.freefem.org/t/pressure-projection-methods/3247/24 "2024-05-28T11:35:28Z")

</div>

The right way is that each time you divide the timestep by 2, you also multiply the number of space points by 2.  
But you can do this only when the H1 error attains its floor value.  
Thus an appropriate experiment could be  
dt=1/4, 1/8, 1/16 → nx=100  
dt=1/32 → nx=200  
dt=1/64 --\>nx=400  
dt=1/128–\>nx=800  
The last line is probably too expensive, thus you can stop at dt=1/64, nx=400.

---

<div class="post-metadata">

**Author:** ![LXX](https://avatars.discourse-cdn.com/v4/letter/l/258eb7/32.png) [@LXX](https://community.freefem.org/u/LXX)\
**Post date:** [May 28, 2024, 12:41pm UTC](https://community.freefem.org/t/pressure-projection-methods/3247/25 "2024-05-28T12:41:19Z")

</div>

I can understand that refining the time step and space step simultaneously can produce better results, but how to calculate the convergence order (time accuracy or spatiotemporal accuracy)?

At a fixed spatial step size, the way I calculate the temporal accuracy is as follows

```auto
if(i > 0){
        ConL2u[i] = log(errL2u(i-1)/errL2u(i))/log(dt(i-1)/dt(i));
        ConH1u[i] = log(errH1u(i-1)/errH1u(i))/log(dt(i-1)/dt(i));
        ConL2p[i] = log(errL2p(i-1)/errL2p(i))/log(dt(i-1)/dt(i));
    } 

```

`dt` is the time step size.

---

<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:** [May 28, 2024, 2:17pm UTC](https://community.freefem.org/t/pressure-projection-methods/3247/26 "2024-05-28T14:17:43Z")

</div>

If we assume that the error is comparable to C\_t dt^{\alpha}+C\_x h^{\beta}, we see that dividing simultaneously dt and h by 2, the error is divided by 2^{\min(\alpha,\beta)}.  
It follows that evaluating the error by dividing the time and space steps, if we obtain a rate of \gamma, it implies that \alpha\geq\gamma and \beta\geq\gamma.  
Thus you prove simultaneously the order at least \gamma for time and space.

If you want to prove the same order \gamma for both time and space this is done.  
However if for example you want to prove order 1 for time and order 2 for space,  
then you have to divide h by 2 and dt by 4, and verify that the error is divided by 4.

If you take h fixed and divide dt by 2, you see that the error C\_t dt^{\alpha}+C\_x h^{\beta}, decays only if C\_t dt^{\alpha}\>\>C\_x h^{\beta}, that is if dt is not too small. Otherwise if C\_t dt^{\alpha}\<\<C\_x h^{\beta} it will remain constant equal to C\_x h^{\beta}. This is what you observe.

[Previous page](https://community.freefem.org/t/pressure-projection-methods/3247.md?page=1)
