<div dir="ltr">Hello,<div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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?</div><div><br></div><div>Thanks</div><div><br></div><div>-David Ortley</div><div><br></div><div><br></div><div># Programmable filter snippet:</div><div><div>pdi=self.GetInput()</div><div>pdo=self.GetOutput()</div><div><br></div><div>numCells = pdi.GetNumberOfCells()</div><div>cells = pdi.GetCellData()</div><div><br></div><div># Some array already in the calc results that I'm going to reason on</div><div># say it's pressure or energy or something</div><div>orig_array = cells.GetArray("orig_array")</div><div><br></div><div># Storing </div><div>new_array = vtk.vtkDoubleArray()</div><div>new_array.SetName("new_array")</div><div><br></div><div>for i in range(numCells):</div><div>    # do some work</div><div>    blah  = pkovpr.GetValue(i) * 1.23456789</div><div>    # store as new val in array</div><div>    new_array.InsertNextValue(blah)</div><div><br></div><div># Add the array I just created to the output so Paraview can do stuff with it</div><div>pdo.GetCellData().AddArray(betaMax)</div></div><div><br></div><div><br></div></div>