[vtkusers] Re: Extracting an unstructured grid from Ensight case files...

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu Mar 30 12:40:20 EST 2006


Renato N. Elias wrote:
> Hi there,
> 
> Since I'm a poor Fortran programmer that can't make the Ensight's binary
> format working in Paraview properly, I've been writing a TCL/VTK script to
> convert from Ensight case files to Paraview/VTK format (and I hope it will
> work out my problems...). 
> 
> A have the following situation to cover:
> 
> 1- Model partitioned in several case files (sometimes I run problems in
> parallel/MPI)
> 2- Each case file has its geometry and results files associated
> 3- The geometry does not change in time
> 
> Then, I was thinking about do the following:
> 
> 1- Read each case file
> 2- Export the Unstructured grid through the vtkXMLUnstructuredGridWriter
> 3- Export the results for each time step through the vtkXMLDataSetWriter
> 4- Assembly the files through a PVD file (Paraview format) as is done with
> the case file
> 
> My problem is: 
> 
> * * * How do I export unstructured grids and results separetely? * * *
> 
> I'm using the following script, but it's only able to save grid+results in
> the same file. Note that it's not good since I'll be replicating grid that
> does not change in time.
> 
<snip>

Hi Renato,

I think vtkDataSetToDataObjectFilter is the class you need. Have a look 
at the docs and the test graphics/testing/tcl/fieldToUGrid.tcl

On a different note, this would be quicker than the code you posted:

vtkGenericEnSightReader reader
vtkXMLUnstructuredGridWriter vtkfile

# loop over the case files that will be read and saved in vtk format
for {set i 0} {$i < $nprocs} {incr i} {
     set filename $arch
     if {$i < 10} { append filename "0" }
     append filename $i
     set casefile $filename
     append casefile ".case"

     puts " Reading Ensight casefile $casefile"
     reader SetCaseFileName $casefile
     reader Update

     vtkfile SetInput [ reader GetOutput ]
     vtkfile SetFileName "$filename.vtk"
     puts " Exporting VTK unified file..."
     vtkfile Write
}

reader  Delete
vtkfile Delete

You can re-use the reader and writer- just create and delete them 
outside of the for loop.

hth,

Goodwin

ps On my VTK build vtkDataSetToDataObjectFilter is throwing up an error, 
but I see it does ok on the dashboard.




More information about the vtkusers mailing list