# About "convect" function

**URL:** <https://community.freefem.org/t/about-convect-function/4348>\
**Category:** General Discussion\
**Created:** [August 27, 2026, 6:59pm UTC](https://community.freefem.org/t/about-convect-function/4348 "2026-08-27T18:59:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nayda](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@Nayda](https://community.freefem.org/u/Nayda)\
**Post date:** [August 27, 2026, 6:59pm UTC](https://community.freefem.org/t/about-convect-function/4348/1 "2026-08-27T18:59:50Z")

</div>

Hello.

I would like to learn more about the convect function.

Am I right to say this uses an explicit Euler method, together with a FEM interpolation?

Where can I find, on the code, how it was implemented?

Thank you!

---

<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:** [August 28, 2026, 5:08pm UTC](https://community.freefem.org/t/about-convect-function/4348/2 "2026-08-28T17:08:43Z")

</div>

The 2d command `wn=convect([ux,uy],dt,w0)` where `w0` is a finite element function (thus a scalar function of position), `dt` is a real number (positive or negative), `[ux,uy]` a vector finite element function (thus a vector function of position, let us denote it by \mathbf{u}(x)), and `wn` (the result) is a finite element function (thus a scalar function of position).

Computes the solution (for each fixed position x) to  
\frac{dX}{dt}(t)=\mathbf{u}(X(t)) with initial condition X(t=0)=x.  
The solution to the ODE is exact up to a certain point (?).  
It sets wn=w0(X(t=dt)).  
The dependency in x is through the initial condition on X. The result is interpolated so that `wn` belongs to the finite element space it has been declared.

A main property is that for `dt` small, wn(x)\simeq w0(x)+dt\,\mathbf{u}(x)\cdot\nabla w0(x)

---

<div class="post-metadata">

**Author:** ![lucas.franceschini](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@lucas.franceschini](https://community.freefem.org/u/lucas.franceschini)\
**Post date:** [September 17, 2026, 5:25pm UTC](https://community.freefem.org/t/about-convect-function/4348/3 "2026-09-17T17:25:44Z")

</div>

Hi François,

Sorry to unearth this discussion again, but how is it possible the solution to X’(t)=u(X(t)) be “exact up to a certain point”? What do you mean by that? In my understanding, only an approximation can be done here, something like X(dt) ~ X(0) + dt.u(X(0)) (explicit Euler). Is this the case?

Lucas

---

<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:** [September 18, 2026, 9:51am UTC](https://community.freefem.org/t/about-convect-function/4348/4 "2026-09-18T09:51:49Z")

</div>

Tue solution is exact is the field [U1,U2] is constant by triangle so the approximate characteristics

scheme is:

compute the characteristics in on triangle by setting U when we enter in the triangle then find the characteristic exit edge with constant velocity , change of triangle and restart.

The only difficulty is when the characteristics arrive on a vertex.
