[Dune] How to write vector fields using VTKWriter?

Andreas Lauser andreas.lauser at iws.uni-stuttgart.de
Sat Jun 18 15:26:41 CEST 2011


Hi Jö,

Thanks, now it compiles and runs, but all my nice vectors still get split in 
the output, i.e. I get nComp scalar fields instead of one vector field with 
nComp components. If my understanding of the VTK file format is correct, it 
would be possible to write out vector fields using the  DataArray tag's 
NumberOfComponents attribute. I have not found a way to do this via VTKWriter, 
though. Is it possible?

thanks
  Andreas

Am Samstag, 18. Juni 2011, 14:19:28 schrieb Jö Fahlke:
> Am Sat, 18. Jun 2011, 14:06:51 +0200 schrieb Andreas Lauser:
> > Does DUNE provide a way to write vector fields to a VTK file? To me it
> > seems that the "nComps" argument in VTKWriter's addVertexData method is
> > there for this purpose, but unfortunately the attached example only
> > compiles for fieldDim == 1.
> 
> vtkWriter.addCellData(vector, "name", fieldDim) is meant for flat vectors,
> not nested ones.  It probably works for fieldDim==1 because
> FieldVector<K,1> and K are meant to be interoperable, while
> FieldVector<K,n> and K are not, for n!=1.
> 
> Either use a flat vector with fieldDim*cellRes[0] entries, or write an
> adapter for your nested vector to present a flat vector view, or wrap the
> vector into a VTKFunction yourself and add that to the vtkWriter.

-- 
Andreas Lauser
Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
Universität Stuttgart - Institut für Wasserbau
Pfaffenwaldring 61
D-70569 Stuttgart
Tel: (+49) 0711/ 685-64719
Fax: (+49) 0711/ 685-60430
e-mail: andreas.lauser at iws.uni-stuttgart.de




More information about the Dune mailing list