Output PVD with a different variable name

Asked by Chris Richardson

I want to save some output to a PVD file to view in Paraview, but with a "name" other than "U" (which seems to be the default).
This is useful if you have more than one field to visualise.

I have been changing the following lines in the VTU output using a text filter... but I was wondering if there is a better way?

e.g. change

<PointData Scalars="U">
<DataArray type="Float32" Name="U" format="ascii">

to

<PointData Scalars="T">
<DataArray type="Float32" Name="T" format="ascii">

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Anders Logg
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

You should be able to do just that by renaming the field you are saving:

  u.rename("T", "temperature");

--
Anders

On Mon, Jun 21, 2010 at 10:31:55AM -0000, Chris Richardson wrote:
> New question #115298 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/115298
>
>
> I want to save some output to a PVD file to view in Paraview, but with a "name" other than "U" (which seems to be the default).
> This is useful if you have more than one field to visualise.
>
> I have been changing the following lines in the VTU output using a text filter... but I was wondering if there is a better way?
>
> e.g. change
>
> <PointData Scalars="U">
> <DataArray type="Float32" Name="U" format="ascii">
>
> to
>
> <PointData Scalars="T">
> <DataArray type="Float32" Name="T" format="ascii">
>
> Thanks!
>

Revision history for this message
Chris Richardson (chris-bpi) said :
#2

I tried this test:

from dolfin import *

m=UnitSquare(20,20)
Q=FunctionSpace(m,"CG",1)
F=Function(Q)
F.rename("F","function")

file=File("f.pvd")
file << F

but I still get this is f000000.vtu:

<PointData Scalars="U">
<DataArray type="Float32" Name="U" format="ascii">

Revision history for this message
Best Anders Logg (logg) said :
#3

On Mon, Jun 21, 2010 at 11:41:00AM -0000, Chris Richardson wrote:
> Question #115298 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/115298
>
> Status: Answered => Open
>
> Chris Richardson is still having a problem:
> I tried this test:
>
> from dolfin import *
>
> m=UnitSquare(20,20)
> Q=FunctionSpace(m,"CG",1)
> F=Function(Q)
> F.rename("F","function")
>
> file=File("f.pvd")
> file << F
>
> but I still get this is f000000.vtu:
>
> <PointData Scalars="U">
> <DataArray type="Float32" Name="U" format="ascii">

ok. Looks like the name is ignored in VTKFile.cpp. I'll fix it.

--
Anders

Revision history for this message
Chris Richardson (chris-bpi) said :
#4

Thanks Anders Logg, that solved my question.

Revision history for this message
Anders Logg (logg) said :
#5

On Mon, Jun 21, 2010 at 01:58:31PM +0200, Anders Logg wrote:
> On Mon, Jun 21, 2010 at 11:41:00AM -0000, Chris Richardson wrote:
> > Question #115298 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/115298
> >
> > Status: Answered => Open
> >
> > Chris Richardson is still having a problem:
> > I tried this test:
> >
> > from dolfin import *
> >
> > m=UnitSquare(20,20)
> > Q=FunctionSpace(m,"CG",1)
> > F=Function(Q)
> > F.rename("F","function")
> >
> > file=File("f.pvd")
> > file << F
> >
> > but I still get this is f000000.vtu:
> >
> > <PointData Scalars="U">
> > <DataArray type="Float32" Name="U" format="ascii">
>
> ok. Looks like the name is ignored in VTKFile.cpp. I'll fix it.

Should be fixed now.