[Paraview] Animation. Second view of a field variable. How to format the file.

David E DeMarle dave.demarle at kitware.com
Fri Sep 12 10:01:06 EDT 2008


Hi Christer,

Hope you don't mind, I've posted back to the list. We at Kitware get
paid by the email response, and others on the list might benefit from
the discussion.

It's very easy to get the file format wrong when you do it by hand.
Plus I'm lazy so I let paraview to do it for me. I've attached an
example vts file with field data.

To create it I opened a SampleStructGrid.vtk from the VTKData
respository, extracted a smaller portion with ExtractVOI, wrote a
python filter script to add a field data array to it, then saved it in
vts format in ascii mode for readability.

Here is the script ( If you go this route make sure you copy the point
and cell centered data across too).
:
sgo = self.GetOutput()
fa = vtk.vtkDoubleArray()
fa.SetName("MyFieldData")
fa.SetNumberOfComponents(1)
fa.SetNumberOfTuples(1)
fa.SetValue(0, 23.1)
sgo.GetFieldData().AddArray(fa)

Here is the file:
<?xml version="1.0"?>
<VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian"
compressor="vtkZLibDataCompressor">
 <StructuredGrid WholeExtent="0 2 0 3 0 4">
   <FieldData>
     <DataArray type="Float64" Name="MyFieldData" NumberOfTuples="1"
format="ascii" RangeMin="23.1" RangeMax="23.1">
       23.1
     </DataArray>
   </FieldData>
 <Piece Extent="0 2 0 3 0 4">
   <PointData>
   </PointData>
   <CellData>
   </CellData>
   <Points>
     <DataArray type="Float32" Name="Array 0x28f46b70"
NumberOfComponents="3" format="ascii" RangeMin="0.00041642661321"
RangeMax="0.13911091179">
       3.9079900548e-16 9.8539503597e-06 0.00041631000931
0.0017664299812 0.003646020079 0.025913299993
       0.00092297600349 0.0048721698113 0.055267501622 0.008619049564
0.032692201436 0.00052579498151
       0.0096672996879 0.028342800215 0.025821000338 0.0027031500358
0.025742599741 0.056762300432
       0.0090828295797 0.05774410069 0.0036606499925 0.0094428798184
0.058848198503 0.029451699927
       0.0016302800504 0.054248198867 0.05479849875 0.0011574799428
0.076589100063 0.0099264401942
       0.006815710105 0.083117999136 0.031422201544 0.0032934199553
0.082375496626 0.058234799653
       0.025214800611 0.0064775100909 0.0075736502185 0.027748899534
0.0040851701051 0.027120700106
       0.026027999818 0.0029381199274 0.056614499539 0.030439399183
0.028574500233 0.0058140899055
       0.026072500274 0.033174499869 0.034619800746 0.025310199708
0.032492898405 0.055563498288
       0.03323860094 0.057029701769 0.0058075999841 0.033679101616
0.052974499762 0.026920899749
       0.028760500252 0.056967001408 0.054102901369 0.026873700321
0.078734099865 0.0093246996403
       0.025664899498 0.082796797156 0.029375499114 0.03076050058
0.083946399391 0.050150398165
       0.053662899882 0.0020936198998 0.00016252600471 0.057337298989
0.006669760216 0.026657199487
       0.050119400024 0.0017834899481 0.057782001793 0.056301899254
0.032688699663 0.0012282000389
       0.056413199753 0.030389100313 0.028318099678 0.055608499795
0.025063499808 0.054603599012
       0.050107099116 0.050262399018 0.0031425000634 0.057066701353
0.054295301437 0.029494099319
       0.05230730027 0.05301560089 0.05106529966 0.057277198881
0.08301910013 0.0074676801451
       0.055973399431 0.075770698488 0.027219099924 0.055399600416
0.082076601684 0.050319399685
       0.076378703117 0.0056706001051 0.007513590157 0.082239799201
0.0072674001567 0.026879800484
       0.080981098115 0.0052918200381 0.05692749843 0.082763902843
0.034413900226 0.0059878798202
       0.076454997063 0.032041601837 0.027205599472 0.079167798162
0.026365099475 0.05625839904
       0.078506201506 0.057479999959 0.0065251099877 0.076115898788
0.058255400509 0.025970499963
       0.084707796574 0.059879798442 0.053907699883 0.080385901034
0.078408002853 0.001676170039
       0.079719297588 0.082419998944 0.03171569854 0.083178497851
0.08456210047 0.05185129866
       0.10174199939 0.0018769500311 0.0078943604603 0.10023999959
0.0038523899857 0.028501899913
       0.10653100163 0.0047191400081 0.05448500067 0.10994999856
0.034004800022 0.0070902002044
       0.10727100074 0.032273400575 0.02829680033 0.10024300218
0.025430399925 0.050955500454
       0.10299800336 0.054873399436 0.0090223997831 0.10284599662
0.053273700178 0.026439199224
       0.10067400336 0.058490801603 0.054035000503 0.10845500231
0.080683797598 0.0031153000891
       0.10098700225 0.079468302429 0.026815200225 0.10461200029
0.075355403125 0.052246898413
     </DataArray>
   </Points>
 </Piece>
 </StructuredGrid>
</VTKFile>


On Fri, Sep 12, 2008 at 4:20 AM, Christer Gustafsson
<gustaf at powertech.no> wrote:
> David,
>
> Thank you for your response! I intend to thank you over the list once the
> things get going, which it unfortunately does not do yet.
> Maybe you could give me a hint about where I misunderstand you?
>
> First I tried to insert text according to your pattern below in may existing
> vts-files which have the following structure:
>
> <?xml version="1.0"?>
> <VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian"
> compressor="vtkZLibDataCompressor">
> <StructuredGrid WholeExtent="0 1 0 40 0 91">
>  <Piece Extent="0 1 0 40 0 45">
>  <PointData Scalars="Temperature">
>   <DataArray type="Float32" Name="Temperature" format="ascii">
>   </DataArray>
>  </PointData>
>  <CellData>
>  </CellData>
>  <Points>
>   <DataArray type="Float32" Name="P0" NumberOfComponents="3" format="ascii">
>   </DataArray>
>  </Points>
>  </Piece>
>  <Piece Extent="0 1 0 40 46 91">
>  <PointData Scalars="Temperature">
>   <DataArray type="Float32" Name="Temperature" format="ascii">
>   </DataArray>
>  </PointData>
>  <CellData>
>  </CellData>
>  <Points>
>   <DataArray type="Float32" Name="P46" NumberOfComponents="3"
> format="ascii">
>   </DataArray>
>  </Points>
>  </Piece>
>  --- Here ----
> </StructuredGrid>
> </VTKFile>
>
> When running the pvd-file all was read but I could not see any track of new
> FieldData. Then I abandoned this method.
>
> Second try: you begin with a VTKFile and I read as attentively I could in
> the VTK User's Guide at pp. 336-339 and constructed
> the following vts-file(s):
>
> <?xml version="1.0"?>
> <VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian"
> compressor="vtkZLibDataCompressor">
> <StructuredGrid WholeExtent="0 0 0 0  0  0">
>  <Piece Extent="0 0 0 0 0 0">
>  <FieldData>
>   <DataArray type="Float32" Name="SF1" NumberOfTuples="1" format="ascii">
>     50.0
>   </DataArray>
>  </FieldData>
>  </Piece>
> </StructuredGrid>
> </VTKFile>
>
> And now ParaView (?) complains about one of two suggested errors:
>   a piece is missing its Points element
>   element does not have exactly one array
>
>
> Please tell me where have I misunderstood you?
>
> Regards,
> Christer
>
>
> David E DeMarle wrote:
>>
>> You could save K(t) as field data. Then you can extract the zero'th
>> entry in the K array (which has just one element) and plot that over
>> time. A vts file with field data in it looks something like this...
>>
>> <VTKFile type="StructuredGrid" [snip]
>> <StructuredGrid WholeExtent=[snip]>
>> <FieldData>
>> <DataArray type="Float64" Name="MyField" NumberOfTuples="1" format="ascii"
>> RangeMin="26.1" RangeMax="26.1">
>> 26.1
>> </DataArray>
>> </FieldData>
>> [snip]
>>
>> On Mon, Sep 8, 2008 at 12:30 AM, Christer Gustafsson
>> <gustaf at powertech.no> wrote:
>>>
>>> Hi All,
>>>
>>> The data (x_i(t),y_i(t),z_i(t)) is formatted as one pvd and many vts
>>> file.
>>> The animation runs fine in one 3D view.
>>>
>>> In addition there is an associated time-varying function (t,K(t)) (e.g.
>>> the
>>> kinetic energy of the system). I would like to create a second view and
>>> herein animate K(t) along with the 3D view.
>>>
>>> In what file format (example?) would the (t,K(t)) be cast in order to
>>> make
>>> the animations in two views be possible? (The ParaView Guide talks about
>>> `unaligned data items' in connection with `Time' in Chapter 10, section
>>> 10.3, but from that point on I find no more path).
>>>
>>> Thanks,
>>> ChG
>>>
>>> _______________________________________________
>>> ParaView mailing list
>>> ParaView at paraview.org
>>> http://www.paraview.org/mailman/listinfo/paraview
>>>
>>
>
>


More information about the ParaView mailing list