# Stream function

**URL:** <https://fenicsproject.discourse.group/t/stream-function/8324>\
**Category:** variational formulation\
**Created:** [May 15, 2022, 7:21pm UTC](https://fenicsproject.discourse.group/t/stream-function/8324 "2022-05-15T19:21:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbenson](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/mrbenson/32/3768_2.png) [@mrbenson](https://fenicsproject.discourse.group/u/mrbenson)\
**Post date:** [May 15, 2022, 7:21pm UTC](https://fenicsproject.discourse.group/t/stream-function/8324/1 "2022-05-15T19:21:22Z")

</div>

Hello, i’m a new user of fenics.

I’d like to get the streamfunction psi of a given 2d thermal heat flux F=k.grad(T) so that the isolines of psi are parallel to F (or orthogonal to isolines of T).

- First i solve the thermal equation to get the vector flux using a P2 interpolation
- Then, streamfunction is a well-known problem in CFD and psi satisfies a vorticity equation defined [here](https://en.wikipedia.org/wiki/Stream_function)  
 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/c/c2400a8a59d5be074e56b98f47b8cb37271e4b36.png)

Unfortunatly the streamlines are not parallel to F.

Did i miss something ?

thanks for helping.

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [May 16, 2022, 2:15pm UTC](https://fenicsproject.discourse.group/t/stream-function/8324/2 "2022-05-16T14:15:22Z")

</div>

Some points to consider are:

- Is the flux \mathbf{F} solenoidal (i.e., does \nabla\cdot\mathbf{F} = 0)? A vector field must be divergence-free to have a streamfunction representation. You would only expect a solenoidal heat flux in the absence of any distributed heat sources.

- Solving the Poisson equation with pure Neumann boundary conditions is ill-posed, which can lead to numerical issues if not done carefully, as discussed, e.g., in [this thread](https://fenicsproject.discourse.group/t/white-spots-in-the-plot/8007/4).
