How to get facet data with VTKRecorder or vtkExporter for visualization by paraview

Asked by Masayuki

Hello,

Please tell me how to get facet data for visualization by Paraview.
I tried free-fall.py in examples folder,
and just added VTKRecoder and vtkExpoter like below in order to output facet data.
However when I added VTKRecoder, I got error message "SyntaxError: invalid syntax" at line of VTKRecoder.
Also, When I added vtkExpoter, I got only one data in which facet data was initial position.

Thanks,

Masayuki

====free-fall.py====================================================
from yade import plot, polyhedra_utils, export, polyhedra_utils

gravel = PolyhedraMat()
gravel.density = 2600 #kg/m^3
gravel.young = 1E7 #Pa
gravel.poisson = 20000/1E7
gravel.frictionAngle = 0.5 #rad

steel = PolyhedraMat()
steel.density = 7850 #kg/m^3
steel.young = 10*gravel.young
steel.poisson = gravel.poisson
steel.frictionAngle = 0.4 #rad

rubber = PolyhedraMat()
rubber.density = 1000 #kg/m^3
rubber.young = gravel.young/10
rubber.poisson = gravel.poisson
rubber.frictionAngle = 0.7 #rad

O.bodies.append(polyhedra_utils.polyhedra(gravel,v=((0,0,-0.05),(0.3,0,-0.05),(0.3,0.3,-0.05),(0,0.3,-0.05),(0,0,0),(0.3,0,0),(0.3,0.3,0),(0,0.3,0)),fixed=True, color=(0.35,0.35,0.35)))

polyhedra_utils.fillBox((0,0,0), (0.3,0.3,0.3),gravel,sizemin=[0.025,0.025,0.025],sizemax=[0.05,0.05,0.05],seed=4)

def checkUnbalancedI():
    print "iter %d, time elapsed %f, time step %.5e, unbalanced forces = %.5f"%(O.iter, O.realtime, O.dt, utils.unbalancedForce())

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Wall_Aabb(),Bo1_Facet_Aabb()]),
   InteractionLoop(
      [Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom(), Ig2_Facet_Polyhedra_PolyhedraGeom()],
      [Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()], # collision "physics"
      [Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()] # contact law -- apply forces
   ),
   #GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.3,gravity=(0,0,-9.81)),
   PyRunner(command='checkUnbalancedI()',realPeriod=5,label='checker')
   VTKRecorder(iterPeriod=100,recorders=['facets'],fileName='/home/username/myYade/trunk/examples/polyhedra/render/poly-')
]

#vtkExporter = export.VTKExporter('/home/username/myYade/trunk/examples/polyhedra/render/poly-')
#vtkExporter.exportPolyhedra(what=[('n','b.id')])

O.dt=0.0025*polyhedra_utils.PWaveTimeStep()

from yade import qt
qt.Controller()
V = qt.View()
V.screenSize = (550,450)
V.sceneRadius = 1
V.eyePosition = (0.7,0.5,0.1)
V.upVector = (0,0,1)
V.lookAt = (0.15,0.15,0.1)
====free-fall.py====================================================

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Masayuki
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

However when I added VTKRecoder, I got error message "SyntaxError: invalid
> syntax" at line of VTKRecoder.

O.engines = [

   ...

   PyRunner(command='checkUnbalancedI()',realPeriod=5,label='checker')
> VTKRecorder(iterPeriod=100,recorders=['facets'],fileName=
> '/home/username/myYade/trunk/

]

As the error says, it is syntax problem. O.engines is a list and elements
are comma separated. Just add comma after PyRunner:

####################
   PyRunner(command='checkUnbalancedI()',realPeriod=5,label='checker') , #
comma here !!
   VTKRecorder(iterPeriod=100,recorders=['facets'],fileName=
'/home/username/myYade/trunk/
####################

Also, When I added vtkExpoter, I got only one data in which facet data was
> initial position.

> vtkExporter.exportPolyhedra(what=[('n','b.id')])

this exports polyhedra to a vtk file at current time step, so in your case
exactly saving just initial position. To save files regularly during
simulation, one option is to put this command into PyRunner in O.engines:

##########################
O.engines = [
   ...
   PyRunner(command='checkUnbalancedI()',realPeriod=5,label='checker'), #
comma :-)
   PyRunner(command="vtkExporter.exportPolyhedra(what=[('n','b.id')])
",iterPeriod=1000)
]
##########################

cheers
Jan

Revision history for this message
Masayuki (inba-masayuki) said :
#2

Thank you very much for quick replying,
I could save the facet data using vtkExpoter regularly, thanks to you.

About VTKRender, I forgot to add the camma, sorry for about that.
But even after I added the camma, I couldn't get proper facet data.
Each data saved by VTKRender has only about 1,210 Byte, though vtkExpoter's one has about 190,928 Byte,
and the contents of the data file doesn't have enough information obviously.

Best regards,
Masayuki

Revision history for this message
Jan Stránský (honzik) said :
#3

Hi Masayuki,

> About VTKRender, I forgot to add the camma, sorry for about that.
> But even after I added the camma, I couldn't get proper facet data.
> Each data saved by VTKRender has only about 1,210 Byte, though
> vtkExpoter's one has about 190,928 Byte,
> and the contents of the data file doesn't have enough information
> obviously.
>

saving polyhedra with VTKRecorder is not (yet) implemented..

cheers
Jan

Revision history for this message
Masayuki (inba-masayuki) said :
#4

I see, so I should use vtkExpoter for facet data.
Thank you so much for answering.

Thanks,
Masayuki

Revision history for this message
De zhang (dzlearnyade) said :
#5

Hi Jan
Did you mean that information of polyhedra could not record by VTKRecord command, as these can not be tackled by Paraview ?
Then, how to deal with the postprocessing of polyhedra ?
Thanks
De

Revision history for this message
Jan Stránský (honzik) said :
#6

Hello,
polyhedra is not yet implemented in VTKRecorder, but you can use export.VTKExporter.exportPolyhedra [1]. Open a new question if something is not clear.
cheers
Jan

[1] https://yade-dem.org/doc/yade.export.html#yade.export.VTKExporter.exportPolyhedra