contact forces in VTKrecorder
I'm sorry if this is trivial, but I have been fighting with it for a while. I need to export all spheres and contact interactions (forces and torques) in an assembly. I am using Yade daily from 2020-12-08 and VTKRecorder(
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Stránský
- Solved:
- 2021-03-15
- Last query:
- 2021-03-15
- Last reply:
- 2021-03-14
Jan Stránský (honzik) said : | #1 |
Hello,
for this kind of questions, please always provide a MWE [1]
E.g. for the code below, I can load "3d-vtk-
For "fancy" VTK exporting, you can try export.VTKExporter [2].
cheers
Jan
###
O.bodies.append([
sphere(
sphere(
sphere(
])
O.step()
vtk = VTKRecorder(
vtk()
###
[1] https:/
[2] https:/
(I failed to answer to the correct adress and now my answer is in yade-users list, sorry - duplicating here)
Hi Eleni!
Don't yo get some "*.intrs.N.vtp" file together with the *.spheres.N.vtu's and others?
Do you want to export for visualization or for acquiring data? It is a bit unusual to look for "particles involved in each contact" in some vtk.
Cheers
Bruno
Eleni Gerolymatou (elenig) said : | #3 |
Thanks for the quick reply Jan and sorry for the lack of an MWE, I missed the instructions.
I am only partly interested in the visualization and was hoping to avoid using the exporter and the recorder, but of course that is fine. What I need is a list of the contacts with contact force and torque vectors and the contacting particles. Am I right that recorder cannot provide this and I should use exporter instead? Where can I find what 'dictionary' includes?
As a workaround I found that
namefor=
a=open(namefor,'w')
for b in O.interactions:
a.write(
a.close()
works, but maybe this is not optimal?
|
#4 |
The VTK* stuff exports data to the VTK format suitable for visualizing in Paraview. So all the data are there, but if you want to do something other with them, it might not be the best choice of data format.
> Am I right that recorder cannot provide this and I should use exporter instead?
It seems like that
> Where can I find what 'dictionary' includes?
what is 'dictionary'?
> As a workaround I found that
> ...
> works, but maybe this is not optimal?
I think it is fine, especially if it works.
I would write it differently, but time spent on rewriting may easily make the approach not optimal :-D
cheers
Jan
PS: how I would write it. I haven't tested it and also would work only with newer Python versions
#
def interaction2lin
fnx,fny,fnz = i.phys.normalForce # similarly for other vector quantities
line = f"{i.id1} {i.id2} {fnx} {fny} {fnz}\n"
# f"..." is "f-string", you can use "old-style" % or .format() replacement
return line
lines = [iteraction2line(i) for i in O.interactions]
with open("force.
f.write("some heading, describing columns\n")
f.writeline
###
I suspect you have definitely no reason to use any vtk-related export. Let you explain what you need.
B
Eleni Gerolymatou (elenig) said : | #6 |
Ideally I would like to export all the contact information both as txt and to visualize in Paraview, but visualization is secondary to me. I will go with Jan's solution and only use exporter at larger intervals for viewing. Thanks a lot!
Eleni Gerolymatou (elenig) said : | #7 |
Thanks Jan Stránský, that solved my question.