Creating an animation of interactions using VTKExporter and Paraview

Asked by Ákos Orosz on 2017-09-11

Hi all,

I would like to create an animation using VTKExporter and Paraview, displaying interaction forces as constant radius tubes with their radii proportional to the force magnitudes [1]. I used the 3d postprocessing tutorial script for testing.
Here are the embedded code segments:

####################################################################
...
PyRunner(command='intexp()',iterPeriod=100),

def intexp ():
 export.VTKExporter(str(O.iter)+'.vtk').exportInteractions(what=[('forceN','i.phys.normalForce.norm()')])
...
####################################################################

This indicates 2 problems:
1. The output file names have the following form: ’[iternumber].vtk-intrs-00000000.vtk’. I think, the zeros should display the iteration number, but they remain constant. Because of this, Paraview cannot recognize the files as a group, and create an animation from them [2]. If I ’manually’ delete the zeros, everything works.
2. If there are no interactions in the simulation, no file is created (instead of making an ’empty’ file). Is there a way to modify this? I also tried to manually create a blank .vtk file to fill the gaps, but I could not find the proper format, as when I deleted the data and set everything to zero, I got an error message.
Coluld you please help to find a way to create a proper animation, without skipping frames? Thank you.

[1] https://yade-dem.org/doc/user.html#rendering-interactions-as-force-chain
[2] https://www.paraview.org/Wiki/Animating_legacy_VTK_file_series

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2017-09-12
Last query:
2017-09-12
Last reply:
2017-09-12
Robert Caulk (rcaulk) said : #1

Hello Ákos,

If you only need the interactions sized proportionally to their forces, you should use VTKRecorder [1] with 'intr':

VTKRecorder(fileName=('out/test-'), iterPeriod=100, initRun=True, recorders=['intr'])

You should add this as one of your engines, it will take care of proper file naming for you.

Best,

Robert

[1]https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.VTKRecorder

Ákos Orosz (oakos) said : #2

Hello Robert,

Thank you for your answer. I already tried VTKRecorder with success, but in this case the result at the end is a little bit different: I get cones instead of cylinders with constant radius, such as [1] describes. Also the interactions acting through the periodic boundary are not shown, so I would prefer VTKExporter, if it is possible. I am also planning to animate polyhedra with the created method, where only VTKExporter can be used.

Thanks,
Ákos

[1] https://yade-dem.org/doc/user.html#rendering-interactions-as-force-chain

>I am also planning to animate polyhedra with the created method, where only VTKExporter can be used

You could also use both, Exporter for the polyhedra, Recorder for the forces, then combine the output in paraview.
B

Best Jan Stránský (honzik) said : #4

Hello,

1) the idea of VTKExporter is that one instance remembers how many times it did the export, saves the data using that info and paraview then recognize it as a sequence

PyRunner(command='intexp()',iterPeriod=100),

vtk = export.VTKExporter(someBase) # e.g. someBase could be "output"
def intexp ():
   vtk.exportInteractions(what=[('forceN','i.phys.normalForce.norm()')]) # using this one 'vtk' instance, not creating each time the new one

2)
you can define a function to produce a valid empty vtk file:
##
def vtkEmptyFile():
   fName = vtk.baseName+'-intrs-%04d'%(vtk.intrsSnapCount)+'.vtk'
   with open(fName,'w') as f:
      f.writelines(l+"\n" for l in (
         "# vtk DataFile Version 3.0",
         "empty file",
         "ASCII",
         "",
         "DATASET POLYDATA",
         "POINTS 0 double",
         "LINES 0 0",
      ))
   vtk.intrsSnapCount += 1
...
def intexp ():
   if len([i for i in O.interactions]) == 0:
      vtkEmptyFile()
   else:
      vtk.exportInteractions(...)
##

cheers
Jan

Ákos Orosz (oakos) said : #5

Thanks Jan Stránský, that solved my question.