CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[General] Paraview.simple python module and loading legacy vtk file timeseries

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 17, 2017, 05:12
Default Paraview.simple python module and loading legacy vtk file timeseries
  #1
New Member
 
Join Date: Mar 2017
Posts: 7
Rep Power: 9
awa5114 is on a distinguished road
I would like to use the Paraview.simple python module to load in a vtk time series containing many many files. I will not be able to type in the files one-by-one. Using the python trace shows a command of the form:

tEST_MPScalar_0 = LegacyVTKReader(FileNames=['D:\\TEMP\\MainProblem4\\TEST_001.vtk', 'D:\\TEMP\\MainProblem4\\TEST_002.vtk', 'D:\\TEMP\\MainProblem4\\TEST_003.vtk', 'D:\\TEMP\\MainProblem4\\TEST_004.vtk' ... 'D:\\TEMP\\MainProblem4\\TEST_500.vtk'])

As you can imagine it will be difficult to enter in the file names one-by-one there are over 500. Also I am not importing any other python modules aside from `paraview.simple`.

Does the `LegacyVTKReader()` object have any options that account for having a full time series? I would like to avoid having to generate the list of filenames programmatically. These vary on a case by case basis and it would be difficult to cover all the cases...
awa5114 is offline   Reply With Quote

Old   July 17, 2017, 08:00
Default
  #2
Member
 
Swempa's Avatar
 
Join Date: Apr 2015
Posts: 37
Rep Power: 11
Swempa is on a distinguished road
Quote:
Originally Posted by awa5114 View Post
I would like to use the Paraview.simple python module to load in a vtk time series containing many many files. I will not be able to type in the files one-by-one. Using the python trace shows a command of the form:

tEST_MPScalar_0 = LegacyVTKReader(FileNames=['D:\\TEMP\\MainProblem4\\TEST_001.vtk', 'D:\\TEMP\\MainProblem4\\TEST_002.vtk', 'D:\\TEMP\\MainProblem4\\TEST_003.vtk', 'D:\\TEMP\\MainProblem4\\TEST_004.vtk' ... 'D:\\TEMP\\MainProblem4\\TEST_500.vtk'])

As you can imagine it will be difficult to enter in the file names one-by-one there are over 500. Also I am not importing any other python modules aside from `paraview.simple`.

Does the `LegacyVTKReader()` object have any options that account for having a full time series? I would like to avoid having to generate the list of filenames programmatically. These vary on a case by case basis and it would be difficult to cover all the cases...
Hi awa5114,

Not sure if i understand the problem correct, but the good thing when running Paraview with python scripts is that you can use all the standard syntax for python.

An easy and pragmatic approach to your problem could just be to define a "while loop" and assemble the full string with all the filenames.

file_count = len([f for f in os.walk(".").next()[2] if f[:5] == "TEST_"])
i=1;
list=['D:\\TEMP\\MainProblem4\\TEST_001.vtk']
while i < file_count:
list.insert(i, 'D:\\TEMP\\MainProblem4\\TEST_00' + str(i+1) + '.vtk')
i=i+1;

Hope this will solve your problem, good luck!

Cheers
Swempa is offline   Reply With Quote

Old   July 17, 2017, 08:40
Default
  #3
New Member
 
Join Date: Mar 2017
Posts: 7
Rep Power: 9
awa5114 is on a distinguished road
Thanks for your response. It turns out I am using a method described by a stackexchange response using the glob module: https://stackoverflow.com/questions/...in-a-directory

It turns out the glob module was already pre-installed with paraview. I will use this for now.
awa5114 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] difficulties installing swak4foam newbie29 OpenFOAM Community Contributions 120 October 21, 2022 04:01
Parallel computing on a personal workstation choiyun STAR-CCM+ 6 April 10, 2017 09:58
[foam-extend.org] Module file foam-extend 3.2 CentOS cluster KarthickRajkumar OpenFOAM Installation 2 March 26, 2017 13:52
[OpenFOAM] Python and paraview.simple libprotobuf error Private Mandella ParaView 1 October 26, 2016 13:25
Linux Batch - Star-CCM+ .. running Sims in batchmode eRzBeNgEl STAR-CCM+ 3 August 29, 2011 04:43


All times are GMT -4. The time now is 08:50.