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

[General] selected cells in python programmable filter

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2017, 10:44
Default selected cells in python programmable filter
  #1
Member
 
Giles Richardson
Join Date: Jun 2012
Location: Cambs UK
Posts: 98
Rep Power: 13
ufocfd is on a distinguished road
How do you operate on screen selected cells (Select Cells On) from within the Python Programmable Filter?

Attached Images
File Type: png demo.PNG (19.9 KB, 11 views)
ufocfd is offline   Reply With Quote

Old   April 22, 2017, 03:14
Default
  #2
Member
 
Giles Richardson
Join Date: Jun 2012
Location: Cambs UK
Posts: 98
Rep Power: 13
ufocfd is on a distinguished road
managed to achieve this using the code below (using tools > python shell):

from paraview.simple import *

####extract
ExtractSelection()
Show()

####filter
trans_prog_filter = ProgrammableFilter()
RenameSource("Translate", trans_prog_filter)
trans_prog_filter.Script = """
pdi = self.GetInput()
pdo = self.GetOutput()
newPoints = vtk.vtkPoints()
numPoints = pdi.GetNumberOfPoints()
for i in range(0, numPoints):
coord = pdi.GetPoint(i)
x, y, z = coord[:3]
x = x - 1.0
y = y + 0.0
z = z + 0.0
newPoints.InsertPoint(i, x, y, z)
pdo.SetPoints(newPoints)
"""
Show()
ufocfd is offline   Reply With Quote

Old   May 29, 2017, 12:46
Default
  #3
New Member
 
MASc Student
Join Date: Sep 2016
Posts: 25
Rep Power: 9
New-to-CFD is on a distinguished road
hey there,

I am having and issue that you may have experience or have some knowledge on.

Do you know if its possible to specify the selected cells from the python shell?

Instead of using "Select Cells" and dragging over an area, maybe specifying a bounding box in python to select the cells automatically?

Regards,

Derek
New-to-CFD is offline   Reply With Quote

Old   May 30, 2017, 10:05
Default
  #4
Member
 
Giles Richardson
Join Date: Jun 2012
Location: Cambs UK
Posts: 98
Rep Power: 13
ufocfd is on a distinguished road
I would suggest using the "start trace" feature in the "Tools" section to explore which python script corresponds to which cell selection method. You should be able to come up with a solution that way, by trying different methods. Try the "Clip" filter based on sphere radius and location to start with, and see how that is done using python commands. The start/stop trace feature is a really useful method (I think) to explore different python script, without having to Google it first. Good luck.
ufocfd is offline   Reply With Quote

Reply

Tags
paraview


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
Problem with divergence TDK FLUENT 13 December 14, 2018 06:00
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 09:38
[snappyHexMesh] problems using snappyHexMesh 2.1.0 on a supercomputer Sunxing OpenFOAM Meshing & Mesh Conversion 9 September 20, 2014 09:30
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 19:43
physical boundary error!! kris Siemens 2 August 3, 2005 00:32


All times are GMT -4. The time now is 16:40.