[Paraview] mapping unstructured grid onto regular grid
Dan Lussier
dan.lussier at sjc.ox.ac.uk
Mon Sep 13 18:01:40 EDT 2010
Ok - that's great. I was able to see how that works with some playing
around at the interactive prompt.
How does this approach using vtkShepardMethod compare to the sampling
probes that are included with the pv-meshless plugin ? I noticed that
they produce an output called Shepard, but wasn't sure how broadly
they apply outside of SPH type of work (i.e. properly defined mass,
density, etc. fields).
Thanks again.
On Sat, Sep 11, 2010 at 3:51 AM, Favre Jean <jfavre at cscs.ch> wrote:
> _______________________________________
> I would like to map an unstructured grid (describing particle data
> with per particle attributes I would like interpolated onto the
> regular grid) onto a regular mesh. I am trying to use the 'Resample
> With Dataset' filter but have not been having much luck.
> ________________________________________
>
> As far as I understand, what you are trying to do is not possible, with the "Resample with dataset filter". The reason is that your input dataset does not seem to have 3D cells. Resampling needs 3D cells for interpolation.
>
> There is a method, vtkShepardMethod (http://www.vtk.org/doc/nightly/html/classvtkShepardMethod.html), which does exactly what you need. However, Shepard is not included in ParaView. No problem, you can do it off-line:
>
> I have tried the following python script with my paraview compilation and my ./bin/vtkpython and it produced the required output. See if it fits your purpose.
>
> from vtk import *
> numPts = 300
>
> ps = vtk.vtkPointSource()
> ps.SetRadius(1)
> ps.SetNumberOfPoints(numPts)
> ps.Update()
>
> ca = vtk.vtkFloatArray()
> ca.SetName("datavalue")
> ca.SetNumberOfComponents(1)
> ca.SetNumberOfTuples(numPts)
>
> for i in range(0, numPts):
> ca.SetValue(i, ps.GetOutput().GetPoint(i)[0])
>
> ps.GetOutput().GetPointData().AddArray(ca)
> ps.GetOutput().GetPointData().SetScalars(ca)
> ps.Update()
> ps.GetOutput().GetPointData().SetScalars(ca)
>
> sh = vtk.vtkShepardMethod()
> sh.SetSampleDimensions(20,20,20)
> sh.SetInputConnection(ps.GetOutputPort())
> sh.SetModelBounds(ps.GetOutput().GetBounds())
>
> wr = vtk.vtkDataSetWriter()
> wr.SetInputConnection(sh.GetOutputPort())
> wr.SetFileName("/tmp/foo.vtk")
> wr.Write()
>
> -----------------
> Jean M. Favre
> Swiss National Supercomputing Center
>
>
More information about the ParaView
mailing list