[Paraview] [EXT] RE: [EXTERNAL] Calculating cylindrical coordinates

Dennis Conklin dennis_conklin at goodyear.com
Mon Apr 30 14:08:28 EDT 2018


Cory,

No, I’m using numpy.arctan2 – sorry, always think of it as atan2.

What I’m doing now is:

   # Undeformed Sector Angles (degrees about Y-axis, 0=FP)
   numPts=block.GetNumberOfPoints()
   node_angles=zeros( (numPts,1) )
                           x_undef,y_undef,z_undef=calc_node_undeformed_coords(block)
   node_angles=arctan2(x_undef,z_undef)*180.0/pi
return node_angles

So, I’m not looping, as you suggest.   I am later doing a custom point-data-to-cell-data by looping over millions of cells and finding each cells nodes and averaging them, but I’ve failed to get vtk.vtkPointDataToCellData to work inside my Programmable filter, so I don’t have a good alternative.

I keep meaning to take out the cell angles and see how much that speeds it up, but haven’t done that yet.

Thanks for looking at this.

Dennis

From: Cory Quammen [mailto:cory.quammen at kitware.com]
Sent: Monday, April 30, 2018 1:44 PM
To: kenichiro yoshimi <rccm.kyoshimi at gmail.com>
Cc: Dennis Conklin <dennis_conklin at goodyear.com>; Paraview (paraview at paraview.org) <paraview at paraview.org>
Subject: Re: [Paraview] [EXT] RE: [EXTERNAL] Calculating cylindrical coordinates

Dennis,

First, do you mean numpy.arctan2? I don't see that numpy.atan2 exists,but math.atan2 exists.

Second, I suspect you are looping over millions of points in Python and are calling numpy.arctan2 on single X, Y values. Looping in Python like that will be very slow. Instead, you can get all your X values into one numpy array and do the same with your Y values, then make a single call to numpy.atan2. Here's an example:


>>> from paraview.simple import *

>>> import numpy

>>> x = [1, 2, 3, 4]

>>> y = [5, 6, 7, 8]

>>> numpy.arctan2(y, x)

array([ 1.37340077, 1.24904577, 1.16590454, 1.10714872])

To get the X and Y arrays, you can use the numpy adapter:


>>> from vtk.numpy_interface import dataset_adapter as dsa

>>> wrappedData = dsa.WrapDataObject(polydata)

>>> X = wrappedData.Points[:,0]

>>> Y = wrappedData.Points[:,1]

>>> result = numpy.arctan2(Y, X)

Hope that helps,
Cory


On Sat, Apr 28, 2018 at 1:25 AM, kenichiro yoshimi <rccm.kyoshimi at gmail.com<mailto:rccm.kyoshimi at gmail.com>> wrote:
Hi Dennis,

You can calculate cylindrical coordinates by utilizing vtkCylindricalTransform within the python programmable filter. It is something like below and faster than numpy.

---
import vtk

input = self.GetInput()
output = self.GetOutput()

transform = vtk.vtkCylindricalTransform()

transformFilter = vtk.vtkTransformFilter()
transformFilter.SetInputData(input)
transformFilter.SetTransform(transform.GetInverse())
transformFilter.Update()

output.ShallowCopy(transformFilter.GetOutput())
---

This converts (x,y,z) coordinates to (r,theta,z) coordinates by GetInverse method,
where the angles are calculated by the following equation to change range to [0, 2*pi]:
  theta = pi + atan2(-y, -x).

Regards

2018-04-28 5:25 GMT+09:00 Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>:
Alan,

Yes, I am calling it many times at the same angular location, but it’s tough to know you’re at the same angular location without calculating the angle.

Also, C++ is definitely orders of magnitude quicker, but once I have to compile routines into Paravew life gets very complicated.   We barely survived compiling for cluster use and I haven’t written C++ for at least 20 years.

So, if possible, I would like a clever external add-on that wouldn’t require us to re-compile PV everytime we update our version.   I have visions of library errors in my nightmares!

Dennis

From: Scott, W Alan [mailto:wascott at sandia.gov<mailto:wascott at sandia.gov>]
Sent: Friday, April 27, 2018 4:00 PM
To: Dennis Conklin <dennis_conklin at goodyear.com<mailto:dennis_conklin at goodyear.com>>; Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: [EXT] RE: [EXTERNAL] [Paraview] Calculating cylindrical coordinates

 CAUTION: EXTERNAL email. Please think before clicking on any links or attachments.



Are there places on the cylinder you are calling atan2 with the same inputs, returning the same data, lots of times?  Alternatively, could you calculate this in the simulation, and just add it to the simulation output?  I am speculating that a C++ call to atan2 may be faster than numpy?

Alan

From: ParaView [mailto:paraview-bounces at public.kitware.com] On Behalf Of Dennis Conklin
Sent: Friday, April 27, 2018 1:39 PM
To: Paraview (paraview at paraview.org<mailto:paraview at paraview.org>) <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: [EXTERNAL] [Paraview] Calculating cylindrical coordinates

All,

If I wanted to run atan2(X,Y) on millions and millions of nodes to calculate cylindrical coordinates, but found that numpy.atan2 in a Programmable Filter was taking 45 minutes to run,   what should I do to make it much faster?

Thanks for any hints

Dennis

_______________________________________________
Powered by www.kitware.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=FVhh30nhp0wVhcyd%2F4hFpRUuM%2BAOFMt7QoDOE54BMoQ%3D&reserved=0>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=3ldRUwa4mjFAej8qHdU%2Bm3hPNt1qi%2Fi%2F2UB8Edjp0uA%3D&reserved=0>

Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fparaview.org%2FWiki%2FParaView&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=X2tWI8BBiUD2n9JXLfMqrB8ZVU2zDCE44%2F86YpebIrc%3D&reserved=0>

Search the list archives at: http://markmail.org/search/?q=ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3DParaView&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=LrjHRj3n56BoYZVKKbZ4BQIasalVoDbwqK4Esrl7NIU%3D&reserved=0>

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fparaview&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=d27eFwhKD9HViwciR9Xa42vLICS34tLZLmL81ZPL%2Bf8%3D&reserved=0>


_______________________________________________
Powered by www.kitware.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=FVhh30nhp0wVhcyd%2F4hFpRUuM%2BAOFMt7QoDOE54BMoQ%3D&reserved=0>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=3ldRUwa4mjFAej8qHdU%2Bm3hPNt1qi%2Fi%2F2UB8Edjp0uA%3D&reserved=0>

Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fparaview.org%2FWiki%2FParaView&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=X2tWI8BBiUD2n9JXLfMqrB8ZVU2zDCE44%2F86YpebIrc%3D&reserved=0>

Search the list archives at: http://markmail.org/search/?q=ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3DParaView&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=LrjHRj3n56BoYZVKKbZ4BQIasalVoDbwqK4Esrl7NIU%3D&reserved=0>

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/paraview<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fparaview&data=01%7C01%7Cdennis_conklin%40goodyear.com%7C4547c889b286410afb1c08d5aec1fb03%7C939e896692854a9a9f040887efe8aae0%7C0&sdata=d27eFwhKD9HViwciR9Xa42vLICS34tLZLmL81ZPL%2Bf8%3D&reserved=0>



--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview/attachments/20180430/fe9584d9/attachment.html>


More information about the ParaView mailing list