Access to UNV facets

Asked by Przemek on 2019-12-03

Hi,

I have a question about the ymport module. I my script I loaded UNV geometry with returnConnectivityTable True value. And now, how I can access to the data of facets?
I wish to use some properties of those facets like, area and coordinates of each area center. Is it possible?

BR
Przemek

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-12-04
Last query:
2019-12-04
Last reply:
2019-12-03
Jan Stránský (honzik) said : #1

Hi Przemek,

> Is it possible?

of course :-)

###
from yade import ymport
facets,nodes,connectivity = ymport.unv(...,returnConnectivityTable=True)
# now facets is list of created facets
for f in facets:
   print(f.shape.area)
   print(f.state.pos) # center of inscribed circle, not center of mass (!)
   # whatever else
###

cheers
Jan

Przemek (przemekn) said : #2

Thanks Jan, and I have one more question to this topic.

In my script, I used command

rod = O.bodies.append(ymport.unv('Geometry/tool.unv',scale=1e-3,returnConnectivityTable=False,wire=False,color=toolColor))

to move this geometry. So the facets coordinates changes in every iteration. Can I connect this two imports to read current position of each facet?

BR
Przemek

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

Sorry, I did not get your question at all :-)

> I used command
> rod = O.bodies.append(ymport.unv(...))
> to move this geometry. So the facets coordinates changes in every iteration

this command dos not imply any move nor coordinate changes..

> Can I connect this two imports to read current position of each facet?

what does "connect" mean here? and "read" and "current position"?

Jan

Przemek (przemekn) said : #4

Sorry, my last comment was not described precisely. My fault.

I'm using this geometry (rod) in O.engines section, that's why I didn't attach it earlier.
It rotates and translates. And I want to apply a function which depends on area and position of each facet in current iteration (area is constant, but position changes due to the combined motion).
So, I want to have an access to to this data.

I hope that this description is more understandable :)

Przemek

Best Jan Stránský (honzik) said : #5

> I hope that this description is more understandable :)

not really :-D

> So, I want to have an access to to this data.

you have access to facet data the same way as any other shape..
###
for b in O.bodies:
   if not isinstance(b.shape,Facet): continue # skip non-facet bodies
   area = b.shape.area
   position = b.state.pos
   ... # whatever with area and position
###
or
###
def functionWhichDependsOnAreaAndPositionOfEachFacet(facet):
   area = facet.shape.area
   position = facet.state.pos
   ... # whatever with area and position

for b in O.bodies:
   if not isinstance(b.shape,Facet): continue # skip non-facet bodies
   functionWhichDependsOnAreaAndPositionOfEachFacet(b)
###

Another point, if the next question is not related with UNV (the original topic), please open a new question [1]

cheers
Jan

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

Przemek (przemekn) said : #6

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