[vtkusers] How to write discontinuous field data
John Platt
jcplatt at dsl.pipex.com
Wed Jun 18 15:27:48 EDT 2008
Hi Serge,
Take a look at vtkShrinkFilter in the docs for a description of
shrinking. Setting a shrink factor of 1 has the effect of uncoupling all
the cells but leaving the geometry unchanged. The trick is just to store
the original node numbers as point data. When vtkShrinkFilter executes,
it creates new cells with unique point Ids but with the original node
number stored as point data. You can now iterate over the topology of
all the cells, get the original node number from the point data and
create the discontinuous point data at the new node VTK has generated.
With a shrink factor of 1, vtkShrinkFilter creates plenty of coincident
points. Some filters will detect if a point Id with the same coordinates
already exists and use this earlier point Id in the cell topology
instead of the supplied Id. This will defeat the purpose of the shrink.
HTH
John.
-----Original Message-----
From: Serge Lalonde [mailto:serge at infolytica.com]
Sent: 18 June 2008 15:06
To: John Platt
Subject: Re: [vtkusers] How to write discontinuous field data
Hi John,
Thanks for your reply. I just succeeded in getting my discontinuous
field to work by doing pretty much what you just described. It's a real
shame that they don't support this better because it is a real waste of
time and memory otherwise. It seems to be the norm though, because I
evaluated Open Inventor from Mercury a couple of years ago and they had
the same limitation.
I am expecting similar limitations when I move to evaluate with high
order elements since VTK only supports up to quadratic elements (we
support 0-4 in 2D and 0-3 in 3D).
If you have a moment, could you explain what you meant about shrinking
the mesh and turning off the merging of points? Isn't a shrink (which I
assume means a scale) by a factor of 1 a no-op? What does point merging
do? For now, I am not programming with VTK directly, since I am
generating the .vtk files for viewing in ParaView, so maybe those issues
don't apply?
Serge
John Platt wrote:
> VTK does not support point data on a cell by cell basis. A hack I have
> used is to shrink the mesh using a shrink factor of 1 and then set the
> point data. Unfortunately, this requires some significant programming
> effort and is inefficient because it duplicates nodal positions. You
> must give each cell unique point IDs and turn off merging of points.
>
> Given that many real problems have scalar gradients that are
> discontinuous across interfaces, personally, I think this is a serious
> shortcoming.
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
> Behalf Of Serge Lalonde
> Sent: 17 June 2008 16:38
> To: vtkusers at vtk.org
> Subject: [vtkusers] How to write discontinuous field data
>
> I'm using ParaView in order to evalutate the visualization
capabilities
> of VTK. In order to do a fair evaluation, I am exporting the
> discontinuous scalar field data from our current application (a
magnetic
>
> FE field solver) to a .vtk file (using the ASCII simple legacy format
> according to http://www.vtk.org/pdf/file-formats.pdf).
>
> The problem is that I can't seem to figure out how to write out the
> discontinuous scalar field. I searched the help and the archives and
> this isn't covered anywhere. There are references to "pulling your
hair
> out", and that it is supported, but it's not explained. Help!
>
> Here is my setup:
> - Tetrahedral elements (hence the data set is an unstructured grid)
> - The scalar field is discontinuous at the cell boundaries. This means
> that my field stores a (possibly different) value for each point,
based
> on which cell is accessed.
>
> I tried generating the following file (abbreviated):
>
> # vtk DataFile Version 3.0
> Export of the mesh and field data for the field.
> ASCII
> DATASET UNSTRUCTURED_GRID
> POINTS 3196 double
> <x y z values for all 3196 points here>
> ...
> CELLS 16528 82640
> 4 <four 0-based indices into the points above to describe all the
16528
> tetrahedra>
> ...
> CELL_TYPES 16528
> 10 <repeated 16528 times because all elements are tetrahedra>
> ...
> CELL_DATA 16528
> FIELD ScalarField 1
> FieldNameHere 4 16528 double
> <four field values to specify the field values at each point of the
> tetrahedra for all 16528 tetrahedra>
> ...
>
> When I open this file, it almost looks right except that ParaView
> calculates the magnitude of the four values for each cell when I
select
> "FieldNameHere" and displays that. So I never see any field variation
in
>
> a cell. I suspect that I have to use POINT_DATA, but I am unclear on
how
>
> to specify multiple scalar values (one for each cell sharing that
> point).
>
> How can this be specified? Would I be better off using the XML file
> format? Do I have to lose the connectivity of my mesh to get what I
want
>
> (i.e. repeat the same point N-times, where N is the number of times
the
> point is shared by a cell)?
>
More information about the vtkusers
mailing list