CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Paraview & paraFoam (
-   -   Paraview and VTK (

Mattijs Janssens (Mattijs) October 28, 2003 07:54

I have a written simple foamT
I have a written simple foamToVTK converter for Foam2.2 meshes and data. Let me know if you would like to give it a try and I'll pack it up.

Mattijs Janssens (Mattijs) October 28, 2003 11:45

foamToVTK : forgot to mention
foamToVTK : forgot to mention but it works quite nicely with the paraview front-end to vtk.

Also I am looking for someone out there who knows how to bind in a reader into vtk.

Rasmus Hemph February 9, 2004 12:17

I find the converter (foamToV
I find the converter (foamToVTK) very useful for post processing in Paraview. However, the conversion algorithm does not seem to work for void fraction in two-phase flow? At least I get strange visual result looking at the 'alpha'-parameter in Paraview. In Ensight7 the same results look as expected.
Any idea as to what might be causing this?

Mattijs Janssens (Mattijs) February 9, 2004 12:33

the foamToVTK converter only
the foamToVTK converter only handles volScalarFields and volVectorFields. If your 'alpha' field is one of those (check the header) there should be no problem with it; all volScalarFields are handled in the same way.

Do you have any pics of 'strange' visual results?

Rasmus Hemph February 9, 2004 13:24

Thank you for the swift reply.
Thank you for the swift reply. Alpha is indeed a volScalarField. I have posted the pictures temporarily on my webpage

The files are converted to VTK with the command
>> foamToVTK . rootcase


Mattijs Janssens (Mattijs) February 9, 2004 14:19

I just tried converting the '
I just tried converting the 'damBreak' tutorial case with foamToVTK.

I get proper point gamma (i.e. void fraction on the points) but zero cell wise gamma. (all my cell fields seem to be zero). Need to look into this.

Are you running 2.2 or 2.3?

Rasmus Hemph February 9, 2004 16:38


Mattijs Janssens (Mattijs) February 10, 2004 06:25

Paraview does not seem to be
Paraview does not seem to be able to display cell values on a cut? I take a 2D case, e.g. dambreak. I can colour the read-in object with 'Cell gamma' but if I create a cut I cannot colour the cut with 'Cell gamma'. Point gamma works though.

Can anyone with more paraview experience tell us how to do this?

Mattijs Janssens (Mattijs) February 18, 2004 05:59

There has been some activity
There has been some activity on the Paraview/VTK front. Seems that the new paraview1.2.1 can display cell values.

Mattijs Janssens (Mattijs) February 27, 2004 06:13

I have hacked a version of fo
I have hacked a version of foamToVTK to write binary format. It might decrease the loading time but I haven't tested it yet on any largish case. Contact me directly if you want to try it out.

Rasmus Hemph February 27, 2004 09:49

I have tried with the new ver
I have tried with the new version of paraview without further success. I got hold of the foamToVTKBin-file through Niklas, but could not compile it. Is it for Foam 2.3?
This is the errormessage I get:

Making dependency list for source file vtkTopo.C
Making dependency list for source file foamToVTKBin.C

SOURCE=vtkTopo.C ; g++ -Dlinux -DlinuxGcc3OptLAM -DscalarMachine -DoptSolvers -DPARALLEL -DUSEMPI -Wall -O2 -DNoRepository -ftemplate-depth-30 -I/users/tfd/md8hemra/foam/foam2.2/src/foam/lnInclude -IlnInclude -I. -I/users/tfd/md8hemra/foam/foam2.2/src/lam-6.5.9/platforms/linuxGcc3OptLAM/include -I/usr/X11/include -DWM_PROJECT_VERSION='"'2.2'"' -DDEBUGList -O0 -g -I/users/tfd/md8hemra/foam/foam2.2/src/cfdTools/lnInclude -I/users/tfd/md8hemra/foam/foam2.2/src/browser/lnInclude -fPIC -c $SOURCE -o Make/linuxGcc3OptLAM/vtkTopo.o
SOURCE=foamToVTKBin.C ; g++ -Dlinux -DlinuxGcc3OptLAM -DscalarMachine -DoptSolvers -DPARALLEL -DUSEMPI -Wall -O2 -DNoRepository -ftemplate-depth-30 -I/users/tfd/md8hemra/foam/foam2.2/src/foam/lnInclude -IlnInclude -I. -I/users/tfd/md8hemra/foam/foam2.2/src/lam-6.5.9/platforms/linuxGcc3OptLAM/include -I/usr/X11/include -DWM_PROJECT_VERSION='"'2.2'"' -DDEBUGList -O0 -g -I/users/tfd/md8hemra/foam/foam2.2/src/cfdTools/lnInclude -I/users/tfd/md8hemra/foam/foam2.2/src/browser/lnInclude -fPIC -c $SOURCE -o Make/linuxGcc3OptLAM/foamToVTKBin.o
foamToVTKBin.C: In function `int main(int, char**)':
foamToVTKBin.C:120: error: 'class Foam::argList' has no member named '
make: *** [Make/linuxGcc3OptLAM/foamToVTKBin.o] Error 1

Mattijs Janssens (Mattijs) February 27, 2004 10:08

Yes, it was written for 2.3.
Yes, it was written for 2.3. Try commenting out the whole line with the 'noParalllel()' (foamToVTKBin.C:120).

Rasmus Hemph March 1, 2004 08:59

Ah, now it works! (and conver
Ah, now it works! (and converts much faster than before) Also see the velocity vectors which have been lost in translation previously.
Thanks for all help!

A small note to other 2.2 users. I had to add
-I$(FOAM_SRC)/browser/lnInclude and
to get it to compile.

Mattijs Janssens (Mattijs) March 4, 2004 07:22

There is a new version of foa
There is a new version of foamToVTK which does patchFields and lagrangian fields. These are dumped to separate directories, one for each patch and one directory 'lagrangian' containing all the lagrangian data. Contact me directly if you want it.


Mattijs Janssens (Mattijs) August 10, 2004 08:52

... > A Paraview reader modul
> A Paraview reader module for 2.3 sounds great,
> but how does it work? To test it,
> I ran the icoFoam tutorial case which produces Foam output files.
> I can convert this output to VTK and look at it in paraview,
> but I have not yet been able to open it without converting.
> Paraview seem to be expecting a file with a .foam-extension??
> Will the reader module work for lagrangian particles?

The new Paraview reader module needs in the case directory .foam file. This is a limitation in the way in which Paraview loads data.

It does not handle any lagrangian data. Feel free to add this yourself - all source is in $FOAM_UTILITIES/postProcessing/graphics/PVFoamReader/

Alternatively you can always convert the lagrangian data separately (using e.g. foamToVTK) and load it on top of any Foam reader data.


Rasmus Hemph (Hemph) September 16, 2004 10:29

Hi Mattijs The new reader mo
Hi Mattijs
The new reader module for Paraview looks good. I do not yet feel comfortable enough with the source code to add lagrangian support to it, but I hope I get better at it as time goes. Unfortunately, Paraview gets very slow when it has to deal with many files, taking almost 3 seconds between time steps, so it is unusable for me at the moment.

I have however had a chance to improve my VTK knowledge, and have written a small tcl/tk program to visualize my lagrangian particles. The problem is the conversion from the FOAM format to VTK. With the supplied converter, i.e. foamToVTK, I can convert my mesh and particles to VTK, but it takes too much time to be practial (approx 20 minutes) for my current case (2000 time steps). I was wondering about the best way for me to proceed:

-Can the classes used for the PVfoamReader be used to output the simulation results directly to VTK, i.e. make the need for conversion afterwards unnecessary?

-Alternatively. I saw that foamToVTK now supports more options on the commandline. I have played with those, but to my knowledge, I can not output ONLY the lagrangian data, that is, skip the mesh data and only print the position of the particles at each time step. The converter also clears the VTK subdirectory at each conversion. This is not necessary always. Can this be changed?

Mattijs Janssens (Mattijs) September 16, 2004 11:19

Hello Rasmus, 1] reader su
Hello Rasmus,

1] reader support. Low on our list of priorities. As for slowness that is part due ofcourse to Foam having to read the meshes and data (though Foam reading is quite fast - especially when using binary or compressed - see your controlDict settings)

2] tcl/tk program: sounds nice. Can I try it?

- "Can the classes used for the PVfoamReader ...". Don't understand fully. You can however do a 'Save Data' to write the vtk objects to a file (and reread it later). I have no experience reading these but am quite interested if you can come up with something..

- foamToVTK. For your purpose just go to the source directories (postProcessing/dataConversion/foamToVTK) and comment out in foamToVTK.C:
- rmDir(fvPath) (line 137 for me)
- all to do with writing fields/meshes
(line 210 to 506)

(I am bit reluctant to add more logic to foamToVTK so you'll have to do it on your own version)

Let me know how you get on.


Mattijs Janssens (Mattijs) September 17, 2004 08:05

Hi Rasmus, many thanks for
Hi Rasmus,

many thanks for your tool - is neat. Just wondering: do you need to dump 2000 results or can you do with less? And if you have 2000 already, do you need to convert all 2000? You can use the -time or -latestTime option to convert one time only.


Jason J Beech-Brandt (Jasonb) October 4, 2004 08:53

Hi, I've downloaded and un

I've downloaded and unpacked paraview-1.6.2 for Solaris as part of foam2.3. However when I try and run paraview I get the following link error

>paraview paraview: fatal: open failed: No such file or directory

Adding the directory /usr/ucblib to my LD_LIBRARY_PATH variable gets rid of this problem, however now I am getting a Segmentation Fault after the paraview startup screen appears.

Any ideas?



Henry Weller (Henry) October 4, 2004 09:09

Hi Jason, I compiled paravi
Hi Jason,

I compiled paraview 1.6.2 on the UltraSparc machine here running Solaris 2.8 and it went without a hitch and ran fine. I am not sure why you are having problems but it may be related to your version of Solaris being more recent.

Try downloading the ParaView binaries for Solaris from (unfortunately only an old version is available) or the sources and see if you can build and run. If you use the binary installation you will not be able to compile the reader-module because the CMake files are not included but you will be able to run foamToVTK and look at your results that way. If you need further help let us know and I will tell you how we built and installed ParaView


All times are GMT -4. The time now is 15:05.