[vtkusers] Help with vtkOpenFOAMReader and extraction
Sandro Grm
sandro at c3m.si
Fri Feb 4 02:34:02 EST 2011
Dear,
I started to use vtk (python interface) last week. I was not
able to
find any example how work with vtkOpenFOAMReader. I'm able to
obtain
vtkMultiBlockDataSet, next I extract a block which is of
vtkUnstructuredGrid type, but from there I was not able to
extract
single data set, for example scalar (pressure "p"), or vector
(velocity
"U") to render or anyhow other manipulate those data.
Please can someone give me a hint how to do it.
Thanks + Best, Sandro.
My python code is:
# -*- coding: utf-8 -*-
import os
import vtk as vtk
import numpy as np
import scipy as sp
import math
rootDir = "thermoViscoPlasticFoam"
fileName = rootDir + "/system/controlDict"
reader = vtk.vtkOpenFOAMReader()
reader.SetFileName(fileName)
reader.CreateCellToPointOn()
reader.DecomposePolyhedraOn()
reader.Update()
# this print is listed at the bottom
print str(reader.GetOutput())
# extract first time interval data set
ug = reader.GetOutput().GetBlock(0)
# saw in same examples, but do not understand the point
compositeFilter = vtk.vtkCompositeDataGeometryFilter()
compositeFilter.SetInputConnection(reader.GetOutputPort())
compositeFilter.Update()
# here is my question, how to see which data set is inside and
# how to extract them for further use (render, cut plain, ...)
# mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(compositeFilter.GetOutputPort())
# plot to screen
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
renWin.SetSize(850, 850)
renWin.Render()
iren.Start();
What I get for output has nothing to do with reality.
And the reader.GetOutput print:
vtkMultiBlockDataSet (0x18f5310)
Debug: Off
Modified Time: 396
Reference Count: 2
Registered Events: (none)
Source: (none)
Information: 0x18ec270
Data Released: False
Global Release Data: Off
UpdateTime: 403
Release Data: Off
UpdateExtent: Not Initialized
Update Number Of Pieces: 1
Update Piece: 0
Update Ghost Level: 0
MaximumNumberOfPieces: -1
RequestExactExtent: Off
Field Data:
Debug: Off
Modified Time: 152
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 1
Array 0 name = CasePath
Number Of Components: 1
Number Of Tuples: 24
Number Of Children: 1
Child 0: vtkUnstructuredGrid
Debug: Off
Modified Time: 390
Reference Count: 2
Registered Events: (none)
Source: (none)
Information: 0x1a330a0
Data Released: False
Global Release Data: Off
UpdateTime: 0
Field Data:
Debug: Off
Modified Time: 174
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 25586
Number Of Cells: 24800
Cell Data:
Debug: Off
Modified Time: 374
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 6
Array 0 name = Sr
Array 1 name = T
Array 2 name = U
Array 3 name = magGradU
Array 4 name = nu
Array 5 name = p
Number Of Components: 8
Number Of Tuples: 24800
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars:
Debug: Off
Modified Time: 371
Reference Count: 1
Registered Events: (none)
Name: p
Data type: float
Size: 24800
MaxId: 24799
NumberOfComponents: 1
Information: 0
Name: p
Number Of Components: 1
Number Of Tuples: 24800
Size: 24800
MaxId: 24799
LookupTable: (none)
Array: 0x1eb0c40
Vectors:
Debug: Off
Modified Time: 296
Reference Count: 1
Registered Events: (none)
Name: U
Data type: float
Size: 74400
MaxId: 74399
NumberOfComponents: 3
Information: 0
Name: U
Number Of Components: 3
Number Of Tuples: 24800
Size: 74400
MaxId: 74399
LookupTable: (none)
Array: 0x1debef0
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Point Data:
Debug: Off
Modified Time: 390
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 6
Array 0 name = Sr
Array 1 name = T
Array 2 name = U
Array 3 name = magGradU
Array 4 name = nu
Array 5 name = p
Number Of Components: 8
Number Of Tuples: 25586
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars:
Debug: Off
Modified Time: 387
Reference Count: 1
Registered Events: (none)
Name: p
Data type: float
Size: 25586
MaxId: 25585
NumberOfComponents: 1
Information: 0
Name: p
Number Of Components: 1
Number Of Tuples: 25586
Size: 25586
MaxId: 25585
LookupTable: (none)
Array: 0x1ec8fd0
Vectors:
Debug: Off
Modified Time: 322
Reference Count: 1
Registered Events: (none)
Name: U
Data type: float
Size: 76758
MaxId: 76757
NumberOfComponents: 3
Information: 0
Name: U
Number Of Components: 3
Number Of Tuples: 25586
Size: 76758
MaxId: 76757
LookupTable: (none)
Array: 0x1e34980
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Bounds:
Xmin,Xmax: (0, 0.61)
Ymin,Ymax: (0, 0.29)
Zmin,Zmax: (-0.0101496, 0.0151496)
Compute Time: 421
Number Of Points: 25586
Point Coordinates: 0x17cae20
Locator: 0
Number Of Pieces: 1
Piece: -1
Ghost Level: 0
More information about the vtkusers
mailing list