[Paraview-developers] Is it possible to implement a POD filter in paraview using python?
Di Cheng
chengdi at imech.ac.cn
Fri Apr 24 08:19:27 EDT 2015
Hi, Andy Bauer
Thanks for your reply. I just read the blogs and it seems it is possible to use “Programmable Filter” to access data of different timesteps by writing a “RequestUpdateExtentScript” like this:
#----------------------------------------------
RUEScript = '''
info0 = inInfo[0].GetInformationObject(0) # Ask for the next timestep.
info0.Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_TIME_STEP(),
{})
info1 = inInfo[1].GetInformationObject(0) # Ask for the next timestep.
info1.Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_TIME_STEP(),
{})
return 1
'''
pf.RequestUpdateExtentScript = RUEScript.format(t1,t2)
#----------------------------------------------
However, I get this error msg on my workstation:
NameError: global name 'inInfo' is not defined
I am using paraview 4.3.1, and the workstation is running on Ubuntu 12.04. I tested the code above in paraview 4.3.1 on windows 8.1 and it still does not works.
And I checked the parameters of “RequestUpdateExtentScript” by:
#----------------------------------------------
print dir()
print locals()
#----------------------------------------------
The result shows that there is no inInfo, but there are “request”, “inputs”, “output”, just like The “Script” of “Programmable filter”. Then I realize that this “Programmable filter” is a proxy to the VTK’s “Programmable filter”. And I cannot access the InformationObject behind the proxy. But I do not know much about the python interface of Proxies.
Now my question is: how can I access vtk Objects directly? Should I use vtk instead of paraview to accomplish my goal?
Di Cheng
From: Andy Bauer [mailto:andy.bauer at kitware.com]
Sent: Thursday, April 23, 2015 9:26 PM
To: Di Cheng
Cc: paraview-developers at paraview.org
Subject: Re: [Paraview-developers] Is it possible to implement a POD filter in paraview using python?
The best way would be to implement this in C++ but it's also doable in Python.
If you want to do it in Python I'd suggest reading through Berk Geveci's blog posts on Python and VTK (http://www.kitware.com/blog/home/user/53). The one most relevant is probably http://www.kitware.com/blog/home/post/783 but the others give good background.
Regards,
Andy
On Thu, Apr 23, 2015 at 3:55 AM, Di Cheng <chengdi at imech.ac.cn <mailto:chengdi at imech.ac.cn> > wrote:
Hi, everyone.
I am interested in using proper orthogonal decomposition to analyze unsteady flow field data obtained from CFD in paraview. I tried to implement it using python. But I am not sure if there is a better way to implement the POD algorithm described in chapter 3.2 of <http://web.mit.edu/kwillcox/Public/Web/BTTanMS.pdf> http://web.mit.edu/kwillcox/Public/Web/BTTanMS.pdf
The algorithm can be summarized as:
0. get timestepvalues of interest as t_i, i=1..N
1. load field P of two timesteps such as as P_i=P(t_i),P_j=P(t_j)
2. calculate the correlation R_ij = inner_product(P_i,P_j)/N, the definition of inner product could be integration of P_i*P_j over the volume.
3. get the eigen values lambda_i and corresponding right egien vector eV_ii of matrix {R_ij}
4. construct the i-th POD basis psi_i = sum(dot(eV_ij,P_j),j=1..N), usually, only the first m bases are used.
5. reconstruct Pr_m field using first m POD bases:
Pr_m = sum(lambda_i * psi_i, i = 1.. m)
6.output the lambda_i, psi_i and Pr_m
The algorithm is simple but the problem is to avoid loading the very large 3D dataset of all timesteps into memory. I tried to use “c1.UpdatePipeline(t_1); c2.UpdatePipeline(t_2);” to load two timesteps at one time to avoid this problem. I do not know if this method works.
Then I tried to implement the following algorithm using python. A pipeline is used to calculate the inner product via Programmable Filter and Integrate Variables. And I can get the correlation matrix and eigen values and eigen vectors.
The final step is the most difficult part in python. I do not know how to implement it in python. I did not implement it yet. I do not want to use Fetch method to collect all data to the master node. But the functionality of python shell seems limited and accessing the cells’ structure is difficult. I want to know how TemporalAverge filter works but I cannot identify where it is in the source code. (I am not familiar with software development using C++).
So, could anyone help me to finish it or tell me it is not possible?
Thanks
p.s. I just posted a Request a New Feature in http://paraview.uservoice.com/forums/11350-general/suggestions/7671768-proper-orthogonal-decomposition-analysis-filter
Di CHENG (Ph.D. candidate)
Supersonic Combustion Group
State Key Laboratory of High Temperature Gas Dynamics
Institute of Mechanics, Chinese Academy of Sciences
ADDRESS: No.15 Beisihuanxi Road, Beijing (100190)
P. R. China
E-mail: <mailto:chengdi at imech.ac.cn> chengdi at imech.ac.cn
Phone: <tel:%2B86-10-82544053> +86-10-82544053
Fax: <tel:%2B86-10-82544034> +86-10-82544034
_______________________________________________
Powered by www.kitware.com <http://www.kitware.com>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Search the list archives at: http://markmail.org/search/?q=Paraview-developers
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20150424/1657ae59/attachment-0001.html>
More information about the Paraview-developers
mailing list