← Back to team overview

yade-users team mailing list archive

Re: [Question #696037]: contact forces in VTKrecorder

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
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 interaction2line(i):
    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.txt","w") as f: # no need to close it if you use 'with'
    f.write("some heading, describing columns\n")
    f.writelines(lines)
###

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