CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [OpenFOAM] How to output images using command automatically? (https://www.cfd-online.com/Forums/paraview/63778-how-output-images-using-command-automatically.html)

lakeat April 19, 2009 21:30

How to output images using command automatically?
 
Dear all,

Other than File->Save screenshot, I want to output images of U, epsilon, etc., automatically using shell script or other methods, do you know how to achieve this goal?

Thank you!

DW

roth April 20, 2009 07:29

Have you considered using Python to call ParaView? Perhaps something along the lines of http://www.cmake.org/pipermail/parav...ly/005427.html

Michael

lakeat April 20, 2009 09:42

Thank you, Michael! But I really don't understand the python script and I think I have no energy to delve into it, and I am looking forward to pyFoam to have that function. It would be very nice if Mr. Gschaider will help us on this.

With Regards, Daniel

gschaider April 21, 2009 07:19

Hi Daniel!

Quote:

Originally Posted by lakeat (Post 213522)
Thank you, Michael! But I really don't understand the python script and I think I have no energy to delve into it, and I am looking forward to pyFoam to have that function. It would be very nice if Mr. Gschaider will help us on this.

I (Bernhard) have spoken to Mr. Gschaider, and he says: PyFoam already has a similar functionality http://openfoamwiki.net/index.php/Co...mPVSnapshot.py. To quote from the online help:

Code:

pyFoamPVSnapshot.py -h
Usage
=====
  pyFoamPVSnapshot.py [options] <case>

 Generates snapshots of an OpenFOAM-case and a predefined paraview State-File
using the PV3FoamReader that comes with OpenFOAM.  The state-file can be
generated using a different case (the script adjusts it before using) but the
original case has to have a similar structure to the current one. Also exactly
one PV3Reader has to be used in the state-file (this requirement is fullfilled
if the StateFile was generated using paraFoam)  In TextSources the string
"%(casename)s" gets replaced by the casename. Additional replacements can be
specified

Is this the thing you are looking for? You have to prepare a state-file once ("Save State" in paraFoam) and then you can use it to make pictures of similar cases.

Bernhard

PS: There seems to be slight problem with the 3.3-version that is distributed with OpenFOAM. But it works with 3.4

lakeat April 21, 2009 08:55

Hi Bernhard, say hi to Mr. Gschaider, when you meet him:D.
But what is state-file, can you give me an example?

gschaider April 21, 2009 11:34

Quote:

Originally Posted by lakeat (Post 213662)
Hi Bernhard, say hi to Mr. Gschaider, when you meet him:D.

I usually avoid that. People look at me funny when I talk aloud to him.
Quote:

Originally Posted by lakeat (Post 213662)
But what is state-file, can you give me an example?

The state file is the file that you produce with "Save State" in the paraview-file menu. With "Load State" it allows you exactly return to the state you had (all the filters etc). Play around with these two menu-entries and you'll see what I mean

BTW: I added on the PyFoam-Wiki-page some information that explains how to set up a OF-installation so that PVSnapshot works

Bernhard

crazysumi May 14, 2009 04:59

Hi All,

I am using pyFoamPVSnapshot utility available in pyFoam. I have :-
pyFoam 0.5.2
python 2.5.4
paraview 3.4
on Opensuse 10.3 x86_64 machine

I installed paraview 3.4 with QT4.3.5.

The pyFoamPVLoadState script works fine but on running the snapshot script, with the provided inputs. I received following error messages :-

> pyFoamPVSnapshot.py --state-file=U.pvsm --latest-time --file-prefix=vel .
Snapshot 0 for t= 1000
vtkPainterPolyDataMapper : [ ...........]
Segmentation fault


Please advice

Regards
Sumeet

gschaider May 19, 2009 17:59

Quote:

Originally Posted by crazysumi (Post 216057)
Hi All,

I am using pyFoamPVSnapshot utility available in pyFoam. I have :-
pyFoam 0.5.2
python 2.5.4
paraview 3.4
on Opensuse 10.3 x86_64 machine

I installed paraview 3.4 with QT4.3.5.

The pyFoamPVLoadState script works fine but on running the snapshot script, with the provided inputs. I received following error messages :-

> pyFoamPVSnapshot.py --state-file=U.pvsm --latest-time --file-prefix=vel .
Snapshot 0 for t= 1000
vtkPainterPolyDataMapper : [ ...........]
Segmentation fault


Please advice

Regards
Sumeet

That's a tough one. "Segmentation Fault" could be almost anything.

Some questions:
Does this happen with every StateFile or just with a specific one? Is the paraView compiled with MESA enabled? Do you feel comfortable with enabling core dumps with "ulimit -c <some value>" and getting a stack-trace with gdb (if not, don't bother it would take too long guiding you through this)?

Bernhard

crazysumi May 20, 2009 01:29

Hi Bernhard,

It happens with every state-file generated in paraFoam (for PV3FoamReader). I checked the script, MESA was not enabled in script. However, I enabled the INCLUDE_PYTHON and set the path for python libs in the script.

"Do you feel comfortable with enabling core dumps with "ulimit -c <some value>" and getting a stack-trace with gdb.."

I don't know how to do it.

Recently I started a bit different way of doing the same thing using pvpython shell. I created some state files by reading thru Parafoam, and paraview for VTK, ensight files. On loading state files using the shell, it is not able to recognize "PV3FoamReader" as a source. Howerver, state files for VTK, Ensight files are well read and loaded and images can be written. Is there any way to include PV3Foamreader as a source to pvpython shell.

Thanks,
Sumeet

gschaider May 20, 2009 10:23

Quote:

Originally Posted by crazysumi (Post 216672)
It happens with every state-file generated in paraFoam (for PV3FoamReader). I checked the script, MESA was not enabled in script. However, I enabled the INCLUDE_PYTHON and set the path for python libs in the script.

OK. Only checking. Because it should work with MESA, but I never tested it because my paraview is compiled without MESA to. But to cover that you could look for

view.UseOffscreenRenderingForScreenshots=True

in PyFoam.Applications.PVSnapshot.py and replace it with False (thus disabling MESA for sure)

Quote:

Originally Posted by crazysumi (Post 216672)
"Do you feel comfortable with enabling core dumps with "ulimit -c <some value>" and getting a stack-trace with gdb.."

I don't know how to do it.

And I don't know how to explain it. Let's leave this out

Quote:

Originally Posted by crazysumi (Post 216672)
Recently I started a bit different way of doing the same thing using pvpython shell. I created some state files by reading thru Parafoam, and paraview for VTK, ensight files. On loading state files using the shell, it is not able to recognize "PV3FoamReader" as a source. Howerver, state files for VTK, Ensight files are well read and loaded and images can be written. Is there any way to include PV3Foamreader as a source to pvpython shell.

PyFoam does this in PyFoam/Paraview/ServermanagerWrapper.py in the __init__-constructor. Have a look there. Maybe the reason for the segmentation fault lies in there

Bernhard

heavy_user August 18, 2010 08:57

Hi There (and special greetings to Bernhard, again :D),

i am using OF1.6 now and pyFoamPVSnapshot.py ist not working...as mentioned above..

So I installed paraview3.4.0 with my ubuntu package-manager.


pyFoamPVSnapshot.py does not care about me having done this, it still refuses to work.
So how can I make pyFoamPVSnapshot.py use a certain paraview-version when i have installed more than one?

Thx!

gschaider August 18, 2010 11:28

Quote:

Originally Posted by heavy_user (Post 271872)
Hi There (and special greetings to Bernhard, again :D),

i am using OF1.6 now and pyFoamPVSnapshot.py ist not working...as mentioned above..

So I installed paraview3.4.0 with my ubuntu package-manager.


pyFoamPVSnapshot.py does not care about me having done this, it still refuses to work.
So how can I make pyFoamPVSnapshot.py use a certain paraview-version when i have installed more than one?

Thx!

First problem you'll have is that the PV3Reader-plugin that comes with OF 1.6 expects a Paraview 3.6 and probably won't work with 3.4 (plus you'll need to compile OF from the sources to make that compile)

Loading the PV3-Plugin is a bit of a due to problems in the Python-code of Paraview and probably never will be supported for the OF1.6/PV3.6-combo and for the OF1.7/PV3.8-combo subject to research.

What is supported since the last version of PyFoam is the native OF reader (plugin for 3.6, built-in since 3.8). PVSnapshot looks at the state-file and tries to load the OF-reader that you used. There still may be a problem if the reader is a plugin

Bernhard

heavy_user August 19, 2010 06:53

Quote:

Originally Posted by gschaider (Post 271898)
First problem you'll have is that the PV3Reader-plugin that comes with OF 1.6 expects a Paraview 3.6 and probably won't work with 3.4 (plus you'll need to compile OF from the sources to make that compile)

Loading the PV3-Plugin is a bit of a due to problems in the Python-code of Paraview and probably never will be supported for the OF1.6/PV3.6-combo and for the OF1.7/PV3.8-combo subject to research.

What is supported since the last version of PyFoam is the native OF reader (plugin for 3.6, built-in since 3.8). PVSnapshot looks at the state-file and tries to load the OF-reader that you used. There still may be a problem if the reader is a plugin

Bernhard

Hi Bernhard,

so this means that there is no good solution to OF1.6 ?
Would it help to install OF1.6 and OF1.5( use the nice pyFoam stuff with of 1.5...) ?

Best

gschaider August 19, 2010 13:11

Quote:

Originally Posted by heavy_user (Post 272000)
Hi Bernhard,

so this means that there is no good solution to OF1.6 ?
Would it help to install OF1.6 and OF1.5( use the nice pyFoam stuff with of 1.5...) ?

Best

Just for snapshoting? I'm afraid that would be an option (But you don't have to switch versions permanently. Using the option --foam=1.5 would make PVSnapShot make believe that it is not living in a 1.6-world)

Alternative would be to install 1.7/3.8 and use a state-file where you used the native reader. That works for me (PV3Reader needs some modifications due to the new path were it is located)

Bernhard

amin.z July 18, 2019 13:39

Quote:

Originally Posted by gschaider (Post 213649)
PyFoam already has a similar functionality


hi Bernhard,

Is it possible to save the PNGs with transparent background?

the paraview's background, from which the state file is being saved, always comes with a color; to my knowledge transparent background is only available under File>save screenshot, is the same option available through pyFoamPVSnapshot.py ?


thanks

gschaider July 19, 2019 03:28

Quote:

Originally Posted by amin.z (Post 739346)
hi Bernhard,

Is it possible to save the PNGs with transparent background?

the paraview's background, from which the state file is being saved, always comes with a color; to my knowledge transparent background is only available under File>save screenshot, is the same option available through pyFoamPVSnapshot.py ?


thanks


I must have a look whether the PYthon-API supports it. But I don't have it inmplemented ... yet

amin.z July 19, 2019 10:06

Quote:

Originally Posted by gschaider (Post 739387)
I must have a look whether the PYthon-API supports it. But I don't have it inmplemented ... yet


great, thanks, looking forward for the "I implemented it" message :)

gschaider July 19, 2019 18:24

Quote:

Originally Posted by amin.z (Post 739434)
great, thanks, looking forward for the "I implemented it" message :)

I guess it happens to you all the time as well: you think "Yeah that feature would be nice. Lets see how much time it taks to implement" You look at the sources and realize "it is already there"
Seems like I already implemented it in January and forgot about it


The reason why you don't see it is that there wasn't a release in the meantime. So the problem shifts to "when I find time for a release"

amin.z July 20, 2019 05:13

Quote:

Originally Posted by gschaider (Post 739455)
I guess it happens to you all the time as well: you think "Yeah that feature would be nice. Lets see how much time it taks to implement" You look at the sources and realize "it is already there"
Seems like I already implemented it in January and forgot about it


The reason why you don't see it is that there wasn't a release in the meantime. So the problem shifts to "when I find time for a release"


yes, I'm familiar with that feeling, kind of a deja vu :)
hope you'll get sometime and share the new features
thanks


All times are GMT -4. The time now is 06:00.