[vtkusers] streamlines in a vtkUnstructuredGrid
John Biddiscombe
biddisco at cscs.ch
Mon Nov 19 09:08:27 EST 2007
The streamtracer requires cells with a finite volume to work with. You
are supplying an unstructured grid with only points defined - and this
requires an interpolation between the points in order to compute the
velocity at the streamline points.
If the points are actually part of an underlying mesh then you should
create a dataset with that topology - if the points are part of some
particle-like data and you require a customized interpolation between
the points to produce the velocity, then it requires much more work. A
simple solution is to triangulate the points using delaunay3D.
Alternatively I'm working on a streamtracer for point data using custom
interpolations, but it won't be ready for a while yet
JB
> Hi,
>
> I have an unstructured grid, which contains points (vertices).
> Each vertex has a vector as value, therefore the grid contains a
> vector field. I want to extract streamlines, however the resulting
> polydata structure is empty! I have no idea why. Any suggestions?
>
> Code:
>
>
>
> vtkPointSource *seeds = vtkPointSource::New();
> seeds->SetRadius(0.15);
> seeds->SetCenter(0, 0, 0);
> seeds->SetNumberOfPoints(6);
>
> vtkUnstructuredGrid *grid = vtkUnstructuredGrid::New();
> vtkRungeKutta4 *integ = vtkRungeKutta4::New();
> vtkStreamTracer *streamline = vtkStreamTracer::New();
> streamline->SetSource(seeds->GetOutput());
> streamline->SetIntegrationDirectionToBoth();
> streamline->SetIntegrator(integ);
>
> vtkAssignAttribute *aa = vtkAssignAttribute::New();
> aa->SetInput(grid);
> aa->Assign(vtkDataSetAttributes::SCALARS,
> vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
>
> streamline->SetInputConnection(aa->GetOutputPort());
>
> // Enter vector field data
>
> vtkPoints *points = vtkPoints::New();
> vtkFloatArray *vectors = vtkFloatArray::New();
> vtkCellArray *cell_array = vtkCellArray::New();
> vectors->SetNumberOfComponents(3);
>
> // test field... a uniform grid with (1,0,0) vectors
> for (vtkIdType i = 0; i < 1000; ++i)
> {
> int ii = i % 30;
> int jj = i / 30;
> points->InsertNextPoint(
> float(ii) / 30.0f,
> float(jj) / 30.0f,
> 0
> );
>
> cell_array->InsertNextCell(1, &i);
>
> vectors->InsertNextValue(1);
> vectors->InsertNextValue(0);
> vectors->InsertNextValue(0);
> }
>
> grid->SetCells(VTK_VERTEX, cell_array);
> grid->SetPoints(points);
> grid->GetPointData()->SetVectors(vectors);
>
> streamline->Update();
>
> // debug output
> grid->Print(std::cout);
> aa->Print(std::cout);
> streamline->Print(std::cout);
> streamline->GetOutput()->Print(std::cout);
>
> cell_array->Delete();
> vectors->Delete();
> points->Delete();
> _______________________________________________
> This is the private VTK discussion list. Please keep messages
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
--
John Biddiscombe, email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
More information about the vtkusers
mailing list