[vtkusers] How to extract multiple scalar values along a stream line?
Amy Squillacote
amy.squillacote at kitware.com
Wed May 11 08:50:06 EDT 2005
Hi Mark,
No, you don't need to add more inputs to the stream tracer. (It doesn't
take additional inputs anyway.) Instead, you need to get the additional
scalar arrays from the point data of the output of the stream tracer. I've
added code below (inserted into the example code you sent) to demonstrate this.
- Amy
At 06:44 PM 5/10/2005, Mark B Stucky wrote:
>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 densityArray [[$s GetPointData] GetArray "density"
> 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 density [$densityArray GetComponent 0 $ptNo] ;
> set coord [$sVrts GetPoint $ptNo] ;# Point # (coords)
> puts $fp " $i $ptNo $coord $mach $density"
> }
> 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
>
>_______________________________________________
>This is the private VTK discussion list. Please keep messages on-topic.
>Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list