[Paraview] [Paraview-developers] Question on programmable filter

Sebastien Jourdain sebastien.jourdain at kitware.com
Wed Oct 29 11:23:37 EDT 2014


Hi Josh,

I've noticed that the default programmable filters does not advertise that
it handle time. To properly do that you can use the attached XML plugin.

Let us know if that fix the problem.

Seb

On Tue, Oct 28, 2014 at 8:48 PM, Joshua Murphy <
Joshua.Murphy at lasp.colorado.edu> wrote:

> Hi all,
>
> I am working with a scientist who is attempting to run a complex
> programmable filter that uses two inputs and produces one output.    The
> script generates a result for the first time step is applied on, but if you
> advance paraview to the next time step, the new result is NOT generated.
> (no streamline update, no recalculation, nothing..)  I am not seeing why
> this is the case.  If you advance the time step, then force a re-apply of
> the filter, it will run, but that doesn't help for automated image
> generation.  I am sure the problem has to do with updating the pipeline,
> but I don't have enough experience with the programmable filter to say for
> sure what needs to be done.  If someone could take a look and let me know
> if there is a simple solution, I would be grateful.
>
> I have tried this with the same result on PV4.0.1 and PV4.1.0.  I have not
> tried on PV4.2 as our reader plugin has not yet been compiled against 4.2.
>
> Thanks,
>
> Josh
>
> The programmable filter script follows:
>
> from paraview.vtk import dataset_adapter as DA
> from paraview import vtk
> from numpy import *
>
> # get inputs and define output
> # first input needs to define the grid used to provide the seed points to
> the stream tracer
> # the second are the resulting stream lines
> # the output is a modified version of the first input
>
> in1 = self.GetInputDataObject(0,0)
> in2 = self.GetInputDataObject(0,1)
> pdo = self.GetOutputDataObject(0)
>
> # get number of lines and total number of pts on the lines
> #  note: paraview does the filed line integration first forward for all
> seed
> #  points, then backward in the same order
> #  ncells is twice the total number of field lines
>
> ncells = inputs[1].GetNumberOfCells()
> npts = inputs[1].GetNumberOfPoints()
> nc2 = ncells/2
>
> # figure out the location and and number of points in each line
>
> numpts = zeros(ncells,dtype=int)
> cellpointer = zeros(ncells,dtype=int)
> for i in range(0,ncells):
>     numpts[i] = in2.GetCell(i).GetNumberOfPoints()
> print numpts
> for i in range(1,ncells):
>     cellpointer[i] = cellpointer[i-1] + numpts[i-1]
>
> #for i in range(0,ncells):
> #    print cellpointer[i],numpts[i],r2[cellpointer[i],:]
>
> #
> # put points into numpy arrays
> #
> r = inputs[0].Points
> r2 = inputs[1].Points
> rmag = mag(r2)
> dR = r2[1:npts,:] - r2[0:npts-1,:]
> dr = mag(dR)
>
> #
> # get variables needed for integration
> #
>
> B = inputs[1].PointData['Magnetic Field Vector']
> den = inputs[1].PointData['Plasma Density']
> csound = inputs[1].PointData['Sound Speed']
> pressure = den*csound**2
> b = mag(B)
> binv = 1./b
>
> #
> # get midpoint values
> #
>
> bav = 0.5*(b[1:npts]+b[:npts-1])
> denav = 0.5*(den[1:npts]+den[0:npts-1])
> pav = 0.5*(pressure[1:npts]+pressure[0:npts-1])
> print 'DR',dR.shape,r.shape
> print numpts
> print cellpointer
>
> #
> #   integrate along field lines
> #
> FTvolume = zeros(ncells)
> FTden = zeros(ncells)
> FTP = zeros(ncells)
> print FTvolume
> for i in range(ncells):
>     for j in range(cellpointer[i],cellpointer[i]+numpts[i]-1):
>         FTvolume[i] = FTvolume[i] + binv[j]*dr[j]
>         FTden[i] = FTden[i] + binv[j]*dr[j]*denav[j]
>         FTP[i] = FTP[i] + binv[j]*dr[j]*pav[j]**0.6
> for i in range(nc2):
>     FTvolume[i] = FTvolume[i] + FTvolume[i+nc2]
>     FTden[i] = FTden[i] + FTden[i+nc2]
>     FTP[i] = FTP[i] + FTP[i+nc2]
> print FTvolume
> print FTden
> print FTP
> #
> # don't really need to reset the positions
> #  but can be useful if we modify to plot in min B surface, say
> #
>
> newPoints = vtk.vtkPoints()
> denout = zeros(ncells)
> for i in range(0,nc2):
>     xi = r2[cellpointer[i],0]
>     yi = r2[cellpointer[i],1]
>     zi = r2[cellpointer[i],2]
>     denout[i] = b[cellpointer[i]]
>     print i,xi,yi,zi,denout[i]
>     newPoints.InsertPoint(i,xi,yi,zi)
>
> print newPoints
>
>
> pdo.SetPoints(newPoints)
>
> #
> # add computed arrays
> #
>
> arrFTV = DA.numpyTovtkDataArray(FTvolume[0:nc2],'Flux Tube Volume')
> pdo.GetPointData().AddArray(arrFTV)
> print 'added stuff'
> arrFTden = DA.numpyTovtkDataArray(FTden[0:nc2],'Flux Tube Mass')
> pdo.GetPointData().AddArray(arrFTden)
>
> arrFTP = DA.numpyTovtkDataArray(FTP[0:nc2],'Flux Tube Entropy')
> pdo.GetPointData().AddArray(arrFTP)
> _______________________________________________
> Paraview-developers mailing list
> Paraview-developers at paraview.org
> http://public.kitware.com/mailman/listinfo/paraview-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20141029/a3d6e8a0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TemporalPythonProxy.xml
Type: text/xml
Size: 1018 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20141029/a3d6e8a0/attachment-0001.xml>


More information about the ParaView mailing list