← Back to team overview

yade-users team mailing list archive

Re: [Question #703920]: How to excute the VTKRecorder at virtual time

 

Question #703920 on Yade changed:
https://answers.launchpad.net/yade/+question/703920

Jan Stránský proposed the following answer:
>
VTKRecorder(fileName='3d-vtk-',recorders=['all','bstresses'],virtPeriod
= 3,nDo = 5)

this creates VTKRecorder engine.
Just create, it does not any output:
- it is not called
- it is not included in O.engines

Below are two possible approaches (rewritten to iterPeriod, but it would
be same with virtPeriod or realPeriod)


##################################
# MWE1, VTKRecorder inside O.engines
b = sphere((0,0,0),1)
b.state.vel = (1,0,0)
O.bodies.append(b)

O.engines += [
    PyRunner(iterPeriod=20,command="enableVtk()",label="enabler"),
    VTKRecorder(dead=True,fileName="test2",iterPeriod=3,nDo=5,label="vtk"),
]

def enableVtk():
    enabler.dead = True
    vtk.dead = False

O.run(100,True)
##################################


##################################
# MWE2, VTKRecorder called
b = sphere((0,0,0),1)
b.state.vel = (1,0,0)
O.bodies.append(b)

vtk = VTKRecorder(fileName="test1")
# vtk() , calling the instance, does the export, not just creating VTKRecorder(...)

O.engines += [
    PyRunner(iterPeriod=20,command="enableVtk()",label="enabler"),
    PyRunner(dead=True,iterPeriod=3,nDo=5,command="vtk()",label="vtkCaller"),
]

def enableVtk():
    enabler.dead = True
    vtkCaller.dead = False

O.run(100,True)
##################################

Cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.