How to plot vector plot in Paraview for particle displacement of simulation run in Yade?

Asked by Nicholas Ng on 2019-05-29

Hi all,

I'm running a direct shear test simulation in Yade, and for postprocessing, I would like to plot vector plots (in ParaView) for particle displacement throughout the direct shear test simulation.

Initially, I use the "VTKRecorder" engine command and set "recorders='all' " to extract output files for postprocessing in ParaView later.

However, when I launch the VTU files for spheres in ParaView, and try to plot vector plot, i notice that there is no option of particle displacement. My ultimate goal here is to plot vector plot for particle displacement, so it seems like the VTKRecorded engine command does not work for me.

Is there any other type of data I can extract from Yade which capture the particle displacement throughout simulation? SO that I can plot the vector plot based on particle displacement later in ParaView.

I forward my thanks for your kind attention on the matter above.

Regards,
Nicholas Ng

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Nicholas Ng
Solved:
2019-05-29
Last query:
2019-05-29
Last reply:
2019-05-29
Jérôme Duriez (jduriez) said : #1

Hi,

I guess you could use VTKExporter.exportSpheres() [*] command, including yourself displacement data in the "what" atribute of that command.

[*] https://yade-dem.org/doc/yade.export.html#yade.export.VTKExporter.exportSpheres

Jan Stránský (honzik) said : #2

Hi Nicholas,

you can use export.VTKExporter [1], created exactly for this purposes:

###
# something simple to save
from yade import export
s1,s2 = sphs = (
   sphere((1,2,3),4),
   sphere((5,6,7),8),
)
s1.state.vel = (2,3,4)
s2.state.vel = (5,6,7)
O.bodies.append(sphs)
O.step()
# actual save
vtk = export.VTKExporter("dspl-export")
vtk.exportSpheres(
   useRef=True, # saves original position of particles, use it or not according to your needs
   what=[("dspl","b.state.displ()")] # saves displacement vector, labeled 'dspl' in Paraview
)
###

you can also use the last command in PyRunner

cheers
Jan

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

Nicholas Ng (nngyongjie) said : #3

Thanks Jerome!

Nicholas Ng (nngyongjie) said : #4

Thanks Jan Stransky!

Nicholas Ng (nngyongjie) said : #5

But I notice I face the same problem as that of [1]:

I only have 1 vtk file generated with "...spheres-0000.vtk"

Then I follow the advice given as reply to [1], i use "def doExport():" function for vtkExporter command, then I use PyRunner for that function to loop for iterPeriod=100.

However, after I made all these changes, I still only get 1 vtk file with "...spheres-0000.vtk", I'm not sure where's the mistake?

Regards,
Nicholas

[1] https://answers.launchpad.net/yade/+question/673124

Jan Stránský (honzik) said : #6

please, provide a MWE [1]
thanks
Jan

[1] https://yade-dem.org/wiki/Howtoask

Nicholas Ng (nngyongjie) said : #7

Hi Jan,

I attach the engine commands I used in my script together with the vtkExporter command for your reference.

=======================================================

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb(),],verletDist=.05*radius_mean),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 PyRunner(iterPeriod=100, command='doExport()')

]
O.dt=5e-2*PWaveTimeStep()

def doExport():
 vtk= export.VTKExporter('.../101_dspl-')
 vtk.exportSpheres(useRef=True,what=[('dspl','b.state.displ()')])

===========================================================================

Do I make any mistake in command?

Regards,
Nicholas

Jan Stránský (honzik) said : #8

Thanks for the code

> Do I make any mistake in command?

yes :-)

VTKExporter remembers how many times it saved something and use contiguous numbering, starting from 0. In your case, every time doExport is called, it creates new VTKExporter, which starts saving from 0.

Fix:
###
vtk= export.VTKExporter('.../101_dspl-') # called only once
def doExport():
 vtk.exportSpheres(useRef=True,what=[('dspl','b.state.displ()')]) # now each time a new file with new number is saved
###

cheers
Jan

Nicholas Ng (nngyongjie) said : #9

Thanks a lot Jan, this really solved my problem!