CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Create dummy file (.OpenFoam) for paraView with touch (

marzbali September 24, 2011 18:43

Create dummy file (.OpenFoam) for paraView with touch
Hello everyone,

I tried to create a dummy file for paraView by touch command and a file by .OpenFoam extension was created but it was empty!

Has anybody experienced the same problem or any idea to solve it?!

Thanks a lot in advance.

wyldckat September 24, 2011 20:06

Greetings Marzbali,

Don't worry, it's meant to be empty :) ParaView only needs a reference as to what the file extension is; having content in said file depends on the reader plugin. In this case, the OpenFOAM plug-in will step in and load the case directly from the simulation files.

Now, if you do want files to be open-able in any ParaView, without the need for the case itself, then you can use foamToVTK. Run:

foamToVTK -help
for more information.

edit: Wait, if you already knew that it was a dummy file, then why did you find it odd to be empty?

Best regards,

marzbali September 27, 2011 11:10

Hi Bruno,

Thanks a lot for your reply.
The dummy file that is created in empty as you mentioned but the thing is that when I run the python script in batch mode with pvbatch it is not able to load the case files.
The error message that it gives is: "NameError: name 'PV3FoamReader' is not defined"
What I did was the following: I postproccessed one case in GUI with paraView, saved the trace, edited the python script, modified it for another case in word editor, created the dummy file for the new case by touch, and executed the python script by pvbatch.
I checked my OF 1.7 utilities directory and saw that PV3FoamReader was compiled, so I think the problem is not the reader since it works in GUI.
Do you have any idea what might cause such a problem?!

marzbali September 27, 2011 11:12

I forgot to mention that I tried foamToVTK but it didn't work. So I guess the plug-in for VTK is not compiled with my paraView, right?

wyldckat October 1, 2011 11:44

Hi Marzbali,

Sorry for taking so long to reply, but here goes:
  1. To use foamToVTK, do this in a terminal:
    • Go to the folder where you have your simulation case;
    • Run:

    • Check the contents of the newly created folder "VTK":

      ls -l VTK
    • Run:

    • Open in the newly open ParaView window the files that are inside the VTK folder, which you saw two steps above. If you open a file shorthand, something like "case..vtk" instead of "case_0.vtk", this means that ParaView should open those files as time snapshots, instead of just opening a single file.
  2. OpenFOAM's "PV3FoamReader" plugin will only work if you launch paraview from the command line in a terminal window where OpenFOAM's environment is active. In other words, you should be able to successfully run the following command when in the case folder:

    and then be able to visualize the case.
By what I can understand, you are trying to do something else beyond these standard procedures, but whichever steps you are taking, should be done in compliance with those steps above that should work.

Or in other words, run pvbatch only from the command line in a terminal window where the OpenFOAM environment is working.
But if this is what you are already doing, then you can try another file extension as well (you'll need at least ParaView 3.8.0 for this to work): instead of using the file extension ".OpenFOAM", use ".foam". This will force the usage of the internal reader that has been updated in ParaView 3.8.0 and above.

Best regards and good luck!

marzbali October 2, 2011 13:11

Thanks a lot Bruno for your thorough reply.

I recompiled the paraView plug-ins and tried foamToVTK agian, it created the VTK folder including the results.

Regarding the PV3FoamReader, that was what I thought as well. This reader is meant to be used in GUI. However, in my case I want to postprocess my results in batch mode. So, which reader should I use instead in my python script?
And if I use the right reader in batch mode can I execute the python script by pvbatch or pvpython without loading paraView graphics?


wyldckat October 2, 2011 15:11

Hi Marzbali,


Originally Posted by marzbali (Post 326414)
And if I use the right reader in batch mode can I execute the python script by pvbatch or pvpython without loading paraView graphics?

Mmm, I've never used pvbatch nor pvpython, so I can only guess:
  • If you use the extension ".foam", it should always work, except when it doesn't :rolleyes: What I mean is: the internal ".foam" reader in ParaView 3.10.1 has some issues with some simulation cases in OpenFOAM 2.0.
  • If you use the extension ".OpenFOAM", then you must run pvbatch or pvpython from a command line that has the OpenFOAM environment activated! Either that or run them sort-of like this:

    /full/path/to/OpenFOAM/bin/foamExec pvbatch ...
*OpenFOAM environment activated: this means that you are able to run (for example) icoFoam from there, right before you run pvbatch.

Best regards,

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