Writing a P2 function to VTK should use VTK's quadratic elements

Bug #1009441 reported by Patrick Farrell
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DOLFIN
New
Undecided
Unassigned

Bug Description

VTK supports P2 fields on triangles and tetrahedra (http://www.vtk.org/doc/nightly/html/classvtkQuadraticTriangle.html).
However, when I dump a P2 field in Dolfin to VTK, I get a P1 representation:

----------------------------------------------------------------
from dolfin import *

mesh = UnitSquare(5, 5)
P2 = FunctionSpace(mesh, "CG", 2)
P1 = FunctionSpace(mesh, "CG", 1)

print "P2.dim(): ", P2.dim()
print "P1.dim(): ", P1.dim()

v = Function(P2)
v.vector()[:] = 1.0
f = File("p2.pvd")
f << v

import os
os.system("grep NumberOfPoints p2000000.vtu")
----------------------------------------------------------------

The output of this script is:
P2.dim(): 121
P1.dim(): 36
<Piece NumberOfPoints="36" NumberOfCells="50">

i.e. the VTK file produced has 36 dof, not 121.

Would it be possible to make VTK output P2 functions without any projections to P1?

Revision history for this message
Garth Wells (garth-wells) wrote : Re: [Bug 1009441] [NEW] Writing a P2 function to VTK should use VTK's quadratic elements

I implemented this a long time ago, but VTK/ParaView did not draw
triangular cells when using high-order triangles, which was a bit
misleading for visualisation.

Garth

On 6 June 2012 13:52, Patrick Farrell <email address hidden> wrote:
> Public bug reported:
>
> VTK supports P2 fields on triangles and tetrahedra (http://www.vtk.org/doc/nightly/html/classvtkQuadraticTriangle.html).
> However, when I dump a P2 field in Dolfin to VTK, I get a P1 representation:
>
> ----------------------------------------------------------------
> from dolfin import *
>
> mesh = UnitSquare(5, 5)
> P2 = FunctionSpace(mesh, "CG", 2)
> P1 = FunctionSpace(mesh, "CG", 1)
>
> print "P2.dim(): ", P2.dim()
> print "P1.dim(): ", P1.dim()
>
> v = Function(P2)
> v.vector()[:] = 1.0
> f = File("p2.pvd")
> f << v
>
> import os
> os.system("grep NumberOfPoints p2000000.vtu")
> ----------------------------------------------------------------
>
> The output of this script is:
> P2.dim():  121
> P1.dim():  36
> <Piece  NumberOfPoints="36" NumberOfCells="50">
>
> i.e. the VTK file produced has 36 dof, not 121.
>
> Would it be possible to make VTK output P2 functions without any
> projections to P1?
>
> ** Affects: dolfin
>     Importance: Undecided
>         Status: New
>
> --
> You received this bug notification because you are a member of DOLFIN
> Core Team, which is subscribed to DOLFIN.
> https://bugs.launchpad.net/bugs/1009441
>
> Title:
>  Writing a P2 function to VTK should use VTK's quadratic elements
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/dolfin/+bug/1009441/+subscriptions

Revision history for this message
Patrick Farrell (pefarrell) wrote :

How inconvenient. I guess I'll just stick with P1 for now then ..

Revision history for this message
Gerard (g-gorman) wrote :

I just bumped into this as well. I think it really should be an option. If you cap from a higher order element to a lower order element the visualisation is also misleading, particularly for narrow channels. Separately we can also chase the VTK developers about improving higher order element visualisation as this is of wide interest.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.