[Paraview] Getting the coordinates of the point with max temperature

David E DeMarle dave.demarle at kitware.com
Wed Sep 7 14:03:05 EDT 2011


vtkPVDataInformation is _only_ lightweight meta information. It
describes some dataset that lives on the server but doesn't give you
access to the actual data.

Fetch should return to you a vtkDataSet. You should be able to get the
points/cells and arrays directly out of that.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909



On Wed, Sep 7, 2011 at 1:45 PM, Tibi Chelcea <tchelcea at transim.com> wrote:
> Hi David,
>
> Thank you very much for the hint. I'm still not entirely sure I'm getting it
> right, though. Here's what I've done:
>
> reader = sources.XMLUnstructuredGridReader(FileName =
> 'C:\\mypath\\output0020.vtu')
> reader.UpdatePipeline()
>
> info_base = reader.GetDataInformation().DataInformation
> pointDataInfo = info_base.GetPointDataInformation()
>
> temp_max = 0
> # here I get the max temperature across all points
> for i in range(pointDataInfo.GetNumberOfArrays()):
>        ai = pointDataInfo.GetArrayInformation(i)
>        if ai.GetName().lower() == 'temperature':
>                temp_max = ai.GetComponentRange(0)[1]
>
> # temp_max is computed correctly at this point, declare the threshold to be
> 95% to 105% of the max temperature
> th = filters.Threshold(Input = reader)
> th.SelectInputScalars = ['0', '0', '0', '1', 'temperature']
> th.ThresholdBetween = [temp_max*0.95,temp_max*1.05]
> th.UpdatePipeline()
> Fetch(th)
>
> pdi = th.GetDataInformation().DataInformation
> print pdi
>
> At this point, 'print pdi' produces this:
>
> vtkPVDataInformation (0000000004089090)
>  Debug: Off
>  Modified Time: 116455
>  Reference Count: 2
>  Registered Events: (none)
>  RootOnly: 0
>  DataSetType: 4
>  CompositeDataSetType: -1
>  NumberOfPoints: 0
>  NumberOfRows: 0
>  NumberOfCells: 0
>  NumberOfDataSets: 1
>  MemorySize: 0
>  PolygonCount: 0
>  Bounds: 1e+299, -1e+299, 1e+299, -1e+299, 1e+299, -1e+299
>  Extent: 2147483647, -2147483647, 2147483647, -2147483647, 2147483647,
> -2147483647
> .......
>
>
> It seems that there are no points selected. I'm wondering whether the
> th.SelectInputScalars does what's it's supposed to do (I've copied that from
> some examples in the mailing list). I'm using Paraview 3.4.0 (the latest
> Paraview 3.10.1 works only in GUI, but fails to execute any script in
> pvbatch).
>
> Thanks,
> Tibi
>
>
> -----Original Message-----
> From: David E DeMarle [mailto:dave.demarle at kitware.com]
> Sent: Wednesday, September 07, 2011 10:41 AM
> To: Tibi Chelcea
> Cc: paraview at paraview.org
> Subject: Re: [Paraview] Getting the coordinates of the point with max
> temperature
>
> The arrays themselves may be extremely large, thus they live on the server,
> not the client and you can't get them directly as you are trying to do.
> You can however use servermanager.Fetch to bring them over, but you should
> only do so once you have filtered them down in size a bit.
> Try using the threshold filter, picking out only those cells/points near the
> maximum, then fetching that.
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
>
>
> On Wed, Sep 7, 2011 at 9:57 AM, Tibi Chelcea <tchelcea at transim.com> wrote:
>> Hi,
>>
>>
>>
>> I’m extremely new to Paraview scripting and Python programming, so the
>> question that I’m asking might have a totally obvious answer, but I
>> can’t figure it out. I need to write a script to analyze the results
>> of a transient analysis simulation. For that, the script needs to read
>> the last .vtu file, figure out the coordinates (or index) of the point
>> with the largest temperature, and then pick the temperatures at that
>> point from all the other simulation steps and then do some
>> computations based on those values.
>>
>>
>>
>> I got stuck at figuring out the coordinates of the point with the max
>> temperature. This is what I got so far:
>>
>>
>>
>> reader = sources.XMLUnstructuredGridReader(FileName =
>> 'C:\\mypath\\output0020.vtu')
>>
>> reader.UpdatePipeline()
>>
>> info_base = reader.GetDataInformation().DataInformation
>>
>> pointArray = info_base.GetPointArrayInformation()
>>
>>
>>
>> I don’t know how to get from pointArray to a list of points (I assume
>> that the info in pointArray is the list of coordinates). Then, I can
>> go through the temperature array obtained with
>> info_base.GetPointDataInformation().GetArrayInformation(..) and get
>> the max temperature and match it with the coordinates.  But, I’m lost
>> at this step on how to get from the reader to the actual array of
>> coordinates and temperature values.
>>
>>
>>
>> I’ve seen posts with some calls to GetPoints, but GetPoints is not a
>> member of pointArray (or any other of the classes used above, for that
> matter).
>>
>>
>>
>> Thanks,
>>
>> Tibi
>>
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>>
>
>


More information about the ParaView mailing list