CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   OpenFOAM reader in the ParaView CVS (http://www.cfd-online.com/Forums/openfoam-paraview/61178-openfoam-reader-paraview-cvs.html)

tj22 November 22, 2006 11:09

If you download and build the
 
If you download and build the CVS version of ParaView, you will now have access to the native OpenFOAM reader. It will also be available in the next release of ParaView.

NOTE: To use you need to copy or rename the "controlDict" to "controlDict.foam".

7islands November 27, 2006 05:55

Hi, I tried building from the
 
Hi, I tried building from the CVS source tree of version 2.5 branch, and found a problem that multi time-step data can't be handled correctly (for example, only the first time step is read in the tutorials/icoFoam/cavity case). I looked into vtkOpenFOAMReader.cxx and found the following fixes the problem. Anyway thanks for a great work, as Windows users don't have to use foamToVTK anymore.
<pre>--- vtkOpenFOAMReader.cxx.orig 2006-11-27 16:02:45.218163200 +0900
+++ vtkOpenFOAMReader.cxx 2006-11-27 16:16:51.605208000 +0900
@@ -861,7 +861,7 @@

//calculate the time step increment based on type of run
//if(writeControl.compare(0,7,"timeStep",0,7) == 0)
- if(!strcmp(temp.substr(0,8).c_str(), "timeStep"))
+ if(!strcmp(writeControl.substr(0,8).c_str(), "timeStep"))
{
vtkDebugMacro(<<"Time step type data");
timeStepIncrement = writeInterval * deltaT;</pre>

tj22 November 30, 2006 17:29

paraview also works under linu
 
paraview also works under linux

7islands December 1, 2006 05:17

Yes, and I had the same proble
 
Yes, and I had the same problem on SUSE 10.1. Of course the same fix worked. It's platform-independent.

tj22 December 1, 2006 16:13

That comment was in response t
 
That comment was in response to
"as Windows users don't have to use foamToVTK anymore." not your patch.

As for the patch, I do not have time right now to test it. To me, the patch, whether it operates properly or not it looks incorrect. I will try to address the issue as soon as I can.

7islands December 2, 2006 00:43

I'm also doubtful if my patch
 
I'm also doubtful if my patch is correct because I still don't fully understand your code. The point is that the number of timesteps is counted incorrectly (at least) if the writeControl entry is set to timeStep. Sorry for taking your time but could you inspect it when you have time to spare.

tj22 December 5, 2006 13:11

Actually your patch does seem
 
Actually your patch does seem to be correct. Sorry I just skimmed the code quickly. I am correcting it now and I will submit it to paraview.

That is what will be great about people using it, we can hammer out all the bugs and hopefully the reader will be very dependable in the end.

hemph December 6, 2006 08:25

I was glad to see that the Ope
 
I was glad to see that the OpenFOAM-reader is also in the latest VTK-sources from CVS. I am trying to use the vtkOpenFOAM-reader using (the Python interface to) VTK, but I am not quite sure of the syntax.

I am able to create the reader using
ofreader = vtkOpenFoamReader(),

and to set the input file name by

ofreader.SetFileName('controlDict.foam'),

but when I call ofreader.Update() to cause reading, I get a crash saying

ofreader.Update()
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create

Is there a way to get VTK to accept my OpenFOAM case?

tj22 December 6, 2006 11:08

The only code I have for VTk i
 
The only code I have for VTk is a tcl script

package require vtk
package require vtkinteraction


# Create a reader and write out the field
vtkOpenFOAMReader reader
reader SetFileName "$VTK_DATA_ROOT/Data/OpenFOAM/system/controlDict.foam"

vtkMultiGroupDataExtractDataSets extract
extract SetInputConnection [reader GetOutputPort]
extract AddDataSet 0 0

vtkMultiGroupDataGeometryFilter geom
geom SetInputConnection [extract GetOutputPort ]

vtkLookupTable lut
lut SetNumberOfTableValues 256
lut SetHueRange 0.6667 0
lut SetSaturationRange 1 1
lut SetValueRange 1 1
lut SetVectorComponent 0
lut SetVectorMode 1


vtkPolyDataMapper mapper
mapper SetInputConnection [geom GetOutputPort]
mapper SetScalarModeToUseCellFieldData
mapper ColorByArrayComponent "alpha" 0
mapper SetScalarRange -0.0428937 1
mapper SetLookupTable lut

vtkActor actor
actor SetMapper mapper

# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin

ren1 AddActor actor

renWin SetSize 300 300
iren Initialize
renWin Render

iren AddObserver UserEvent {wm deiconify .vtkInteract}

# prevent the tk window from showing up then start the event loop
wm withdraw .

hemph December 6, 2006 12:56

Thanks for the file Terry. Thi
 
Thanks for the file Terry. This will be is a very useful addition to the VTK-readers. I located the cause of error. To create the reader, I need to be in a directory below the controlDict.

e.g.
chdir ./cavity/system/
ofreader.SetFileName('controlDict')

does not work, but
ofreader.SetFileName('./cavity/system/controlDict')
works.

(But for some reason
ofreader.SetFileName('/home/myUserName/OpenFOAM/OpenFOAM-1.3/tutorials/cavity/sy stem/controlDict')
does NOT work, but gives 100% CPU usage and no result!)

One more question. For some reason I only get the first time step when I use the reader above. Thus,

ofreader.GetNumberOfTimeSteps() gives 1, and
ofreader.GetTimeStepRange() gives (0,0),

but there are 5 time steps in the directory. Do you have any clues to how I can tell the reader about the other time steps?
Incidentally, I could not find the file
"$VTK_DATA_ROOT/Data/OpenFOAM/system/controlDict.foam"
in the VTKData directory I downloaded from kitware cvs page, so I dont know If the example include time step data.

7islands December 6, 2006 18:58

Hi Rasmus, as for the number o
 
Hi Rasmus, as for the number of timesteps, did you read this thread from the beginning? I reported exactly the same problem and a fix to the reader code. Sorry if I'm wrong as I know nothing about tcl but probably the same thing applies.

hemph December 7, 2006 11:30

Hi Takuya. Should have looked
 
Hi Takuya. Should have looked up! With your fix I get the time steps using VTK. Thanks!
However, I upgraded Paraview from CVS today and saw that the patch has been included in the official reader. I compiled a new Paraview, but it now crashes when I try to open a foam-case. This is the error message I get:

ErrorMessage
# Error or warning: There was a VTK Error in file: /usr/local/src/ParaView/GUI/Widgets/vtkKWTkUtilities.cxx (221)
vtkPVApplication (0x80d9388):
Script:
vtkTemp2 OpenCallback
Returned Error on line 1:
56Uncaught exception: basic_string::_S_create

Stack trace:
56Uncaught exception: basic_string::_S_create

while executing
"vtkTemp2 OpenCallback"
ErrorMessage end
ErrorMessage
# Error or warning: There was a VTK Error in file: /usr/local/src/ParaView/VTK/Filtering/vtkExecutive.cxx (784)
vtkCompositeDataPipeline (0x90cab30): UpdateInformation invoked during another request. Returning failure to algorithm vtkOpenFOAMRead er(0x90c85f8).
ErrorMessage end

Has anyone tried compiling with the new sources?

tj22 December 21, 2006 10:16

You need to download the parav
 
You need to download the paraview 2.6 cvs version. Looks like it is working correctly to me. The commands to get 2.6 are:

cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView login

cvs -d :pserver:anoncvs@www.paraview.org:/cvsroot/ParaView co -r ParaView-2-6 ParaView

hemph January 4, 2007 03:43

Great, With a new compilation,
 
Great, With a new compilation, it is working. Something must have been messed up with my old installation.

tj22 January 23, 2007 15:51

The reader was just updated on
 
The reader was just updated on 1/18, there were some memory leaks and issues with windows. Seems to be working well now. Check it out. Of course you have to download the latest 2.6 CVS.

iyer_arvind December 22, 2007 09:18

I had some problems in using v
 
I had some problems in using vtkOpenFOAMReader with OpenFOAM runs with timeFormat fixed; Does anyone have a solution for the same?

7islands December 22, 2007 10:05

Hi Iyer, If you are using 3.2
 
Hi Iyer,
If you are using 3.2 or 3.3 series of ParaView you can try the reader I posted to another thread on 23/Oct/2007.

Takuya


All times are GMT -4. The time now is 03:24.