Export velocity and force

Asked by Mu Wh

Hi!
I want to export the force and the velocity in 02-gravity-deposition.py[1] to ParaView through vtkExporter. In vtkExporter, the parameter of ‘what (dictionary)’ can export scalar, vector, and tensor variables. I read some of the earlier responses[2-4] and Yade Documentation. I have written a vtkExport function according to [5], but I still have several problems:
1. The variables of what(dictionary) content coordnumber, forceLen, forceVec, stressLen, stressVec, torqueLen, torqueVec[3]. I want to know the meaning of coordnumber, ‘Vec’, and ‘Len’. In addition, I would like to know which variables can be referenced in what (dictionary) and how to describe them correctly.
2. The different supported export types like exportContactPoints, exportSpheres, and exportInteractions.etc. I want to export the force of spheres and facets, and these force parameters need to be entered into those export types.

Here is the MWE:

from yade import pack, plot, export
O.bodies.append(geom.facetBox((.5, .5, .5),(.5, .5, .5),wallMask=31))
sp = pack.SpherePack()
sp.makeCloud((0, 0, 0),(1, 1, 1),rMean= .02,rRelFuzz= .5)
sp.toSimulation()
O.engines=[
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
        InteractionLoop(
                [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
                [Ip2_FrictMat_FrictMat_FrictPhys()],
                [Law2_ScGeom_FrictPhys_CundallStrack()]
        ),
        NewtonIntegrator(gravity=(0, 0, -9.81),damping=0.4),
        PyRunner(command='vtkExport()', iterPeriod=100),
        PyRunner(command='checkUnbalanced()', realPeriod=2),
        PyRunner(command='addPlotData()', iterPeriod=100)
]
O.dt= .5* PWaveTimeStep()
O.trackEnergy = True
vtkExporter= export.VTKExporter('deposited')

def vtkExport():
    vtkExporter.exportSpheres(ids='all',what=dict(particleVelocity='b.state.vel'))
    vtkExporter.exportFacets(ids='all',what={'pos': 'b.state.pos'})
    vtkExporter.exportInteractions(ids='all',what=dict(kn='i.phys.kn'))
    vtkExporter.exportContactPoints(ids='all',what={'nn': 'i.geom.normal'})

def checkUnbalanced():
        if unbalancedForce() < .05:
              O.pause()
def addPlotData():
       plot.addData(i=O.iter, unbalanced=unbalancedForce(), **O.energy)
plot.plots={'i': ('unbalanced', None, O.energy.keys)}
plot. Plot()
O.saveTmp()

Cheers,
Weihao Mu

[1] https://gitlab.com/yade-dev/trunk/blob/master/doc/sphinx/tutorial/02-gravity-deposition.py
[2] https://answers.launchpad.net/yade/+question/689234
[3] https://answers.launchpad.net/yade/+question/695966
[4] https://answers.launchpad.net/yade/+question/689542
[5] https://gitlab.com/yade-dev/trunk/-/blob/master/examples/test/vtk-exporter/vtkExporter.py

Question information

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

Hello,

> I want to know the meaning of coordnumber, ‘Vec’, and ‘Len’.

The code is IMO self-explanatory, but:

('coordnumber','len(b.intrs())'),
[6]
b.intrs() -> list of interactions of the body
len(intrs()) -> length ot this list, number of interactions of the body (coordination number)

('forceVec','O.forces.f(b.id)'),
[7]
body force vector

('forceLen','O.forces.f(b.id).norm()'),
norm of body force vector, body force vector magnitude / length

> In addition, I would like to know which variables can be referenced in what (dictionary)

any variable you can get in python using "b" as the body instance (or "i" for interactions, see documentation)

> and how to describe them correctly.

what does "describe" mean?

> 2. The different supported export types like exportContactPoints, exportSpheres, and exportInteractions.etc.

different "export types" export different entities (spheres, facets, interactions, contact points)...

> I want to export the force of spheres and facets, and these force parameters need to be entered into those export types.

.exportSpheres(what=dict(...,f="O.forces.f(b.id)"))
.exportFacets(what={...,"f":"O.forces.f(b.id)"})

Cheers
Jan

[6] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.Body.intrs
[7] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.ForceContainer.f

Revision history for this message
Mu Wh (muwh-2023) said :
#2

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

Revision history for this message
Mu Wh (muwh-2023) said (last edit ):
#3

Hi!
Thank you for your reply, and your answer has solved the questions. Furthermore, I found several interesting points in vtkExporter which I want to check with you.

> Whether spheres, facets, interactions, and contactpoints in ParaView have the same units as those in Yade?

>I found there are several formats of exportSpheres, exportFacets, exportInteractions, and exportContactPoint [5] as below. I tried two formats that can export information about spheres, facets, interactions, and contactpoints, and I think the two formats are correct representations.
(1) vtkExporter.exportSpheres(what=dict(dist='b.state.pos.norm()'))
(2) vtkExporter.exportFacets(what={'pos': 'b.state.pos'})

> The export information of spheres contains velocity and force. However, the coloring in the Glyph of spheres contains ‘Normals’ options, but the cloud map of spheres is irregular in Paraview 5.7.0. I think the ‘Normals ’ is meaningless.

Cheers,
Weihao Mu

[5] https://gitlab.com/yade-dev/trunk/-/blob/master/examples/test/vtk-exporter/vtkExporter.py

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

> Whether spheres, facets, interactions, and contactpoints in ParaView have the same units as those in Yade?

Yade have no units, just numbers.
What you import in Paraview are the same numbers as you export from Yade.
So in this sense they have the "same units".

But in general, during Yade export and then in Paraview you can "screw" the numbers in any arbitrary way.

> I think the two formats are correct representations.
> (1) vtkExporter.exportSpheres(what=dict(dist='b.state.pos.norm()'))
> (2) vtkExporter.exportFacets(what={'pos': 'b.state.pos'})

if you want to export distance of spheres from coordinates origin (1) and position of facets "center" (2), then it is correct.

> the coloring in the Glyph of spheres contains ‘Normals’ options, but the cloud map of spheres is irregular in Paraview 5.7.0. I think the ‘Normals ’ is meaningless.

It may be.
However, this is now fully Paraview field and probably does not belong to Yade discussion...

Cheers
Jan

Revision history for this message
Mu Wh (muwh-2023) said :
#6

Thanks Jan, What you said is right, cheers!