[Dune] How to write vector fields using VTKWriter?

Jö Fahlke jorrit at jorrit.de
Sat Jun 18 17:46:34 CEST 2011


Am Sat, 18. Jun 2011, 15:57:23 +0200 schrieb Andreas Lauser:
> I have attached a modified version of the sample code I send earlier today plus 
> the resulting vtp file. Note that there are three scalar fields called "foo[0]", 
> "foo[1]" and "foo[2]" instead of just one vector field.

OK, I looked at the code, and the behaviour you observed is indeed intended.
I'm not sure whether this behaviour is good or not, but that doesn't really
matter since I won't change it anyway for reasons of backward compatibility.

Even using P0VTKFunction directly won't help you since it can apparantly only
ever handle one component.  I guess you'll have to write your own VTKFunction
wrapper for your vector.

Alternatively you can extend the P0VTKFunction constructor to the number of
components to export as an additional argument:

  P0VTKFunction(const GV &gv, const V &v_, const std::string &s_,
                int ncomps = 1, int mycomp = 0, int myncomps = 1);

This could then be used in addCellData():

  typedef P0VTKFunction<GridView, Field> VTKFunction;
  vtkWriter.addCellData(
    shared_ptr<VTKFunction>(
      new VTKFunction(grid.leafView(), field, "foo", fieldDim, 0, fieldDim)));

Of course, this is an interface addition, so we have to discuss it first.
Pending a positive outcome, I think a patch would be appreciated.

@Dune: Is anybody opposed to this or has any better ideas?

Bye,
Jö.

-- 
P.S: P.S. in Emails ist ziemlich überflüssing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20110618/efd4e9ac/attachment.sig>


More information about the Dune mailing list