[Dune] How to write vector fields using VTKWriter?

Christian Engwer christian.engwer at uni-muenster.de
Sun Jun 19 20:51:26 CEST 2011


On Sat, Jun 18, 2011 at 03:26:41PM +0200, Andreas Lauser wrote:
> 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?

I did this several times. You have to write your own VTKFuntion which
outputs 3-comp data. This can then be attached via addCellData or
addVertexData.

Christian

> 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
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
> 



More information about the Dune mailing list