CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   HELP - stream function from the velocity field (

Fred January 22, 1999 05:38

HELP - stream function from the velocity field
Could anyone please help me with the following problem

I have some solutions to the 2D driven cavity problem, where the solutions have been obtained using primitive variables. I would like to be able to plot contours of stream function, but as I only have the u and v velocity fields, I would need to derive the stream function from this.

Does anyone out there know how to do this? If so, your help would be much appreciated.

Many thanks.

Roland Bender January 22, 1999 06:00

Re: HELP - stream function from the velocity field
Hi in my diploma work i had the same problem. You can get the streamfunktion by a integrating over the velocity-field.

I think you can find the formular in a fluid dynamics book. Then you must transform the integration into a summation.

Essemiani January 22, 1999 06:15

Re: HELP - stream function from the velocity field
you can calculate that by preapearing a subroutine , where for every cell position you caculate the derivate of the stream function U=d (ksi)/dy and V= d ( ksi)/dx , by using a finite difference method you can get the value of the variation of the stream function at the bondaries of your cell.

Generate this for your whole volume

good luck

Duane Baker January 22, 1999 20:46

Re: HELP - stream function from the velocity field
A quick correction:

caculate the derivate of the stream function U=d (ksi)/dy and V= d ( ksi)/dx

should read:

caculate the derivative of the stream function U=d (ksi)/dy and V= - d ( ksi)/dx

but this is going the wrong way. The question is how to go from velocity to stream function NOT the other way. The guy from Stuttgart has the right idea this means that one has to integrate!!

Michael Song January 23, 1999 12:03

Re: HELP - stream function from the velocity field
I believe Essemiani is also right. A PDE can be either integrated or finite-differenced for a solution. I guess the latter is preferable for a general problem. Hope you agree with me.


Christoph Lund January 25, 1999 04:07

Re: HELP - stream function from the velocity field

Set u=d(Psi)/d(y) and v=-d(Psi)/d(x), where Psi is supposed to be the stream function. Take the definition of the vorticity, omega=d(u)/d(y)-d(v)/d(x) and express u and v in this equation using the stream function. This will give you a poisson equation for the stream function,

div grad (Psi) = d^2(Psi)/dx^2+d^2(Psi)/dy^2 = omega,

which can easily be solved by any method you like. Applying this equation to your driven cavity problem you should use Psi=0 on all boundaries, even on the upper (or whatever) moving plate.

For some reference data you could check Sohn, J.L., Int.J.for Num. Meth. in Fluids, 8, (1988), 14469-1490.


John C. Chien January 25, 1999 11:50

Re: HELP - stream function from the velocity field
Ah! A long trip from the primitive-variable-approach back to the stream-function-vorticity-approach. It is an acceptable approach. For the direct-line-integration-approach, the derived stream-function value may not be unique, depending on the direction of integration ( you can integrate the definition in either x- or y-direction). Most of the time, the particle trajectory method is used for the primitive-variable-approach to obtain the streamline information. This is because neither stream-function nor vorticity is used directly in the formulation. And the vorticity calculation has to be defined through out the flow field and boundary consistently.

Christoph Lund January 26, 1999 03:47

Re: HELP - stream function from the velocity field
Hi John,

in what way do you think will your response to my response to fred's original question be of any help to fred ?

With the incompressibility constraint satisfied only in the mean I can for a given velocity field - at least for the driven cavity problem in question - not think of any other method as simple as the one described.

If you have a (concrete) better suggestion I am of course interested to hear about it.

Ronan Laffan January 26, 1999 08:02

Re: HELP - stream function from the velocity field
For a particle trajectory method, how do you decide where to 'start' each streamline? I am looking at a similar problem with a triangular mesh and primitive variables.


John C. Chien January 26, 1999 13:35

Re: HELP - stream function from the velocity field
When I answer a question, normally, I don't have any particular person in mind. But rather the issues related to the original question. The practical answer to the original question first: the field approach of solving the stream-function equation with the vorticity source term derived from the U,V velocity field is the nature selection. Because this will eliminate the uniqueness issue associated with the directional integration of the velocity component to obtain the streamfunction. This does not mean that the direct integration is not practical. When you have fine mesh solution, the error will be small. Therefore, if you have fine mesh solution, you can do it either way. Otherwise, I would say, the field approach is a more formal solution. Now that I have answered the original question, I'd like to expand it a little more in this primitive-variable-stream-function-vorticity loop. Suppose that we derive the vorticity from the velocity components field and obtain the stream-function from stream-function field equation with vorticity source term, then ask a question: " Will the derived vorticity function still follow the vorticity governing equation ?" If it does not satisfy the vorticity equation, then " Is the derived streamfunction still valid ?"

John C. Chien January 26, 1999 13:58

Re: HELP - stream function from the velocity field
Based on my experience with the commercial CFD codes and post-processors, I normally pick a point a couple of points aways from the wall and several points away from the inlet to start the trajectory tracing to begin with. Once I have some general picture of the flow field, I then move to other neighboring points ( skipping a point is a good idea).Once the general flow pattern ( or separation regions) is defined, I can move into the specific region and start a trajectory tracing process there. You will get better pictures when you are dealing with fine mesh solutions. In 3-D simulation, trajectory tracing is extremely important, because there is no replacement for it yet. It is a great tool for viscous flows. So, if you have not used this tool before, you are encouraged to check it out. It will help you a great deal in your CFD career.

All times are GMT -4. The time now is 17:27.