[vtkusers] Vtk and AMR

Burlen burlen at apollo.sr.unh.edu
Thu Mar 1 10:34:41 EST 2007


Hi Alex, 

before committing to vtkHierarchicalDataSet you will want to consider what 
visualization algorithms are important to you. I have found that the use of 
image data type to represent amr data prevents certain visualization 
algorithms such as contours and stream lines from working correctly at grid 
interfaces. 

The problems occur at grid interfaces and are due to the fact that the cell 
type used intrinsically in image data VTK_VOXEL & VTK_PIXEL are limitted to 
cubes and squares with 8 and 4 nodes and cell connectivity lists don't 
reflect the higher resolution across the amr grid interface. This can clearly 
be seen in the following images generated using VTK.  

For a summary of the problem and some solutions see
http://quaoar.sr.unh.edu/chhdf52FlatVtk/amr_vis_cell_types.png

If you don't want to apply any of the vtk filters to your data and all you 
care about is having each cell colored according to its value the 
vtkHierarchicalData will be suitable for your application. However if you 
plan to use more involved visualization techniques you will run into 
problems. Here is an example of the problems you might encounter if you use 
the vtkHierarchicalDataSet.
http://quaoar.sr.unh.edu/chhdf52FlatVtk/hierarch_data_issues.png

In my research I found two solutions applicable to visualization of 2d AMR 
grids. The first is to use use vtkUnstructuredGrid and VTK_POLYGON cell. The 
VTK_POLYGON  cell type uses an arbitry number of nodes, and the visualization 
algorithms work correctly across grid interfaces. 

The second solution I found was a result of the fact that many of VTK 
algorithms/filters require point data or node centered data, and my AMR data 
was cell centered in nature. In this solution one creates a new grid for 
visualization using a point set where points are at the cell centers of the 
AMR grid. These points are then triangulated using delaunay filter. This 
creates the cells and conectivity lists. The result is a vtkPolyData dataset 
which has both cell annd point data(any vtk filter will work on it) and VTK 
filter or algorithms work flawlessly across the grid interfaces. In my 
opinion this is the better of the two solutions.

Both of these solutions require that higher resolution data is used where it 
exists and that points or cells from coarser levels which overlap this data 
are discarded. this email is only in reference to 2d amr grids.

To see my methods applied to real AMR data sets check out the images at the 
bottom of this page:
http://quaoar.sr.unh.edu/chhdf52FlatVtk/index.html#gallery

-- 

Burlen Loring
Space Science Center
Institute for the Study of Earth, Oceans, and Space
University of New Hampshire
39 College Road, Durham, NH 03824
Phone: 603-862-1140







On Thursday 01 March 2007 08:16 am, Jean Favre wrote:
> alexposts at free.fr wrote:
> > Hi,
> >
> > I want to use VTK (with python : pyvtk) to visualize of 2 dimensional
> > mesh (more particulary adataptive mesh,
>
> VTK (and ParaView) support AMR data quite well. You will need something
> that creates a vtkHierarchicalDataSet for you (2D or 3D)
>
> 1)What is your data format? If that is already fixed, you will need to
> write your own reader. Otherwise, you can use a VTK XML-based format
>
> 2) VTK supports AMR where each grid is a VtkImageData. Regions of grids
> which are "covered" by sub-grids at finer resolution are "blanked-out".
>
> A *.vtm file would look like this:
>
> <?xml version="1.0"?>
> <VTKFile type="vtkHierarchicalBoxDataSet" version="0.1"
> byte_order="LittleEndian" compressor="vtkZLibDataCompressor">
>   <vtkHierarchicalBoxDataSet>
>     <RefinementRatio level="0" refinement="2"/>
>     <RefinementRatio level="1" refinement="4"/>
>     <DataSet group="0" dataset="0" amr_box="375 499 0 9 0 0"
> file="amr2d/amr2d_3.vti"/>
>     <DataSet group="0" dataset="1" amr_box="500 624 0 9 0 0"
> file="amr2d/amr2d_4.vti"/>
>     <DataSet group="1" dataset="0" amr_box="1014 1045 0 19 0 0"
> file="amr2d/amr2d_8.vti"/>
>     <DataSet group="2" dataset="0" amr_box="4072 4167 0 79 0 0"
> file="amr2d/amr2d_9.vti"/>
>   </vtkHierarchicalBoxDataSet>
> </VTKFile>
>
> you can see that the refinement ratio can change from one level to the
> other (In this example, of a 3-level hierarchy, it is 2 and 4)
> each grid is defined as a standard <VTKFile type="ImageData"> file. The
> "group" id is the AMR level, and the amr_box represents the coverage of
> the current grid with respect to the original grid in cell coordinates.
> Each grid is stored in the sub-directory amr2d.
>
> I suggest looking at http://www.vtk.org/doc/release/5.0/html/a01153.html
> for the documentation of vtkAMRBox.
>
> You may also look here
> http://www.paraview.org/doc/nightly/html/classvtkHierarchicalFractal.html
> for an example of a source generating an AMR set.
>
> Example of a practical use can be found here
> http://iacs.epfl.ch/colloqnum06/posters/18_Favre.pdf





More information about the vtkusers mailing list