[Paraview] Complex filters for structured meshes

David Ortley djortley at gmail.com
Tue May 9 10:33:10 EDT 2017


Hello,

I work with a CFD code that uses a structured mesh.  We frequently want to
do math operations that require each cell to have knowledge of its
neighbors.  Things such as a calculating the max of a certain variable, or
a gradient in a given direction.

I'm not sure the best way to accomplish this.  I have a code snippet for
use in the programmable filter that I use (copied below), but its behavior
is similar to the calculator in that it works on individual cells without
knowledge of cell neighbors.

Can somebody A) critique my skeleton code below to let me know if I could
write it better and B) help me with figuring out a method (any method) that
has visibility of neighbor cells?

Thanks

-David Ortley


# Programmable filter snippet:
pdi=self.GetInput()
pdo=self.GetOutput()

numCells = pdi.GetNumberOfCells()
cells = pdi.GetCellData()

# Some array already in the calc results that I'm going to reason on
# say it's pressure or energy or something
orig_array = cells.GetArray("orig_array")

# Storing
new_array = vtk.vtkDoubleArray()
new_array.SetName("new_array")

for i in range(numCells):
    # do some work
    blah  = pkovpr.GetValue(i) * 1.23456789
    # store as new val in array
    new_array.InsertNextValue(blah)

# Add the array I just created to the output so Paraview can do stuff with
it
pdo.GetCellData().AddArray(betaMax)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170509/761a77ed/attachment.html>


More information about the ParaView mailing list