[vtkusers] How to extract multiple scalar values along a stream line?

Mark B Stucky mstucky5 at cox.net
Tue May 10 18:44:19 EDT 2005


First of all, I'm fairly new to VTK, so please excuse my ignorance.
I've tried searching the mailing list archives, but I didn't find
anything that seemed like what I needed.


I have a structured grid that represents a 3d flow field.  At
each grid point, there are multiple scalars defined.

     vtkStructuredGridReader SGR
        SGR SetOutput [SGR GetOutput]
        SGR SetFileName sgl3d.vtk
        SGR SetScalarsName mach
        SGR SetVectorsName velocity

     other scalars include: density, stagnation_energy, etc.

I then use "vtkStreamTracer" to generate a series of
stream lines.

     vtkStreamTracer SL
     SL SetInput [SGR GetOutput]
     SL SetSource aPolyLineGrid
     SL SetIntegratorTypeToRungeKutta4
     SL SetIntegrationDirection 1
     SL SetTerminalSpeed 0.0

        [etc.]


I've been able dump out the coordinates of each streamline
along with the scalar, "mach", at each coordinate with the
following code:

     set s [SL GetOutput]

     prtStreamLines $s lines_1.dat

     ------------------------------------------------

     proc prtStreamLines {s file_name} {

         set fp [open $file_name w]

         set ld       [[$s GetLines] GetData]
         set ssd      [[$s GetPointData] GetScalars]

         set numLines [$s GetNumberOfLines]
         set sVrts    [$s GetPoints]

         set idx 0
         set stLst {}
         for {set i 0} {$i<$numLines} {incr i} {    ;# For each line...
             set nPts [$ld GetComponent $idx 0]     ;# # of points in this 
line
             set endPt [expr $idx + $nPts]          ;# Indx to last pt in 
this line

             for {set j [expr $idx+1]} {$j<=$endPt} {incr j} {

                 set ptNo  [$ld GetComponent $j 0]      ;# Point # (indx 
into scalars)
                 set mach  [$ssd GetComponent 0 $ptNo]  ;# Point # (scalar)
                 set coord [$sVrts GetPoint $ptNo]      ;# Point # (coords)
                 puts $fp "  $i $ptNo $coord $mach"
             }
             incr idx [expr $nPts + 1]                  ;# Move to next line
         }
         close $fp
     }


What I want to do is to dump out some of the additional scalar
values.  I'm guessing that I need to add additional inputs (?)
to the streamtracer object, "SL", to make them available to the
"prtStreamLines" routine.  I just haven't figured out the right
sequence of steps.

I'm hoping that someone will be able to point me in the right
direction.

Thanks,

--Mark Stucky 





More information about the vtkusers mailing list