[Paraview] Getting the extreme value of the coordinates in pvpython

Felix Salazar felix.salazar at polymtl.ca
Mon May 4 16:48:18 EDT 2015


I added a few lines to my script to address this issue. I guess that I
can't see the coordinates array directly in the NS_quad_vtk object due to
the structure of the VTK file. I create a Calculator, calling the z
coordinate as function definition, and then get the maximum of this object.

Thanks,

======START OF SCRIPT
#!/bin/pvpython

try: paraview.simple
except: from paraview.simple import *

Nstep   = 500
zEnd    = 25

def velZaxis(filename):
W = list(0 for i in range(0,Nstep))
z = list(0.0 for i in range(0,Nstep))

NS_quad_vtk = OpenDataFile(filename)
try:
TempCalc=Calculator()
TempCalc.Function='coordsZ'
TempCalc.ResultArrayName='PointZ'
maxZ = Calc.PointData["PointZ"].GetRange(0)[1]
Delete(TempCalc)
except Exception as e:
maxZ    = zEnd
PlotOverLine1 = PlotOverLine( Source="High Resolution Line Source" )
PlotOverLine1.Source.Point1 = [0.0, 0.0, 0.0]
PlotOverLine1.Source.Point2 = [0.0, 0.0, maxZ]
PlotOverLine1.Source.Resolution = Nstep
for i in range (0,Nstep):
z[i] = i*(maxZ/float(Nstep))
W[i]=servermanager.Fetch(PlotOverLine1,0).GetPointData().GetArray("U+V+W").GetTuple3(i)[2]
return z, W
======END OF SCRIPT

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

*Félix Salazar**felix.salazar at polymtl.ca <felix.salazar at polymtl.ca>*
Étudiant au doctorat - PhD Student
*École Polytechnique de Montréal*
*     LADYF*
     Lab. de dynamique des fluides
(514) 340 4711 ext 2489
Local: C-318.21.3
------------------------------------

On Mon, May 4, 2015 at 12:58 PM, Felix Salazar <felix.salazar at polymtl.ca>
wrote:

> Hello community,
>
> I'm writing a pvpython script to export the 3rd component of the velocity
> vector on the z-axis of my domain. Here's a fragment of the script used.
> Not very refined, but does the trick.
>
> ======START OF SCRIPT
> #!/bin/pvpython
>
> try: paraview.simple
> except: from paraview.simple import *
>
> Nstep   = 500
> zEnd    = 25
>
> def velZaxis(filename):
> W = list(0 for i in range(0,Nstep))
> z = list(0.0 for i in range(0,Nstep))
>
> NS_quad_vtk = OpenDataFile(filename)
> PlotOverLine1 = PlotOverLine( Source="High Resolution Line Source" )
> PlotOverLine1.Source.Point1 = [0.0, 0.0, 0.0]
> PlotOverLine1.Source.Point2 = [0.0, 0.0, zEnd]
> PlotOverLine1.Source.Resolution = Nstep
> for i in range (0,Nstep):
> z[i] = i*(zEnd/float(Nstep))
>
> W[i]=servermanager.Fetch(PlotOverLine1,0).GetPointData().GetArray("U+V+W").GetTuple3(i)[2]
> return z, W
> ======END OF SCRIPT
>
>
> Now, I was wondering if someone could give me some tips on how to set the
> value of zEnd based on the actual maximum value in the geometry, instead
> of using a fixed value. Is there any recommended way to obtain this
> information?
>
> Thanks
>
>
> ------------------------------------
>
> *Félix Salazar**felix.salazar at polymtl.ca <felix.salazar at polymtl.ca>*
> Étudiant au doctorat - PhD Student
> *École Polytechnique de Montréal*
> ------------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150504/3f15105d/attachment.html>


More information about the ParaView mailing list